source: trip-planner-front/node_modules/@angular/compiler-cli/ngcc/src/host/esm2015_host.d.ts

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 41.6 KB
Line 
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/// <amd-module name="@angular/compiler-cli/ngcc/src/host/esm2015_host" />
9import * as ts from 'typescript';
10import { Logger } from '../../../src/ngtsc/logging';
11import { ClassDeclaration, ClassMember, ClassMemberKind, CtorParameter, Declaration, DeclarationNode, Decorator, EnumMember, TypeScriptReflectionHost } from '../../../src/ngtsc/reflection';
12import { BundleProgram } from '../packages/bundle_program';
13import { NgccClassSymbol, NgccReflectionHost, SwitchableVariableDeclaration } from './ngcc_host';
14export declare const DECORATORS: ts.__String;
15export declare const PROP_DECORATORS: ts.__String;
16export declare const CONSTRUCTOR: ts.__String;
17export declare const CONSTRUCTOR_PARAMS: ts.__String;
18/**
19 * Esm2015 packages contain ECMAScript 2015 classes, etc.
20 * Decorators are defined via static properties on the class. For example:
21 *
22 * ```
23 * class SomeDirective {
24 * }
25 * SomeDirective.decorators = [
26 * { type: Directive, args: [{ selector: '[someDirective]' },] }
27 * ];
28 * SomeDirective.ctorParameters = () => [
29 * { type: ViewContainerRef, },
30 * { type: TemplateRef, },
31 * { type: undefined, decorators: [{ type: Inject, args: [INJECTED_TOKEN,] },] },
32 * ];
33 * SomeDirective.propDecorators = {
34 * "input1": [{ type: Input },],
35 * "input2": [{ type: Input },],
36 * };
37 * ```
38 *
39 * * Classes are decorated if they have a static property called `decorators`.
40 * * Members are decorated if there is a matching key on a static property
41 * called `propDecorators`.
42 * * Constructor parameters decorators are found on an object returned from
43 * a static method called `ctorParameters`.
44 */
45export declare class Esm2015ReflectionHost extends TypeScriptReflectionHost implements NgccReflectionHost {
46 protected logger: Logger;
47 protected isCore: boolean;
48 protected src: BundleProgram;
49 protected dts: BundleProgram | null;
50 /**
51 * A mapping from source declarations to typings declarations, which are both publicly exported.
52 *
53 * There should be one entry for every public export visible from the root file of the source
54 * tree. Note that by definition the key and value declarations will not be in the same TS
55 * program.
56 */
57 protected publicDtsDeclarationMap: Map<DeclarationNode, ts.Declaration> | null;
58 /**
59 * A mapping from source declarations to typings declarations, which are not publicly exported.
60 *
61 * This mapping is a best guess between declarations that happen to be exported from their file by
62 * the same name in both the source and the dts file. Note that by definition the key and value
63 * declarations will not be in the same TS program.
64 */
65 protected privateDtsDeclarationMap: Map<DeclarationNode, ts.Declaration> | null;
66 /**
67 * The set of source files that have already been preprocessed.
68 */
69 protected preprocessedSourceFiles: Set<ts.SourceFile>;
70 /**
71 * In ES2015, class declarations may have been down-leveled into variable declarations,
72 * initialized using a class expression. In certain scenarios, an additional variable
73 * is introduced that represents the class so that results in code such as:
74 *
75 * ```
76 * let MyClass_1; let MyClass = MyClass_1 = class MyClass {};
77 * ```
78 *
79 * This map tracks those aliased variables to their original identifier, i.e. the key
80 * corresponds with the declaration of `MyClass_1` and its value becomes the `MyClass` identifier
81 * of the variable declaration.
82 *
83 * This map is populated during the preprocessing of each source file.
84 */
85 protected aliasedClassDeclarations: Map<DeclarationNode, ts.Identifier>;
86 /**
87 * Caches the information of the decorators on a class, as the work involved with extracting
88 * decorators is complex and frequently used.
89 *
90 * This map is lazily populated during the first call to `acquireDecoratorInfo` for a given class.
91 */
92 protected decoratorCache: Map<ClassDeclaration<DeclarationNode>, DecoratorInfo>;
93 constructor(logger: Logger, isCore: boolean, src: BundleProgram, dts?: BundleProgram | null);
94 /**
95 * Find a symbol for a node that we think is a class.
96 * Classes should have a `name` identifier, because they may need to be referenced in other parts
97 * of the program.
98 *
99 * In ES2015, a class may be declared using a variable declaration of the following structures:
100 *
101 * ```
102 * var MyClass = MyClass_1 = class MyClass {};
103 * ```
104 *
105 * or
106 *
107 * ```
108 * var MyClass = MyClass_1 = (() => { class MyClass {} ... return MyClass; })()
109 * ```
110 *
111 * Here, the intermediate `MyClass_1` assignment is optional. In the above example, the
112 * `class MyClass {}` node is returned as declaration of `MyClass`.
113 *
114 * @param declaration the declaration node whose symbol we are finding.
115 * @returns the symbol for the node or `undefined` if it is not a "class" or has no symbol.
116 */
117 getClassSymbol(declaration: ts.Node): NgccClassSymbol | undefined;
118 /**
119 * Examine a declaration (for example, of a class or function) and return metadata about any
120 * decorators present on the declaration.
121 *
122 * @param declaration a TypeScript node representing the class or function over which to reflect.
123 * For example, if the intent is to reflect the decorators of a class and the source is in ES6
124 * format, this will be a `ts.ClassDeclaration` node. If the source is in ES5 format, this
125 * might be a `ts.VariableDeclaration` as classes in ES5 are represented as the result of an
126 * IIFE execution.
127 *
128 * @returns an array of `Decorator` metadata if decorators are present on the declaration, or
129 * `null` if either no decorators were present or if the declaration is not of a decoratable
130 * type.
131 */
132 getDecoratorsOfDeclaration(declaration: DeclarationNode): Decorator[] | null;
133 /**
134 * Examine a declaration which should be of a class, and return metadata about the members of the
135 * class.
136 *
137 * @param clazz a `ClassDeclaration` representing the class over which to reflect.
138 *
139 * @returns an array of `ClassMember` metadata representing the members of the class.
140 *
141 * @throws if `declaration` does not resolve to a class declaration.
142 */
143 getMembersOfClass(clazz: ClassDeclaration): ClassMember[];
144 /**
145 * Reflect over the constructor of a class and return metadata about its parameters.
146 *
147 * This method only looks at the constructor of a class directly and not at any inherited
148 * constructors.
149 *
150 * @param clazz a `ClassDeclaration` representing the class over which to reflect.
151 *
152 * @returns an array of `Parameter` metadata representing the parameters of the constructor, if
153 * a constructor exists. If the constructor exists and has 0 parameters, this array will be empty.
154 * If the class has no constructor, this method returns `null`.
155 *
156 * @throws if `declaration` does not resolve to a class declaration.
157 */
158 getConstructorParameters(clazz: ClassDeclaration): CtorParameter[] | null;
159 getBaseClassExpression(clazz: ClassDeclaration): ts.Expression | null;
160 getInternalNameOfClass(clazz: ClassDeclaration): ts.Identifier;
161 getAdjacentNameOfClass(clazz: ClassDeclaration): ts.Identifier;
162 private getNameFromClassSymbolDeclaration;
163 /**
164 * Check whether the given node actually represents a class.
165 */
166 isClass(node: ts.Node): node is ClassDeclaration;
167 /**
168 * Trace an identifier to its declaration, if possible.
169 *
170 * This method attempts to resolve the declaration of the given identifier, tracing back through
171 * imports and re-exports until the original declaration statement is found. A `Declaration`
172 * object is returned if the original declaration is found, or `null` is returned otherwise.
173 *
174 * In ES2015, we need to account for identifiers that refer to aliased class declarations such as
175 * `MyClass_1`. Since such declarations are only available within the module itself, we need to
176 * find the original class declaration, e.g. `MyClass`, that is associated with the aliased one.
177 *
178 * @param id a TypeScript `ts.Identifier` to trace back to a declaration.
179 *
180 * @returns metadata about the `Declaration` if the original declaration is found, or `null`
181 * otherwise.
182 */
183 getDeclarationOfIdentifier(id: ts.Identifier): Declaration | null;
184 /**
185 * Gets all decorators of the given class symbol. Any decorator that have been synthetically
186 * injected by a migration will not be present in the returned collection.
187 */
188 getDecoratorsOfSymbol(symbol: NgccClassSymbol): Decorator[] | null;
189 /**
190 * Search the given module for variable declarations in which the initializer
191 * is an identifier marked with the `PRE_R3_MARKER`.
192 * @param module the module in which to search for switchable declarations.
193 * @returns an array of variable declarations that match.
194 */
195 getSwitchableDeclarations(module: ts.Node): SwitchableVariableDeclaration[];
196 getVariableValue(declaration: ts.VariableDeclaration): ts.Expression | null;
197 /**
198 * Find all top-level class symbols in the given file.
199 * @param sourceFile The source file to search for classes.
200 * @returns An array of class symbols.
201 */
202 findClassSymbols(sourceFile: ts.SourceFile): NgccClassSymbol[];
203 /**
204 * Get the number of generic type parameters of a given class.
205 *
206 * @param clazz a `ClassDeclaration` representing the class over which to reflect.
207 *
208 * @returns the number of type parameters of the class, if known, or `null` if the declaration
209 * is not a class or has an unknown number of type parameters.
210 */
211 getGenericArityOfClass(clazz: ClassDeclaration): number | null;
212 /**
213 * Take an exported declaration of a class (maybe down-leveled to a variable) and look up the
214 * declaration of its type in a separate .d.ts tree.
215 *
216 * This function is allowed to return `null` if the current compilation unit does not have a
217 * separate .d.ts tree. When compiling TypeScript code this is always the case, since .d.ts files
218 * are produced only during the emit of such a compilation. When compiling .js code, however,
219 * there is frequently a parallel .d.ts tree which this method exposes.
220 *
221 * Note that the `ts.ClassDeclaration` returned from this function may not be from the same
222 * `ts.Program` as the input declaration.
223 */
224 getDtsDeclaration(declaration: DeclarationNode): ts.Declaration | null;
225 getEndOfClass(classSymbol: NgccClassSymbol): ts.Node;
226 /**
227 * Check whether a `Declaration` corresponds with a known declaration, such as `Object`, and set
228 * its `known` property to the appropriate `KnownDeclaration`.
229 *
230 * @param decl The `Declaration` to check.
231 * @return The passed in `Declaration` (potentially enhanced with a `KnownDeclaration`).
232 */
233 detectKnownDeclaration<T extends Declaration>(decl: T): T;
234 /**
235 * Extract all the "classes" from the `statement` and add them to the `classes` map.
236 */
237 protected addClassSymbolsFromStatement(classes: Map<ts.Symbol, NgccClassSymbol>, statement: ts.Statement): void;
238 /**
239 * Compute the inner declaration node of a "class" from the given `declaration` node.
240 *
241 * @param declaration a node that is either an inner declaration or an alias of a class.
242 */
243 protected getInnerDeclarationFromAliasOrInner(declaration: ts.Node): ts.Node;
244 /**
245 * A class may be declared as a top level class declaration:
246 *
247 * ```
248 * class OuterClass { ... }
249 * ```
250 *
251 * or in a variable declaration to a class expression:
252 *
253 * ```
254 * var OuterClass = ClassAlias = class InnerClass {};
255 * ```
256 *
257 * or in a variable declaration to an IIFE containing a class declaration
258 *
259 * ```
260 * var OuterClass = ClassAlias = (() => {
261 * class InnerClass {}
262 * ...
263 * return InnerClass;
264 * })()
265 * ```
266 *
267 * or in a variable declaration to an IIFE containing a function declaration
268 *
269 * ```
270 * var OuterClass = ClassAlias = (() => {
271 * function InnerClass() {}
272 * ...
273 * return InnerClass;
274 * })()
275 * ```
276 *
277 * This method returns an `NgccClassSymbol` when provided with one of these cases.
278 *
279 * @param declaration the declaration whose symbol we are finding.
280 * @returns the symbol for the class or `undefined` if `declaration` does not represent an outer
281 * declaration of a class.
282 */
283 protected getClassSymbolFromOuterDeclaration(declaration: ts.Node): NgccClassSymbol | undefined;
284 /**
285 * In ES2015, a class may be declared using a variable declaration of the following structures:
286 *
287 * ```
288 * let MyClass = MyClass_1 = class MyClass {};
289 * ```
290 *
291 * or
292 *
293 * ```
294 * let MyClass = MyClass_1 = (() => { class MyClass {} ... return MyClass; })()
295 * ```
296 *
297 * or
298 *
299 * ```
300 * let MyClass = MyClass_1 = (() => { let MyClass = class MyClass {}; ... return MyClass; })()
301 * ```
302 *
303 * This method extracts the `NgccClassSymbol` for `MyClass` when provided with the
304 * `class MyClass {}` declaration node. When the `var MyClass` node or any other node is given,
305 * this method will return undefined instead.
306 *
307 * @param declaration the declaration whose symbol we are finding.
308 * @returns the symbol for the node or `undefined` if it does not represent an inner declaration
309 * of a class.
310 */
311 protected getClassSymbolFromInnerDeclaration(declaration: ts.Node): NgccClassSymbol | undefined;
312 /**
313 * Creates an `NgccClassSymbol` from an outer and inner declaration. If a class only has an outer
314 * declaration, the "implementation" symbol of the created `NgccClassSymbol` will be set equal to
315 * the "declaration" symbol.
316 *
317 * @param outerDeclaration The outer declaration node of the class.
318 * @param innerDeclaration The inner declaration node of the class, or undefined if no inner
319 * declaration is present.
320 * @returns the `NgccClassSymbol` representing the class, or undefined if a `ts.Symbol` for any of
321 * the declarations could not be resolved.
322 */
323 protected createClassSymbol(outerDeclaration: ts.Identifier, innerDeclaration: ts.Node | null): NgccClassSymbol | undefined;
324 private getAdjacentSymbol;
325 /**
326 * Resolve a `ts.Symbol` to its declaration and detect whether it corresponds with a known
327 * declaration.
328 */
329 protected getDeclarationOfSymbol(symbol: ts.Symbol, originalId: ts.Identifier | null): Declaration | null;
330 /**
331 * Finds the identifier of the actual class declaration for a potentially aliased declaration of a
332 * class.
333 *
334 * If the given declaration is for an alias of a class, this function will determine an identifier
335 * to the original declaration that represents this class.
336 *
337 * @param declaration The declaration to resolve.
338 * @returns The original identifier that the given class declaration resolves to, or `undefined`
339 * if the declaration does not represent an aliased class.
340 */
341 protected resolveAliasedClassIdentifier(declaration: DeclarationNode): ts.Identifier | null;
342 /**
343 * Ensures that the source file that `node` is part of has been preprocessed.
344 *
345 * During preprocessing, all statements in the source file will be visited such that certain
346 * processing steps can be done up-front and cached for subsequent usages.
347 *
348 * @param sourceFile The source file that needs to have gone through preprocessing.
349 */
350 protected ensurePreprocessed(sourceFile: ts.SourceFile): void;
351 /**
352 * Analyzes the given statement to see if it corresponds with a variable declaration like
353 * `let MyClass = MyClass_1 = class MyClass {};`. If so, the declaration of `MyClass_1`
354 * is associated with the `MyClass` identifier.
355 *
356 * @param statement The statement that needs to be preprocessed.
357 */
358 protected preprocessStatement(statement: ts.Statement): void;
359 /**
360 * Get the top level statements for a module.
361 *
362 * In ES5 and ES2015 this is just the top level statements of the file.
363 * @param sourceFile The module whose statements we want.
364 * @returns An array of top level statements for the given module.
365 */
366 protected getModuleStatements(sourceFile: ts.SourceFile): ts.Statement[];
367 /**
368 * Walk the AST looking for an assignment to the specified symbol.
369 * @param node The current node we are searching.
370 * @returns an expression that represents the value of the variable, or undefined if none can be
371 * found.
372 */
373 protected findDecoratedVariableValue(node: ts.Node | undefined, symbol: ts.Symbol): ts.CallExpression | null;
374 /**
375 * Try to retrieve the symbol of a static property on a class.
376 *
377 * In some cases, a static property can either be set on the inner (implementation or adjacent)
378 * declaration inside the class' IIFE, or it can be set on the outer variable declaration.
379 * Therefore, the host checks all places, first looking up the property on the inner symbols, and
380 * if the property is not found it will fall back to looking up the property on the outer symbol.
381 *
382 * @param symbol the class whose property we are interested in.
383 * @param propertyName the name of static property.
384 * @returns the symbol if it is found or `undefined` if not.
385 */
386 protected getStaticProperty(symbol: NgccClassSymbol, propertyName: ts.__String): ts.Symbol | undefined;
387 /**
388 * This is the main entry-point for obtaining information on the decorators of a given class. This
389 * information is computed either from static properties if present, or using `tslib.__decorate`
390 * helper calls otherwise. The computed result is cached per class.
391 *
392 * @param classSymbol the class for which decorators should be acquired.
393 * @returns all information of the decorators on the class.
394 */
395 protected acquireDecoratorInfo(classSymbol: NgccClassSymbol): DecoratorInfo;
396 /**
397 * Attempts to compute decorator information from static properties "decorators", "propDecorators"
398 * and "ctorParameters" on the class. If neither of these static properties is present the
399 * library is likely not compiled using tsickle for usage with Closure compiler, in which case
400 * `null` is returned.
401 *
402 * @param classSymbol The class symbol to compute the decorators information for.
403 * @returns All information on the decorators as extracted from static properties, or `null` if
404 * none of the static properties exist.
405 */
406 protected computeDecoratorInfoFromStaticProperties(classSymbol: NgccClassSymbol): {
407 classDecorators: Decorator[] | null;
408 memberDecorators: Map<string, Decorator[]> | null;
409 constructorParamInfo: ParamInfo[] | null;
410 };
411 /**
412 * Get all class decorators for the given class, where the decorators are declared
413 * via a static property. For example:
414 *
415 * ```
416 * class SomeDirective {}
417 * SomeDirective.decorators = [
418 * { type: Directive, args: [{ selector: '[someDirective]' },] }
419 * ];
420 * ```
421 *
422 * @param decoratorsSymbol the property containing the decorators we want to get.
423 * @returns an array of decorators or null if none where found.
424 */
425 protected getClassDecoratorsFromStaticProperty(decoratorsSymbol: ts.Symbol): Decorator[] | null;
426 /**
427 * Examine a symbol which should be of a class, and return metadata about its members.
428 *
429 * @param symbol the `ClassSymbol` representing the class over which to reflect.
430 * @returns an array of `ClassMember` metadata representing the members of the class.
431 */
432 protected getMembersOfSymbol(symbol: NgccClassSymbol): ClassMember[];
433 /**
434 * Member decorators may be declared as static properties of the class:
435 *
436 * ```
437 * SomeDirective.propDecorators = {
438 * "ngForOf": [{ type: Input },],
439 * "ngForTrackBy": [{ type: Input },],
440 * "ngForTemplate": [{ type: Input },],
441 * };
442 * ```
443 *
444 * @param decoratorsProperty the class whose member decorators we are interested in.
445 * @returns a map whose keys are the name of the members and whose values are collections of
446 * decorators for the given member.
447 */
448 protected getMemberDecoratorsFromStaticProperty(decoratorsProperty: ts.Symbol): Map<string, Decorator[]>;
449 /**
450 * For a given class symbol, collects all decorator information from tslib helper methods, as
451 * generated by TypeScript into emitted JavaScript files.
452 *
453 * Class decorators are extracted from calls to `tslib.__decorate` that look as follows:
454 *
455 * ```
456 * let SomeDirective = class SomeDirective {}
457 * SomeDirective = __decorate([
458 * Directive({ selector: '[someDirective]' }),
459 * ], SomeDirective);
460 * ```
461 *
462 * The extraction of member decorators is similar, with the distinction that its 2nd and 3rd
463 * argument correspond with a "prototype" target and the name of the member to which the
464 * decorators apply.
465 *
466 * ```
467 * __decorate([
468 * Input(),
469 * __metadata("design:type", String)
470 * ], SomeDirective.prototype, "input1", void 0);
471 * ```
472 *
473 * @param classSymbol The class symbol for which decorators should be extracted.
474 * @returns All information on the decorators of the class.
475 */
476 protected computeDecoratorInfoFromHelperCalls(classSymbol: NgccClassSymbol): DecoratorInfo;
477 /**
478 * Extract the details of an entry within a `__decorate` helper call. For example, given the
479 * following code:
480 *
481 * ```
482 * __decorate([
483 * Directive({ selector: '[someDirective]' }),
484 * tslib_1.__param(2, Inject(INJECTED_TOKEN)),
485 * tslib_1.__metadata("design:paramtypes", [ViewContainerRef, TemplateRef, String])
486 * ], SomeDirective);
487 * ```
488 *
489 * it can be seen that there are calls to regular decorators (the `Directive`) and calls into
490 * `tslib` functions which have been inserted by TypeScript. Therefore, this function classifies
491 * a call to correspond with
492 * 1. a real decorator like `Directive` above, or
493 * 2. a decorated parameter, corresponding with `__param` calls from `tslib`, or
494 * 3. the type information of parameters, corresponding with `__metadata` call from `tslib`
495 *
496 * @param expression the expression that needs to be reflected into a `DecorateHelperEntry`
497 * @returns an object that indicates which of the three categories the call represents, together
498 * with the reflected information of the call, or null if the call is not a valid decorate call.
499 */
500 protected reflectDecorateHelperEntry(expression: ts.Expression): DecorateHelperEntry | null;
501 protected reflectDecoratorCall(call: ts.CallExpression): Decorator | null;
502 /**
503 * Check the given statement to see if it is a call to any of the specified helper functions or
504 * null if not found.
505 *
506 * Matching statements will look like: `tslib_1.__decorate(...);`.
507 * @param statement the statement that may contain the call.
508 * @param helperNames the names of the helper we are looking for.
509 * @returns the node that corresponds to the `__decorate(...)` call or null if the statement
510 * does not match.
511 */
512 protected getHelperCall(statement: ts.Statement, helperNames: string[]): ts.CallExpression | null;
513 /**
514 * Reflect over the given array node and extract decorator information from each element.
515 *
516 * This is used for decorators that are defined in static properties. For example:
517 *
518 * ```
519 * SomeDirective.decorators = [
520 * { type: Directive, args: [{ selector: '[someDirective]' },] }
521 * ];
522 * ```
523 *
524 * @param decoratorsArray an expression that contains decorator information.
525 * @returns an array of decorator info that was reflected from the array node.
526 */
527 protected reflectDecorators(decoratorsArray: ts.Expression): Decorator[];
528 /**
529 * Reflect over a symbol and extract the member information, combining it with the
530 * provided decorator information, and whether it is a static member.
531 *
532 * A single symbol may represent multiple class members in the case of accessors;
533 * an equally named getter/setter accessor pair is combined into a single symbol.
534 * When the symbol is recognized as representing an accessor, its declarations are
535 * analyzed such that both the setter and getter accessor are returned as separate
536 * class members.
537 *
538 * One difference wrt the TypeScript host is that in ES2015, we cannot see which
539 * accessor originally had any decorators applied to them, as decorators are applied
540 * to the property descriptor in general, not a specific accessor. If an accessor
541 * has both a setter and getter, any decorators are only attached to the setter member.
542 *
543 * @param symbol the symbol for the member to reflect over.
544 * @param decorators an array of decorators associated with the member.
545 * @param isStatic true if this member is static, false if it is an instance property.
546 * @returns the reflected member information, or null if the symbol is not a member.
547 */
548 protected reflectMembers(symbol: ts.Symbol, decorators?: Decorator[], isStatic?: boolean): ClassMember[] | null;
549 /**
550 * Reflect over a symbol and extract the member information, combining it with the
551 * provided decorator information, and whether it is a static member.
552 * @param node the declaration node for the member to reflect over.
553 * @param kind the assumed kind of the member, may become more accurate during reflection.
554 * @param decorators an array of decorators associated with the member.
555 * @param isStatic true if this member is static, false if it is an instance property.
556 * @returns the reflected member information, or null if the symbol is not a member.
557 */
558 protected reflectMember(node: ts.Declaration, kind: ClassMemberKind | null, decorators?: Decorator[], isStatic?: boolean): ClassMember | null;
559 /**
560 * Find the declarations of the constructor parameters of a class identified by its symbol.
561 * @param classSymbol the class whose parameters we want to find.
562 * @returns an array of `ts.ParameterDeclaration` objects representing each of the parameters in
563 * the class's constructor or null if there is no constructor.
564 */
565 protected getConstructorParameterDeclarations(classSymbol: NgccClassSymbol): ts.ParameterDeclaration[] | null;
566 /**
567 * Get the parameter decorators of a class constructor.
568 *
569 * @param classSymbol the class whose parameter info we want to get.
570 * @param parameterNodes the array of TypeScript parameter nodes for this class's constructor.
571 * @returns an array of constructor parameter info objects.
572 */
573 protected getConstructorParamInfo(classSymbol: NgccClassSymbol, parameterNodes: ts.ParameterDeclaration[]): CtorParameter[];
574 /**
575 * Compute the `TypeValueReference` for the given `typeExpression`.
576 *
577 * Although `typeExpression` is a valid `ts.Expression` that could be emitted directly into the
578 * generated code, ngcc still needs to resolve the declaration and create an `IMPORTED` type
579 * value reference as the compiler has specialized handling for some symbols, for example
580 * `ChangeDetectorRef` from `@angular/core`. Such an `IMPORTED` type value reference will result
581 * in a newly generated namespace import, instead of emitting the original `typeExpression` as is.
582 */
583 private typeToValue;
584 /**
585 * Determines where the `expression` is imported from.
586 *
587 * @param expression the expression to determine the import details for.
588 * @returns the `Import` for the expression, or `null` if the expression is not imported or the
589 * expression syntax is not supported.
590 */
591 private getImportOfExpression;
592 /**
593 * Get the parameter type and decorators for the constructor of a class,
594 * where the information is stored on a static property of the class.
595 *
596 * Note that in ESM2015, the property is defined an array, or by an arrow function that returns
597 * an array, of decorator and type information.
598 *
599 * For example,
600 *
601 * ```
602 * SomeDirective.ctorParameters = () => [
603 * {type: ViewContainerRef},
604 * {type: TemplateRef},
605 * {type: undefined, decorators: [{ type: Inject, args: [INJECTED_TOKEN]}]},
606 * ];
607 * ```
608 *
609 * or
610 *
611 * ```
612 * SomeDirective.ctorParameters = [
613 * {type: ViewContainerRef},
614 * {type: TemplateRef},
615 * {type: undefined, decorators: [{type: Inject, args: [INJECTED_TOKEN]}]},
616 * ];
617 * ```
618 *
619 * @param paramDecoratorsProperty the property that holds the parameter info we want to get.
620 * @returns an array of objects containing the type and decorators for each parameter.
621 */
622 protected getParamInfoFromStaticProperty(paramDecoratorsProperty: ts.Symbol): ParamInfo[] | null;
623 /**
624 * Search statements related to the given class for calls to the specified helper.
625 * @param classSymbol the class whose helper calls we are interested in.
626 * @param helperNames the names of the helpers (e.g. `__decorate`) whose calls we are interested
627 * in.
628 * @returns an array of CallExpression nodes for each matching helper call.
629 */
630 protected getHelperCallsForClass(classSymbol: NgccClassSymbol, helperNames: string[]): ts.CallExpression[];
631 /**
632 * Find statements related to the given class that may contain calls to a helper.
633 *
634 * In ESM2015 code the helper calls are in the top level module, so we have to consider
635 * all the statements in the module.
636 *
637 * @param classSymbol the class whose helper calls we are interested in.
638 * @returns an array of statements that may contain helper calls.
639 */
640 protected getStatementsForClass(classSymbol: NgccClassSymbol): ts.Statement[];
641 /**
642 * Test whether a decorator was imported from `@angular/core`.
643 *
644 * Is the decorator:
645 * * externally imported from `@angular/core`?
646 * * the current hosted program is actually `@angular/core` and
647 * - relatively internally imported; or
648 * - not imported, from the current file.
649 *
650 * @param decorator the decorator to test.
651 */
652 protected isFromCore(decorator: Decorator): boolean;
653 /**
654 * Create a mapping between the public exports in a src program and the public exports of a dts
655 * program.
656 *
657 * @param src the program bundle containing the source files.
658 * @param dts the program bundle containing the typings files.
659 * @returns a map of source declarations to typings declarations.
660 */
661 protected computePublicDtsDeclarationMap(src: BundleProgram, dts: BundleProgram): Map<DeclarationNode, ts.Declaration>;
662 /**
663 * Create a mapping between the "private" exports in a src program and the "private" exports of a
664 * dts program. These exports may be exported from individual files in the src or dts programs,
665 * but not exported from the root file (i.e publicly from the entry-point).
666 *
667 * This mapping is a "best guess" since we cannot guarantee that two declarations that happen to
668 * be exported from a file with the same name are actually equivalent. But this is a reasonable
669 * estimate for the purposes of ngcc.
670 *
671 * @param src the program bundle containing the source files.
672 * @param dts the program bundle containing the typings files.
673 * @returns a map of source declarations to typings declarations.
674 */
675 protected computePrivateDtsDeclarationMap(src: BundleProgram, dts: BundleProgram): Map<DeclarationNode, ts.Declaration>;
676 /**
677 * Collect mappings between names of exported declarations in a file and its actual declaration.
678 *
679 * Any new mappings are added to the `dtsDeclarationMap`.
680 */
681 protected collectDtsExportedDeclarations(dtsDeclarationMap: Map<string, ts.Declaration>, srcFile: ts.SourceFile, checker: ts.TypeChecker): void;
682 protected collectSrcExportedDeclarations(declarationMap: Map<DeclarationNode, ts.Declaration>, dtsDeclarationMap: Map<string, ts.Declaration>, srcFile: ts.SourceFile): void;
683 protected getDeclarationOfExpression(expression: ts.Expression): Declaration | null;
684 /** Checks if the specified declaration resolves to the known JavaScript global `Object`. */
685 protected isJavaScriptObjectDeclaration(decl: Declaration): boolean;
686 /**
687 * In JavaScript, enum declarations are emitted as a regular variable declaration followed by an
688 * IIFE in which the enum members are assigned.
689 *
690 * export var Enum;
691 * (function (Enum) {
692 * Enum["a"] = "A";
693 * Enum["b"] = "B";
694 * })(Enum || (Enum = {}));
695 *
696 * @param declaration A variable declaration that may represent an enum
697 * @returns An array of enum members if the variable declaration is followed by an IIFE that
698 * declares the enum members, or null otherwise.
699 */
700 protected resolveEnumMembers(declaration: ts.VariableDeclaration): EnumMember[] | null;
701 /**
702 * Attempts to extract all `EnumMember`s from a function that is according to the JavaScript emit
703 * format for enums:
704 *
705 * function (Enum) {
706 * Enum["MemberA"] = "a";
707 * Enum["MemberB"] = "b";
708 * }
709 *
710 * @param fn The function expression that is assumed to contain enum members.
711 * @returns All enum members if the function is according to the correct syntax, null otherwise.
712 */
713 private reflectEnumMembers;
714 /**
715 * Attempts to extract a single `EnumMember` from a statement in the following syntax:
716 *
717 * Enum["MemberA"] = "a";
718 *
719 * or, for enum member with numeric values:
720 *
721 * Enum[Enum["MemberA"] = 0] = "MemberA";
722 *
723 * @param enumName The identifier of the enum that the members should be set on.
724 * @param statement The statement to inspect.
725 * @returns An `EnumMember` if the statement is according to the expected syntax, null otherwise.
726 */
727 protected reflectEnumMember(enumName: ts.Identifier, statement: ts.Statement): EnumMember | null;
728 private getAdjacentNameOfClassSymbol;
729}
730/**
731 * An enum member assignment that looks like `Enum[X] = Y;`.
732 */
733export declare type EnumMemberAssignment = ts.BinaryExpression & {
734 left: ts.ElementAccessExpression;
735};
736export declare type ParamInfo = {
737 decorators: Decorator[] | null;
738 typeExpression: ts.Expression | null;
739};
740/**
741 * Represents a call to `tslib.__metadata` as present in `tslib.__decorate` calls. This is a
742 * synthetic decorator inserted by TypeScript that contains reflection information about the
743 * target of the decorator, i.e. the class or property.
744 */
745export interface ParameterTypes {
746 type: 'params';
747 types: ts.Expression[];
748}
749/**
750 * Represents a call to `tslib.__param` as present in `tslib.__decorate` calls. This contains
751 * information on any decorators were applied to a certain parameter.
752 */
753export interface ParameterDecorators {
754 type: 'param:decorators';
755 index: number;
756 decorator: Decorator;
757}
758/**
759 * Represents a call to a decorator as it was present in the original source code, as present in
760 * `tslib.__decorate` calls.
761 */
762export interface DecoratorCall {
763 type: 'decorator';
764 decorator: Decorator;
765}
766/**
767 * Represents the different kinds of decorate helpers that may be present as first argument to
768 * `tslib.__decorate`, as follows:
769 *
770 * ```
771 * __decorate([
772 * Directive({ selector: '[someDirective]' }),
773 * tslib_1.__param(2, Inject(INJECTED_TOKEN)),
774 * tslib_1.__metadata("design:paramtypes", [ViewContainerRef, TemplateRef, String])
775 * ], SomeDirective);
776 * ```
777 */
778export declare type DecorateHelperEntry = ParameterTypes | ParameterDecorators | DecoratorCall;
779/**
780 * The recorded decorator information of a single class. This information is cached in the host.
781 */
782interface DecoratorInfo {
783 /**
784 * All decorators that were present on the class. If no decorators were present, this is `null`
785 */
786 classDecorators: Decorator[] | null;
787 /**
788 * All decorators per member of the class they were present on.
789 */
790 memberDecorators: Map<string, Decorator[]>;
791 /**
792 * Represents the constructor parameter information, such as the type of a parameter and all
793 * decorators for a certain parameter. Indices in this array correspond with the parameter's
794 * index in the constructor. Note that this array may be sparse, i.e. certain constructor
795 * parameters may not have any info recorded.
796 */
797 constructorParamInfo: ParamInfo[];
798}
799/**
800 * A statement node that represents an assignment.
801 */
802export declare type AssignmentStatement = ts.ExpressionStatement & {
803 expression: {
804 left: ts.Identifier;
805 right: ts.Expression;
806 };
807};
808/**
809 * Test whether a statement node is an assignment statement.
810 * @param statement the statement to test.
811 */
812export declare function isAssignmentStatement(statement: ts.Statement): statement is AssignmentStatement;
813/**
814 * Parse the `expression` that is believed to be an IIFE and return the AST node that corresponds to
815 * the body of the IIFE.
816 *
817 * The expression may be wrapped in parentheses, which are stripped off.
818 *
819 * If the IIFE is an arrow function then its body could be a `ts.Expression` rather than a
820 * `ts.FunctionBody`.
821 *
822 * @param expression the expression to parse.
823 * @returns the `ts.Expression` or `ts.FunctionBody` that holds the body of the IIFE or `undefined`
824 * if the `expression` did not have the correct shape.
825 */
826export declare function getIifeBody(expression: ts.Expression): ts.ConciseBody | undefined;
827/**
828 * Returns true if the `node` is an assignment of the form `a = b`.
829 *
830 * @param node The AST node to check.
831 */
832export declare function isAssignment(node: ts.Node): node is ts.AssignmentExpression<ts.EqualsToken>;
833/**
834 * Tests whether the provided call expression targets a class, by verifying its arguments are
835 * according to the following form:
836 *
837 * ```
838 * __decorate([], SomeDirective);
839 * ```
840 *
841 * @param call the call expression that is tested to represent a class decorator call.
842 * @param matches predicate function to test whether the call is associated with the desired class.
843 */
844export declare function isClassDecorateCall(call: ts.CallExpression, matches: (identifier: ts.Identifier) => boolean): call is ts.CallExpression & {
845 arguments: [ts.ArrayLiteralExpression, ts.Expression];
846};
847/**
848 * Tests whether the provided call expression targets a member of the class, by verifying its
849 * arguments are according to the following form:
850 *
851 * ```
852 * __decorate([], SomeDirective.prototype, "member", void 0);
853 * ```
854 *
855 * @param call the call expression that is tested to represent a member decorator call.
856 * @param matches predicate function to test whether the call is associated with the desired class.
857 */
858export declare function isMemberDecorateCall(call: ts.CallExpression, matches: (identifier: ts.Identifier) => boolean): call is ts.CallExpression & {
859 arguments: [ts.ArrayLiteralExpression, ts.StringLiteral, ts.StringLiteral];
860};
861/**
862 * Helper method to extract the value of a property given the property's "symbol",
863 * which is actually the symbol of the identifier of the property.
864 */
865export declare function getPropertyValueFromSymbol(propSymbol: ts.Symbol): ts.Expression | undefined;
866declare type InitializedVariableClassDeclaration = ClassDeclaration<ts.VariableDeclaration> & {
867 initializer: ts.Expression;
868};
869/**
870 * Handle a variable declaration of the form
871 *
872 * ```
873 * var MyClass = alias1 = alias2 = <<declaration>>
874 * ```
875 *
876 * @param node the LHS of a variable declaration.
877 * @returns the original AST node or the RHS of a series of assignments in a variable
878 * declaration.
879 */
880export declare function skipClassAliases(node: InitializedVariableClassDeclaration): ts.Expression;
881/**
882 * This expression could either be a class expression
883 *
884 * ```
885 * class MyClass {};
886 * ```
887 *
888 * or an IIFE wrapped class expression
889 *
890 * ```
891 * (() => {
892 * class MyClass {}
893 * ...
894 * return MyClass;
895 * })()
896 * ```
897 *
898 * or an IIFE wrapped aliased class expression
899 *
900 * ```
901 * (() => {
902 * let MyClass = class MyClass {}
903 * ...
904 * return MyClass;
905 * })()
906 * ```
907 *
908 * or an IFFE wrapped ES5 class function
909 *
910 * ```
911 * (function () {
912 * function MyClass() {}
913 * ...
914 * return MyClass
915 * })()
916 * ```
917 *
918 * @param expression the node that represents the class whose declaration we are finding.
919 * @returns the declaration of the class or `null` if it is not a "class".
920 */
921export declare function getInnerClassDeclaration(expression: ts.Expression): ClassDeclaration<ts.ClassExpression | ts.ClassDeclaration | ts.FunctionDeclaration> | null;
922/**
923 * Find the statement that contains the given node
924 * @param node a node whose containing statement we wish to find
925 */
926export declare function getContainingStatement(node: ts.Node): ts.Statement;
927/**
928 * Get a node that represents the actual (outer) declaration of a class from its implementation.
929 *
930 * Sometimes, the implementation of a class is an expression that is hidden inside an IIFE and
931 * assigned to a variable outside the IIFE, which is what the rest of the program interacts with.
932 * For example,
933 *
934 * ```
935 * OuterNode = Alias = (function() { function InnerNode() {} return InnerNode; })();
936 * ```
937 *
938 * @param node a node that could be the implementation inside an IIFE.
939 * @returns a node that represents the outer declaration, or `null` if it is does not match the IIFE
940 * format shown above.
941 */
942export declare function getOuterNodeFromInnerDeclaration(node: ts.Node): ts.Node | null;
943export {};
Note: See TracBrowser for help on using the repository browser.