fixes and tested deployment
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
export * from './src/Decorator';
|
||||||
|
export * from './src/Injector';
|
||||||
|
export * from './src/Types';
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
"reflect-metadata": "^0.1.13"
|
"reflect-metadata": "^0.1.13"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"typescript": "^4.7.2",
|
||||||
"@types/node": "^11.13.19",
|
"@types/node": "^11.13.19",
|
||||||
"@types/chai": "^4.2.21",
|
"@types/chai": "^4.2.21",
|
||||||
"@types/expect": "^1.20.4",
|
"@types/expect": "^1.20.4",
|
||||||
|
|||||||
+2
-2
@@ -15,7 +15,7 @@ export function Singleton(_interface?: Constructor<any>): GenericClassDecorator<
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function Inject(clazz: Constructor<any>) {
|
export function Inject(clazz: Constructor<any>) {
|
||||||
return function (prototype: Object, key: string) {
|
return function (instance: Object, key: string) {
|
||||||
Injector['injectionQueue'].push({ injectionType: clazz, prototype: prototype, injectIntoKey: key })
|
Injector['injectionQueue'].push({ injectionType: clazz, instance: instance, injectIntoKey: key })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -13,7 +13,7 @@ class _Injector {
|
|||||||
* @param {Type<any>} target
|
* @param {Type<any>} target
|
||||||
* @returns {T}
|
* @returns {T}
|
||||||
*/
|
*/
|
||||||
public resolve<T>(target: Type<T>): T {
|
public resolve<T>(target: Constructor<T>): T {
|
||||||
if (!this.initialized) {
|
if (!this.initialized) {
|
||||||
this.initialize()
|
this.initialize()
|
||||||
this.initialized = true
|
this.initialized = true
|
||||||
@@ -55,7 +55,7 @@ class _Injector {
|
|||||||
const inj = this.injectionQueue.shift()
|
const inj = this.injectionQueue.shift()
|
||||||
|
|
||||||
if (this.moduleObjs[inj.injectionType.name]) {
|
if (this.moduleObjs[inj.injectionType.name]) {
|
||||||
inj.prototype[inj.injectIntoKey] = this.moduleObjs[inj.injectionType.name]
|
this.moduleObjs[inj.instance.constructor.name][inj.injectIntoKey] = this.moduleObjs[inj.injectionType.name]
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Cannot resolve injection token " + inj.injectionType.name)
|
throw new Error("Cannot resolve injection token " + inj.injectionType.name)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user