fix(ivy): getSourceFile() of transformed nodes returns undefined (#28412)

In some cases, calling getSourceFile() on a node from within a TS
transform can return undefined (against the signature of the method).
In these cases, getting the original node first will work.

PR Close #28412
This commit is contained in:
Alex Rickabaugh 2019-01-28 16:26:17 -08:00 committed by Jason Aden
parent 6e16338302
commit 66335c36e6
1 changed files with 4 additions and 1 deletions

View File

@ -167,7 +167,10 @@ export class NgModuleDecoratorHandler implements DecoratorHandler<NgModuleAnalys
if (analysis.metadataStmt !== null) {
ngModuleStatements.push(analysis.metadataStmt);
}
const context = node.getSourceFile();
let context = node.getSourceFile();
if (context === undefined) {
context = ts.getOriginalNode(node).getSourceFile();
}
for (const decl of analysis.declarations) {
if (this.scopeRegistry.requiresRemoteScope(decl.node)) {
const scope = this.scopeRegistry.lookupCompilationScopeAsRefs(decl.node);