mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Does not add a duplicate completion when offering an export which was re-declared as a global - fixes #32675
This commit is contained in:
parent
b7c85c7382
commit
c40ddb183e
@ -1000,6 +1000,7 @@ namespace ts.Completions {
|
||||
let completionKind = CompletionKind.None;
|
||||
let isNewIdentifierLocation = false;
|
||||
let keywordFilters = KeywordCompletionFilters.None;
|
||||
// This also gets mutated in nested-functions after the return
|
||||
let symbols: Symbol[] = [];
|
||||
const symbolToOriginInfoMap: SymbolOriginInfoMap = [];
|
||||
const symbolToSortTextMap: SymbolSortTextMap = [];
|
||||
@ -1342,9 +1343,12 @@ namespace ts.Completions {
|
||||
}
|
||||
|
||||
const symbolId = getSymbolId(symbol);
|
||||
symbols.push(symbol);
|
||||
symbolToOriginInfoMap[symbolId] = origin;
|
||||
symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions;
|
||||
const existingSymbol = findLast(symbols, symbol => symbol.id === symbolId);
|
||||
if (!existingSymbol) {
|
||||
symbols.push(symbol);
|
||||
symbolToOriginInfoMap[symbolId] = origin;
|
||||
symbolToSortTextMap[symbolId] = SortText.AutoImportSuggestions;
|
||||
}
|
||||
});
|
||||
}
|
||||
filterGlobalCompletion(symbols);
|
||||
|
||||
33
tests/cases/fourslash/completionsRedeclareModuleAsGlobal.ts
Normal file
33
tests/cases/fourslash/completionsRedeclareModuleAsGlobal.ts
Normal file
@ -0,0 +1,33 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @esModuleInterop: true,
|
||||
// @target: esnext
|
||||
|
||||
// @Filename: /myAssert.d.ts
|
||||
////declare function assert(value:any, message?:string):void;
|
||||
////export = assert;
|
||||
////export as namespace assert;
|
||||
|
||||
// @Filename: /ambient.d.ts
|
||||
////import assert from './myAssert';
|
||||
////
|
||||
////type Assert = typeof assert;
|
||||
////
|
||||
////declare global {
|
||||
//// const assert: Assert;
|
||||
////}
|
||||
|
||||
// @Filename: /index.ts
|
||||
/////// <reference path="./ambient.d.ts" />
|
||||
////asser/**/;
|
||||
|
||||
verify.completions({
|
||||
marker: "",
|
||||
includes: [
|
||||
{
|
||||
name: "assert",
|
||||
sortText: completion.SortText.GlobalsOrKeywords
|
||||
}
|
||||
],
|
||||
preferences: { includeCompletionsForModuleExports: true, includeInsertTextCompletions: true }
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user