Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,9 +854,9 @@ namespace FourSlash {
}
}

assert.equal(actual.hasAction, hasAction);
assert.equal(actual.isRecommended, isRecommended);
assert.equal(actual.source, source);
assert.equal(actual.hasAction, hasAction, `Expected 'hasAction' value '${actual.hasAction}' to equal '${hasAction}'`);
assert.equal(actual.isRecommended, isRecommended, `Expected 'isRecommended' value '${actual.source}' to equal '${isRecommended}'`);
assert.equal(actual.source, source, `Expected 'source' value '${actual.source}' to equal '${source}'`);
assert.equal(actual.sortText, sortText || ts.Completions.SortText.LocationPriority, this.messageAtLastKnownMarker(`Actual entry: ${JSON.stringify(actual)}`));

if (text !== undefined) {
Expand Down
9 changes: 6 additions & 3 deletions src/services/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ namespace ts.Completions {
// If the symbol/moduleSymbol was a merged symbol, it will have a new identity
// in the checker, even though the symbols to merge are the same (guaranteed by
// cache invalidation in synchronizeHostData).
if (suggestion.symbol.declarations) {
if (suggestion.symbol.declarations?.length) {
suggestion.symbol = checker.getMergedSymbol(suggestion.origin.isDefaultExport
? suggestion.symbol.declarations[0].localSymbol || suggestion.symbol.declarations[0].symbol
? suggestion.symbol.declarations[0].localSymbol ?? suggestion.symbol.declarations[0].symbol
: suggestion.symbol.declarations[0].symbol);
}
if (suggestion.origin.moduleSymbol.declarations) {
if (suggestion.origin.moduleSymbol.declarations?.length) {
suggestion.origin.moduleSymbol = checker.getMergedSymbol(suggestion.origin.moduleSymbol.declarations[0].symbol);
}
});
Expand Down Expand Up @@ -1624,6 +1624,9 @@ namespace ts.Completions {
if (isDefaultExport) {
symbol = getLocalSymbolForExportDefault(symbol) || symbol;
}
if (typeChecker.isUndefinedSymbol(symbol)) {
return;
}
addToSeen(resultSymbolIds, getSymbolId(symbol));
const origin: SymbolOriginInfoExport = { kind: SymbolOriginInfoKind.Export, moduleSymbol, isDefaultExport };
results.push({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/// <reference path="../fourslash.ts" />

// @Filename: /tsconfig.json
////{ "compilerOptions": { "module": "esnext" } }

// @Filename: /undefined.ts
////export = undefined;

// @Filename: /undefinedAlias.ts
////const x = undefined;
////export = x;

// @Filename: /index.ts
//// /**/

// Would throw error if undefined appears twice
goTo.marker("");
verify.completions({
includes: [{
name: "x",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
source: "/undefinedAlias"
}],
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true
}
});

// Do it again for cache test
verify.completions({
includes: [{
name: "x",
hasAction: true,
sortText: completion.SortText.AutoImportSuggestions,
source: "/undefinedAlias"
}],
preferences: {
includeCompletionsForModuleExports: true,
includeInsertTextCompletions: true
}
});