Fix getTypeFromJSDocValueReference

When using `{import('./b').FOO}` which is defined as a string literal,
`valueType` doesn't have a `symbol`.  Leave it for the fallback value
for now.

This was exposed in 8223c0752.

Fixes #34869.
This commit is contained in:
Eli Barzilay
2019-11-25 18:12:45 -05:00
parent d6bd3ac552
commit d6740cf410
4 changed files with 30 additions and 1 deletions

View File

@@ -10840,7 +10840,8 @@ namespace ts {
isRequireAlias = isCallExpression(expr) && isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol;
}
const isImportTypeWithQualifier = node.kind === SyntaxKind.ImportType && (node as ImportTypeNode).qualifier;
if (isRequireAlias || isImportTypeWithQualifier) {
// valueType might not have a symbol, eg, {import('./b').STRING_LITERAL}
if (valueType.symbol && (isRequireAlias || isImportTypeWithQualifier)) {
typeType = getTypeReferenceType(node, valueType.symbol);
}
}