Elide export assignment when it does not resolve to a value (#41904)

* Only mark aliases that resolve to values referenced

* Update other affected baselines

* Remove redundant check
This commit is contained in:
Andrew Branch authored and GitHub committed 2020-12-10 10:17:28 -08:00
1 parent d156bb805e
commit 035c7ca905
5 files changed
+33 -7

No files matched your search

+8 -5
View File
@@ -22868,11 +22868,14 @@ namespace ts {
function markAliasReferenced(symbol: Symbol, location: Node) {
if (isNonLocalAlias(symbol, /*excludes*/ SymbolFlags.Value) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
if (compilerOptions.preserveConstEnums && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) {
markAliasSymbolAsReferenced(symbol);
}
else {
markConstEnumAliasAsReferenced(symbol);
const target = resolveAlias(symbol);
if (target.flags & SymbolFlags.Value) {
if (compilerOptions.preserveConstEnums && isExportOrExportExpression(location) || !isConstEnumOrConstEnumOnlyModule(target)) {
markAliasSymbolAsReferenced(symbol);
}
else {
markConstEnumAliasAsReferenced(symbol);
}
}
}
}