diff --git a/src/services/completions.ts b/src/services/completions.ts
index 9de0d2cb761..cf5b38a71d1 100644
--- a/src/services/completions.ts
+++ b/src/services/completions.ts
@@ -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;
diff --git a/tests/cases/fourslash/completionImportMeta.ts b/tests/cases/fourslash/completionImportMeta.ts
index 45b6f889a11..255c1aa569a 100644
--- a/tests/cases/fourslash/completionImportMeta.ts
+++ b/tests/cases/fourslash/completionImportMeta.ts
@@ -1,5 +1,25 @@
///
-////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"
+ }
+);
diff --git a/tests/cases/fourslash/completionImportMetaWithGlobalDeclaration.ts b/tests/cases/fourslash/completionImportMetaWithGlobalDeclaration.ts
new file mode 100644
index 00000000000..2be5ea54692
--- /dev/null
+++ b/tests/cases/fourslash/completionImportMetaWithGlobalDeclaration.ts
@@ -0,0 +1,41 @@
+///
+
+// 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"
+ }
+);
diff --git a/tests/cases/fourslash/completionsNewTarget.ts b/tests/cases/fourslash/completionsNewTarget.ts
index 5c25ecbc739..293b2c32ff0 100644
--- a/tests/cases/fourslash/completionsNewTarget.ts
+++ b/tests/cases/fourslash/completionsNewTarget.ts
@@ -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"] });