Don't include completions for current and later parameters (#52690)

This commit is contained in:
Vitaly
2023-04-14 17:05:55 -07:00
committed by GitHub
parent 0c5be02dcc
commit c70fa514b0
16 changed files with 96 additions and 34 deletions
@@ -7,6 +7,5 @@
verify.completions({
marker: "1",
// Note: `c: typeof c` would be a compile error
includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"],
includes: ["foo", "x", "y", "z", "bar", "a", "b"],
});
@@ -9,5 +9,5 @@
verify.completions({
marker: "1",
// Note: `c = c` would be a compile error
includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"],
includes: ["foo", "x", "y", "z", "bar", "a", "b"],
});
@@ -9,5 +9,5 @@
verify.completions({
marker: "1",
// Note: `b = b` or `b = c` would be a compile error
includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"],
includes: ["foo", "x", "y", "z", "bar", "a"],
});
@@ -8,7 +8,6 @@
verify.completions({
marker: "1",
// Note: `v = v` would be a compile error
includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v"],
includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"],
isNewIdentifierLocation: true,
});
@@ -7,4 +7,4 @@
////var C4 = class D<T extends /*4*/>{}
verify.completions({ marker: ["0", "1", "2", "3"], exact: undefined });
verify.completions({ marker: "4", exact: completion.globalTypesPlus(["D", "T"]) });
verify.completions({ marker: "4", exact: completion.globalTypesPlus(["D"]) });
@@ -3,5 +3,4 @@
////function foo(x: string, y: number, z: boolean) {
//// function bar(a: number, b: string, c: typeof /*1*/
// Note: Ideally `c` wouldn't be included since it hasn't been initialized yet.
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"]})
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b"]})
@@ -4,5 +4,4 @@
//// function bar(a: number, b: string, c: typeof /*1*/
////}
// Note: Ideally `c` wouldn't be included since it hasn't been initialized yet.
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"]})
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b"]})
@@ -3,5 +3,4 @@
////function foo(x: string, y: number, z: boolean) {
//// function bar(a: number, b: string, c: typeof x = /*1*/
// Note: Ideally `c` wouldn't be included since it hasn't been initialized yet.
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"]})
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b"]})
@@ -4,5 +4,4 @@
//// function bar(a: number, b: string, c: typeof x = /*1*/
////}
// Note: Ideally `c` wouldn't be included since it hasn't been initialized yet.
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"]})
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b"]})
@@ -4,5 +4,4 @@
//// function bar(a: number, b: string = /*1*/, c: typeof x = "hello"
////
// Note: Ideally `c` wouldn't be included since it hasn't been initialized yet.
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"]})
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a"]})
@@ -4,5 +4,4 @@
//// function bar(a: number, b: string = /*1*/, c: typeof x = "hello"
////}
// Note: Ideally `c` wouldn't be included since it hasn't been initialized yet.
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"]})
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a"]})
@@ -4,5 +4,4 @@
//// function bar(a: number, b: string = "hello", c: typeof x = "hello") {
//// var v = /*1*/
// Note: "v" questionable since we're in its initializer
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v"], isNewIdentifierLocation: true });
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"], isNewIdentifierLocation: true });
@@ -5,5 +5,4 @@
//// var v = /*1*/
////}
// Note: "v" questionable since we're in its initializer
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c", "v"], isNewIdentifierLocation: true });
verify.completions({ marker: "1", includes: ["foo", "x", "y", "z", "bar", "a", "b", "c"], isNewIdentifierLocation: true });
@@ -46,8 +46,7 @@ verify.completions({
verify.completions({
marker: ["7"],
includes: ["a", "b", "c", "d", "e"],
excludes: ["fn"],
includes: ["a", "b", "c", "d", "e", "fn"],
});
verify.completions({
@@ -59,4 +58,3 @@ verify.completions({
marker: ["9"],
includes: ["a", "b", "c", "d", "e", "fn"],
});
@@ -0,0 +1,47 @@
/// <reference path='fourslash.ts' />
//// function f1(a = /*1*/, b) { }
//// function f2(a = a/*2*/, b) { }
//// function f3(a = a + /*3*/, b = a/*4*/, c = /*5*/) { }
//// function f3(a) {
//// function f4(b = /*6*/, c) { }
//// }
//// const f5 = (a, b = (c = /*7*/, e) => { }, d = b) => { }
////
//// type A1<K = /*T1*/, L> = K
//// type A2<K extends /*T2*/, L> = K
verify.completions({
marker: ["1", "2"],
excludes: ["a", "b"],
})
verify.completions({
marker: ["3"],
excludes: ["a", "b"],
})
verify.completions({
marker: ["4"],
includes: ["a"],
})
verify.completions({
marker: ["5"],
includes: ["a", "b"],
})
verify.completions({
marker: ["6"],
excludes: ["b", "c"],
includes: ["a"],
})
verify.completions({
marker: ["7"],
includes: ["a", "b", "d"],
})
verify.completions({
marker: ["T1", "T2"],
excludes: ["K", "L"],
})