fix(ngcc): handle imports in dts files when processing CommonJS (#35191)
When statically evaluating CommonJS code it is possible to find that we are looking for the declaration of an identifier that actually came from a typings file (rather than a CommonJS file). Previously, the CommonJS reflection host would always try to use a CommonJS specific algorithm for finding identifier declarations, but when the id is actually in a typings file this resulted in the returned declaration being the containing file of the declaration rather than the declaration itself. Now the CommonJS reflection host will check to see if the file containing the identifier is a typings file and use the appropriate stategy. (Note: This is the equivalent of #34356 but for CommonJS.) PR Close #35191
This commit is contained in:

committed by
Miško Hevery

parent
d7d359e3ee
commit
b6e8847967
@ -47,7 +47,8 @@ export class CommonJsReflectionHost extends Esm5ReflectionHost {
|
||||
}
|
||||
|
||||
getDeclarationOfIdentifier(id: ts.Identifier): Declaration|null {
|
||||
return this.getCommonJsImportedDeclaration(id) || super.getDeclarationOfIdentifier(id);
|
||||
return (!id.getSourceFile().isDeclarationFile && this.getCommonJsImportedDeclaration(id)) ||
|
||||
super.getDeclarationOfIdentifier(id);
|
||||
}
|
||||
|
||||
getExportsOfModule(module: ts.Node): Map<string, Declaration>|null {
|
||||
|
Reference in New Issue
Block a user