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
@@ -1,26 +1,6 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
4
  };
25
5
  Object.defineProperty(exports, "__esModule", { value: true });
26
6
  exports.attachComments = exports.createTemplateTail = exports.createTemplateMiddle = exports.TypeScriptAstFactory = void 0;
@@ -31,7 +11,8 @@ exports.attachComments = exports.createTemplateTail = exports.createTemplateMidd
31
11
  * Use of this source code is governed by an MIT-style license that can be
32
12
  * found in the LICENSE file at https://angular.io/license
33
13
  */
34
- const ts = __importStar(require("typescript"));
14
+ const typescript_1 = __importDefault(require("typescript"));
15
+ const ts_compatibility_1 = require("../../ts_compatibility");
35
16
  /**
36
17
  * Different optimizers use different annotations on a function or method call to indicate its pure
37
18
  * status.
@@ -47,33 +28,33 @@ var PureAnnotation;
47
28
  PureAnnotation["TERSER"] = "@__PURE__";
48
29
  })(PureAnnotation || (PureAnnotation = {}));
49
30
  const UNARY_OPERATORS = {
50
- '+': ts.SyntaxKind.PlusToken,
51
- '-': ts.SyntaxKind.MinusToken,
52
- '!': ts.SyntaxKind.ExclamationToken,
31
+ '+': typescript_1.default.SyntaxKind.PlusToken,
32
+ '-': typescript_1.default.SyntaxKind.MinusToken,
33
+ '!': typescript_1.default.SyntaxKind.ExclamationToken,
53
34
  };
54
35
  const BINARY_OPERATORS = {
55
- '&&': ts.SyntaxKind.AmpersandAmpersandToken,
56
- '>': ts.SyntaxKind.GreaterThanToken,
57
- '>=': ts.SyntaxKind.GreaterThanEqualsToken,
58
- '&': ts.SyntaxKind.AmpersandToken,
59
- '/': ts.SyntaxKind.SlashToken,
60
- '==': ts.SyntaxKind.EqualsEqualsToken,
61
- '===': ts.SyntaxKind.EqualsEqualsEqualsToken,
62
- '<': ts.SyntaxKind.LessThanToken,
63
- '<=': ts.SyntaxKind.LessThanEqualsToken,
64
- '-': ts.SyntaxKind.MinusToken,
65
- '%': ts.SyntaxKind.PercentToken,
66
- '*': ts.SyntaxKind.AsteriskToken,
67
- '!=': ts.SyntaxKind.ExclamationEqualsToken,
68
- '!==': ts.SyntaxKind.ExclamationEqualsEqualsToken,
69
- '||': ts.SyntaxKind.BarBarToken,
70
- '+': ts.SyntaxKind.PlusToken,
71
- '??': ts.SyntaxKind.QuestionQuestionToken,
36
+ '&&': typescript_1.default.SyntaxKind.AmpersandAmpersandToken,
37
+ '>': typescript_1.default.SyntaxKind.GreaterThanToken,
38
+ '>=': typescript_1.default.SyntaxKind.GreaterThanEqualsToken,
39
+ '&': typescript_1.default.SyntaxKind.AmpersandToken,
40
+ '/': typescript_1.default.SyntaxKind.SlashToken,
41
+ '==': typescript_1.default.SyntaxKind.EqualsEqualsToken,
42
+ '===': typescript_1.default.SyntaxKind.EqualsEqualsEqualsToken,
43
+ '<': typescript_1.default.SyntaxKind.LessThanToken,
44
+ '<=': typescript_1.default.SyntaxKind.LessThanEqualsToken,
45
+ '-': typescript_1.default.SyntaxKind.MinusToken,
46
+ '%': typescript_1.default.SyntaxKind.PercentToken,
47
+ '*': typescript_1.default.SyntaxKind.AsteriskToken,
48
+ '!=': typescript_1.default.SyntaxKind.ExclamationEqualsToken,
49
+ '!==': typescript_1.default.SyntaxKind.ExclamationEqualsEqualsToken,
50
+ '||': typescript_1.default.SyntaxKind.BarBarToken,
51
+ '+': typescript_1.default.SyntaxKind.PlusToken,
52
+ '??': typescript_1.default.SyntaxKind.QuestionQuestionToken,
72
53
  };
73
54
  const VAR_TYPES = {
74
- const: ts.NodeFlags.Const,
75
- let: ts.NodeFlags.Let,
76
- var: ts.NodeFlags.None,
55
+ const: typescript_1.default.NodeFlags.Const,
56
+ let: typescript_1.default.NodeFlags.Let,
57
+ var: typescript_1.default.NodeFlags.None,
77
58
  };
78
59
  /**
79
60
  * A TypeScript flavoured implementation of the AstFactory.
@@ -83,28 +64,28 @@ class TypeScriptAstFactory {
83
64
  this.annotateForClosureCompiler = annotateForClosureCompiler;
84
65
  this.externalSourceFiles = new Map();
85
66
  this.attachComments = attachComments;
86
- this.createArrayLiteral = ts.factory.createArrayLiteralExpression;
87
- this.createElementAccess = ts.factory.createElementAccessExpression;
88
- this.createExpressionStatement = ts.factory.createExpressionStatement;
89
- this.createIdentifier = ts.factory.createIdentifier;
90
- this.createParenthesizedExpression = ts.factory.createParenthesizedExpression;
91
- this.createPropertyAccess = ts.factory.createPropertyAccessExpression;
92
- this.createThrowStatement = ts.factory.createThrowStatement;
93
- this.createTypeOfExpression = ts.factory.createTypeOfExpression;
67
+ this.createArrayLiteral = typescript_1.default.factory.createArrayLiteralExpression;
68
+ this.createElementAccess = typescript_1.default.factory.createElementAccessExpression;
69
+ this.createExpressionStatement = typescript_1.default.factory.createExpressionStatement;
70
+ this.createIdentifier = typescript_1.default.factory.createIdentifier;
71
+ this.createParenthesizedExpression = typescript_1.default.factory.createParenthesizedExpression;
72
+ this.createPropertyAccess = typescript_1.default.factory.createPropertyAccessExpression;
73
+ this.createThrowStatement = typescript_1.default.factory.createThrowStatement;
74
+ this.createTypeOfExpression = typescript_1.default.factory.createTypeOfExpression;
94
75
  }
95
76
  createAssignment(target, value) {
96
- return ts.factory.createBinaryExpression(target, ts.SyntaxKind.EqualsToken, value);
77
+ return typescript_1.default.factory.createBinaryExpression(target, typescript_1.default.SyntaxKind.EqualsToken, value);
97
78
  }
98
79
  createBinaryExpression(leftOperand, operator, rightOperand) {
99
- return ts.factory.createBinaryExpression(leftOperand, BINARY_OPERATORS[operator], rightOperand);
80
+ return typescript_1.default.factory.createBinaryExpression(leftOperand, BINARY_OPERATORS[operator], rightOperand);
100
81
  }
101
82
  createBlock(body) {
102
- return ts.factory.createBlock(body);
83
+ return typescript_1.default.factory.createBlock(body);
103
84
  }
104
85
  createCallExpression(callee, args, pure) {
105
- const call = ts.factory.createCallExpression(callee, undefined, args);
86
+ const call = typescript_1.default.factory.createCallExpression(callee, undefined, args);
106
87
  if (pure) {
107
- ts.addSyntheticLeadingComment(call, ts.SyntaxKind.MultiLineCommentTrivia, this.annotateForClosureCompiler
88
+ typescript_1.default.addSyntheticLeadingComment(call, typescript_1.default.SyntaxKind.MultiLineCommentTrivia, this.annotateForClosureCompiler
108
89
  ? PureAnnotation.CLOSURE
109
90
  : PureAnnotation.TERSER,
110
91
  /* trailing newline */ false);
@@ -112,57 +93,57 @@ class TypeScriptAstFactory {
112
93
  return call;
113
94
  }
114
95
  createConditional(condition, whenTrue, whenFalse) {
115
- return ts.factory.createConditionalExpression(condition, undefined, whenTrue, undefined, whenFalse);
96
+ return typescript_1.default.factory.createConditionalExpression(condition, undefined, whenTrue, undefined, whenFalse);
116
97
  }
117
98
  createFunctionDeclaration(functionName, parameters, body) {
118
- if (!ts.isBlock(body)) {
119
- throw new Error(`Invalid syntax, expected a block, but got ${ts.SyntaxKind[body.kind]}.`);
99
+ if (!typescript_1.default.isBlock(body)) {
100
+ throw new Error(`Invalid syntax, expected a block, but got ${typescript_1.default.SyntaxKind[body.kind]}.`);
120
101
  }
121
- return ts.factory.createFunctionDeclaration(undefined, undefined, undefined, functionName, undefined, parameters.map((param) => ts.factory.createParameterDeclaration(undefined, undefined, undefined, param)), undefined, body);
102
+ return (0, ts_compatibility_1.createFunctionDeclaration)(undefined, undefined, functionName, undefined, parameters.map((param) => (0, ts_compatibility_1.createParameterDeclaration)(undefined, undefined, param)), undefined, body);
122
103
  }
123
104
  createFunctionExpression(functionName, parameters, body) {
124
- if (!ts.isBlock(body)) {
125
- throw new Error(`Invalid syntax, expected a block, but got ${ts.SyntaxKind[body.kind]}.`);
105
+ if (!typescript_1.default.isBlock(body)) {
106
+ throw new Error(`Invalid syntax, expected a block, but got ${typescript_1.default.SyntaxKind[body.kind]}.`);
126
107
  }
127
- return ts.factory.createFunctionExpression(undefined, undefined, functionName !== null && functionName !== void 0 ? functionName : undefined, undefined, parameters.map((param) => ts.factory.createParameterDeclaration(undefined, undefined, undefined, param)), undefined, body);
108
+ return typescript_1.default.factory.createFunctionExpression(undefined, undefined, functionName !== null && functionName !== void 0 ? functionName : undefined, undefined, parameters.map((param) => (0, ts_compatibility_1.createParameterDeclaration)(undefined, undefined, param)), undefined, body);
128
109
  }
129
110
  createIfStatement(condition, thenStatement, elseStatement) {
130
- return ts.factory.createIfStatement(condition, thenStatement, elseStatement !== null && elseStatement !== void 0 ? elseStatement : undefined);
111
+ return typescript_1.default.factory.createIfStatement(condition, thenStatement, elseStatement !== null && elseStatement !== void 0 ? elseStatement : undefined);
131
112
  }
132
113
  createLiteral(value) {
133
114
  if (value === undefined) {
134
- return ts.factory.createIdentifier('undefined');
115
+ return typescript_1.default.factory.createIdentifier('undefined');
135
116
  }
136
117
  else if (value === null) {
137
- return ts.factory.createNull();
118
+ return typescript_1.default.factory.createNull();
138
119
  }
139
120
  else if (typeof value === 'boolean') {
140
- return value ? ts.factory.createTrue() : ts.factory.createFalse();
121
+ return value ? typescript_1.default.factory.createTrue() : typescript_1.default.factory.createFalse();
141
122
  }
142
123
  else if (typeof value === 'number') {
143
- return ts.factory.createNumericLiteral(value);
124
+ return typescript_1.default.factory.createNumericLiteral(value);
144
125
  }
145
126
  else {
146
- return ts.factory.createStringLiteral(value);
127
+ return typescript_1.default.factory.createStringLiteral(value);
147
128
  }
148
129
  }
149
130
  createNewExpression(expression, args) {
150
- return ts.factory.createNewExpression(expression, undefined, args);
131
+ return typescript_1.default.factory.createNewExpression(expression, undefined, args);
151
132
  }
152
133
  createObjectLiteral(properties) {
153
- return ts.factory.createObjectLiteralExpression(properties.map((prop) => ts.factory.createPropertyAssignment(prop.quoted
154
- ? ts.factory.createStringLiteral(prop.propertyName)
155
- : ts.factory.createIdentifier(prop.propertyName), prop.value)));
134
+ return typescript_1.default.factory.createObjectLiteralExpression(properties.map((prop) => typescript_1.default.factory.createPropertyAssignment(prop.quoted
135
+ ? typescript_1.default.factory.createStringLiteral(prop.propertyName)
136
+ : typescript_1.default.factory.createIdentifier(prop.propertyName), prop.value)));
156
137
  }
157
138
  createReturnStatement(expression) {
158
- return ts.factory.createReturnStatement(expression !== null && expression !== void 0 ? expression : undefined);
139
+ return typescript_1.default.factory.createReturnStatement(expression !== null && expression !== void 0 ? expression : undefined);
159
140
  }
160
141
  createTaggedTemplate(tag, template) {
161
142
  let templateLiteral;
162
143
  const length = template.elements.length;
163
144
  const head = template.elements[0];
164
145
  if (length === 1) {
165
- templateLiteral = ts.factory.createNoSubstitutionTemplateLiteral(head.cooked, head.raw);
146
+ templateLiteral = typescript_1.default.factory.createNoSubstitutionTemplateLiteral(head.cooked, head.raw);
166
147
  }
167
148
  else {
168
149
  const spans = [];
@@ -173,7 +154,7 @@ class TypeScriptAstFactory {
173
154
  if (range !== null) {
174
155
  this.setSourceMapRange(middle, range);
175
156
  }
176
- spans.push(ts.factory.createTemplateSpan(template.expressions[i - 1], middle));
157
+ spans.push(typescript_1.default.factory.createTemplateSpan(template.expressions[i - 1], middle));
177
158
  }
178
159
  // Create the tail part
179
160
  const resolvedExpression = template.expressions[length - 2];
@@ -182,21 +163,21 @@ class TypeScriptAstFactory {
182
163
  if (templatePart.range !== null) {
183
164
  this.setSourceMapRange(templateTail, templatePart.range);
184
165
  }
185
- spans.push(ts.factory.createTemplateSpan(resolvedExpression, templateTail));
166
+ spans.push(typescript_1.default.factory.createTemplateSpan(resolvedExpression, templateTail));
186
167
  // Put it all together
187
- templateLiteral = ts.factory.createTemplateExpression(ts.factory.createTemplateHead(head.cooked, head.raw), spans);
168
+ templateLiteral = typescript_1.default.factory.createTemplateExpression(typescript_1.default.factory.createTemplateHead(head.cooked, head.raw), spans);
188
169
  }
189
170
  if (head.range !== null) {
190
171
  this.setSourceMapRange(templateLiteral, head.range);
191
172
  }
192
- return ts.factory.createTaggedTemplateExpression(tag, undefined, templateLiteral);
173
+ return typescript_1.default.factory.createTaggedTemplateExpression(tag, undefined, templateLiteral);
193
174
  }
194
175
  createUnaryExpression(operator, operand) {
195
- return ts.factory.createPrefixUnaryExpression(UNARY_OPERATORS[operator], operand);
176
+ return typescript_1.default.factory.createPrefixUnaryExpression(UNARY_OPERATORS[operator], operand);
196
177
  }
197
178
  createVariableDeclaration(variableName, initializer, type) {
198
- return ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([
199
- ts.factory.createVariableDeclaration(variableName, undefined, undefined, initializer !== null && initializer !== void 0 ? initializer : undefined),
179
+ return typescript_1.default.factory.createVariableStatement(undefined, typescript_1.default.factory.createVariableDeclarationList([
180
+ typescript_1.default.factory.createVariableDeclaration(variableName, undefined, undefined, initializer !== null && initializer !== void 0 ? initializer : undefined),
200
181
  ], VAR_TYPES[type]));
201
182
  }
202
183
  setSourceMapRange(node, sourceMapRange) {
@@ -205,10 +186,10 @@ class TypeScriptAstFactory {
205
186
  }
206
187
  const url = sourceMapRange.url;
207
188
  if (!this.externalSourceFiles.has(url)) {
208
- this.externalSourceFiles.set(url, ts.createSourceMapSource(url, sourceMapRange.content, (pos) => pos));
189
+ this.externalSourceFiles.set(url, typescript_1.default.createSourceMapSource(url, sourceMapRange.content, (pos) => pos));
209
190
  }
210
191
  const source = this.externalSourceFiles.get(url);
211
- ts.setSourceMapRange(node, {
192
+ typescript_1.default.setSourceMapRange(node, {
212
193
  pos: sourceMapRange.start.offset,
213
194
  end: sourceMapRange.end.offset,
214
195
  source,
@@ -220,16 +201,16 @@ exports.TypeScriptAstFactory = TypeScriptAstFactory;
220
201
  // HACK: Use this in place of `ts.createTemplateMiddle()`.
221
202
  // Revert once https://github.com/microsoft/TypeScript/issues/35374 is fixed.
222
203
  function createTemplateMiddle(cooked, raw) {
223
- const node = ts.createTemplateHead(cooked, raw);
224
- node.kind = ts.SyntaxKind.TemplateMiddle;
204
+ const node = typescript_1.default.factory.createTemplateHead(cooked, raw);
205
+ node.kind = typescript_1.default.SyntaxKind.TemplateMiddle;
225
206
  return node;
226
207
  }
227
208
  exports.createTemplateMiddle = createTemplateMiddle;
228
209
  // HACK: Use this in place of `ts.createTemplateTail()`.
229
210
  // Revert once https://github.com/microsoft/TypeScript/issues/35374 is fixed.
230
211
  function createTemplateTail(cooked, raw) {
231
- const node = ts.factory.createTemplateHead(cooked, raw);
232
- node.kind = ts.SyntaxKind.TemplateTail;
212
+ const node = typescript_1.default.factory.createTemplateHead(cooked, raw);
213
+ node.kind = typescript_1.default.SyntaxKind.TemplateTail;
233
214
  return node;
234
215
  }
235
216
  exports.createTemplateTail = createTemplateTail;
@@ -242,14 +223,14 @@ exports.createTemplateTail = createTemplateTail;
242
223
  function attachComments(statement, leadingComments) {
243
224
  for (const comment of leadingComments) {
244
225
  const commentKind = comment.multiline
245
- ? ts.SyntaxKind.MultiLineCommentTrivia
246
- : ts.SyntaxKind.SingleLineCommentTrivia;
226
+ ? typescript_1.default.SyntaxKind.MultiLineCommentTrivia
227
+ : typescript_1.default.SyntaxKind.SingleLineCommentTrivia;
247
228
  if (comment.multiline) {
248
- ts.addSyntheticLeadingComment(statement, commentKind, comment.toString(), comment.trailingNewline);
229
+ typescript_1.default.addSyntheticLeadingComment(statement, commentKind, comment.toString(), comment.trailingNewline);
249
230
  }
250
231
  else {
251
232
  for (const line of comment.toString().split('\n')) {
252
- ts.addSyntheticLeadingComment(statement, commentKind, line, comment.trailingNewline);
233
+ typescript_1.default.addSyntheticLeadingComment(statement, commentKind, line, comment.trailingNewline);
253
234
  }
254
235
  }
255
236
  }
@@ -5,9 +5,9 @@
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
- import * as o from "../../../../../compiler";
9
- import * as ts from "typescript";
10
- import { ImportGenerator } from "./api/import_generator";
11
- import { TranslatorOptions } from "./translator";
8
+ import * as o from 'static-injector/transform/compiler';
9
+ import ts from 'typescript';
10
+ import { ImportGenerator } from './api/import_generator';
11
+ import { TranslatorOptions } from './translator';
12
12
  export declare function translateExpression(expression: o.Expression, imports: ImportGenerator<ts.Expression>, options?: TranslatorOptions<ts.Expression>): ts.Expression;
13
13
  export declare function translateStatement(statement: o.Statement, imports: ImportGenerator<ts.Expression>, options?: TranslatorOptions<ts.Expression>): ts.Statement;
@@ -6,146 +6,40 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import ts from 'typescript';
9
- /** Equivalent of `ts.ModifierLike` which is only present in TS 4.8+. */
10
- export declare type ModifierLike = ts.Modifier | ts.Decorator;
11
- /** Type of `ts.factory.updateParameterDeclaration` in TS 4.8+. */
12
- declare type Ts48UpdateParameterDeclarationFn = (node: ts.ParameterDeclaration, modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: ts.DotDotDotToken | undefined, name: string | ts.BindingName, questionToken: ts.QuestionToken | undefined, type: ts.TypeNode | undefined, initializer: ts.Expression | undefined) => ts.ParameterDeclaration;
9
+ /** Type of `ts.factory.CreateParameterDeclaration` in TS 4.9+. */
10
+ type Ts49CreateParameterDeclarationFn = (modifiers: readonly ts.ModifierLike[] | undefined, dotDotDotToken: ts.DotDotDotToken | undefined, name: string | ts.BindingName, questionToken?: ts.QuestionToken | undefined, type?: ts.TypeNode | undefined, initializer?: ts.Expression) => ts.ParameterDeclaration;
13
11
  /**
14
- * Updates a `ts.ParameterDeclaration` declaration.
12
+ * Creates a `ts.ParameterDeclaration` declaration.
15
13
  *
16
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
14
+ * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
17
15
  * We should remove it once we have dropped support for the older versions.
18
16
  */
19
- export declare const updateParameterDeclaration: Ts48UpdateParameterDeclarationFn;
20
- /** Type of `ts.factory.updateImportDeclaration` in TS 4.8+. */
21
- declare type Ts48UpdateImportDeclarationFn = (node: ts.ImportDeclaration, modifiers: readonly ts.Modifier[] | undefined, importClause: ts.ImportClause | undefined, moduleSpecifier: ts.Expression, assertClause: ts.AssertClause | undefined) => ts.ImportDeclaration;
17
+ export declare const createParameterDeclaration: Ts49CreateParameterDeclarationFn;
18
+ /** Type of `ts.factory.createImportDeclaration` in TS 4.9+. */
19
+ type Ts49CreateImportDeclarationFn = (modifiers: readonly ts.Modifier[] | undefined, importClause: ts.ImportClause | undefined, moduleSpecifier: ts.Expression, assertClause?: ts.AssertClause) => ts.ImportDeclaration;
22
20
  /**
23
- * Updates a `ts.ImportDeclaration` declaration.
21
+ * Creates a `ts.ImportDeclaration` declaration.
24
22
  *
25
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
23
+ * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
26
24
  * We should remove it once we have dropped support for the older versions.
27
25
  */
28
- export declare const updateImportDeclaration: Ts48UpdateImportDeclarationFn;
29
- /** Type of `ts.factory.updateClassDeclaration` in TS 4.8+. */
30
- declare type Ts48UpdateClassDeclarationFn = (node: ts.ClassDeclaration, modifiers: readonly ModifierLike[] | undefined, name: ts.Identifier | undefined, typeParameters: readonly ts.TypeParameterDeclaration[] | undefined, heritageClauses: readonly ts.HeritageClause[] | undefined, members: readonly ts.ClassElement[]) => ts.ClassDeclaration;
26
+ export declare const createImportDeclaration: Ts49CreateImportDeclarationFn;
27
+ /** Type of `ts.factory.createFunctionDeclaration` in TS 4.9+. */
28
+ type Ts49CreateFunctionDeclarationFn = (modifiers: readonly ts.ModifierLike[] | undefined, asteriskToken: ts.AsteriskToken | undefined, name: string | ts.Identifier | undefined, typeParameters: readonly ts.TypeParameterDeclaration[] | undefined, parameters: readonly ts.ParameterDeclaration[], type: ts.TypeNode | undefined, body: ts.Block | undefined) => ts.FunctionDeclaration;
31
29
  /**
32
- * Updates a `ts.ClassDeclaration` declaration.
30
+ * Creates a `ts.FunctionDeclaration` declaration.
33
31
  *
34
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
32
+ * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
35
33
  * We should remove it once we have dropped support for the older versions.
36
34
  */
37
- export declare const updateClassDeclaration: Ts48UpdateClassDeclarationFn;
38
- /** Type of `ts.factory.createClassDeclaration` in TS 4.8+. */
39
- declare type Ts48CreateClassDeclarationFn = (modifiers: readonly ModifierLike[] | undefined, name: ts.Identifier | undefined, typeParameters: readonly ts.TypeParameterDeclaration[] | undefined, heritageClauses: readonly ts.HeritageClause[] | undefined, members: readonly ts.ClassElement[]) => ts.ClassDeclaration;
35
+ export declare const createFunctionDeclaration: Ts49CreateFunctionDeclarationFn;
36
+ /** Type of `ts.factory.createIndexSignature` in TS 4.9+. */
37
+ type Ts49CreateIndexSignatureFn = (modifiers: readonly ts.Modifier[] | undefined, parameters: readonly ts.ParameterDeclaration[], type: ts.TypeNode) => ts.IndexSignatureDeclaration;
40
38
  /**
41
- * Creates a `ts.ClassDeclaration` declaration.
39
+ * Creates a `ts.IndexSignatureDeclaration` declaration.
42
40
  *
43
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
41
+ * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.9.
44
42
  * We should remove it once we have dropped support for the older versions.
45
43
  */
46
- export declare const createClassDeclaration: Ts48CreateClassDeclarationFn;
47
- /** Type of `ts.factory.updateMethodDeclaration` in TS 4.8+. */
48
- declare type Ts48UpdateMethodDeclarationFn = (node: ts.MethodDeclaration, modifiers: readonly ModifierLike[] | undefined, asteriskToken: ts.AsteriskToken | undefined, name: ts.PropertyName, questionToken: ts.QuestionToken | undefined, typeParameters: readonly ts.TypeParameterDeclaration[] | undefined, parameters: readonly ts.ParameterDeclaration[], type: ts.TypeNode | undefined, body: ts.Block | undefined) => ts.MethodDeclaration;
49
- /**
50
- * Updates a `ts.MethodDeclaration` declaration.
51
- *
52
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
53
- * We should remove it once we have dropped support for the older versions.
54
- */
55
- export declare const updateMethodDeclaration: Ts48UpdateMethodDeclarationFn;
56
- /** Type of `ts.factory.createMethodDeclaration` in TS 4.8+. */
57
- declare type Ts48CreateMethodDeclarationFn = (modifiers: readonly ModifierLike[] | undefined, asteriskToken: ts.AsteriskToken | undefined, name: ts.PropertyName, questionToken: ts.QuestionToken | undefined, typeParameters: readonly ts.TypeParameterDeclaration[] | undefined, parameters: readonly ts.ParameterDeclaration[], type: ts.TypeNode | undefined, body: ts.Block | undefined) => ts.MethodDeclaration;
58
- /**
59
- * Creates a `ts.MethodDeclaration` declaration.
60
- *
61
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
62
- * We should remove it once we have dropped support for the older versions.
63
- */
64
- export declare const createMethodDeclaration: Ts48CreateMethodDeclarationFn;
65
- /** Type of `ts.factory.updatePropertyDeclaration` in TS 4.8+. */
66
- declare type Ts48UpdatePropertyDeclarationFn = (node: ts.PropertyDeclaration, modifiers: readonly ModifierLike[] | undefined, name: string | ts.PropertyName, questionOrExclamationToken: ts.QuestionToken | ts.ExclamationToken | undefined, type: ts.TypeNode | undefined, initializer: ts.Expression | undefined) => ts.PropertyDeclaration;
67
- /**
68
- * Updates a `ts.PropertyDeclaration` declaration.
69
- *
70
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
71
- * We should remove it once we have dropped support for the older versions.
72
- */
73
- export declare const updatePropertyDeclaration: Ts48UpdatePropertyDeclarationFn;
74
- /** Type of `ts.factory.createPropertyDeclaration` in TS 4.8+. */
75
- declare type Ts48CreatePropertyDeclarationFn = (modifiers: readonly ModifierLike[] | undefined, name: string | ts.PropertyName, questionOrExclamationToken: ts.QuestionToken | ts.ExclamationToken | undefined, type: ts.TypeNode | undefined, initializer: ts.Expression | undefined) => ts.PropertyDeclaration;
76
- /**
77
- * Creates a `ts.PropertyDeclaration` declaration.
78
- *
79
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
80
- * We should remove it once we have dropped support for the older versions.
81
- */
82
- export declare const createPropertyDeclaration: Ts48CreatePropertyDeclarationFn;
83
- /** Type of `ts.factory.updateGetAccessorDeclaration` in TS 4.8+. */
84
- declare type Ts48UpdateGetAccessorDeclarationFn = (node: ts.GetAccessorDeclaration, modifiers: readonly ModifierLike[] | undefined, name: ts.PropertyName, parameters: readonly ts.ParameterDeclaration[], type: ts.TypeNode | undefined, body: ts.Block | undefined) => ts.GetAccessorDeclaration;
85
- /**
86
- * Updates a `ts.GetAccessorDeclaration` declaration.
87
- *
88
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
89
- * We should remove it once we have dropped support for the older versions.
90
- */
91
- export declare const updateGetAccessorDeclaration: Ts48UpdateGetAccessorDeclarationFn;
92
- /** Type of `ts.factory.createGetAccessorDeclaration` in TS 4.8+. */
93
- declare type Ts48CreateGetAccessorDeclarationFn = (modifiers: readonly ModifierLike[] | undefined, name: ts.PropertyName, parameters: readonly ts.ParameterDeclaration[], type: ts.TypeNode | undefined, body: ts.Block | undefined) => ts.GetAccessorDeclaration;
94
- /**
95
- * Creates a `ts.GetAccessorDeclaration` declaration.
96
- *
97
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
98
- * We should remove it once we have dropped support for the older versions.
99
- */
100
- export declare const createGetAccessorDeclaration: Ts48CreateGetAccessorDeclarationFn;
101
- /** Type of `ts.factory.updateSetAccessorDeclaration` in TS 4.8+. */
102
- declare type Ts48UpdateSetAccessorDeclarationFn = (node: ts.SetAccessorDeclaration, modifiers: readonly ModifierLike[] | undefined, name: ts.PropertyName, parameters: readonly ts.ParameterDeclaration[], body: ts.Block | undefined) => ts.SetAccessorDeclaration;
103
- /**
104
- * Updates a `ts.GetAccessorDeclaration` declaration.
105
- *
106
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
107
- * We should remove it once we have dropped support for the older versions.
108
- */
109
- export declare const updateSetAccessorDeclaration: Ts48UpdateSetAccessorDeclarationFn;
110
- /** Type of `ts.factory.createSetAccessorDeclaration` in TS 4.8+. */
111
- declare type Ts48CreateSetAccessorDeclarationFn = (modifiers: readonly ModifierLike[] | undefined, name: ts.PropertyName, parameters: readonly ts.ParameterDeclaration[], body: ts.Block | undefined) => ts.SetAccessorDeclaration;
112
- /**
113
- * Creates a `ts.GetAccessorDeclaration` declaration.
114
- *
115
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
116
- * We should remove it once we have dropped support for the older versions.
117
- */
118
- export declare const createSetAccessorDeclaration: Ts48CreateSetAccessorDeclarationFn;
119
- /** Type of `ts.factory.updateConstructorDeclaration` in TS 4.8+. */
120
- declare type Ts48UpdateConstructorDeclarationFn = (node: ts.ConstructorDeclaration, modifiers: readonly ts.Modifier[] | undefined, parameters: readonly ts.ParameterDeclaration[], body: ts.Block | undefined) => ts.ConstructorDeclaration;
121
- /**
122
- * Updates a `ts.ConstructorDeclaration` declaration.
123
- *
124
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
125
- * We should remove it once we have dropped support for the older versions.
126
- */
127
- export declare const updateConstructorDeclaration: Ts48UpdateConstructorDeclarationFn;
128
- /**
129
- * Gets the decorators that have been applied to a node.
130
- *
131
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
132
- * We should remove it once we have dropped support for the older versions.
133
- */
134
- export declare const getDecorators: (node: ts.Node) => readonly ts.Decorator[] | undefined;
135
- /**
136
- * Gets the modifiers that have been set on a node.
137
- *
138
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
139
- * We should remove it once we have dropped support for the older versions.
140
- */
141
- export declare const getModifiers: (node: ts.Node) => readonly ts.Modifier[] | undefined;
142
- /**
143
- * Combines an optional array of decorators with an optional array of modifiers into a single
144
- * `ts.ModifierLike` array. Used in version of TypeScript after 4.8 where the `decorators` and
145
- * `modifiers` arrays have been combined.
146
- *
147
- * TODO(crisbeto): this is a backwards-compatibility layer for versions of TypeScript less than 4.8.
148
- * We should remove it once we have dropped support for the older versions.
149
- */
150
- export declare function combineModifiers(decorators: readonly ts.Decorator[] | undefined, modifiers: readonly ModifierLike[] | undefined): readonly ModifierLike[] | undefined;
44
+ export declare const createIndexSignature: Ts49CreateIndexSignatureFn;
151
45
  export {};