diff --git a/src/ServiceContainer.ts b/src/ServiceContainer.ts index bbeb88e..e90353d 100644 --- a/src/ServiceContainer.ts +++ b/src/ServiceContainer.ts @@ -24,7 +24,7 @@ export default { } if (!service.instance) { - service.instance = service.factory(); + service.instance = service.factory?.(); service.factory = undefined; } @@ -63,6 +63,6 @@ function getFactory(factoryOrClassReference: Factory | Function): Factory { type Factory = () => any; type Service = { - factory: () => any; + factory?: () => any; instance?: any; } diff --git a/tsconfig.json b/tsconfig.json index 1d09eec..3aec876 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,10 @@ "declaration": true, "esModuleInterop": true, "moduleResolution": "node", - "module": "commonjs" + "module": "commonjs", + "strict": true, + "noImplicitAny": true, + "strictPropertyInitialization": true }, "include": [ "src/**/*"