static-injector 2.1.1 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/import/commonjs/index.js +127 -197
  2. package/import/{es2015 → es2022}/di/create_injector.js +0 -2
  3. package/import/{es2015 → es2022}/di/forward_ref.js +29 -2
  4. package/import/{es2015 → es2022}/di/injection_token.js +5 -3
  5. package/import/{es2015 → es2022}/di/injector.js +15 -16
  6. package/import/{es2015 → es2022}/di/injector_compatibility.js +8 -3
  7. package/import/{es2015 → es2022}/di/interface/defs.js +2 -16
  8. package/import/{es2015 → es2022}/di/interface/injector.js +1 -1
  9. package/import/es2022/di/provider_collection.js +104 -0
  10. package/import/{es2015 → es2022}/di/r3_injector.js +46 -15
  11. package/import/{es2015 → es2022}/errors.js +4 -2
  12. package/import/{es2015 → es2022}/render3/error_code.js +1 -0
  13. package/import/es2022/render3/fields.js +22 -0
  14. package/import/{fesm2015 → fesm2022}/index.js +127 -198
  15. package/import/typings/di/create_injector.d.ts +3 -5
  16. package/import/typings/di/forward_ref.d.ts +29 -2
  17. package/import/typings/di/inject_switch.d.ts +1 -1
  18. package/import/typings/di/injection_token.d.ts +1 -1
  19. package/import/typings/di/injector.d.ts +3 -3
  20. package/import/typings/di/injector_compatibility.d.ts +1 -0
  21. package/import/typings/di/interface/defs.d.ts +2 -1
  22. package/import/typings/di/interface/injector.d.ts +2 -2
  23. package/import/typings/di/interface/provider.d.ts +7 -7
  24. package/import/typings/di/metadata.d.ts +4 -4
  25. package/import/typings/di/provider_collection.d.ts +1 -12
  26. package/import/typings/di/r3_injector.d.ts +8 -6
  27. package/import/typings/di/scope.d.ts +1 -1
  28. package/import/typings/errors.d.ts +28 -3
  29. package/import/typings/render3/fields.d.ts +9 -0
  30. package/import/typings/util/decorators.d.ts +1 -0
  31. package/package.json +7 -7
  32. package/readme.md +4 -1
  33. package/transform/compiler/src/injectable_compiler_2.d.ts +0 -1
  34. package/transform/compiler/src/injectable_compiler_2.js +31 -16
  35. package/transform/compiler/src/output/output_ast.d.ts +53 -10
  36. package/transform/compiler/src/output/output_ast.js +211 -12
  37. package/transform/compiler/src/parse_util.js +10 -0
  38. package/transform/compiler/src/render3/partial/api.js +1 -1
  39. package/transform/compiler/src/render3/r3_factory.d.ts +0 -8
  40. package/transform/compiler/src/render3/r3_factory.js +5 -4
  41. package/transform/compiler/src/render3/r3_identifiers.js +37 -37
  42. package/transform/compiler/src/render3/view/util.js +1 -3
  43. package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.js +2 -4
  44. package/transform/compiler-cli/src/ngtsc/annotations/common/src/factory.js +1 -0
  45. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.d.ts +1 -1
  46. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.js +5 -9
  47. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +2 -1
  48. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +12 -8
  49. package/transform/compiler-cli/src/ngtsc/diagnostics/error.d.ts +2 -2
  50. package/transform/compiler-cli/src/ngtsc/diagnostics/error.js +8 -4
  51. package/transform/compiler-cli/src/ngtsc/diagnostics/error_code.js +1 -1
  52. package/transform/compiler-cli/src/ngtsc/imports/src/default.js +1 -2
  53. package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +24 -173
  54. package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +2 -51
  55. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +5 -3
  56. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +5 -10
  57. package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +5 -23
  58. package/transform/compiler-cli/src/ngtsc/transform/src/api.js +0 -21
  59. package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +1 -2
  60. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +7 -0
  61. package/transform/compiler-cli/src/ngtsc/translator/src/context.js +1 -0
  62. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +4 -2
  63. package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +1 -0
  64. package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +10 -4
  65. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +2 -1
  66. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +20 -16
  67. package/transform/injectable-transform.d.ts +2 -2
  68. package/transform/injectable-transform.js +32 -6
  69. package/import/es2015/di/provider_collection.js +0 -244
  70. package/import/es2015/render3/fields.js +0 -11
  71. /package/import/{es2015 → es2022}/di/initializer_token.js +0 -0
  72. /package/import/{es2015 → es2022}/di/inject_switch.js +0 -0
  73. /package/import/{es2015 → es2022}/di/injectable.js +0 -0
  74. /package/import/{es2015 → es2022}/di/injector_marker.js +0 -0
  75. /package/import/{es2015 → es2022}/di/injector_token.js +0 -0
  76. /package/import/{es2015 → es2022}/di/interface/provider.js +0 -0
  77. /package/import/{es2015 → es2022}/di/internal_tokens.js +0 -0
  78. /package/import/{es2015 → es2022}/di/metadata.js +0 -0
  79. /package/import/{es2015 → es2022}/di/null_injector.js +0 -0
  80. /package/import/{es2015 → es2022}/di/provider_token.js +0 -0
  81. /package/import/{es2015 → es2022}/di/scope.js +0 -0
  82. /package/import/{es2015 → es2022}/error_details_base_url.js +0 -0
  83. /package/import/{es2015 → es2022}/index.js +0 -0
  84. /package/import/{es2015 → es2022}/interface/lifecycle_hooks.js +0 -0
  85. /package/import/{es2015 → es2022}/interface/type.js +0 -0
  86. /package/import/{es2015 → es2022}/render3/definition_factory.js +0 -0
  87. /package/import/{es2015 → es2022}/render3/di.js +0 -0
  88. /package/import/{es2015 → es2022}/render3/errors_di.js +0 -0
  89. /package/import/{es2015 → es2022}/render3/instructions/di.js +0 -0
  90. /package/import/{es2015 → es2022}/render3/util/stringify_utils.js +0 -0
  91. /package/import/{es2015 → es2022}/util/array_utils.js +0 -0
  92. /package/import/{es2015 → es2022}/util/closure.js +0 -0
  93. /package/import/{es2015 → es2022}/util/decorators.js +0 -0
  94. /package/import/{es2015 → es2022}/util/empty.js +0 -0
  95. /package/import/{es2015 → es2022}/util/property.js +0 -0
  96. /package/import/{es2015 → es2022}/util/stringify.js +0 -0
@@ -31,7 +31,7 @@ var R3FactoryDelegateType;
31
31
  (function (R3FactoryDelegateType) {
32
32
  R3FactoryDelegateType[R3FactoryDelegateType["Class"] = 0] = "Class";
33
33
  R3FactoryDelegateType[R3FactoryDelegateType["Function"] = 1] = "Function";
34
- })(R3FactoryDelegateType = exports.R3FactoryDelegateType || (exports.R3FactoryDelegateType = {}));
34
+ })(R3FactoryDelegateType || (exports.R3FactoryDelegateType = R3FactoryDelegateType = {}));
35
35
  var FactoryTarget;
36
36
  (function (FactoryTarget) {
37
37
  FactoryTarget[FactoryTarget["Directive"] = 0] = "Directive";
@@ -39,7 +39,7 @@ var FactoryTarget;
39
39
  FactoryTarget[FactoryTarget["Injectable"] = 2] = "Injectable";
40
40
  FactoryTarget[FactoryTarget["Pipe"] = 3] = "Pipe";
41
41
  FactoryTarget[FactoryTarget["NgModule"] = 4] = "NgModule";
42
- })(FactoryTarget = exports.FactoryTarget || (exports.FactoryTarget = {}));
42
+ })(FactoryTarget || (exports.FactoryTarget = FactoryTarget = {}));
43
43
  /**
44
44
  * Construct a factory function expression for the given `R3FactoryMetadata`.
45
45
  */
@@ -52,7 +52,7 @@ function compileFactoryFunction(meta) {
52
52
  // delegated factory (which is used to create the current type) then this is only the type-to-
53
53
  // create parameter (t).
54
54
  const typeForCtor = !isDelegatedFactoryMetadata(meta)
55
- ? new o.BinaryOperatorExpr(o.BinaryOperator.Or, t, meta.internalType)
55
+ ? new o.BinaryOperatorExpr(o.BinaryOperator.Or, t, meta.type.value)
56
56
  : t;
57
57
  let ctorExpr = null;
58
58
  if (meta.deps !== null) {
@@ -102,7 +102,7 @@ function compileFactoryFunction(meta) {
102
102
  // This factory uses a base factory, so call `ɵɵgetInheritedFactory()` to compute it.
103
103
  const getInheritedFactoryCall = o
104
104
  .importExpr(r3_identifiers_1.Identifiers.getInheritedFactory)
105
- .callFn([meta.internalType]);
105
+ .callFn([meta.type.value]);
106
106
  // Memoize the base factoryFn: `baseFactory || (baseFactory = ɵɵgetInheritedFactory(...))`
107
107
  const baseFactory = new o.BinaryOperatorExpr(o.BinaryOperator.Or, baseFactoryVar, baseFactoryVar.set(getInheritedFactoryCall));
108
108
  body.push(new o.ReturnStatement(baseFactory.callFn([typeForCtor])));
@@ -168,6 +168,7 @@ function compileInjectDependency(dep, target, index) {
168
168
  return o.importExpr(injectFn).callFn(injectArgs);
169
169
  }
170
170
  else {
171
+ throw new Error('compileInjectDependency');
171
172
  }
172
173
  }
173
174
  function createCtorDepsType(deps) {
@@ -10,42 +10,42 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.Identifiers = void 0;
11
11
  const CORE = 'static-injector';
12
12
  class Identifiers {
13
+ static inject = { name: 'ɵɵinject', moduleName: CORE };
14
+ static directiveInject = {
15
+ name: 'ɵɵdirectiveInject',
16
+ moduleName: CORE,
17
+ };
18
+ static invalidFactory = {
19
+ name: 'ɵɵinvalidFactory',
20
+ moduleName: CORE,
21
+ };
22
+ static invalidFactoryDep = {
23
+ name: 'ɵɵinvalidFactoryDep',
24
+ moduleName: CORE,
25
+ };
26
+ static forwardRef = {
27
+ name: 'forwardRef',
28
+ moduleName: CORE,
29
+ };
30
+ static resolveForwardRef = {
31
+ name: 'resolveForwardRef',
32
+ moduleName: CORE,
33
+ };
34
+ static ɵɵdefineInjectable = {
35
+ name: 'ɵɵdefineInjectable',
36
+ moduleName: CORE,
37
+ };
38
+ static InjectableDeclaration = {
39
+ name: 'ɵɵInjectableDeclaration',
40
+ moduleName: CORE,
41
+ };
42
+ static FactoryDeclaration = {
43
+ name: 'ɵɵFactoryDeclaration',
44
+ moduleName: CORE,
45
+ };
46
+ static getInheritedFactory = {
47
+ name: 'ɵɵgetInheritedFactory',
48
+ moduleName: CORE,
49
+ };
13
50
  }
14
51
  exports.Identifiers = Identifiers;
15
- Identifiers.inject = { name: 'ɵɵinject', moduleName: CORE };
16
- Identifiers.directiveInject = {
17
- name: 'ɵɵdirectiveInject',
18
- moduleName: CORE,
19
- };
20
- Identifiers.invalidFactory = {
21
- name: 'ɵɵinvalidFactory',
22
- moduleName: CORE,
23
- };
24
- Identifiers.invalidFactoryDep = {
25
- name: 'ɵɵinvalidFactoryDep',
26
- moduleName: CORE,
27
- };
28
- Identifiers.forwardRef = {
29
- name: 'forwardRef',
30
- moduleName: CORE,
31
- };
32
- Identifiers.resolveForwardRef = {
33
- name: 'resolveForwardRef',
34
- moduleName: CORE,
35
- };
36
- Identifiers.ɵɵdefineInjectable = {
37
- name: 'ɵɵdefineInjectable',
38
- moduleName: CORE,
39
- };
40
- Identifiers.InjectableDeclaration = {
41
- name: 'ɵɵInjectableDeclaration',
42
- moduleName: CORE,
43
- };
44
- Identifiers.FactoryDeclaration = {
45
- name: 'ɵɵFactoryDeclaration',
46
- moduleName: CORE,
47
- };
48
- Identifiers.getInheritedFactory = {
49
- name: 'ɵɵgetInheritedFactory',
50
- moduleName: CORE,
51
- };
@@ -38,9 +38,7 @@ const o = __importStar(require("../../output/output_ast"));
38
38
  * property names that are set can be resolved to their documented declaration.
39
39
  */
40
40
  class DefinitionMap {
41
- constructor() {
42
- this.values = [];
43
- }
41
+ values = [];
44
42
  set(key, value) {
45
43
  if (value) {
46
44
  this.values.push({ key: key, value, quoted: false });
@@ -14,7 +14,6 @@ exports.validateConstructorDependencies = exports.getValidConstructorDependencie
14
14
  const compiler_1 = require("static-injector/transform/compiler");
15
15
  const typescript_1 = __importDefault(require("typescript"));
16
16
  const diagnostics_1 = require("../../../diagnostics");
17
- const reflection_1 = require("../../../reflection");
18
17
  const util_1 = require("./util");
19
18
  function getConstructorDependencies(clazz, reflector, isCore) {
20
19
  const deps = [];
@@ -38,7 +37,7 @@ function getConstructorDependencies(clazz, reflector, isCore) {
38
37
  const name = isCore || dec.import === null ? dec.name : dec.import.name;
39
38
  if (name === 'Inject') {
40
39
  if (dec.args === null || dec.args.length !== 1) {
41
- throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_ARITY_WRONG, reflection_1.Decorator.nodeForError(dec), `Unexpected number of arguments to @Inject().`);
40
+ throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_ARITY_WRONG, dec.node, `Unexpected number of arguments to @Inject().`);
42
41
  }
43
42
  token = new compiler_1.WrappedNodeExpr(dec.args[0]);
44
43
  }
@@ -56,7 +55,7 @@ function getConstructorDependencies(clazz, reflector, isCore) {
56
55
  else if (name === 'Attribute') {
57
56
  }
58
57
  else {
59
- throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_UNEXPECTED, reflection_1.Decorator.nodeForError(dec), `Unexpected decorator ${name} on parameter.`);
58
+ throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_UNEXPECTED, dec.node, `Unexpected decorator ${name} on parameter.`);
60
59
  }
61
60
  });
62
61
  if (token === null) {
@@ -120,7 +119,6 @@ function validateConstructorDependencies(clazz, deps) {
120
119
  return deps.deps;
121
120
  }
122
121
  else {
123
- // TODO(alxhub): this cast is necessary because the g3 typescript version doesn't narrow here.
124
122
  // There is at least one error.
125
123
  const error = deps.errors[0];
126
124
  throw createUnsuitableInjectionTokenError(clazz, error);
@@ -16,6 +16,7 @@ function compileNgFactoryDefField(metadata) {
16
16
  initializer: res.expression,
17
17
  statements: res.statements,
18
18
  type: res.type,
19
+ deferrableImports: null,
19
20
  };
20
21
  }
21
22
  exports.compileNgFactoryDefField = compileNgFactoryDefField;
@@ -54,7 +54,7 @@ export declare function wrapFunctionExpressionsInParens(expression: ts.Expressio
54
54
  * Create an R3Reference for a class.
55
55
  *
56
56
  * The `value` is the exported declaration of the class from its source file.
57
- * The `type` is an expression that would be used by ngcc in the typings (.d.ts) files.
57
+ * The `type` is an expression that would be used in the typings (.d.ts) files.
58
58
  */
59
59
  export declare function wrapTypeReference(reflector: ReflectionHost, clazz: ClassDeclaration): R3Reference;
60
60
  export declare function toFactoryMetadata(meta: Omit<R3FactoryMetadata, 'target'>, target: FactoryTarget): R3FactoryMetadata;
@@ -13,7 +13,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.isAbstractClassDeclaration = exports.toFactoryMetadata = exports.wrapTypeReference = exports.wrapFunctionExpressionsInParens = exports.tryUnwrapForwardRef = exports.unwrapExpression = exports.isAngularDecorator = exports.findAngularDecorator = exports.isAngularCore = exports.valueReferenceToExpression = void 0;
14
14
  const compiler_1 = require("static-injector/transform/compiler");
15
15
  const typescript_1 = __importDefault(require("typescript"));
16
- const reflection_1 = require("../../../reflection");
17
16
  function valueReferenceToExpression(valueRef) {
18
17
  if (valueRef.kind === 2 /* TypeValueReferenceKind.UNAVAILABLE */) {
19
18
  return null;
@@ -152,14 +151,11 @@ exports.wrapFunctionExpressionsInParens = wrapFunctionExpressionsInParens;
152
151
  * Create an R3Reference for a class.
153
152
  *
154
153
  * The `value` is the exported declaration of the class from its source file.
155
- * The `type` is an expression that would be used by ngcc in the typings (.d.ts) files.
154
+ * The `type` is an expression that would be used in the typings (.d.ts) files.
156
155
  */
157
156
  function wrapTypeReference(reflector, clazz) {
158
- const dtsClass = reflector.getDtsDeclaration(clazz);
159
157
  const value = new compiler_1.WrappedNodeExpr(clazz.name);
160
- const type = dtsClass !== null && (0, reflection_1.isNamedClassDeclaration)(dtsClass)
161
- ? new compiler_1.WrappedNodeExpr(dtsClass.name)
162
- : value;
158
+ const type = value;
163
159
  return { value, type };
164
160
  }
165
161
  exports.wrapTypeReference = wrapTypeReference;
@@ -167,7 +163,6 @@ function toFactoryMetadata(meta, target) {
167
163
  return {
168
164
  name: meta.name,
169
165
  type: meta.type,
170
- internalType: meta.internalType,
171
166
  typeArgumentCount: meta.typeArgumentCount,
172
167
  deps: meta.deps,
173
168
  target,
@@ -175,7 +170,8 @@ function toFactoryMetadata(meta, target) {
175
170
  }
176
171
  exports.toFactoryMetadata = toFactoryMetadata;
177
172
  function isAbstractClassDeclaration(clazz) {
178
- return (clazz.modifiers !== undefined &&
179
- clazz.modifiers.some((mod) => mod.kind === typescript_1.default.SyntaxKind.AbstractKeyword));
173
+ return typescript_1.default.canHaveModifiers(clazz) && clazz.modifiers !== undefined
174
+ ? clazz.modifiers.some((mod) => mod.kind === typescript_1.default.SyntaxKind.AbstractKeyword)
175
+ : false;
180
176
  }
181
177
  exports.isAbstractClassDeclaration = isAbstractClassDeclaration;
@@ -19,6 +19,7 @@ export declare class InjectableDecoratorHandler implements DecoratorHandler<Deco
19
19
  private reflector;
20
20
  private isCore;
21
21
  private strictCtorDeps;
22
+ private includeClassMetadata;
22
23
  /**
23
24
  * What to do if the injectable already contains a ɵprov property.
24
25
  *
@@ -26,7 +27,7 @@ export declare class InjectableDecoratorHandler implements DecoratorHandler<Deco
26
27
  * If false then there is no error and a new ɵprov property is not added.
27
28
  */
28
29
  private errorOnDuplicateProv;
29
- constructor(reflector: ReflectionHost, isCore: boolean, strictCtorDeps: boolean,
30
+ constructor(reflector: ReflectionHost, isCore: boolean, strictCtorDeps: boolean, includeClassMetadata: boolean,
30
31
  /**
31
32
  * What to do if the injectable already contains a ɵprov property.
32
33
  *
@@ -21,7 +21,12 @@ const common_2 = require("../common");
21
21
  * Adapts the `compileInjectable` compiler for `@Injectable` decorators to the Ivy compiler.
22
22
  */
23
23
  class InjectableDecoratorHandler {
24
- constructor(reflector, isCore, strictCtorDeps,
24
+ reflector;
25
+ isCore;
26
+ strictCtorDeps;
27
+ includeClassMetadata;
28
+ errorOnDuplicateProv;
29
+ constructor(reflector, isCore, strictCtorDeps, includeClassMetadata,
25
30
  /**
26
31
  * What to do if the injectable already contains a ɵprov property.
27
32
  *
@@ -32,6 +37,7 @@ class InjectableDecoratorHandler {
32
37
  this.reflector = reflector;
33
38
  this.isCore = isCore;
34
39
  this.strictCtorDeps = strictCtorDeps;
40
+ this.includeClassMetadata = includeClassMetadata;
35
41
  this.errorOnDuplicateProv = errorOnDuplicateProv;
36
42
  }
37
43
  detect(node, decorators) {
@@ -68,7 +74,7 @@ class InjectableDecoratorHandler {
68
74
  const results = [];
69
75
  if (true) {
70
76
  const meta = analysis.meta;
71
- const factoryRes = compileFactoryFn((0, common_2.toFactoryMetadata)(Object.assign(Object.assign({}, meta), { deps: analysis.ctorDeps }), compiler_1.FactoryTarget.Injectable));
77
+ const factoryRes = compileFactoryFn((0, common_2.toFactoryMetadata)({ ...meta, deps: analysis.ctorDeps }, compiler_1.FactoryTarget.Injectable));
72
78
  results.push(factoryRes);
73
79
  }
74
80
  const ɵprov = this.reflector
@@ -85,6 +91,7 @@ class InjectableDecoratorHandler {
85
91
  initializer: res.expression,
86
92
  statements: res.statements,
87
93
  type: res.type,
94
+ deferrableImports: null,
88
95
  });
89
96
  }
90
97
  return results;
@@ -100,17 +107,15 @@ exports.InjectableDecoratorHandler = InjectableDecoratorHandler;
100
107
  function extractInjectableMetadata(clazz, decorator, reflector) {
101
108
  const name = clazz.name.text;
102
109
  const type = (0, common_2.wrapTypeReference)(reflector, clazz);
103
- const internalType = new compiler_1.WrappedNodeExpr(reflector.getInternalNameOfClass(clazz));
104
110
  const typeArgumentCount = reflector.getGenericArityOfClass(clazz) || 0;
105
111
  if (decorator.args === null) {
106
- throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_NOT_CALLED, reflection_1.Decorator.nodeForError(decorator), '@Injectable must be called');
112
+ throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_NOT_CALLED, decorator.node, '@Injectable must be called');
107
113
  }
108
114
  if (decorator.args.length === 0) {
109
115
  return {
110
116
  name,
111
117
  type,
112
118
  typeArgumentCount,
113
- internalType,
114
119
  providedIn: (0, compiler_1.createMayBeForwardRefExpression)(new compiler_1.LiteralExpr(null), 0 /* ForwardRefHandling.None */),
115
120
  };
116
121
  }
@@ -139,7 +144,6 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
139
144
  name,
140
145
  type,
141
146
  typeArgumentCount,
142
- internalType,
143
147
  providedIn,
144
148
  };
145
149
  if (meta.has('useValue')) {
@@ -171,13 +175,13 @@ function extractInjectableMetadata(clazz, decorator, reflector) {
171
175
  */
172
176
  function getProviderExpression(expression, reflector) {
173
177
  const forwardRefValue = (0, common_2.tryUnwrapForwardRef)(expression, reflector);
174
- return (0, compiler_1.createMayBeForwardRefExpression)(new compiler_1.WrappedNodeExpr(forwardRefValue !== null && forwardRefValue !== void 0 ? forwardRefValue : expression), forwardRefValue !== null
178
+ return (0, compiler_1.createMayBeForwardRefExpression)(new compiler_1.WrappedNodeExpr(forwardRefValue ?? expression), forwardRefValue !== null
175
179
  ? 2 /* ForwardRefHandling.Unwrapped */
176
180
  : 0 /* ForwardRefHandling.None */);
177
181
  }
178
182
  function extractInjectableCtorDeps(clazz, meta, decorator, reflector, isCore, strictCtorDeps) {
179
183
  if (decorator.args === null) {
180
- throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_NOT_CALLED, reflection_1.Decorator.nodeForError(decorator), '@Injectable must be called');
184
+ throw new diagnostics_1.FatalDiagnosticError(diagnostics_1.ErrorCode.DECORATOR_NOT_CALLED, decorator.node, '@Injectable must be called');
181
185
  }
182
186
  let ctorDeps = null;
183
187
  if (decorator.args.length === 0) {
@@ -11,8 +11,8 @@ export declare class FatalDiagnosticError {
11
11
  readonly code: ErrorCode;
12
12
  readonly node: ts.Node;
13
13
  readonly message: string | ts.DiagnosticMessageChain;
14
- readonly relatedInformation?: ts.DiagnosticRelatedInformation[];
15
- constructor(code: ErrorCode, node: ts.Node, message: string | ts.DiagnosticMessageChain, relatedInformation?: ts.DiagnosticRelatedInformation[]);
14
+ readonly relatedInformation?: ts.DiagnosticRelatedInformation[] | undefined;
15
+ constructor(code: ErrorCode, node: ts.Node, message: string | ts.DiagnosticMessageChain, relatedInformation?: ts.DiagnosticRelatedInformation[] | undefined);
16
16
  /**
17
17
  * @internal
18
18
  */
@@ -34,16 +34,20 @@ exports.isFatalDiagnosticError = exports.makeRelatedInformation = exports.makeDi
34
34
  const ts = __importStar(require("typescript"));
35
35
  const error_code_1 = require("./error_code");
36
36
  class FatalDiagnosticError {
37
+ code;
38
+ node;
39
+ message;
40
+ relatedInformation;
37
41
  constructor(code, node, message, relatedInformation) {
38
42
  this.code = code;
39
43
  this.node = node;
40
44
  this.message = message;
41
45
  this.relatedInformation = relatedInformation;
42
- /**
43
- * @internal
44
- */
45
- this._isFatalDiagnosticError = true;
46
46
  }
47
+ /**
48
+ * @internal
49
+ */
50
+ _isFatalDiagnosticError = true;
47
51
  toDiagnostic() {
48
52
  return makeDiagnostic(this.code, this.node, this.message, this.relatedInformation);
49
53
  }
@@ -175,7 +175,7 @@ var ErrorCode;
175
175
  * type inference.
176
176
  */
177
177
  ErrorCode[ErrorCode["SUGGEST_SUBOPTIMAL_TYPE_INFERENCE"] = 10002] = "SUGGEST_SUBOPTIMAL_TYPE_INFERENCE";
178
- })(ErrorCode = exports.ErrorCode || (exports.ErrorCode = {}));
178
+ })(ErrorCode || (exports.ErrorCode = ErrorCode = {}));
179
179
  /**
180
180
  * @internal
181
181
  * Base URL for the error details page.
@@ -22,7 +22,6 @@ exports.attachDefaultImportDeclaration = attachDefaultImportDeclaration;
22
22
  * dependency.
23
23
  */
24
24
  function getDefaultImportDeclaration(expr) {
25
- var _a;
26
- return ((_a = expr[DefaultImportDeclaration]) !== null && _a !== void 0 ? _a : null);
25
+ return (expr[DefaultImportDeclaration] ?? null);
27
26
  }
28
27
  exports.getDefaultImportDeclaration = getDefaultImportDeclaration;
@@ -7,11 +7,9 @@
7
7
  */
8
8
  import ts from 'typescript';
9
9
  /**
10
- * Metadata extracted from an instance of a decorator on another declaration, or synthesized from
11
- * other information about a class.
10
+ * Metadata extracted from an instance of a decorator on another declaration.
12
11
  */
13
- export type Decorator = ConcreteDecorator | SyntheticDecorator;
14
- export interface BaseDecorator {
12
+ export interface Decorator {
15
13
  /**
16
14
  * Name by which the decorator was invoked in the user's code.
17
15
  *
@@ -22,48 +20,25 @@ export interface BaseDecorator {
22
20
  /**
23
21
  * Identifier which refers to the decorator in the user's code.
24
22
  */
25
- identifier: DecoratorIdentifier | null;
23
+ identifier: DecoratorIdentifier;
26
24
  /**
27
25
  * `Import` by which the decorator was brought into the module in which it was invoked, or `null`
28
26
  * if the decorator was declared in the same module and not imported.
27
+ *
28
+ * Note: this field is declared using computed property syntax to work around a clang-format bug
29
+ * that resulted in inconsistent indentation of this comment block.
29
30
  */
30
- import: Import | null;
31
+ ['import']: Import | null;
31
32
  /**
32
- * TypeScript reference to the decorator itself, or `null` if the decorator is synthesized (e.g.
33
- * in ngcc).
33
+ * TypeScript reference to the decorator itself.
34
34
  */
35
- node: ts.Node | null;
35
+ node: ts.Node;
36
36
  /**
37
37
  * Arguments of the invocation of the decorator, if the decorator is invoked, or `null`
38
38
  * otherwise.
39
39
  */
40
40
  args: ts.Expression[] | null;
41
41
  }
42
- /**
43
- * Metadata extracted from an instance of a decorator on another declaration, which was actually
44
- * present in a file.
45
- *
46
- * Concrete decorators always have an `identifier` and a `node`.
47
- */
48
- export interface ConcreteDecorator extends BaseDecorator {
49
- identifier: DecoratorIdentifier;
50
- node: ts.Node;
51
- }
52
- /**
53
- * Synthetic decorators never have an `identifier` or a `node`, but know the node for which they
54
- * were synthesized.
55
- */
56
- export interface SyntheticDecorator extends BaseDecorator {
57
- identifier: null;
58
- node: null;
59
- /**
60
- * The `ts.Node` for which this decorator was created.
61
- */
62
- synthesizedFor: ts.Node;
63
- }
64
- export declare const Decorator: {
65
- nodeForError: (decorator: Decorator) => ts.Node;
66
- };
67
42
  /**
68
43
  * A decorator is identified by either a simple identifier (e.g. `Decorator`) or, in some cases,
69
44
  * a namespaced property access (e.g. `core.Decorator`).
@@ -367,7 +342,7 @@ export interface FunctionDefinition {
367
342
  /**
368
343
  * A reference to the node which declares the function.
369
344
  */
370
- node: ts.MethodDeclaration | ts.FunctionDeclaration | ts.FunctionExpression | ts.VariableDeclaration;
345
+ node: ts.MethodDeclaration | ts.FunctionDeclaration | ts.FunctionExpression | ts.VariableDeclaration | ts.ArrowFunction;
371
346
  /**
372
347
  * Statements of the function body, if a body is present, or null if no body is present or the
373
348
  * function is identified to represent a tslib helper function, in which case `helper` will
@@ -381,35 +356,14 @@ export interface FunctionDefinition {
381
356
  * Metadata regarding the function's parameters, including possible default value expressions.
382
357
  */
383
358
  parameters: Parameter[];
384
- }
385
- /**
386
- * Possible declarations of known values, such as built-in objects/functions or TypeScript helpers.
387
- */
388
- export declare enum KnownDeclaration {
389
- /**
390
- * Indicates the JavaScript global `Object` class.
391
- */
392
- JsGlobalObject = 0,
393
- /**
394
- * Indicates the `__assign` TypeScript helper function.
395
- */
396
- TsHelperAssign = 1,
397
- /**
398
- * Indicates the `__spread` TypeScript helper function.
399
- */
400
- TsHelperSpread = 2,
401
- /**
402
- * Indicates the `__spreadArrays` TypeScript helper function.
403
- */
404
- TsHelperSpreadArrays = 3,
405
359
  /**
406
- * Indicates the `__spreadArray` TypeScript helper function.
360
+ * Generic type parameters of the function.
407
361
  */
408
- TsHelperSpreadArray = 4,
362
+ typeParameters: ts.TypeParameterDeclaration[] | null;
409
363
  /**
410
- * Indicates the `__read` TypeScript helper function.
364
+ * Number of known signatures of the function.
411
365
  */
412
- TsHelperRead = 5
366
+ signatureCount: number;
413
367
  }
414
368
  /**
415
369
  * A parameter to a function or method.
@@ -427,6 +381,10 @@ export interface Parameter {
427
381
  * Expression which represents the default value of the parameter, if any.
428
382
  */
429
383
  initializer: ts.Expression | null;
384
+ /**
385
+ * Type of the parameter.
386
+ */
387
+ type: ts.TypeNode | null;
430
388
  }
431
389
  /**
432
390
  * The source of an imported symbol, including the original symbol name and the module from which it
@@ -443,50 +401,20 @@ export interface Import {
443
401
  * This could either be an absolute module name (@angular/core for example) or a relative path.
444
402
  */
445
403
  from: string;
446
- }
447
- /**
448
- * A single enum member extracted from JavaScript when no `ts.EnumDeclaration` is available.
449
- */
450
- export interface EnumMember {
451
- /**
452
- * The name of the enum member.
453
- */
454
- name: ts.PropertyName;
455
404
  /**
456
- * The initializer expression of the enum member. Unlike in TypeScript, this is always available
457
- * in emitted JavaScript.
405
+ * TypeScript node that represents this import.
458
406
  */
459
- initializer: ts.Expression;
407
+ node: ts.ImportDeclaration;
460
408
  }
461
409
  /**
462
410
  * A type that is used to identify a declaration.
463
- *
464
- * Declarations are normally `ts.Declaration` types such as variable declarations, class
465
- * declarations, function declarations etc.
466
- * But in some cases there is no `ts.Declaration` that can be used for a declaration, such
467
- * as when they are declared inline as part of an exported expression. Then we must use a
468
- * `ts.Expression` as the declaration.
469
- * An example of this is `exports.someVar = 42` where the declaration expression would be
470
- * `exports.someVar`.
471
411
  */
472
- export type DeclarationNode = ts.Declaration | ts.Expression;
412
+ export type DeclarationNode = ts.Declaration;
473
413
  /**
474
- * The type of a Declaration - whether its node is concrete (ts.Declaration) or inline
475
- * (ts.Expression). See `ConcreteDeclaration`, `InlineDeclaration` and `DeclarationNode` for more
476
- * information about this.
477
- */
478
- export declare const enum DeclarationKind {
479
- Concrete = 0,
480
- Inline = 1
481
- }
482
- /**
483
- * Base type for all `Declaration`s.
414
+ * The declaration of a symbol, along with information about how it was imported into the
415
+ * application.
484
416
  */
485
- export interface BaseDeclaration<T extends DeclarationNode> {
486
- /**
487
- * The type of the underlying `node`.
488
- */
489
- kind: DeclarationKind;
417
+ export interface Declaration<T extends ts.Declaration = ts.Declaration> {
490
418
  /**
491
419
  * The absolute module path from which the symbol was imported into the application, if the symbol
492
420
  * was imported via an absolute module (even through a chain of re-exports). If the symbol is part
@@ -497,53 +425,7 @@ export interface BaseDeclaration<T extends DeclarationNode> {
497
425
  * TypeScript reference to the declaration itself, if one exists.
498
426
  */
499
427
  node: T;
500
- /**
501
- * If set, describes the type of the known declaration this declaration resolves to.
502
- */
503
- known: KnownDeclaration | null;
504
- }
505
- /**
506
- * Returns true if the `decl` is a `ConcreteDeclaration` (ie. that its `node` property is a
507
- * `ts.Declaration`).
508
- */
509
- export declare function isConcreteDeclaration(decl: Declaration): decl is ConcreteDeclaration;
510
- export interface ConcreteDeclaration<T extends ts.Declaration = ts.Declaration> extends BaseDeclaration<T> {
511
- kind: DeclarationKind.Concrete;
512
- /**
513
- * Optionally represents a special identity of the declaration, or `null` if the declaration
514
- * does not have a special identity.
515
- */
516
- identity: SpecialDeclarationIdentity | null;
517
- }
518
- export type SpecialDeclarationIdentity = DownleveledEnum;
519
- export declare const enum SpecialDeclarationKind {
520
- DownleveledEnum = 0
521
- }
522
- /**
523
- * A special declaration identity that represents an enum. This is used in downleveled forms where
524
- * a `ts.EnumDeclaration` is emitted in an alternative form, e.g. an IIFE call that declares all
525
- * members.
526
- */
527
- export interface DownleveledEnum {
528
- kind: SpecialDeclarationKind.DownleveledEnum;
529
- enumMembers: EnumMember[];
530
428
  }
531
- /**
532
- * A declaration that does not have an associated TypeScript `ts.Declaration`.
533
- *
534
- * This can occur in some downlevelings when an `export const VAR = ...;` (a `ts.Declaration`) is
535
- * transpiled to an assignment statement (e.g. `exports.VAR = ...;`). There is no `ts.Declaration`
536
- * associated with `VAR` in that case, only an expression.
537
- */
538
- export interface InlineDeclaration extends BaseDeclaration<Exclude<DeclarationNode, ts.Declaration>> {
539
- kind: DeclarationKind.Inline;
540
- implementation?: DeclarationNode;
541
- }
542
- /**
543
- * The declaration of a symbol, along with information about how it was imported into the
544
- * application.
545
- */
546
- export type Declaration<T extends ts.Declaration = ts.Declaration> = ConcreteDeclaration<T> | InlineDeclaration;
547
429
  /**
548
430
  * Abstracts reflection operations on a TypeScript AST.
549
431
  *
@@ -632,35 +514,4 @@ export interface ReflectionHost {
632
514
  * is not a class or has an unknown number of type parameters.
633
515
  */
634
516
  getGenericArityOfClass(clazz: ClassDeclaration): number | null;
635
- /**
636
- * Take an exported declaration (maybe a class down-leveled to a variable) and look up the
637
- * declaration of its type in a separate .d.ts tree.
638
- *
639
- * This function is allowed to return `null` if the current compilation unit does not have a
640
- * separate .d.ts tree. When compiling TypeScript code this is always the case, since .d.ts files
641
- * are produced only during the emit of such a compilation. When compiling .js code, however,
642
- * there is frequently a parallel .d.ts tree which this method exposes.
643
- *
644
- * Note that the `ts.Declaration` returned from this function may not be from the same
645
- * `ts.Program` as the input declaration.
646
- */
647
- getDtsDeclaration(declaration: DeclarationNode): ts.Declaration | null;
648
- /**
649
- * Get a `ts.Identifier` for a given `ClassDeclaration` which can be used to refer to the class
650
- * within its definition (such as in static fields).
651
- *
652
- * This can differ from `clazz.name` when ngcc runs over ES5 code, since the class may have a
653
- * different name within its IIFE wrapper than it does externally.
654
- */
655
- getInternalNameOfClass(clazz: ClassDeclaration): ts.Identifier;
656
- /**
657
- * Get a `ts.Identifier` for a given `ClassDeclaration` which can be used to refer to the class
658
- * from statements that are "adjacent", and conceptually tightly bound, to the class but not
659
- * actually inside it.
660
- *
661
- * Similar to `getInternalNameOfClass()`, this name can differ from `clazz.name` when ngcc runs
662
- * over ES5 code, since these "adjacent" statements need to exist in the IIFE where the class may
663
- * have a different name than it does externally.
664
- */
665
- getAdjacentNameOfClass(clazz: ClassDeclaration): ts.Identifier;
666
517
  }