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:
Elizabeth Dinella 2018-05-24 14:12:33 -07:00 committed by GitHub
parent 13734e7d68
commit b745ea059e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

View File

@ -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)!);
}

View File

@ -0,0 +1,6 @@
/// <reference path='fourslash.ts' />
////import./**/
goTo.marker("");
verify.completionListContains("meta");

View File

@ -0,0 +1,10 @@
/// <reference path='fourslash.ts' />
////class C {
//// constructor() {
//// if (C === new./**/)
//// }
////}
goTo.marker("");
verify.completionListContains("target");