Skip to content

Commit 5b38cb9

Browse files
committed
harden 'get import declaration' logic
1 parent c24f75f commit 5b38cb9

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/compiler/checker.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4742,7 +4742,9 @@ module ts {
47424742
nodeLinks.importOnRightSide = undefined;
47434743

47444744
getSymbolLinks(rightSide).referenced = true;
4745-
nodeLinks = getNodeLinks(rightSide.declarations[0])
4745+
Debug.assert((rightSide.flags & SymbolFlags.Import) !== 0);
4746+
4747+
nodeLinks = getNodeLinks(getDeclarationOfKind(rightSide, SyntaxKind.ImportDeclaration))
47464748
}
47474749
}
47484750

@@ -4773,7 +4775,7 @@ module ts {
47734775
}
47744776

47754777
if (symbolLinks.referenced) {
4776-
markLinkedImportsAsReferenced(<ImportDeclaration>symbol.declarations[0]);
4778+
markLinkedImportsAsReferenced(<ImportDeclaration>getDeclarationOfKind(symbol, SyntaxKind.ImportDeclaration));
47774779
}
47784780
}
47794781

@@ -8906,7 +8908,7 @@ module ts {
89068908
// Mark the import as referenced so that we emit it in the final .js file.
89078909
getSymbolLinks(symbol).referenced = true;
89088910
// mark any import declarations that depend upon this import as referenced
8909-
markLinkedImportsAsReferenced(<ImportDeclaration>symbol.declarations[0])
8911+
markLinkedImportsAsReferenced(<ImportDeclaration>getDeclarationOfKind(symbol, SyntaxKind.ImportDeclaration))
89108912
}
89118913
}
89128914

0 commit comments

Comments
 (0)