@wessberg/di-compiler
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -114,2 +114,3 @@ import { TransformOptions, TransformResult } from "./transform-options"; | ||
declare function pickServiceOrImplementationName(node: TS.Expression | TS.TypeNode | TS.EntityName, context: VisitorContext): string; | ||
declare function getModifierLikes(node: TS.Node): readonly TS.ModifierLike[] | undefined; | ||
declare const CONSTRUCTOR_ARGUMENTS_SYMBOL_IDENTIFIER = "___CTOR_ARGS___"; | ||
@@ -128,6 +129,6 @@ declare const DI_CONTAINER_NAME = "DIContainer"; | ||
private readTransformResult; | ||
get(key: string): T | undefined; | ||
get(key: string): NonNullable<T> | undefined; | ||
set(key: string, value: T): this; | ||
expireDiskCache(): void; | ||
} | ||
export { transform, di, getBaseVisitorContext, afterTransformer, visitNode, visitDefineArrayLiteralExpression, visitRootBlockBlock, visitRootBlockSourceFile, visitRootBlock, beforeTransformer, transformSourceFile, visitCallExpression, needsImportPreservationLogic, getImportDefaultHelper, getImportStarHelper, moduleKindSupportsImportHelpers, moduleKindDefinesDependencies, getUnscopedHelperName, getRootBlockInsertionPosition, getDefineArrayLiteralExpression, getRootBlock, isImportedSymbolImported, generateImportStatementForImportedSymbolInContext, visitClassLikeDeclaration, pickServiceOrImplementationName, CONSTRUCTOR_ARGUMENTS_SYMBOL_IDENTIFIER, DI_CONTAINER_NAME, DiMethodName, FileCache }; | ||
export { transform, di, getBaseVisitorContext, afterTransformer, visitNode, visitDefineArrayLiteralExpression, visitRootBlockBlock, visitRootBlockSourceFile, visitRootBlock, beforeTransformer, transformSourceFile, visitCallExpression, needsImportPreservationLogic, getImportDefaultHelper, getImportStarHelper, moduleKindSupportsImportHelpers, moduleKindDefinesDependencies, getUnscopedHelperName, getRootBlockInsertionPosition, getDefineArrayLiteralExpression, getRootBlock, isImportedSymbolImported, generateImportStatementForImportedSymbolInContext, visitClassLikeDeclaration, pickServiceOrImplementationName, getModifierLikes, CONSTRUCTOR_ARGUMENTS_SYMBOL_IDENTIFIER, DI_CONTAINER_NAME, DiMethodName, FileCache }; |
@@ -30,2 +30,11 @@ import * as TS from 'typescript'; | ||
} | ||
function getModifierLikes(node) { | ||
var _a, _b; | ||
if ("decorators" in node && Array.isArray(node.decorators)) { | ||
return [...(_a = node.decorators) !== null && _a !== void 0 ? _a : [], ...((_b = node.modifiers) !== null && _b !== void 0 ? _b : [])]; | ||
} | ||
else { | ||
return node.modifiers; | ||
} | ||
} | ||
@@ -42,9 +51,10 @@ function visitClassLikeDeclaration(options) { | ||
...node.members.map(continuation), | ||
factory.createGetAccessorDeclaration(undefined, [factory.createModifier(typescript.SyntaxKind.StaticKeyword)], factory.createComputedPropertyName(factory.createIdentifier(`Symbol.for("${CONSTRUCTOR_ARGUMENTS_SYMBOL_IDENTIFIER}")`)), [], undefined, factory.createBlock([factory.createReturnStatement(getParameterTypeNamesAsArrayLiteral(constructorDeclaration.parameters, context))])) | ||
factory.createGetAccessorDeclaration([factory.createModifier(typescript.SyntaxKind.StaticKeyword)], factory.createComputedPropertyName(factory.createIdentifier(`Symbol.for("${CONSTRUCTOR_ARGUMENTS_SYMBOL_IDENTIFIER}")`)), [], undefined, factory.createBlock([factory.createReturnStatement(getParameterTypeNamesAsArrayLiteral(constructorDeclaration.parameters, context))])) | ||
]; | ||
const modifierLikes = getModifierLikes(node); | ||
if (typescript.isClassDeclaration(node)) { | ||
return factory.updateClassDeclaration(node, node.decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, updatedClassMembers); | ||
return factory.updateClassDeclaration(node, modifierLikes, node.name, node.typeParameters, node.heritageClauses, updatedClassMembers); | ||
} | ||
else { | ||
return factory.updateClassExpression(node, node.decorators, node.modifiers, node.name, node.typeParameters, node.heritageClauses, updatedClassMembers); | ||
return factory.updateClassExpression(node, modifierLikes, node.name, node.typeParameters, node.heritageClauses, updatedClassMembers); | ||
} | ||
@@ -368,3 +378,3 @@ } | ||
case typescript.ModuleKind.ESNext: { | ||
return factory.createImportDeclaration(undefined, undefined, "isDefaultImport" in importedSymbol | ||
return factory.createImportDeclaration(undefined, "isDefaultImport" in importedSymbol | ||
? factory.createImportClause(false, !importedSymbol.isDefaultImport ? undefined : factory.createIdentifier(importedSymbol.name), importedSymbol.isDefaultImport | ||
@@ -371,0 +381,0 @@ ? undefined |
The MIT License (MIT) | ||
Copyright © 2022 [Frederik Wessberg](mailto:frederikwessberg@hotmail.com) ([@FredWessberg](https://twitter.com/FredWessberg)) ([Website](https://github.com/wessberg)) | ||
Copyright © 2023 [Frederik Wessberg](mailto:frederikwessberg@hotmail.com) ([@FredWessberg](https://twitter.com/FredWessberg)) ([Website](https://github.com/wessberg)) | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
{ | ||
"name": "@wessberg/di-compiler", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "A Custom Transformer for Typescript that enables compile-time Dependency Injection", | ||
@@ -56,29 +56,30 @@ "scripts": { | ||
"devDependencies": { | ||
"@types/node": "^18.6.2", | ||
"@types/prettier": "^2.6.4", | ||
"@types/semver": "^7.3.10", | ||
"@typescript-eslint/eslint-plugin": "^5.31.0", | ||
"@typescript-eslint/parser": "^5.31.0", | ||
"@types/node": "^18.11.18", | ||
"@types/prettier": "^2.7.2", | ||
"@types/semver": "^7.3.13", | ||
"@typescript-eslint/eslint-plugin": "^5.48.1", | ||
"@typescript-eslint/parser": "^5.48.1", | ||
"eslint-plugin-deprecation": "1.3.3", | ||
"@wessberg/ts-config": "^2.0.4", | ||
"@wessberg/prettier-config": "^1.0.0", | ||
"rollup-plugin-ts": "^3.0.2", | ||
"semver": "^7.3.7", | ||
"rollup-plugin-ts": "^3.1.1", | ||
"semver": "^7.3.8", | ||
"ava": "3.15.0", | ||
"eslint": "^8.20.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint": "^8.31.0", | ||
"eslint-config-prettier": "^8.6.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-jsdoc": "^39.3.4", | ||
"husky": "^8.0.1", | ||
"np": "^7.6.2", | ||
"pnpm": "^7.7.0", | ||
"prettier": "^2.7.1", | ||
"eslint-plugin-jsdoc": "^39.6.4", | ||
"husky": "^8.0.3", | ||
"np": "^7.6.3", | ||
"pnpm": "^7.23.0", | ||
"prettier": "^2.8.2", | ||
"pretty-quick": "^3.1.3", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.77.2", | ||
"rollup": "^3.9.1", | ||
"sandhog": "^2.0.2", | ||
"standard-changelog": "^2.0.27", | ||
"ts-node": "^10.9.1", | ||
"npm-check-updates": "^16.0.3", | ||
"@esbuild-kit/esm-loader": "^2.4.2", | ||
"typescript": "^4.7.4", | ||
"npm-check-updates": "^16.6.2", | ||
"@esbuild-kit/esm-loader": "^2.5.4", | ||
"typescript": "^4.9.4", | ||
"typescript-3-4-1": "npm:typescript@3.4.1", | ||
@@ -96,11 +97,13 @@ "typescript-3-5-1": "npm:typescript@3.5.1", | ||
"typescript-4-5-4": "npm:typescript@4.5.4", | ||
"typescript-4-6-4": "npm:typescript@4.6.4" | ||
"typescript-4-6-4": "npm:typescript@4.6.4", | ||
"typescript-4-7-2": "npm:typescript@4.7.2", | ||
"typescript-4-8-2": "npm:typescript@4.8.2" | ||
}, | ||
"dependencies": { | ||
"crosspath": "^2.0.0", | ||
"helpertypes": "^0.0.18", | ||
"helpertypes": "^0.0.19", | ||
"pirates": "^4.0.5", | ||
"get-tsconfig": "4.2.0", | ||
"ts-evaluator": "^1.0.7", | ||
"compatfactory": "^1.0.1" | ||
"get-tsconfig": "4.3.0", | ||
"ts-evaluator": "^1.1.0", | ||
"compatfactory": "^2.0.9" | ||
}, | ||
@@ -107,0 +110,0 @@ "peerDependencies": { |
@@ -283,3 +283,3 @@ <!-- SHADOW_SECTION_LOGO_START --> | ||
```json | ||
```js | ||
// Inside your tsconfig.json | ||
@@ -476,3 +476,3 @@ { | ||
```json | ||
```js | ||
{ | ||
@@ -493,3 +493,3 @@ "ava": { | ||
```json | ||
```js | ||
{ | ||
@@ -614,7 +614,7 @@ "ava": { | ||
If you pass a Program to DI-Compiler (such as you typically do when you use it as a Custom Transformer), this means that the Typechecker wasn't able to determine that one or mode identifiers in your | ||
If you pass a Program to DI-Compiler (such as you typically do when you use it as a Custom Transformer), this means that the Typechecker wasn't able to determine that one or more identifiers in your | ||
code was in fact instances of DIContainer. Please verify that TypeScript correctly tracks the type of the objects on which you invoke the relevant DIContainer methods. | ||
If you _don't_ pass a Program to DI-Compiler, then you're relying on DI-Compiler being able to statically infer whether or not identifiers are instances of DIContainer without having access to multiple files | ||
inside your application. This will very often lead to problems if you reference an instance of DIContainer from another file inside your application. To fix it, pass one or mode identifiers that should be | ||
inside your application. This will very often lead to problems if you reference an instance of DIContainer from another file inside your application. To fix it, pass one or more identifiers that should be | ||
considered instances of DIContainer as an option. Please see [this section](#optimization-2-pass-in-one-or-more-identifiers-to-consider-instances-of-dicontainer-instead-of-relying-on-partial-evaluation) for details | ||
@@ -621,0 +621,0 @@ on how you can do that. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
386884
2613
0
43
+ Addedcompatfactory@2.0.9(transitive)
+ Addedget-tsconfig@4.3.0(transitive)
+ Addedhelpertypes@0.0.19(transitive)
- Removedcompatfactory@1.0.1(transitive)
- Removedget-tsconfig@4.2.0(transitive)
- Removedhelpertypes@0.0.18(transitive)
Updatedcompatfactory@^2.0.9
Updatedget-tsconfig@4.3.0
Updatedhelpertypes@^0.0.19
Updatedts-evaluator@^1.1.0