Start JSDocs

This commit is contained in:
2020-08-16 14:31:47 -05:00
parent 673fbc84f8
commit c2a7c3f914
29 changed files with 830 additions and 16 deletions

View File

@@ -1,5 +1,10 @@
import Instantiable from './Instantiable.ts'
import {StaticClass} from './StaticClass.ts'
const DEPENDENCY_KEYS_METADATA_KEY = 'daton:di:dependencyKeys.ts'
/**
* Type used to represent a value that can identify a factory in the container.
*/
type DependencyKey = Instantiable<any> | StaticClass<any, any> | string
export { DependencyKey, DEPENDENCY_KEYS_METADATA_KEY }

View File

@@ -1,5 +1,9 @@
import { DependencyKey } from './DependencyKey.ts'
/**
* Interface used to store dependency requirements by their place in the injectable
* target's constructor parameters.
*/
interface DependencyRequirement {
param_index: number,
key: DependencyKey,

View File

@@ -1,7 +1,14 @@
/**
* Interface that designates a particular value as able to be constructed.
*/
export default interface Instantiable<T> {
new(...args: any[]): T
}
/**
* Returns true if the given value is instantiable.
* @param what
*/
const isInstantiable = <T>(what: any): what is Instantiable<T> => {
return (typeof what === 'object' || typeof what === 'function') && 'constructor' in what && typeof what.constructor === 'function'
}

View File

@@ -1,5 +1,12 @@
/**
* Type that identifies a value as a static class, even if it is not instantiable.
*/
export type StaticClass<T, T2> = Function & {prototype: T} & T2
/**
* Returns true if the parameter is a static class.
* @param something
*/
export function isStaticClass<T, T2>(something: any): something is StaticClass<T, T2> {
return typeof something === 'function' && typeof something.prototype !== 'undefined'
}