Skip to content

Commit da413d6

Browse files
author
Andy
authored
Remove unnecessary filtering of tsx completions (microsoft#24004)
1 parent 11e3e24 commit da413d6

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

src/harness/fourslash.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ namespace FourSlash {
899899
}
900900
else {
901901
const found = actualByName.get(exclude.name);
902-
if (found.source === exclude.source) {
902+
if (found && found.source === exclude.source) {
903903
this.raiseError(`Did not expect to get a completion named ${exclude.name} with source ${exclude.source}`);
904904
}
905905
}

src/services/completions.ts

+3-7
Original file line numberDiff line numberDiff line change
@@ -972,12 +972,8 @@ namespace ts.Completions {
972972
}
973973
else if (isRightOfOpenTag) {
974974
const tagSymbols = Debug.assertEachDefined(typeChecker.getJsxIntrinsicTagNamesAt(location), "getJsxIntrinsicTagNames() should all be defined");
975-
if (tryGetGlobalSymbols()) {
976-
symbols = tagSymbols.concat(symbols.filter(s => !!(s.flags & (SymbolFlags.Value | SymbolFlags.Alias))));
977-
}
978-
else {
979-
symbols = tagSymbols;
980-
}
975+
tryGetGlobalSymbols();
976+
symbols = tagSymbols.concat(symbols);
981977
completionKind = CompletionKind.MemberLike;
982978
}
983979
else if (isStartingCloseTag) {
@@ -1298,7 +1294,7 @@ namespace ts.Completions {
12981294
const exportedSymbols = typeChecker.getExportsOfModule(symbol);
12991295
// If the exported symbols contains type,
13001296
// symbol can be referenced at locations where type is allowed
1301-
return forEach(exportedSymbols, symbolCanBeReferencedAtTypeLocation);
1297+
return exportedSymbols.some(symbolCanBeReferencedAtTypeLocation);
13021298
}
13031299
}
13041300

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @noLib: true
4+
// @nolib: true
5+
// @jsx: preserve
6+
7+
// @Filename: /a.tsx
8+
////export type Bar = 0;
9+
////export default function Foo() {};
10+
11+
// @Filename: /b.tsx
12+
////<Fo/**/ />;
13+
14+
verify.completions({
15+
marker: "",
16+
includes: { name: "Foo", source: "/a.tsx", hasAction: true },
17+
excludes: "Bar",
18+
preferences: {
19+
includeCompletionsForModuleExports: true,
20+
},
21+
});

0 commit comments

Comments
 (0)