Initial commit
This commit is contained in:
4
di/src/type/DependencyKey.ts
Normal file
4
di/src/type/DependencyKey.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import Instantiable from './Instantiable.ts'
|
||||
const DEPENDENCY_KEYS_METADATA_KEY = 'daton:di:dependencyKeys.ts'
|
||||
type DependencyKey = Instantiable<any> | string
|
||||
export { DependencyKey, DEPENDENCY_KEYS_METADATA_KEY }
|
||||
9
di/src/type/DependencyRequirement.ts
Normal file
9
di/src/type/DependencyRequirement.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { DependencyKey } from './DependencyKey.ts'
|
||||
|
||||
interface DependencyRequirement {
|
||||
param_index: number,
|
||||
key: DependencyKey,
|
||||
overridden: boolean,
|
||||
}
|
||||
|
||||
export { DependencyRequirement }
|
||||
9
di/src/type/Instantiable.ts
Normal file
9
di/src/type/Instantiable.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export default interface Instantiable<T> {
|
||||
new(...args: any[]): T
|
||||
}
|
||||
|
||||
const isInstantiable = (what: any): what is Instantiable<any> => {
|
||||
return (typeof what === 'object' || typeof what === 'function') && 'constructor' in what && typeof what.constructor === 'function'
|
||||
}
|
||||
|
||||
export { isInstantiable }
|
||||
Reference in New Issue
Block a user