Browse Source

fixes and tested deployment

master
nitowa 1 year ago
parent
commit
076064ad98
5 changed files with 8 additions and 4 deletions
  1. 3
    0
      Index.ts
  2. 0
    0
      index.ts
  3. 1
    0
      package.json
  4. 2
    2
      src/Decorator.ts
  5. 2
    2
      src/Injector.ts

+ 3
- 0
Index.ts View File

1
+export * from './src/Decorator';
2
+export * from './src/Injector';
3
+export * from './src/Types';

+ 0
- 0
index.ts View File


+ 1
- 0
package.json View File

28
     "reflect-metadata": "^0.1.13"
28
     "reflect-metadata": "^0.1.13"
29
   },
29
   },
30
   "devDependencies": {
30
   "devDependencies": {
31
+    "typescript": "^4.7.2",
31
     "@types/node": "^11.13.19",
32
     "@types/node": "^11.13.19",
32
     "@types/chai": "^4.2.21",
33
     "@types/chai": "^4.2.21",
33
     "@types/expect": "^1.20.4",
34
     "@types/expect": "^1.20.4",

+ 2
- 2
src/Decorator.ts View File

15
 }
15
 }
16
 
16
 
17
 export function Inject(clazz: Constructor<any>) {
17
 export function Inject(clazz: Constructor<any>) {
18
-  return function (prototype: Object, key: string) {
19
-    Injector['injectionQueue'].push({ injectionType: clazz, prototype: prototype, injectIntoKey: key })
18
+  return function (instance: Object, key: string) {
19
+    Injector['injectionQueue'].push({ injectionType: clazz, instance: instance, injectIntoKey: key })
20
   }
20
   }
21
 }
21
 }

+ 2
- 2
src/Injector.ts View File

13
    * @param {Type<any>} target
13
    * @param {Type<any>} target
14
    * @returns {T}
14
    * @returns {T}
15
    */
15
    */
16
-  public resolve<T>(target: Type<T>): T {
16
+  public resolve<T>(target: Constructor<T>): T {
17
     if (!this.initialized) {
17
     if (!this.initialized) {
18
       this.initialize()
18
       this.initialize()
19
       this.initialized = true
19
       this.initialized = true
55
       const inj = this.injectionQueue.shift()
55
       const inj = this.injectionQueue.shift()
56
 
56
 
57
       if (this.moduleObjs[inj.injectionType.name]) {
57
       if (this.moduleObjs[inj.injectionType.name]) {
58
-        inj.prototype[inj.injectIntoKey] = this.moduleObjs[inj.injectionType.name]
58
+        this.moduleObjs[inj.instance.constructor.name][inj.injectIntoKey] = this.moduleObjs[inj.injectionType.name]
59
       } else {
59
       } else {
60
         throw new Error("Cannot resolve injection token " + inj.injectionType.name)
60
         throw new Error("Cannot resolve injection token " + inj.injectionType.name)
61
       }
61
       }

Loading…
Cancel
Save