mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Fix to issue 23326 for completions on new.target (#24342)
* Fix to issue 23326 for completions on new.target * Fixed linting issues - whitespace in if statements * Removed debug statement in test case and consolidated and cleaned up code in switch statement for completions * Added support for import.meta completion
This commit is contained in:
parent
13734e7d68
commit
b745ea059e
@ -895,6 +895,7 @@ namespace ts.Completions {
|
||||
node = (parent as QualifiedName).left;
|
||||
break;
|
||||
case SyntaxKind.ImportType:
|
||||
case SyntaxKind.MetaProperty:
|
||||
node = parent;
|
||||
break;
|
||||
default:
|
||||
@ -1061,6 +1062,12 @@ namespace ts.Completions {
|
||||
}
|
||||
}
|
||||
|
||||
if (isMetaProperty(node) && (node.keywordToken === SyntaxKind.NewKeyword || node.keywordToken === SyntaxKind.ImportKeyword)) {
|
||||
const completion = (node.keywordToken === SyntaxKind.NewKeyword) ? "target" : "meta";
|
||||
symbols.push(typeChecker.createSymbol(SymbolFlags.Property, escapeLeadingUnderscores(completion)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isTypeLocation) {
|
||||
addTypeProperties(typeChecker.getTypeAtLocation(node)!);
|
||||
}
|
||||
|
||||
6
tests/cases/fourslash/completionImportMeta.ts
Normal file
6
tests/cases/fourslash/completionImportMeta.ts
Normal file
@ -0,0 +1,6 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////import./**/
|
||||
|
||||
goTo.marker("");
|
||||
verify.completionListContains("meta");
|
||||
10
tests/cases/fourslash/completionsNewTarget.ts
Normal file
10
tests/cases/fourslash/completionsNewTarget.ts
Normal file
@ -0,0 +1,10 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////class C {
|
||||
//// constructor() {
|
||||
//// if (C === new./**/)
|
||||
//// }
|
||||
////}
|
||||
|
||||
goTo.marker("");
|
||||
verify.completionListContains("target");
|
||||
Loading…
x
Reference in New Issue
Block a user