fix(ivy): ngcc - properly handle aliases class expressions (#29119)

In ES2015, classes could have been emitted as a variable declaration
initialized with a class expression. In certain situations, an intermediary
variable suffixed with `_1` is present such that the variable
declaration's initializer becomes a binary expression with its rhs being
the class expression, and its lhs being the identifier of the intermediate
variable. This structure was not recognized, resulting in such classes not
being considered as a class in `Esm2015ReflectionHost`.

As a consequence, the analysis of functions/methods that return a
`ModuleWithProviders` object did not take the methods of such classes into
account.

Another edge-case with such intermediate variable was that static
properties would not be considered as class members. A testcase was added
to prevent regressions.

Fixes #29078

PR Close #29119
This commit is contained in:
JoostK
2019-03-05 23:29:28 +01:00
committed by Jason Aden
parent 5a1d21ebb4
commit 98f8b0f328
12 changed files with 431 additions and 74 deletions

View File

@ -317,11 +317,11 @@ export interface Import {
* The declaration of a symbol, along with information about how it was imported into the
* application.
*/
export interface Declaration {
export interface Declaration<T extends ts.Declaration = ts.Declaration> {
/**
* TypeScript reference to the declaration itself.
*/
node: ts.Declaration;
node: T;
/**
* The absolute module path from which the symbol was imported into the application, if the symbol

View File

@ -25,7 +25,7 @@ export function isFromDtsFile(node: ts.Node): boolean {
if (sf === undefined) {
sf = ts.getOriginalNode(node).getSourceFile();
}
return sf !== undefined && D_TS.test(sf.fileName);
return sf !== undefined && sf.isDeclarationFile;
}
export function nodeNameForError(node: ts.Node & {name?: ts.Node}): string {