static-injector 2.0.0 → 2.1.0

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 (72) hide show
  1. package/import/commonjs/index.js +6 -6
  2. package/import/es2015/di/r3_injector.js +6 -6
  3. package/import/fesm2015/index.js +6 -6
  4. package/import/typings/di/injectable.d.ts +1 -1
  5. package/import/typings/di/interface/provider.d.ts +2 -2
  6. package/import/typings/di/provider_collection.d.ts +1 -1
  7. package/import/typings/di/provider_token.d.ts +1 -1
  8. package/import/typings/di/r3_injector.d.ts +1 -1
  9. package/import/typings/di/scope.d.ts +1 -1
  10. package/import/typings/render3/definition_factory.d.ts +1 -1
  11. package/package.json +3 -3
  12. package/transform/compiler/compiler.d.ts +8 -0
  13. package/transform/compiler/compiler.js +28 -0
  14. package/transform/compiler/index.d.ts +8 -5
  15. package/transform/compiler/index.js +12 -5
  16. package/transform/compiler/public_api.d.ts +13 -0
  17. package/transform/compiler/public_api.js +30 -0
  18. package/transform/compiler/src/compiler.d.ts +27 -0
  19. package/transform/compiler/src/compiler.js +47 -0
  20. package/transform/compiler/src/output/output_ast.d.ts +1 -1
  21. package/transform/compiler/src/render3/partial/api.d.ts +1 -1
  22. package/transform/compiler/src/render3/partial/api.js +7 -0
  23. package/transform/compiler/src/render3/r3_factory.d.ts +8 -15
  24. package/transform/compiler/src/render3/r3_factory.js +37 -56
  25. package/transform/compiler/src/render3/view/util.d.ts +0 -8
  26. package/transform/compiler/src/render3/view/util.js +0 -8
  27. package/transform/compiler-cli/src/ngtsc/annotations/common/index.d.ts +10 -0
  28. package/transform/compiler-cli/src/ngtsc/annotations/common/index.js +26 -0
  29. package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.d.ts +37 -0
  30. package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.js +197 -0
  31. package/transform/compiler-cli/src/ngtsc/annotations/{src → common/src}/factory.d.ts +3 -3
  32. package/transform/compiler-cli/src/ngtsc/annotations/{src → common/src}/factory.js +2 -2
  33. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.d.ts +3 -34
  34. package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.js +18 -216
  35. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +3 -4
  36. package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +31 -50
  37. package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +9 -2
  38. package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +7 -0
  39. package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +7 -0
  40. package/transform/compiler-cli/src/ngtsc/imports/index.js +7 -0
  41. package/transform/compiler-cli/src/ngtsc/imports/src/default.d.ts +19 -0
  42. package/transform/compiler-cli/src/ngtsc/imports/src/default.js +28 -0
  43. package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +10 -3
  44. package/transform/compiler-cli/src/ngtsc/reflection/index.js +7 -0
  45. package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +12 -13
  46. package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +7 -28
  47. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +1 -1
  48. package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +17 -41
  49. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +1 -1
  50. package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +46 -65
  51. package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +2 -2
  52. package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +7 -27
  53. package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +9 -2
  54. package/transform/compiler-cli/src/ngtsc/transform/index.js +7 -0
  55. package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +4 -4
  56. package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +1 -1
  57. package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +15 -35
  58. package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +12 -5
  59. package/transform/compiler-cli/src/ngtsc/translator/index.js +7 -0
  60. package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +5 -5
  61. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +2 -2
  62. package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +4 -24
  63. package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +2 -2
  64. package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +1 -1
  65. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +1 -1
  66. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +76 -95
  67. package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +4 -4
  68. package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.d.ts +20 -126
  69. package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.js +23 -147
  70. package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +1 -8
  71. package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +4 -31
  72. package/transform/injectable-transform.js +36 -7
@@ -10,170 +10,46 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10
10
  return (mod && mod.__esModule) ? mod : { "default": mod };
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.combineModifiers = exports.getModifiers = exports.getDecorators = exports.updateConstructorDeclaration = exports.createSetAccessorDeclaration = exports.updateSetAccessorDeclaration = exports.createGetAccessorDeclaration = exports.updateGetAccessorDeclaration = exports.createPropertyDeclaration = exports.updatePropertyDeclaration = exports.createMethodDeclaration = exports.updateMethodDeclaration = exports.createClassDeclaration = exports.updateClassDeclaration = exports.updateImportDeclaration = exports.updateParameterDeclaration = void 0;
13
+ exports.createIndexSignature = exports.createFunctionDeclaration = exports.createImportDeclaration = exports.createParameterDeclaration = void 0;
14
14
  const typescript_1 = __importDefault(require("typescript"));
15
- /** Whether the current TypeScript version is after 4.8. */
16
- const IS_AFTER_TS_48 = isAfterVersion(4, 8);
15
+ /** Whether the current TypeScript version is after 4.9. */
16
+ const IS_AFTER_TS_49 = isAfterVersion(4, 9);
17
17
  /**
18
- * Updates a `ts.ParameterDeclaration` declaration.
18
+ * Creates a `ts.ParameterDeclaration` declaration.
19
19
  *
20
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
20
+ * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
21
21
  * We should remove it once we have dropped support for the older versions.
22
22
  */
23
- exports.updateParameterDeclaration = IS_AFTER_TS_48
24
- ? typescript_1.default.factory.updateParameterDeclaration
25
- : (node, modifiers, dotDotDotToken, name, questionToken, type, initializer) => typescript_1.default.factory.updateParameterDeclaration(node, ...splitModifiers(modifiers), dotDotDotToken, name, questionToken, type, initializer);
23
+ exports.createParameterDeclaration = IS_AFTER_TS_49
24
+ ? typescript_1.default.factory.createParameterDeclaration
25
+ : (modifiers, dotDotDotToken, name, questionToken, type, initializer) => typescript_1.default.factory.createParameterDeclaration(...splitModifiers(modifiers), dotDotDotToken, name, questionToken, type, initializer);
26
26
  /**
27
- * Updates a `ts.ImportDeclaration` declaration.
27
+ * Creates a `ts.ImportDeclaration` declaration.
28
28
  *
29
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
29
+ * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
30
30
  * We should remove it once we have dropped support for the older versions.
31
31
  */
32
- exports.updateImportDeclaration = IS_AFTER_TS_48
33
- ? typescript_1.default.factory.updateImportDeclaration
34
- : (node, modifiers, importClause, moduleSpecifier, assertClause) => typescript_1.default.factory.updateImportDeclaration(node, undefined, modifiers, importClause, moduleSpecifier, assertClause);
32
+ exports.createImportDeclaration = IS_AFTER_TS_49
33
+ ? typescript_1.default.factory.createImportDeclaration
34
+ : (modifiers, importClause, moduleSpecifier, assertClause) => typescript_1.default.factory.createImportDeclaration(undefined, modifiers, importClause, moduleSpecifier, assertClause);
35
35
  /**
36
- * Updates a `ts.ClassDeclaration` declaration.
36
+ * Creates a `ts.FunctionDeclaration` declaration.
37
37
  *
38
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
38
+ * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
39
39
  * We should remove it once we have dropped support for the older versions.
40
40
  */
41
- exports.updateClassDeclaration = IS_AFTER_TS_48
42
- ? typescript_1.default.factory.updateClassDeclaration
43
- : (node, combinedModifiers, name, typeParameters, heritageClauses, members) => typescript_1.default.factory.updateClassDeclaration(node, ...splitModifiers(combinedModifiers), name, typeParameters, heritageClauses, members);
41
+ exports.createFunctionDeclaration = IS_AFTER_TS_49
42
+ ? typescript_1.default.factory.createFunctionDeclaration
43
+ : (modifiers, asteriskToken, name, typeParameters, parameters, type, body) => typescript_1.default.factory.createFunctionDeclaration(...splitModifiers(modifiers), asteriskToken, name, typeParameters, parameters, type, body);
44
44
  /**
45
- * Creates a `ts.ClassDeclaration` declaration.
45
+ * Creates a `ts.IndexSignatureDeclaration` declaration.
46
46
  *
47
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
47
+ * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
48
48
  * We should remove it once we have dropped support for the older versions.
49
49
  */
50
- exports.createClassDeclaration = IS_AFTER_TS_48
51
- ? typescript_1.default.factory.createClassDeclaration
52
- : (combinedModifiers, name, typeParameters, heritageClauses, members) => typescript_1.default.factory.createClassDeclaration(...splitModifiers(combinedModifiers), name, typeParameters, heritageClauses, members);
53
- /**
54
- * Updates a `ts.MethodDeclaration` declaration.
55
- *
56
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
57
- * We should remove it once we have dropped support for the older versions.
58
- */
59
- exports.updateMethodDeclaration = IS_AFTER_TS_48
60
- ? typescript_1.default.factory.updateMethodDeclaration
61
- : (node, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) => typescript_1.default.factory.updateMethodDeclaration(node, ...splitModifiers(modifiers), asteriskToken, name, questionToken, typeParameters, parameters, type, body);
62
- /**
63
- * Creates a `ts.MethodDeclaration` declaration.
64
- *
65
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
66
- * We should remove it once we have dropped support for the older versions.
67
- */
68
- exports.createMethodDeclaration = IS_AFTER_TS_48
69
- ? typescript_1.default.factory.createMethodDeclaration
70
- : (modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) => typescript_1.default.factory.createMethodDeclaration(...splitModifiers(modifiers), asteriskToken, name, questionToken, typeParameters, parameters, type, body);
71
- /**
72
- * Updates a `ts.PropertyDeclaration` declaration.
73
- *
74
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
75
- * We should remove it once we have dropped support for the older versions.
76
- */
77
- exports.updatePropertyDeclaration = IS_AFTER_TS_48
78
- ? typescript_1.default.factory.updatePropertyDeclaration
79
- : (node, modifiers, name, questionOrExclamationToken, type, initializer) => typescript_1.default.factory.updatePropertyDeclaration(node, ...splitModifiers(modifiers), name, questionOrExclamationToken, type, initializer);
80
- /**
81
- * Creates a `ts.PropertyDeclaration` declaration.
82
- *
83
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
84
- * We should remove it once we have dropped support for the older versions.
85
- */
86
- exports.createPropertyDeclaration = IS_AFTER_TS_48
87
- ? typescript_1.default.factory.createPropertyDeclaration
88
- : (modifiers, name, questionOrExclamationToken, type, initializer) => typescript_1.default.factory.createPropertyDeclaration(...splitModifiers(modifiers), name, questionOrExclamationToken, type, initializer);
89
- /**
90
- * Updates a `ts.GetAccessorDeclaration` declaration.
91
- *
92
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
93
- * We should remove it once we have dropped support for the older versions.
94
- */
95
- exports.updateGetAccessorDeclaration = IS_AFTER_TS_48
96
- ? typescript_1.default.factory.updateGetAccessorDeclaration
97
- : (node, modifiers, name, parameters, type, body) => typescript_1.default.factory.updateGetAccessorDeclaration(node, ...splitModifiers(modifiers), name, parameters, type, body);
98
- /**
99
- * Creates a `ts.GetAccessorDeclaration` declaration.
100
- *
101
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
102
- * We should remove it once we have dropped support for the older versions.
103
- */
104
- exports.createGetAccessorDeclaration = IS_AFTER_TS_48
105
- ? typescript_1.default.factory.createGetAccessorDeclaration
106
- : (modifiers, name, parameters, type, body) => typescript_1.default.factory.createGetAccessorDeclaration(...splitModifiers(modifiers), name, parameters, type, body);
107
- /**
108
- * Updates a `ts.GetAccessorDeclaration` declaration.
109
- *
110
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
111
- * We should remove it once we have dropped support for the older versions.
112
- */
113
- exports.updateSetAccessorDeclaration = IS_AFTER_TS_48
114
- ? typescript_1.default.factory.updateSetAccessorDeclaration
115
- : (node, modifiers, name, parameters, body) => typescript_1.default.factory.updateSetAccessorDeclaration(node, ...splitModifiers(modifiers), name, parameters, body);
116
- /**
117
- * Creates a `ts.GetAccessorDeclaration` declaration.
118
- *
119
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
120
- * We should remove it once we have dropped support for the older versions.
121
- */
122
- exports.createSetAccessorDeclaration = IS_AFTER_TS_48
123
- ? typescript_1.default.factory.createSetAccessorDeclaration
124
- : (modifiers, name, parameters, body) => typescript_1.default.factory.createSetAccessorDeclaration(...splitModifiers(modifiers), name, parameters, body);
125
- /**
126
- * Updates a `ts.ConstructorDeclaration` declaration.
127
- *
128
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
129
- * We should remove it once we have dropped support for the older versions.
130
- */
131
- exports.updateConstructorDeclaration = IS_AFTER_TS_48
132
- ? typescript_1.default.factory.updateConstructorDeclaration
133
- : (node, modifiers, parameters, body) => typescript_1.default.factory.updateConstructorDeclaration(node, undefined, modifiers, parameters, body);
134
- /**
135
- * Gets the decorators that have been applied to a node.
136
- *
137
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
138
- * We should remove it once we have dropped support for the older versions.
139
- */
140
- exports.getDecorators = IS_AFTER_TS_48
141
- ? typescript_1.default.getDecorators
142
- : (node) => node.decorators;
143
- /**
144
- * Gets the modifiers that have been set on a node.
145
- *
146
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
147
- * We should remove it once we have dropped support for the older versions.
148
- */
149
- exports.getModifiers = IS_AFTER_TS_48
150
- ? typescript_1.default.getModifiers
151
- : (node) => node.modifiers;
152
- /**
153
- * Combines an optional array of decorators with an optional array of modifiers into a single
154
- * `ts.ModifierLike` array. Used in version of TypeScript after 4.8 where the `decorators` and
155
- * `modifiers` arrays have been combined.
156
- *
157
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
158
- * We should remove it once we have dropped support for the older versions.
159
- */
160
- function combineModifiers(decorators, modifiers) {
161
- const hasDecorators = decorators === null || decorators === void 0 ? void 0 : decorators.length;
162
- const hasModifiers = modifiers === null || modifiers === void 0 ? void 0 : modifiers.length;
163
- // This function can be written more compactly, but it is somewhat performance-sensitive
164
- // so we have some additional logic only to create new arrays when necessary.
165
- if (hasDecorators && hasModifiers) {
166
- return [...decorators, ...modifiers];
167
- }
168
- if (hasDecorators && !hasModifiers) {
169
- return decorators;
170
- }
171
- if (hasModifiers && !hasDecorators) {
172
- return modifiers;
173
- }
174
- return undefined;
175
- }
176
- exports.combineModifiers = combineModifiers;
50
+ exports.createIndexSignature = IS_AFTER_TS_49
51
+ ? typescript_1.default.factory.createIndexSignature
52
+ : (modifiers, parameters, type) => typescript_1.default.factory.createIndexSignature(modifiers, parameters, type);
177
53
  /**
178
54
  * Splits a `ModifierLike` into two arrays: decorators and modifiers. Used for backwards
179
55
  * compatibility with TS 4.7 and below where most factory functions require separate `decorators`
@@ -1,11 +1,4 @@
1
- /**
2
- * @license
3
- * Copyright Google LLC All Rights Reserved.
4
- *
5
- * Use of this source code is governed by an MIT-style license that can be
6
- * found in the LICENSE file at https://angular.io/license
7
- */
8
- import * as ts from "typescript";
1
+ import ts from 'typescript';
9
2
  export declare function identifierOfNode(decl: ts.Node & {
10
3
  name?: ts.Node;
11
4
  }): ts.Identifier | null;
@@ -1,39 +1,12 @@
1
1
  "use strict";
2
- /**
3
- * @license
4
- * Copyright Google LLC All Rights Reserved.
5
- *
6
- * Use of this source code is governed by an MIT-style license that can be
7
- * found in the LICENSE file at https://angular.io/license
8
- */
9
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- var desc = Object.getOwnPropertyDescriptor(m, k);
12
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
- desc = { enumerable: true, get: function() { return m[k]; } };
14
- }
15
- Object.defineProperty(o, k2, desc);
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
- Object.defineProperty(o, "default", { enumerable: true, value: v });
22
- }) : function(o, v) {
23
- o["default"] = v;
24
- });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
31
4
  };
32
5
  Object.defineProperty(exports, "__esModule", { value: true });
33
6
  exports.identifierOfNode = void 0;
34
- const ts = __importStar(require("typescript"));
7
+ const typescript_1 = __importDefault(require("typescript"));
35
8
  function identifierOfNode(decl) {
36
- if (decl.name !== undefined && ts.isIdentifier(decl.name)) {
9
+ if (decl.name !== undefined && typescript_1.default.isIdentifier(decl.name)) {
37
10
  return decl.name;
38
11
  }
39
12
  else {
@@ -10,7 +10,6 @@ const imports_1 = require("./compiler-cli/src/ngtsc/imports");
10
10
  const reflection_1 = require("./compiler-cli/src/ngtsc/reflection");
11
11
  const transform_1 = require("./compiler-cli/src/ngtsc/transform");
12
12
  const translator_1 = require("./compiler-cli/src/ngtsc/translator");
13
- const ts_compatibility_1 = require("./compiler-cli/src/ngtsc/ts_compatibility");
14
13
  const node_Iteration_1 = require("./node-Iteration");
15
14
  const NO_DECORATORS = new Set();
16
15
  function createTransformer(program, options) {
@@ -33,8 +32,18 @@ class InjectableTransformerFactory {
33
32
  return typescript_1.default.visitEachChild(node, (node) => {
34
33
  let result = map.get(node);
35
34
  if (result) {
36
- let decoratorList = (0, ts_compatibility_1.getDecorators)(node).filter((item) => item !== result.decorator);
37
- return (0, ts_compatibility_1.updateClassDeclaration)(node, (0, ts_compatibility_1.combineModifiers)(decoratorList.length ? decoratorList : undefined, (0, ts_compatibility_1.getModifiers)(node)), node.name, node.typeParameters, node.heritageClauses, [
35
+ const filteredDecorators =
36
+ // Remove the decorator which triggered this compilation, leaving the others alone.
37
+ maybeFilterDecorator(typescript_1.default.getDecorators(node), [result.decorator]);
38
+ const nodeModifiers = typescript_1.default.getModifiers(node);
39
+ let updatedModifiers;
40
+ if ((filteredDecorators === null || filteredDecorators === void 0 ? void 0 : filteredDecorators.length) || (nodeModifiers === null || nodeModifiers === void 0 ? void 0 : nodeModifiers.length)) {
41
+ updatedModifiers = [
42
+ ...(filteredDecorators || []),
43
+ ...(nodeModifiers || []),
44
+ ];
45
+ }
46
+ return typescript_1.default.factory.updateClassDeclaration(node, updatedModifiers, node.name, node.typeParameters, node.heritageClauses, [
38
47
  ...node.members.map((node) => this._stripAngularDecorators(node)),
39
48
  ...result.members,
40
49
  ]);
@@ -82,7 +91,7 @@ class InjectableTransformerFactory {
82
91
  // Translate the initializer for the field into TS nodes.
83
92
  const exprNode = (0, translator_1.translateExpression)(field.initializer, importManager);
84
93
  // Create a static property declaration for the new field.
85
- const property = (0, ts_compatibility_1.createPropertyDeclaration)([typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.StaticKeyword)], field.name, undefined, undefined, exprNode);
94
+ const property = typescript_1.default.factory.createPropertyDeclaration([typescript_1.default.factory.createToken(typescript_1.default.SyntaxKind.StaticKeyword)], field.name, undefined, undefined, exprNode);
86
95
  if (false) {
87
96
  // Closure compiler transforms the form `Service.ɵprov = X` into `Service$ɵprov = X`. To
88
97
  // prevent this transformation, such assignments need to be annotated with @nocollapse.
@@ -105,14 +114,24 @@ class InjectableTransformerFactory {
105
114
  * as parameters of constructors.
106
115
  */
107
116
  _stripAngularDecorators(node) {
117
+ const modifiers = typescript_1.default.canHaveModifiers(node)
118
+ ? typescript_1.default.getModifiers(node)
119
+ : undefined;
120
+ const nonCoreDecorators = typescript_1.default.canHaveDecorators(node)
121
+ ? this._nonCoreDecoratorsOnly(node)
122
+ : undefined;
123
+ const combinedModifiers = [
124
+ ...(nonCoreDecorators || []),
125
+ ...(modifiers || []),
126
+ ];
108
127
  if (typescript_1.default.isParameter(node)) {
109
128
  // Strip decorators from parameters (probably of the constructor).
110
- node = (0, ts_compatibility_1.updateParameterDeclaration)(node, (0, ts_compatibility_1.combineModifiers)(this._nonCoreDecoratorsOnly(node), (0, ts_compatibility_1.getModifiers)(node)), node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer);
129
+ node = typescript_1.default.factory.updateParameterDeclaration(node, combinedModifiers, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer);
111
130
  }
112
131
  else if (typescript_1.default.isConstructorDeclaration(node)) {
113
132
  // For constructors, strip decorators of the parameters.
114
133
  const parameters = node.parameters.map((param) => this._stripAngularDecorators(param));
115
- node = (0, ts_compatibility_1.updateConstructorDeclaration)(node, (0, ts_compatibility_1.getModifiers)(node), parameters, node.body);
134
+ node = typescript_1.default.factory.updateConstructorDeclaration(node, modifiers, parameters, node.body);
116
135
  }
117
136
  return node;
118
137
  }
@@ -143,7 +162,7 @@ class InjectableTransformerFactory {
143
162
  * `undefined`.
144
163
  */
145
164
  _nonCoreDecoratorsOnly(node) {
146
- const decorators = (0, ts_compatibility_1.getDecorators)(node);
165
+ const decorators = typescript_1.default.getDecorators(node);
147
166
  // Shortcut if the node has no decorators.
148
167
  if (decorators === undefined) {
149
168
  return undefined;
@@ -188,3 +207,13 @@ function nodeArrayFromDecoratorsArray(decorators) {
188
207
  }
189
208
  return array;
190
209
  }
210
+ function maybeFilterDecorator(decorators, toRemove) {
211
+ if (decorators === undefined) {
212
+ return undefined;
213
+ }
214
+ const filtered = decorators.filter((dec) => toRemove.find((decToRemove) => typescript_1.default.getOriginalNode(dec) === decToRemove) === undefined);
215
+ if (filtered.length === 0) {
216
+ return undefined;
217
+ }
218
+ return typescript_1.default.factory.createNodeArray(filtered);
219
+ }