static-injector 2.0.0 → 2.1.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.
- package/import/commonjs/index.js +425 -163
- package/import/es2015/di/create_injector.js +5 -1
- package/import/es2015/di/forward_ref.js +3 -3
- package/import/es2015/di/injection_token.js +18 -11
- package/import/es2015/di/injector_compatibility.js +19 -10
- package/import/es2015/di/injector_token.js +3 -3
- package/import/es2015/di/interface/defs.js +21 -12
- package/import/es2015/di/interface/provider.js +3 -1
- package/import/es2015/di/null_injector.js +3 -3
- package/import/es2015/di/provider_collection.js +196 -1
- package/import/es2015/di/r3_injector.js +31 -28
- package/import/es2015/error_details_base_url.js +19 -0
- package/import/es2015/errors.js +42 -0
- package/import/es2015/interface/type.js +14 -1
- package/import/es2015/render3/definition_factory.js +2 -3
- package/import/es2015/render3/errors_di.js +2 -3
- package/import/es2015/render3/instructions/di.js +0 -7
- package/import/es2015/render3/util/stringify_utils.js +5 -5
- package/import/es2015/util/array_utils.js +0 -7
- package/import/es2015/util/decorators.js +24 -1
- package/import/es2015/util/empty.js +4 -0
- package/import/es2015/util/stringify.js +5 -5
- package/import/fesm2015/index.js +422 -161
- package/import/typings/di/forward_ref.d.ts +1 -1
- package/import/typings/di/injectable.d.ts +5 -4
- package/import/typings/di/injection_token.d.ts +21 -6
- package/import/typings/di/injector.d.ts +16 -0
- package/import/typings/di/injector_compatibility.d.ts +11 -5
- package/import/typings/di/injector_token.d.ts +2 -2
- package/import/typings/di/interface/defs.d.ts +15 -8
- package/import/typings/di/interface/provider.d.ts +62 -2
- package/import/typings/di/null_injector.d.ts +1 -1
- package/import/typings/di/provider_collection.d.ts +55 -2
- package/import/typings/di/provider_token.d.ts +3 -3
- package/import/typings/di/r3_injector.d.ts +3 -8
- package/import/typings/di/scope.d.ts +1 -1
- package/import/typings/error_details_base_url.d.ts +19 -0
- package/import/typings/errors.d.ts +89 -0
- package/import/typings/interface/type.d.ts +45 -0
- package/import/typings/render3/definition_factory.d.ts +1 -1
- package/import/typings/render3/errors_di.d.ts +7 -0
- package/import/typings/render3/instructions/di.d.ts +0 -7
- package/import/typings/util/array_utils.d.ts +15 -7
- package/import/typings/util/decorators.d.ts +2 -1
- package/import/typings/util/empty.d.ts +1 -0
- package/package.json +3 -3
- package/transform/compiler/compiler.d.ts +8 -0
- package/transform/compiler/compiler.js +28 -0
- package/transform/compiler/index.d.ts +8 -5
- package/transform/compiler/index.js +12 -5
- package/transform/compiler/public_api.d.ts +13 -0
- package/transform/compiler/public_api.js +30 -0
- package/transform/compiler/src/compiler.d.ts +27 -0
- package/transform/compiler/src/compiler.js +47 -0
- package/transform/compiler/src/output/output_ast.d.ts +1 -1
- package/transform/compiler/src/render3/partial/api.d.ts +1 -1
- package/transform/compiler/src/render3/partial/api.js +7 -0
- package/transform/compiler/src/render3/r3_factory.d.ts +8 -15
- package/transform/compiler/src/render3/r3_factory.js +37 -56
- package/transform/compiler/src/render3/view/util.d.ts +0 -8
- package/transform/compiler/src/render3/view/util.js +0 -8
- package/transform/compiler-cli/src/ngtsc/annotations/common/index.d.ts +10 -0
- package/transform/compiler-cli/src/ngtsc/annotations/common/index.js +26 -0
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.d.ts +37 -0
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/di.js +197 -0
- package/transform/compiler-cli/src/ngtsc/annotations/{src → common/src}/factory.d.ts +3 -3
- package/transform/compiler-cli/src/ngtsc/annotations/{src → common/src}/factory.js +2 -2
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.d.ts +3 -34
- package/transform/compiler-cli/src/ngtsc/annotations/common/src/util.js +18 -216
- package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.d.ts +3 -4
- package/transform/compiler-cli/src/ngtsc/annotations/src/injectable.js +31 -50
- package/transform/compiler-cli/src/ngtsc/diagnostics/index.d.ts +9 -2
- package/transform/compiler-cli/src/ngtsc/diagnostics/index.js +7 -0
- package/transform/compiler-cli/src/ngtsc/imports/index.d.ts +7 -0
- package/transform/compiler-cli/src/ngtsc/imports/index.js +7 -0
- package/transform/compiler-cli/src/ngtsc/imports/src/default.d.ts +19 -0
- package/transform/compiler-cli/src/ngtsc/imports/src/default.js +28 -0
- package/transform/compiler-cli/src/ngtsc/reflection/index.d.ts +10 -3
- package/transform/compiler-cli/src/ngtsc/reflection/index.js +7 -0
- package/transform/compiler-cli/src/ngtsc/reflection/src/host.d.ts +12 -13
- package/transform/compiler-cli/src/ngtsc/reflection/src/host.js +7 -28
- package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.d.ts +1 -1
- package/transform/compiler-cli/src/ngtsc/reflection/src/type_to_value.js +17 -41
- package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.d.ts +1 -1
- package/transform/compiler-cli/src/ngtsc/reflection/src/typescript.js +46 -65
- package/transform/compiler-cli/src/ngtsc/reflection/src/util.d.ts +2 -2
- package/transform/compiler-cli/src/ngtsc/reflection/src/util.js +7 -27
- package/transform/compiler-cli/src/ngtsc/transform/index.d.ts +9 -2
- package/transform/compiler-cli/src/ngtsc/transform/index.js +7 -0
- package/transform/compiler-cli/src/ngtsc/transform/src/api.d.ts +4 -4
- package/transform/compiler-cli/src/ngtsc/transform/src/utils.d.ts +1 -1
- package/transform/compiler-cli/src/ngtsc/transform/src/utils.js +15 -35
- package/transform/compiler-cli/src/ngtsc/translator/index.d.ts +12 -5
- package/transform/compiler-cli/src/ngtsc/translator/index.js +7 -0
- package/transform/compiler-cli/src/ngtsc/translator/src/api/ast_factory.d.ts +5 -5
- package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.d.ts +2 -2
- package/transform/compiler-cli/src/ngtsc/translator/src/import_manager.js +4 -24
- package/transform/compiler-cli/src/ngtsc/translator/src/translator.d.ts +2 -2
- package/transform/compiler-cli/src/ngtsc/translator/src/translator.js +1 -1
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.d.ts +1 -1
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_ast_factory.js +76 -95
- package/transform/compiler-cli/src/ngtsc/translator/src/typescript_translator.d.ts +4 -4
- package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.d.ts +20 -126
- package/transform/compiler-cli/src/ngtsc/ts_compatibility/src/ts_cross_version_utils.js +23 -147
- package/transform/compiler-cli/src/ngtsc/util/src/typescript.d.ts +1 -8
- package/transform/compiler-cli/src/ngtsc/util/src/typescript.js +4 -31
- 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.
|
|
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.
|
|
16
|
-
const
|
|
15
|
+
/** Whether the current TypeScript version is after 4.9. */
|
|
16
|
+
const IS_AFTER_TS_49 = isAfterVersion(4, 9);
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Creates a `ts.ParameterDeclaration` declaration.
|
|
19
19
|
*
|
|
20
|
-
* TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.
|
|
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.
|
|
24
|
-
? typescript_1.default.factory.
|
|
25
|
-
: (
|
|
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
|
-
*
|
|
27
|
+
* Creates a `ts.ImportDeclaration` declaration.
|
|
28
28
|
*
|
|
29
|
-
* TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.
|
|
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.
|
|
33
|
-
? typescript_1.default.factory.
|
|
34
|
-
: (
|
|
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
|
-
*
|
|
36
|
+
* Creates a `ts.FunctionDeclaration` declaration.
|
|
37
37
|
*
|
|
38
|
-
* TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.
|
|
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.
|
|
42
|
-
? typescript_1.default.factory.
|
|
43
|
-
: (
|
|
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.
|
|
45
|
+
* Creates a `ts.IndexSignatureDeclaration` declaration.
|
|
46
46
|
*
|
|
47
|
-
* TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.
|
|
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.
|
|
51
|
-
? typescript_1.default.factory.
|
|
52
|
-
: (
|
|
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
|
-
|
|
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
|
|
7
|
+
const typescript_1 = __importDefault(require("typescript"));
|
|
35
8
|
function identifierOfNode(decl) {
|
|
36
|
-
if (decl.name !== undefined &&
|
|
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
|
-
|
|
37
|
-
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
+
}
|