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
2020-12-10 10:17:28 -08:00
committed by GitHub
parent d156bb805e
commit 035c7ca905
5 changed files with 33 additions and 7 deletions

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);
}
}
}
}