Skip to content

Commit

Permalink
- improved tsconfig.json
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcwbr committed Aug 8, 2023
1 parent ec878a1 commit b3dd1b8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/ServiceContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default {
}

if (!service.instance) {
service.instance = service.factory();
service.instance = service.factory?.();
service.factory = undefined;
}

Expand Down Expand Up @@ -63,6 +63,6 @@ function getFactory(factoryOrClassReference: Factory | Function): Factory {

type Factory = () => any;
type Service = {
factory: () => any;
factory?: Factory;
instance?: any;
}
2 changes: 1 addition & 1 deletion src/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function inject(serviceIdOrTarget: Object | string, propertyKey?: string)
};
}

redefineObject(serviceIdOrTarget, propertyKey);
redefineObject(serviceIdOrTarget, propertyKey!);
}

function redefineObject(target: Object, propertyKey: string, serviceId?: string) {
Expand Down
1 change: 1 addition & 0 deletions tests/decorators.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ describe('decorators', () => {

inject(anObject, 'aService');

// @ts-ignore
expect(() => anObject.aService = jest.fn()).toThrow('Injected property [aService] can\'t be reset');
});

Expand Down
5 changes: 4 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
"declaration": true,
"esModuleInterop": true,
"moduleResolution": "node",
"module": "commonjs"
"module": "commonjs",
"strict": true,
"noImplicitAny": true,
"strictPropertyInitialization": true
},
"include": [
"src/**/*"
Expand Down

0 comments on commit b3dd1b8

Please sign in to comment.