fix(ivy): use ReflectionHost to check exports when writing an import (#33192)
This commit fixes ngtsc's import generator to use the ReflectionHost when looking through the exports of an ES module to find the export of a particular declaration that's being imported. This is necessary because some module formats like CommonJS have unusual export mechanics, and the normal TypeScript ts.TypeChecker does not understand them. This fixes an issue with ngcc + CommonJS where exports were not being enumerated correctly. FW-1630 #resolve PR Close #33192
This commit is contained in:

committed by
Matias Niemelä

parent
50710838bf
commit
de445709d4
@ -280,6 +280,13 @@ export class TypeScriptReflectionHost implements ReflectionHost {
|
||||
return null;
|
||||
}
|
||||
return this.getDeclarationOfSymbol(shorthandSymbol, originalId);
|
||||
} else if (
|
||||
symbol.valueDeclaration !== undefined && ts.isExportSpecifier(symbol.valueDeclaration)) {
|
||||
const localTarget = this.checker.getExportSpecifierLocalTargetSymbol(symbol.valueDeclaration);
|
||||
if (localTarget === undefined) {
|
||||
return null;
|
||||
}
|
||||
return this.getDeclarationOfSymbol(localTarget, originalId);
|
||||
}
|
||||
|
||||
const importInfo = originalId && this.getImportOfIdentifier(originalId);
|
||||
|
Reference in New Issue
Block a user