diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index cde61bb407..2ad014aaab 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -1733,13 +1733,24 @@ namespace ts { return undefined; } const right = name.kind === SyntaxKind.QualifiedName ? name.right : name.name; - const namespace = resolveEntityName(left, SymbolFlags.Namespace, ignoreErrors, /*dontResolveAlias*/ false, location); + let namespace = resolveEntityName(left, SymbolFlags.Namespace, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); + if (!namespace && name.parent && isJSDocTypeReference(name.parent as TypeReferenceType)) { + // jsdoc type references may be values + namespace = resolveEntityName(left, SymbolFlags.Value, ignoreErrors, /*dontResolveAlias*/ false, location); + } + else if (!ignoreErrors) { + // run again for error reporting purposes + resolveEntityName(left, SymbolFlags.Namespace, /*ignoreErrors*/ false, /*dontResolveAlias*/ false, location); + } if (!namespace || nodeIsMissing(right)) { return undefined; } else if (namespace === unknownSymbol) { return namespace; } + if (isInJavaScriptFile(name) && isDeclarationOfFunctionOrClassExpression(namespace)) { + namespace = getSymbolOfNode((namespace.valueDeclaration as VariableDeclaration).initializer); + } symbol = getSymbol(getExportsOfSymbol(namespace), right.escapedText, meaning); if (!symbol) { if (!ignoreErrors) { diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 4bc519c2b8..a08990e4c4 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1435,7 +1435,7 @@ namespace ts { } /** - * Returns true if the node is a variable declaration whose initializer is a function expression. + * Returns true if the node is a variable declaration whose initializer is a function or class expression. * This function does not test if the node is in a JavaScript file or not. */ export function isDeclarationOfFunctionOrClassExpression(s: Symbol) {