Fix decorator metadata references to type-only-imported namespaces (#44915)

* Add test

* Fix metadata references to type-only-imported namespaces

* Use `!!` instead of `|| false`
This commit is contained in:
Andrew Branch
2021-08-02 14:18:15 -07:00
committed by GitHub
parent 7669bfba15
commit bfd5b2f7f0
5 changed files with 130 additions and 1 deletions

View File

@@ -40480,9 +40480,14 @@ namespace ts {
}
// Resolve the symbol as a value to ensure the type can be reached at runtime during emit.
let isTypeOnly = false;
if (isQualifiedName(typeName)) {
const rootValueSymbol = resolveEntityName(getFirstIdentifier(typeName), SymbolFlags.Value, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location);
isTypeOnly = !!rootValueSymbol?.declarations?.every(isTypeOnlyImportOrExportDeclaration);
}
const valueSymbol = resolveEntityName(typeName, SymbolFlags.Value, /*ignoreErrors*/ true, /*dontResolveAlias*/ true, location);
const isTypeOnly = valueSymbol?.declarations?.every(isTypeOnlyImportOrExportDeclaration) || false;
const resolvedSymbol = valueSymbol && valueSymbol.flags & SymbolFlags.Alias ? resolveAlias(valueSymbol) : valueSymbol;
isTypeOnly ||= !!valueSymbol?.declarations?.every(isTypeOnlyImportOrExportDeclaration);
// Resolve the symbol as a type so that we can provide a more useful hint for the type serializer.
const typeSymbol = resolveEntityName(typeName, SymbolFlags.Type, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location);