Skip to content

Commit 318930b

Browse files
authored
fix(45221): suggest unknown symbols in type positions (#45323)
1 parent f1ce0f5 commit 318930b

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/services/completions.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3309,10 +3309,9 @@ namespace ts.Completions {
33093309
/** True if symbol is a type or a module containing at least one type. */
33103310
function symbolCanBeReferencedAtTypeLocation(symbol: Symbol, checker: TypeChecker, seenModules = new Map<SymbolId, true>()): boolean {
33113311
const sym = skipAlias(symbol.exportSymbol || symbol, checker);
3312-
return !!(sym.flags & SymbolFlags.Type) ||
3313-
!!(sym.flags & SymbolFlags.Module) &&
3314-
addToSeen(seenModules, getSymbolId(sym)) &&
3315-
checker.getExportsOfModule(sym).some(e => symbolCanBeReferencedAtTypeLocation(e, checker, seenModules));
3312+
return !!(sym.flags & SymbolFlags.Type) || checker.isUnknownSymbol(sym) ||
3313+
!!(sym.flags & SymbolFlags.Module) && addToSeen(seenModules, getSymbolId(sym)) &&
3314+
checker.getExportsOfModule(sym).some(e => symbolCanBeReferencedAtTypeLocation(e, checker, seenModules));
33163315
}
33173316

33183317
function isDeprecated(symbol: Symbol, checker: TypeChecker) {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
////import { NonExistentType } from "non-existent-module";
4+
////let foo: /**/
5+
6+
verify.completions({
7+
marker: "",
8+
includes: ["NonExistentType"]
9+
});

tests/cases/fourslash/nonExistingImport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
//// var n: num/*1*/
66
////}
77

8-
verify.completions({ marker: "1", exact: completion.globalTypes });
8+
verify.completions({ marker: "1", exact: ["foo", ...completion.globalTypes] });

0 commit comments

Comments
 (0)