Remove escaped names of well known symbols from string completions
This commit is contained in:
parent
ceba50750b
commit
a31ce789f4
|
@ -385,6 +385,12 @@ namespace ts {
|
|||
return (identifier.length >= 2 && identifier.charCodeAt(0) === CharacterCodes._ && identifier.charCodeAt(1) === CharacterCodes._ ? "_" + identifier : identifier) as __String;
|
||||
}
|
||||
|
||||
export function isEscapedNameOfWellKnownSymbol(escapedName: __String) {
|
||||
return (escapedName as string).charCodeAt(0) === CharacterCodes._ &&
|
||||
(escapedName as string).charCodeAt(1) === CharacterCodes._ &&
|
||||
(escapedName as string).charCodeAt(2) === CharacterCodes.at;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use `id.escapedText` to get the escaped text of an Identifier.
|
||||
* @param identifier The identifier to escape
|
||||
|
|
|
@ -167,15 +167,17 @@ namespace ts.Completions {
|
|||
const uniqueNames = createMap<true>();
|
||||
if (symbols) {
|
||||
for (const symbol of symbols) {
|
||||
const entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target, allowStringLiteral);
|
||||
if (entry) {
|
||||
const id = entry.name;
|
||||
if (!uniqueNames.has(id)) {
|
||||
if (symbolToOriginInfoMap && symbolToOriginInfoMap[getUniqueSymbolId(symbol, typeChecker)]) {
|
||||
entry.hasAction = true;
|
||||
if (!isEscapedNameOfWellKnownSymbol(symbol.escapedName)) {
|
||||
const entry = createCompletionEntry(symbol, location, performCharacterChecks, typeChecker, target, allowStringLiteral);
|
||||
if (entry) {
|
||||
const id = entry.name;
|
||||
if (!uniqueNames.has(id)) {
|
||||
if (symbolToOriginInfoMap && symbolToOriginInfoMap[getUniqueSymbolId(symbol, typeChecker)]) {
|
||||
entry.hasAction = true;
|
||||
}
|
||||
entries.push(entry);
|
||||
uniqueNames.set(id, true);
|
||||
}
|
||||
entries.push(entry);
|
||||
uniqueNames.set(id, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
14
tests/cases/fourslash/completionForStringLiteral13.ts
Normal file
14
tests/cases/fourslash/completionForStringLiteral13.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
/// <reference path='fourslash.ts'/>
|
||||
|
||||
////interface SymbolConstructor {
|
||||
//// readonly species: symbol;
|
||||
////}
|
||||
////var Symbol: SymbolConstructor;
|
||||
////interface PromiseConstructor {
|
||||
//// [Symbol.species]: PromiseConstructor;
|
||||
////}
|
||||
////var Promise: PromiseConstructor;
|
||||
////Promise["/*1*/"];
|
||||
|
||||
goTo.marker('1');
|
||||
verify.not.completionListContains("__@species");
|
Loading…
Reference in a new issue