Skip to content

Commit b745ea0

Browse files
Fix to issue 23326 for completions on new.target (microsoft#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
1 parent 13734e7 commit b745ea0

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/services/completions.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,7 @@ namespace ts.Completions {
895895
node = (parent as QualifiedName).left;
896896
break;
897897
case SyntaxKind.ImportType:
898+
case SyntaxKind.MetaProperty:
898899
node = parent;
899900
break;
900901
default:
@@ -1061,6 +1062,12 @@ namespace ts.Completions {
10611062
}
10621063
}
10631064

1065+
if (isMetaProperty(node) && (node.keywordToken === SyntaxKind.NewKeyword || node.keywordToken === SyntaxKind.ImportKeyword)) {
1066+
const completion = (node.keywordToken === SyntaxKind.NewKeyword) ? "target" : "meta";
1067+
symbols.push(typeChecker.createSymbol(SymbolFlags.Property, escapeLeadingUnderscores(completion)));
1068+
return;
1069+
}
1070+
10641071
if (!isTypeLocation) {
10651072
addTypeProperties(typeChecker.getTypeAtLocation(node)!);
10661073
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////import./**/
4+
5+
goTo.marker("");
6+
verify.completionListContains("meta");
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////class C {
4+
//// constructor() {
5+
//// if (C === new./**/)
6+
//// }
7+
////}
8+
9+
goTo.marker("");
10+
verify.completionListContains("target");

0 commit comments

Comments
 (0)