Fix for issue #32528: Prevent meta property from appearing twice (#35844)

* fix meta property from appearing twice

* handle case where ImportMeta has props defined

* rename file

* use exclude instead of exact

* undo comment

* this file should have no change

* change file name back

* add more test cases

* remove comment and text validation

* fix formatting
This commit is contained in:
Sheon Han 2020-01-17 16:56:50 -05:00 committed by Sheetal Nandi
parent 1a10e712e6
commit 96e8fbc657
4 changed files with 72 additions and 5 deletions

View File

@ -1143,7 +1143,7 @@ namespace ts.Completions {
}
}
if (isMetaProperty(node) && (node.keywordToken === SyntaxKind.NewKeyword || node.keywordToken === SyntaxKind.ImportKeyword)) {
if (isMetaProperty(node) && (node.keywordToken === SyntaxKind.NewKeyword || node.keywordToken === SyntaxKind.ImportKeyword) && contextToken === node.getChildAt(1)) {
const completion = (node.keywordToken === SyntaxKind.NewKeyword) ? "target" : "meta";
symbols.push(typeChecker.createSymbol(SymbolFlags.Property, escapeLeadingUnderscores(completion)));
return;

View File

@ -1,5 +1,25 @@
/// <reference path='fourslash.ts' />
////import./**/
// @Filename: a.ts
////import./*1*/
verify.completions({ marker: "", exact: "meta" });
// @Filename: b.ts
////import.meta./*2*/
// @Filename: c.ts
////import./*3*/meta
verify.completions(
{
marker: "1",
exact: "meta"
},
{
marker: "2",
exact: undefined
},
{
marker: "3",
exact: "meta"
}
);

View File

@ -0,0 +1,41 @@
/// <reference path='fourslash.ts' />
// Module: esnext
// @Filename: a.ts
////import./*1*/
// @Filename: b.ts
////declare global {
//// interface ImportMeta {
//// url: string;
//// }
////}
////import.meta./*2*/
// @Filename: c.ts
////import.meta./*3*/url
// @Filename: d.ts
////import./*4*/meta
verify.completions(
{
marker: "1",
exact: "meta"
},
{
marker: "2",
includes: ["url"],
excludes: ["meta"]
},
{
marker: "3",
includes: ["url"],
excludes: ["meta"]
},
{
marker: "4",
exact: "meta"
}
);

View File

@ -2,8 +2,14 @@
////class C {
//// constructor() {
//// if (C === new./**/)
//// if (C === new./*1*/)
//// }
////}
////class D {
//// constructor() {
//// if (D === new.target./*2*/)
//// }
////}
verify.completions({ marker: "", exact: "target" });
verify.completions({ marker: "1", exact: "target" });
verify.completions({ marker: "2", excludes: ["target"] });