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 | (function (factory) {
|
---|
9 | if (typeof module === "object" && typeof module.exports === "object") {
|
---|
10 | var v = factory(require, exports);
|
---|
11 | if (v !== undefined) module.exports = v;
|
---|
12 | }
|
---|
13 | else if (typeof define === "function" && define.amd) {
|
---|
14 | define("@angular/compiler-cli/ngcc/src/host/esm5_host", ["require", "exports", "tslib", "typescript", "@angular/compiler-cli/src/ngtsc/reflection", "@angular/compiler-cli/ngcc/src/utils", "@angular/compiler-cli/ngcc/src/host/esm2015_host"], factory);
|
---|
15 | }
|
---|
16 | })(function (require, exports) {
|
---|
17 | "use strict";
|
---|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
19 | exports.Esm5ReflectionHost = void 0;
|
---|
20 | var tslib_1 = require("tslib");
|
---|
21 | var ts = require("typescript");
|
---|
22 | var reflection_1 = require("@angular/compiler-cli/src/ngtsc/reflection");
|
---|
23 | var utils_1 = require("@angular/compiler-cli/ngcc/src/utils");
|
---|
24 | var esm2015_host_1 = require("@angular/compiler-cli/ngcc/src/host/esm2015_host");
|
---|
25 | /**
|
---|
26 | * ESM5 packages contain ECMAScript IIFE functions that act like classes. For example:
|
---|
27 | *
|
---|
28 | * ```
|
---|
29 | * var CommonModule = (function () {
|
---|
30 | * function CommonModule() {
|
---|
31 | * }
|
---|
32 | * CommonModule.decorators = [ ... ];
|
---|
33 | * return CommonModule;
|
---|
34 | * ```
|
---|
35 | *
|
---|
36 | * * "Classes" are decorated if they have a static property called `decorators`.
|
---|
37 | * * Members are decorated if there is a matching key on a static property
|
---|
38 | * called `propDecorators`.
|
---|
39 | * * Constructor parameters decorators are found on an object returned from
|
---|
40 | * a static method called `ctorParameters`.
|
---|
41 | *
|
---|
42 | */
|
---|
43 | var Esm5ReflectionHost = /** @class */ (function (_super) {
|
---|
44 | tslib_1.__extends(Esm5ReflectionHost, _super);
|
---|
45 | function Esm5ReflectionHost() {
|
---|
46 | return _super !== null && _super.apply(this, arguments) || this;
|
---|
47 | }
|
---|
48 | Esm5ReflectionHost.prototype.getBaseClassExpression = function (clazz) {
|
---|
49 | var superBaseClassExpression = _super.prototype.getBaseClassExpression.call(this, clazz);
|
---|
50 | if (superBaseClassExpression !== null) {
|
---|
51 | return superBaseClassExpression;
|
---|
52 | }
|
---|
53 | var iife = getIifeFn(this.getClassSymbol(clazz));
|
---|
54 | if (iife === null)
|
---|
55 | return null;
|
---|
56 | if (iife.parameters.length !== 1 || !isSuperIdentifier(iife.parameters[0].name)) {
|
---|
57 | return null;
|
---|
58 | }
|
---|
59 | if (!ts.isCallExpression(iife.parent)) {
|
---|
60 | return null;
|
---|
61 | }
|
---|
62 | return iife.parent.arguments[0];
|
---|
63 | };
|
---|
64 | /**
|
---|
65 | * Trace an identifier to its declaration, if possible.
|
---|
66 | *
|
---|
67 | * This method attempts to resolve the declaration of the given identifier, tracing back through
|
---|
68 | * imports and re-exports until the original declaration statement is found. A `Declaration`
|
---|
69 | * object is returned if the original declaration is found, or `null` is returned otherwise.
|
---|
70 | *
|
---|
71 | * In ES5, the implementation of a class is a function expression that is hidden inside an IIFE.
|
---|
72 | * If we are looking for the declaration of the identifier of the inner function expression, we
|
---|
73 | * will get hold of the outer "class" variable declaration and return its identifier instead. See
|
---|
74 | * `getClassDeclarationFromInnerFunctionDeclaration()` for more info.
|
---|
75 | *
|
---|
76 | * @param id a TypeScript `ts.Identifier` to trace back to a declaration.
|
---|
77 | *
|
---|
78 | * @returns metadata about the `Declaration` if the original declaration is found, or `null`
|
---|
79 | * otherwise.
|
---|
80 | */
|
---|
81 | Esm5ReflectionHost.prototype.getDeclarationOfIdentifier = function (id) {
|
---|
82 | var declaration = _super.prototype.getDeclarationOfIdentifier.call(this, id);
|
---|
83 | if (declaration === null) {
|
---|
84 | var nonEmittedNorImportedTsHelperDeclaration = utils_1.getTsHelperFnFromIdentifier(id);
|
---|
85 | if (nonEmittedNorImportedTsHelperDeclaration !== null) {
|
---|
86 | // No declaration could be found for this identifier and its name matches a known TS helper
|
---|
87 | // function. This can happen if a package is compiled with `noEmitHelpers: true` and
|
---|
88 | // `importHelpers: false` (the default). This is, for example, the case with
|
---|
89 | // `@nativescript/angular@9.0.0-next-2019-11-12-155500-01`.
|
---|
90 | return {
|
---|
91 | kind: 1 /* Inline */,
|
---|
92 | node: id,
|
---|
93 | known: nonEmittedNorImportedTsHelperDeclaration,
|
---|
94 | viaModule: null,
|
---|
95 | };
|
---|
96 | }
|
---|
97 | }
|
---|
98 | if (declaration === null || declaration.node === null || declaration.known !== null) {
|
---|
99 | return declaration;
|
---|
100 | }
|
---|
101 | if (!ts.isVariableDeclaration(declaration.node) || declaration.node.initializer !== undefined ||
|
---|
102 | // VariableDeclaration => VariableDeclarationList => VariableStatement => IIFE Block
|
---|
103 | !ts.isBlock(declaration.node.parent.parent.parent)) {
|
---|
104 | return declaration;
|
---|
105 | }
|
---|
106 | // We might have an alias to another variable declaration.
|
---|
107 | // Search the containing iife body for it.
|
---|
108 | var block = declaration.node.parent.parent.parent;
|
---|
109 | var aliasSymbol = this.checker.getSymbolAtLocation(declaration.node.name);
|
---|
110 | for (var i = 0; i < block.statements.length; i++) {
|
---|
111 | var statement = block.statements[i];
|
---|
112 | // Looking for statement that looks like: `AliasedVariable = OriginalVariable;`
|
---|
113 | if (esm2015_host_1.isAssignmentStatement(statement) && ts.isIdentifier(statement.expression.left) &&
|
---|
114 | ts.isIdentifier(statement.expression.right) &&
|
---|
115 | this.checker.getSymbolAtLocation(statement.expression.left) === aliasSymbol) {
|
---|
116 | return this.getDeclarationOfIdentifier(statement.expression.right);
|
---|
117 | }
|
---|
118 | }
|
---|
119 | return declaration;
|
---|
120 | };
|
---|
121 | /**
|
---|
122 | * Parse a function declaration to find the relevant metadata about it.
|
---|
123 | *
|
---|
124 | * In ESM5 we need to do special work with optional arguments to the function, since they get
|
---|
125 | * their own initializer statement that needs to be parsed and then not included in the "body"
|
---|
126 | * statements of the function.
|
---|
127 | *
|
---|
128 | * @param node the function declaration to parse.
|
---|
129 | * @returns an object containing the node, statements and parameters of the function.
|
---|
130 | */
|
---|
131 | Esm5ReflectionHost.prototype.getDefinitionOfFunction = function (node) {
|
---|
132 | var definition = _super.prototype.getDefinitionOfFunction.call(this, node);
|
---|
133 | if (definition === null) {
|
---|
134 | return null;
|
---|
135 | }
|
---|
136 | // Filter out and capture parameter initializers
|
---|
137 | if (definition.body !== null) {
|
---|
138 | var lookingForInitializers_1 = true;
|
---|
139 | var statements = definition.body.filter(function (s) {
|
---|
140 | lookingForInitializers_1 =
|
---|
141 | lookingForInitializers_1 && captureParamInitializer(s, definition.parameters);
|
---|
142 | // If we are no longer looking for parameter initializers then we include this statement
|
---|
143 | return !lookingForInitializers_1;
|
---|
144 | });
|
---|
145 | definition.body = statements;
|
---|
146 | }
|
---|
147 | return definition;
|
---|
148 | };
|
---|
149 | /**
|
---|
150 | * Check whether a `Declaration` corresponds with a known declaration, such as a TypeScript helper
|
---|
151 | * function, and set its `known` property to the appropriate `KnownDeclaration`.
|
---|
152 | *
|
---|
153 | * @param decl The `Declaration` to check.
|
---|
154 | * @return The passed in `Declaration` (potentially enhanced with a `KnownDeclaration`).
|
---|
155 | */
|
---|
156 | Esm5ReflectionHost.prototype.detectKnownDeclaration = function (decl) {
|
---|
157 | decl = _super.prototype.detectKnownDeclaration.call(this, decl);
|
---|
158 | // Also check for TS helpers
|
---|
159 | if (decl.known === null && decl.node !== null) {
|
---|
160 | decl.known = utils_1.getTsHelperFnFromDeclaration(decl.node);
|
---|
161 | }
|
---|
162 | return decl;
|
---|
163 | };
|
---|
164 | ///////////// Protected Helpers /////////////
|
---|
165 | /**
|
---|
166 | * In ES5, the implementation of a class is a function expression that is hidden inside an IIFE,
|
---|
167 | * whose value is assigned to a variable (which represents the class to the rest of the program).
|
---|
168 | * So we might need to dig around to get hold of the "class" declaration.
|
---|
169 | *
|
---|
170 | * This method extracts a `NgccClassSymbol` if `declaration` is the function declaration inside
|
---|
171 | * the IIFE. Otherwise, undefined is returned.
|
---|
172 | *
|
---|
173 | * @param declaration the declaration whose symbol we are finding.
|
---|
174 | * @returns the symbol for the node or `undefined` if it is not a "class" or has no symbol.
|
---|
175 | */
|
---|
176 | Esm5ReflectionHost.prototype.getClassSymbolFromInnerDeclaration = function (declaration) {
|
---|
177 | var classSymbol = _super.prototype.getClassSymbolFromInnerDeclaration.call(this, declaration);
|
---|
178 | if (classSymbol !== undefined) {
|
---|
179 | return classSymbol;
|
---|
180 | }
|
---|
181 | if (!reflection_1.isNamedFunctionDeclaration(declaration)) {
|
---|
182 | return undefined;
|
---|
183 | }
|
---|
184 | var outerNode = esm2015_host_1.getOuterNodeFromInnerDeclaration(declaration);
|
---|
185 | if (outerNode === null || !utils_1.hasNameIdentifier(outerNode)) {
|
---|
186 | return undefined;
|
---|
187 | }
|
---|
188 | return this.createClassSymbol(outerNode.name, declaration);
|
---|
189 | };
|
---|
190 | /**
|
---|
191 | * Find the declarations of the constructor parameters of a class identified by its symbol.
|
---|
192 | *
|
---|
193 | * In ESM5, there is no "class" so the constructor that we want is actually the inner function
|
---|
194 | * declaration inside the IIFE, whose return value is assigned to the outer variable declaration
|
---|
195 | * (that represents the class to the rest of the program).
|
---|
196 | *
|
---|
197 | * @param classSymbol the symbol of the class (i.e. the outer variable declaration) whose
|
---|
198 | * parameters we want to find.
|
---|
199 | * @returns an array of `ts.ParameterDeclaration` objects representing each of the parameters in
|
---|
200 | * the class's constructor or `null` if there is no constructor.
|
---|
201 | */
|
---|
202 | Esm5ReflectionHost.prototype.getConstructorParameterDeclarations = function (classSymbol) {
|
---|
203 | var constructor = classSymbol.implementation.valueDeclaration;
|
---|
204 | if (!ts.isFunctionDeclaration(constructor))
|
---|
205 | return null;
|
---|
206 | if (constructor.parameters.length > 0) {
|
---|
207 | return Array.from(constructor.parameters);
|
---|
208 | }
|
---|
209 | if (this.isSynthesizedConstructor(constructor)) {
|
---|
210 | return null;
|
---|
211 | }
|
---|
212 | return [];
|
---|
213 | };
|
---|
214 | /**
|
---|
215 | * Get the parameter type and decorators for the constructor of a class,
|
---|
216 | * where the information is stored on a static method of the class.
|
---|
217 | *
|
---|
218 | * In this case the decorators are stored in the body of a method
|
---|
219 | * (`ctorParatemers`) attached to the constructor function.
|
---|
220 | *
|
---|
221 | * Note that unlike ESM2015 this is a function expression rather than an arrow
|
---|
222 | * function:
|
---|
223 | *
|
---|
224 | * ```
|
---|
225 | * SomeDirective.ctorParameters = function() { return [
|
---|
226 | * { type: ViewContainerRef, },
|
---|
227 | * { type: TemplateRef, },
|
---|
228 | * { type: IterableDiffers, },
|
---|
229 | * { type: undefined, decorators: [{ type: Inject, args: [INJECTED_TOKEN,] },] },
|
---|
230 | * ]; };
|
---|
231 | * ```
|
---|
232 | *
|
---|
233 | * @param paramDecoratorsProperty the property that holds the parameter info we want to get.
|
---|
234 | * @returns an array of objects containing the type and decorators for each parameter.
|
---|
235 | */
|
---|
236 | Esm5ReflectionHost.prototype.getParamInfoFromStaticProperty = function (paramDecoratorsProperty) {
|
---|
237 | var _this = this;
|
---|
238 | var paramDecorators = esm2015_host_1.getPropertyValueFromSymbol(paramDecoratorsProperty);
|
---|
239 | // The decorators array may be wrapped in a function. If so unwrap it.
|
---|
240 | var returnStatement = getReturnStatement(paramDecorators);
|
---|
241 | var expression = returnStatement ? returnStatement.expression : paramDecorators;
|
---|
242 | if (expression && ts.isArrayLiteralExpression(expression)) {
|
---|
243 | var elements = expression.elements;
|
---|
244 | return elements.map(reflectArrayElement).map(function (paramInfo) {
|
---|
245 | var typeExpression = paramInfo && paramInfo.has('type') ? paramInfo.get('type') : null;
|
---|
246 | var decoratorInfo = paramInfo && paramInfo.has('decorators') ? paramInfo.get('decorators') : null;
|
---|
247 | var decorators = decoratorInfo && _this.reflectDecorators(decoratorInfo);
|
---|
248 | return { typeExpression: typeExpression, decorators: decorators };
|
---|
249 | });
|
---|
250 | }
|
---|
251 | else if (paramDecorators !== undefined) {
|
---|
252 | this.logger.warn('Invalid constructor parameter decorator in ' + paramDecorators.getSourceFile().fileName +
|
---|
253 | ':\n', paramDecorators.getText());
|
---|
254 | }
|
---|
255 | return null;
|
---|
256 | };
|
---|
257 | /**
|
---|
258 | * Reflect over a symbol and extract the member information, combining it with the
|
---|
259 | * provided decorator information, and whether it is a static member.
|
---|
260 | *
|
---|
261 | * If a class member uses accessors (e.g getters and/or setters) then it gets downleveled
|
---|
262 | * in ES5 to a single `Object.defineProperty()` call. In that case we must parse this
|
---|
263 | * call to extract the one or two ClassMember objects that represent the accessors.
|
---|
264 | *
|
---|
265 | * @param symbol the symbol for the member to reflect over.
|
---|
266 | * @param decorators an array of decorators associated with the member.
|
---|
267 | * @param isStatic true if this member is static, false if it is an instance property.
|
---|
268 | * @returns the reflected member information, or null if the symbol is not a member.
|
---|
269 | */
|
---|
270 | Esm5ReflectionHost.prototype.reflectMembers = function (symbol, decorators, isStatic) {
|
---|
271 | var node = symbol.valueDeclaration || symbol.declarations && symbol.declarations[0];
|
---|
272 | var propertyDefinition = node && getPropertyDefinition(node);
|
---|
273 | if (propertyDefinition) {
|
---|
274 | var members_1 = [];
|
---|
275 | if (propertyDefinition.setter) {
|
---|
276 | members_1.push({
|
---|
277 | node: node,
|
---|
278 | implementation: propertyDefinition.setter,
|
---|
279 | kind: reflection_1.ClassMemberKind.Setter,
|
---|
280 | type: null,
|
---|
281 | name: symbol.name,
|
---|
282 | nameNode: null,
|
---|
283 | value: null,
|
---|
284 | isStatic: isStatic || false,
|
---|
285 | decorators: decorators || [],
|
---|
286 | });
|
---|
287 | // Prevent attaching the decorators to a potential getter. In ES5, we can't tell where the
|
---|
288 | // decorators were originally attached to, however we only want to attach them to a single
|
---|
289 | // `ClassMember` as otherwise ngtsc would handle the same decorators twice.
|
---|
290 | decorators = undefined;
|
---|
291 | }
|
---|
292 | if (propertyDefinition.getter) {
|
---|
293 | members_1.push({
|
---|
294 | node: node,
|
---|
295 | implementation: propertyDefinition.getter,
|
---|
296 | kind: reflection_1.ClassMemberKind.Getter,
|
---|
297 | type: null,
|
---|
298 | name: symbol.name,
|
---|
299 | nameNode: null,
|
---|
300 | value: null,
|
---|
301 | isStatic: isStatic || false,
|
---|
302 | decorators: decorators || [],
|
---|
303 | });
|
---|
304 | }
|
---|
305 | return members_1;
|
---|
306 | }
|
---|
307 | var members = _super.prototype.reflectMembers.call(this, symbol, decorators, isStatic);
|
---|
308 | members && members.forEach(function (member) {
|
---|
309 | if (member && member.kind === reflection_1.ClassMemberKind.Method && member.isStatic && member.node &&
|
---|
310 | ts.isPropertyAccessExpression(member.node) && member.node.parent &&
|
---|
311 | ts.isBinaryExpression(member.node.parent) &&
|
---|
312 | ts.isFunctionExpression(member.node.parent.right)) {
|
---|
313 | // Recompute the implementation for this member:
|
---|
314 | // ES5 static methods are variable declarations so the declaration is actually the
|
---|
315 | // initializer of the variable assignment
|
---|
316 | member.implementation = member.node.parent.right;
|
---|
317 | }
|
---|
318 | });
|
---|
319 | return members;
|
---|
320 | };
|
---|
321 | /**
|
---|
322 | * Find statements related to the given class that may contain calls to a helper.
|
---|
323 | *
|
---|
324 | * In ESM5 code the helper calls are hidden inside the class's IIFE.
|
---|
325 | *
|
---|
326 | * @param classSymbol the class whose helper calls we are interested in. We expect this symbol
|
---|
327 | * to reference the inner identifier inside the IIFE.
|
---|
328 | * @returns an array of statements that may contain helper calls.
|
---|
329 | */
|
---|
330 | Esm5ReflectionHost.prototype.getStatementsForClass = function (classSymbol) {
|
---|
331 | var classDeclarationParent = classSymbol.implementation.valueDeclaration.parent;
|
---|
332 | return ts.isBlock(classDeclarationParent) ? Array.from(classDeclarationParent.statements) : [];
|
---|
333 | };
|
---|
334 | ///////////// Host Private Helpers /////////////
|
---|
335 | /**
|
---|
336 | * A constructor function may have been "synthesized" by TypeScript during JavaScript emit,
|
---|
337 | * in the case no user-defined constructor exists and e.g. property initializers are used.
|
---|
338 | * Those initializers need to be emitted into a constructor in JavaScript, so the TypeScript
|
---|
339 | * compiler generates a synthetic constructor.
|
---|
340 | *
|
---|
341 | * We need to identify such constructors as ngcc needs to be able to tell if a class did
|
---|
342 | * originally have a constructor in the TypeScript source. For ES5, we can not tell an
|
---|
343 | * empty constructor apart from a synthesized constructor, but fortunately that does not
|
---|
344 | * matter for the code generated by ngtsc.
|
---|
345 | *
|
---|
346 | * When a class has a superclass however, a synthesized constructor must not be considered
|
---|
347 | * as a user-defined constructor as that prevents a base factory call from being created by
|
---|
348 | * ngtsc, resulting in a factory function that does not inject the dependencies of the
|
---|
349 | * superclass. Hence, we identify a default synthesized super call in the constructor body,
|
---|
350 | * according to the structure that TypeScript's ES2015 to ES5 transformer generates in
|
---|
351 | * https://github.com/Microsoft/TypeScript/blob/v3.2.2/src/compiler/transformers/es2015.ts#L1082-L1098
|
---|
352 | *
|
---|
353 | * Additionally, we handle synthetic delegate constructors that are emitted when TypeScript
|
---|
354 | * downlevel's ES2015 synthetically generated to ES5. These vary slightly from the default
|
---|
355 | * structure mentioned above because the ES2015 output uses a spread operator, for delegating
|
---|
356 | * to the parent constructor, that is preserved through a TypeScript helper in ES5. e.g.
|
---|
357 | *
|
---|
358 | * ```
|
---|
359 | * return _super.apply(this, tslib.__spread(arguments)) || this;
|
---|
360 | * ```
|
---|
361 | *
|
---|
362 | * or, since TypeScript 4.2 it would be
|
---|
363 | *
|
---|
364 | * ```
|
---|
365 | * return _super.apply(this, tslib.__spreadArray([], tslib.__read(arguments))) || this;
|
---|
366 | * ```
|
---|
367 | *
|
---|
368 | * Such constructs can be still considered as synthetic delegate constructors as they are
|
---|
369 | * the product of a common TypeScript to ES5 synthetic constructor, just being downleveled
|
---|
370 | * to ES5 using `tsc`. See: https://github.com/angular/angular/issues/38453.
|
---|
371 | *
|
---|
372 | *
|
---|
373 | * @param constructor a constructor function to test
|
---|
374 | * @returns true if the constructor appears to have been synthesized
|
---|
375 | */
|
---|
376 | Esm5ReflectionHost.prototype.isSynthesizedConstructor = function (constructor) {
|
---|
377 | if (!constructor.body)
|
---|
378 | return false;
|
---|
379 | var firstStatement = constructor.body.statements[0];
|
---|
380 | if (!firstStatement)
|
---|
381 | return false;
|
---|
382 | return this.isSynthesizedSuperThisAssignment(firstStatement) ||
|
---|
383 | this.isSynthesizedSuperReturnStatement(firstStatement);
|
---|
384 | };
|
---|
385 | /**
|
---|
386 | * Identifies synthesized super calls which pass-through function arguments directly and are
|
---|
387 | * being assigned to a common `_this` variable. The following patterns we intend to match:
|
---|
388 | *
|
---|
389 | * 1. Delegate call emitted by TypeScript when it emits ES5 directly.
|
---|
390 | * ```
|
---|
391 | * var _this = _super !== null && _super.apply(this, arguments) || this;
|
---|
392 | * ```
|
---|
393 | *
|
---|
394 | * 2. Delegate call emitted by TypeScript when it downlevel's ES2015 to ES5.
|
---|
395 | * ```
|
---|
396 | * var _this = _super.apply(this, tslib.__spread(arguments)) || this;
|
---|
397 | * ```
|
---|
398 | * or using the syntax emitted since TypeScript 4.2:
|
---|
399 | * ```
|
---|
400 | * return _super.apply(this, tslib.__spreadArray([], tslib.__read(arguments))) || this;
|
---|
401 | * ```
|
---|
402 | *
|
---|
403 | * @param statement a statement that may be a synthesized super call
|
---|
404 | * @returns true if the statement looks like a synthesized super call
|
---|
405 | */
|
---|
406 | Esm5ReflectionHost.prototype.isSynthesizedSuperThisAssignment = function (statement) {
|
---|
407 | if (!ts.isVariableStatement(statement))
|
---|
408 | return false;
|
---|
409 | var variableDeclarations = statement.declarationList.declarations;
|
---|
410 | if (variableDeclarations.length !== 1)
|
---|
411 | return false;
|
---|
412 | var variableDeclaration = variableDeclarations[0];
|
---|
413 | if (!ts.isIdentifier(variableDeclaration.name) ||
|
---|
414 | !variableDeclaration.name.text.startsWith('_this'))
|
---|
415 | return false;
|
---|
416 | var initializer = variableDeclaration.initializer;
|
---|
417 | if (!initializer)
|
---|
418 | return false;
|
---|
419 | return this.isSynthesizedDefaultSuperCall(initializer);
|
---|
420 | };
|
---|
421 | /**
|
---|
422 | * Identifies synthesized super calls which pass-through function arguments directly and
|
---|
423 | * are being returned. The following patterns correspond to synthetic super return calls:
|
---|
424 | *
|
---|
425 | * 1. Delegate call emitted by TypeScript when it emits ES5 directly.
|
---|
426 | * ```
|
---|
427 | * return _super !== null && _super.apply(this, arguments) || this;
|
---|
428 | * ```
|
---|
429 | *
|
---|
430 | * 2. Delegate call emitted by TypeScript when it downlevel's ES2015 to ES5.
|
---|
431 | * ```
|
---|
432 | * return _super.apply(this, tslib.__spread(arguments)) || this;
|
---|
433 | * ```
|
---|
434 | * or using the syntax emitted since TypeScript 4.2:
|
---|
435 | * ```
|
---|
436 | * return _super.apply(this, tslib.__spreadArray([], tslib.__read(arguments))) || this;
|
---|
437 | * ```
|
---|
438 | *
|
---|
439 | * @param statement a statement that may be a synthesized super call
|
---|
440 | * @returns true if the statement looks like a synthesized super call
|
---|
441 | */
|
---|
442 | Esm5ReflectionHost.prototype.isSynthesizedSuperReturnStatement = function (statement) {
|
---|
443 | if (!ts.isReturnStatement(statement))
|
---|
444 | return false;
|
---|
445 | var expression = statement.expression;
|
---|
446 | if (!expression)
|
---|
447 | return false;
|
---|
448 | return this.isSynthesizedDefaultSuperCall(expression);
|
---|
449 | };
|
---|
450 | /**
|
---|
451 | * Identifies synthesized super calls which pass-through function arguments directly. The
|
---|
452 | * synthetic delegate super call match the following patterns we intend to match:
|
---|
453 | *
|
---|
454 | * 1. Delegate call emitted by TypeScript when it emits ES5 directly.
|
---|
455 | * ```
|
---|
456 | * _super !== null && _super.apply(this, arguments) || this;
|
---|
457 | * ```
|
---|
458 | *
|
---|
459 | * 2. Delegate call emitted by TypeScript when it downlevel's ES2015 to ES5.
|
---|
460 | * ```
|
---|
461 | * _super.apply(this, tslib.__spread(arguments)) || this;
|
---|
462 | * ```
|
---|
463 | * or using the syntax emitted since TypeScript 4.2:
|
---|
464 | * ```
|
---|
465 | * return _super.apply(this, tslib.__spreadArray([], tslib.__read(arguments))) || this;
|
---|
466 | * ```
|
---|
467 | *
|
---|
468 | * @param expression an expression that may represent a default super call
|
---|
469 | * @returns true if the expression corresponds with the above form
|
---|
470 | */
|
---|
471 | Esm5ReflectionHost.prototype.isSynthesizedDefaultSuperCall = function (expression) {
|
---|
472 | if (!isBinaryExpr(expression, ts.SyntaxKind.BarBarToken))
|
---|
473 | return false;
|
---|
474 | if (expression.right.kind !== ts.SyntaxKind.ThisKeyword)
|
---|
475 | return false;
|
---|
476 | var left = expression.left;
|
---|
477 | if (isBinaryExpr(left, ts.SyntaxKind.AmpersandAmpersandToken)) {
|
---|
478 | return isSuperNotNull(left.left) && this.isSuperApplyCall(left.right);
|
---|
479 | }
|
---|
480 | else {
|
---|
481 | return this.isSuperApplyCall(left);
|
---|
482 | }
|
---|
483 | };
|
---|
484 | /**
|
---|
485 | * Tests whether the expression corresponds to a `super` call passing through
|
---|
486 | * function arguments without any modification. e.g.
|
---|
487 | *
|
---|
488 | * ```
|
---|
489 | * _super !== null && _super.apply(this, arguments) || this;
|
---|
490 | * ```
|
---|
491 | *
|
---|
492 | * This structure is generated by TypeScript when transforming ES2015 to ES5, see
|
---|
493 | * https://github.com/Microsoft/TypeScript/blob/v3.2.2/src/compiler/transformers/es2015.ts#L1148-L1163
|
---|
494 | *
|
---|
495 | * Additionally, we also handle cases where `arguments` are wrapped by a TypeScript spread
|
---|
496 | * helper.
|
---|
497 | * This can happen if ES2015 class output contain auto-generated constructors due to class
|
---|
498 | * members. The ES2015 output will be using `super(...arguments)` to delegate to the superclass,
|
---|
499 | * but once downleveled to ES5, the spread operator will be persisted through a TypeScript spread
|
---|
500 | * helper. For example:
|
---|
501 | *
|
---|
502 | * ```
|
---|
503 | * _super.apply(this, __spread(arguments)) || this;
|
---|
504 | * ```
|
---|
505 | *
|
---|
506 | * or, since TypeScript 4.2 it would be
|
---|
507 | *
|
---|
508 | * ```
|
---|
509 | * _super.apply(this, tslib.__spreadArray([], tslib.__read(arguments))) || this;
|
---|
510 | * ```
|
---|
511 | *
|
---|
512 | * More details can be found in: https://github.com/angular/angular/issues/38453.
|
---|
513 | *
|
---|
514 | * @param expression an expression that may represent a default super call
|
---|
515 | * @returns true if the expression corresponds with the above form
|
---|
516 | */
|
---|
517 | Esm5ReflectionHost.prototype.isSuperApplyCall = function (expression) {
|
---|
518 | if (!ts.isCallExpression(expression) || expression.arguments.length !== 2)
|
---|
519 | return false;
|
---|
520 | var targetFn = expression.expression;
|
---|
521 | if (!ts.isPropertyAccessExpression(targetFn))
|
---|
522 | return false;
|
---|
523 | if (!isSuperIdentifier(targetFn.expression))
|
---|
524 | return false;
|
---|
525 | if (targetFn.name.text !== 'apply')
|
---|
526 | return false;
|
---|
527 | var thisArgument = expression.arguments[0];
|
---|
528 | if (thisArgument.kind !== ts.SyntaxKind.ThisKeyword)
|
---|
529 | return false;
|
---|
530 | var argumentsExpr = expression.arguments[1];
|
---|
531 | // If the super is directly invoked with `arguments`, return `true`. This represents the
|
---|
532 | // common TypeScript output where the delegate constructor super call matches the following
|
---|
533 | // pattern: `super.apply(this, arguments)`.
|
---|
534 | if (isArgumentsIdentifier(argumentsExpr)) {
|
---|
535 | return true;
|
---|
536 | }
|
---|
537 | // The other scenario we intend to detect: The `arguments` variable might be wrapped with the
|
---|
538 | // TypeScript spread helper (either through tslib or inlined). This can happen if an explicit
|
---|
539 | // delegate constructor uses `super(...arguments)` in ES2015 and is downleveled to ES5 using
|
---|
540 | // `--downlevelIteration`.
|
---|
541 | return this.isSpreadArgumentsExpression(argumentsExpr);
|
---|
542 | };
|
---|
543 | /**
|
---|
544 | * Determines if the provided expression is one of the following call expressions:
|
---|
545 | *
|
---|
546 | * 1. `__spread(arguments)`
|
---|
547 | * 2. `__spreadArray([], __read(arguments))`
|
---|
548 | *
|
---|
549 | * The tslib helpers may have been emitted inline as in the above example, or they may be read
|
---|
550 | * from a namespace import.
|
---|
551 | */
|
---|
552 | Esm5ReflectionHost.prototype.isSpreadArgumentsExpression = function (expression) {
|
---|
553 | var call = this.extractKnownHelperCall(expression);
|
---|
554 | if (call === null) {
|
---|
555 | return false;
|
---|
556 | }
|
---|
557 | if (call.helper === reflection_1.KnownDeclaration.TsHelperSpread) {
|
---|
558 | // `__spread(arguments)`
|
---|
559 | return call.args.length === 1 && isArgumentsIdentifier(call.args[0]);
|
---|
560 | }
|
---|
561 | else if (call.helper === reflection_1.KnownDeclaration.TsHelperSpreadArray) {
|
---|
562 | // `__spreadArray([], __read(arguments))`
|
---|
563 | if (call.args.length !== 2) {
|
---|
564 | return false;
|
---|
565 | }
|
---|
566 | var firstArg = call.args[0];
|
---|
567 | if (!ts.isArrayLiteralExpression(firstArg) || firstArg.elements.length !== 0) {
|
---|
568 | return false;
|
---|
569 | }
|
---|
570 | var secondArg = this.extractKnownHelperCall(call.args[1]);
|
---|
571 | if (secondArg === null || secondArg.helper !== reflection_1.KnownDeclaration.TsHelperRead) {
|
---|
572 | return false;
|
---|
573 | }
|
---|
574 | return secondArg.args.length === 1 && isArgumentsIdentifier(secondArg.args[0]);
|
---|
575 | }
|
---|
576 | else {
|
---|
577 | return false;
|
---|
578 | }
|
---|
579 | };
|
---|
580 | /**
|
---|
581 | * Inspects the provided expression and determines if it corresponds with a known helper function
|
---|
582 | * as receiver expression.
|
---|
583 | */
|
---|
584 | Esm5ReflectionHost.prototype.extractKnownHelperCall = function (expression) {
|
---|
585 | if (!ts.isCallExpression(expression)) {
|
---|
586 | return null;
|
---|
587 | }
|
---|
588 | var receiverExpr = expression.expression;
|
---|
589 | // The helper could be globally available, or accessed through a namespaced import. Hence we
|
---|
590 | // support a property access here as long as it resolves to the actual known TypeScript helper.
|
---|
591 | var receiver = null;
|
---|
592 | if (ts.isIdentifier(receiverExpr)) {
|
---|
593 | receiver = this.getDeclarationOfIdentifier(receiverExpr);
|
---|
594 | }
|
---|
595 | else if (ts.isPropertyAccessExpression(receiverExpr) && ts.isIdentifier(receiverExpr.name)) {
|
---|
596 | receiver = this.getDeclarationOfIdentifier(receiverExpr.name);
|
---|
597 | }
|
---|
598 | if (receiver === null || receiver.known === null) {
|
---|
599 | return null;
|
---|
600 | }
|
---|
601 | return {
|
---|
602 | helper: receiver.known,
|
---|
603 | args: expression.arguments,
|
---|
604 | };
|
---|
605 | };
|
---|
606 | return Esm5ReflectionHost;
|
---|
607 | }(esm2015_host_1.Esm2015ReflectionHost));
|
---|
608 | exports.Esm5ReflectionHost = Esm5ReflectionHost;
|
---|
609 | /**
|
---|
610 | * In ES5, getters and setters have been downleveled into call expressions of
|
---|
611 | * `Object.defineProperty`, such as
|
---|
612 | *
|
---|
613 | * ```
|
---|
614 | * Object.defineProperty(Clazz.prototype, "property", {
|
---|
615 | * get: function () {
|
---|
616 | * return 'value';
|
---|
617 | * },
|
---|
618 | * set: function (value) {
|
---|
619 | * this.value = value;
|
---|
620 | * },
|
---|
621 | * enumerable: true,
|
---|
622 | * configurable: true
|
---|
623 | * });
|
---|
624 | * ```
|
---|
625 | *
|
---|
626 | * This function inspects the given node to determine if it corresponds with such a call, and if so
|
---|
627 | * extracts the `set` and `get` function expressions from the descriptor object, if they exist.
|
---|
628 | *
|
---|
629 | * @param node The node to obtain the property definition from.
|
---|
630 | * @returns The property definition if the node corresponds with accessor, null otherwise.
|
---|
631 | */
|
---|
632 | function getPropertyDefinition(node) {
|
---|
633 | if (!ts.isCallExpression(node))
|
---|
634 | return null;
|
---|
635 | var fn = node.expression;
|
---|
636 | if (!ts.isPropertyAccessExpression(fn) || !ts.isIdentifier(fn.expression) ||
|
---|
637 | fn.expression.text !== 'Object' || fn.name.text !== 'defineProperty')
|
---|
638 | return null;
|
---|
639 | var descriptor = node.arguments[2];
|
---|
640 | if (!descriptor || !ts.isObjectLiteralExpression(descriptor))
|
---|
641 | return null;
|
---|
642 | return {
|
---|
643 | setter: readPropertyFunctionExpression(descriptor, 'set'),
|
---|
644 | getter: readPropertyFunctionExpression(descriptor, 'get'),
|
---|
645 | };
|
---|
646 | }
|
---|
647 | function readPropertyFunctionExpression(object, name) {
|
---|
648 | var property = object.properties.find(function (p) {
|
---|
649 | return ts.isPropertyAssignment(p) && ts.isIdentifier(p.name) && p.name.text === name;
|
---|
650 | });
|
---|
651 | return property && ts.isFunctionExpression(property.initializer) && property.initializer || null;
|
---|
652 | }
|
---|
653 | function getReturnStatement(declaration) {
|
---|
654 | return declaration && ts.isFunctionExpression(declaration) ?
|
---|
655 | declaration.body.statements.find(ts.isReturnStatement) :
|
---|
656 | undefined;
|
---|
657 | }
|
---|
658 | function reflectArrayElement(element) {
|
---|
659 | return ts.isObjectLiteralExpression(element) ? reflection_1.reflectObjectLiteral(element) : null;
|
---|
660 | }
|
---|
661 | function isArgumentsIdentifier(expression) {
|
---|
662 | return ts.isIdentifier(expression) && expression.text === 'arguments';
|
---|
663 | }
|
---|
664 | function isSuperNotNull(expression) {
|
---|
665 | return isBinaryExpr(expression, ts.SyntaxKind.ExclamationEqualsEqualsToken) &&
|
---|
666 | isSuperIdentifier(expression.left);
|
---|
667 | }
|
---|
668 | function isBinaryExpr(expression, operator) {
|
---|
669 | return ts.isBinaryExpression(expression) && expression.operatorToken.kind === operator;
|
---|
670 | }
|
---|
671 | function isSuperIdentifier(node) {
|
---|
672 | // Verify that the identifier is prefixed with `_super`. We don't test for equivalence
|
---|
673 | // as TypeScript may have suffixed the name, e.g. `_super_1` to avoid name conflicts.
|
---|
674 | // Requiring only a prefix should be sufficiently accurate.
|
---|
675 | return ts.isIdentifier(node) && node.text.startsWith('_super');
|
---|
676 | }
|
---|
677 | /**
|
---|
678 | * Parse the statement to extract the ESM5 parameter initializer if there is one.
|
---|
679 | * If one is found, add it to the appropriate parameter in the `parameters` collection.
|
---|
680 | *
|
---|
681 | * The form we are looking for is:
|
---|
682 | *
|
---|
683 | * ```
|
---|
684 | * if (arg === void 0) { arg = initializer; }
|
---|
685 | * ```
|
---|
686 | *
|
---|
687 | * @param statement a statement that may be initializing an optional parameter
|
---|
688 | * @param parameters the collection of parameters that were found in the function definition
|
---|
689 | * @returns true if the statement was a parameter initializer
|
---|
690 | */
|
---|
691 | function captureParamInitializer(statement, parameters) {
|
---|
692 | if (ts.isIfStatement(statement) && isUndefinedComparison(statement.expression) &&
|
---|
693 | ts.isBlock(statement.thenStatement) && statement.thenStatement.statements.length === 1) {
|
---|
694 | var ifStatementComparison = statement.expression; // (arg === void 0)
|
---|
695 | var thenStatement = statement.thenStatement.statements[0]; // arg = initializer;
|
---|
696 | if (esm2015_host_1.isAssignmentStatement(thenStatement)) {
|
---|
697 | var comparisonName_1 = ifStatementComparison.left.text;
|
---|
698 | var assignmentName = thenStatement.expression.left.text;
|
---|
699 | if (comparisonName_1 === assignmentName) {
|
---|
700 | var parameter = parameters.find(function (p) { return p.name === comparisonName_1; });
|
---|
701 | if (parameter) {
|
---|
702 | parameter.initializer = thenStatement.expression.right;
|
---|
703 | return true;
|
---|
704 | }
|
---|
705 | }
|
---|
706 | }
|
---|
707 | }
|
---|
708 | return false;
|
---|
709 | }
|
---|
710 | function isUndefinedComparison(expression) {
|
---|
711 | return ts.isBinaryExpression(expression) &&
|
---|
712 | expression.operatorToken.kind === ts.SyntaxKind.EqualsEqualsEqualsToken &&
|
---|
713 | ts.isVoidExpression(expression.right) && ts.isIdentifier(expression.left);
|
---|
714 | }
|
---|
715 | /**
|
---|
716 | * Parse the declaration of the given `classSymbol` to find the IIFE wrapper function.
|
---|
717 | *
|
---|
718 | * This function may accept a `_super` argument if there is a base class.
|
---|
719 | *
|
---|
720 | * ```
|
---|
721 | * var TestClass = (function (_super) {
|
---|
722 | * __extends(TestClass, _super);
|
---|
723 | * function TestClass() {}
|
---|
724 | * return TestClass;
|
---|
725 | * }(BaseClass));
|
---|
726 | * ```
|
---|
727 | *
|
---|
728 | * @param classSymbol the class whose iife wrapper function we want to get.
|
---|
729 | * @returns the IIFE function or null if it could not be parsed.
|
---|
730 | */
|
---|
731 | function getIifeFn(classSymbol) {
|
---|
732 | if (classSymbol === undefined) {
|
---|
733 | return null;
|
---|
734 | }
|
---|
735 | var innerDeclaration = classSymbol.implementation.valueDeclaration;
|
---|
736 | var iifeBody = innerDeclaration.parent;
|
---|
737 | if (!ts.isBlock(iifeBody)) {
|
---|
738 | return null;
|
---|
739 | }
|
---|
740 | var iifeWrapper = iifeBody.parent;
|
---|
741 | return iifeWrapper && ts.isFunctionExpression(iifeWrapper) ? iifeWrapper : null;
|
---|
742 | }
|
---|
743 | });
|
---|
744 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXNtNV9ob3N0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vLi4vLi4vcGFja2FnZXMvY29tcGlsZXItY2xpL25nY2Mvc3JjL2hvc3QvZXNtNV9ob3N0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRzs7Ozs7Ozs7Ozs7Ozs7SUFFSCwrQkFBaUM7SUFFakMseUVBQXlPO0lBQ3pPLDhEQUFzRztJQUV0RyxpRkFBcUo7SUFJcko7Ozs7Ozs7Ozs7Ozs7Ozs7O09BaUJHO0lBQ0g7UUFBd0MsOENBQXFCO1FBQTdEOztRQTZsQkEsQ0FBQztRQTVsQlUsbURBQXNCLEdBQS9CLFVBQWdDLEtBQXVCO1lBQ3JELElBQU0sd0JBQXdCLEdBQUcsaUJBQU0sc0JBQXNCLFlBQUMsS0FBSyxDQUFDLENBQUM7WUFDckUsSUFBSSx3QkFBd0IsS0FBSyxJQUFJLEVBQUU7Z0JBQ3JDLE9BQU8sd0JBQXdCLENBQUM7YUFDakM7WUFFRCxJQUFNLElBQUksR0FBRyxTQUFTLENBQUMsSUFBSSxDQUFDLGNBQWMsQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDO1lBQ25ELElBQUksSUFBSSxLQUFLLElBQUk7Z0JBQUUsT0FBTyxJQUFJLENBQUM7WUFFL0IsSUFBSSxJQUFJLENBQUMsVUFBVSxDQUFDLE1BQU0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