Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1819397
Fixed an issue with shorter param list not being assignable to rest p…
Andarist May 23, 2022
67892c3
Merge branch 'main' into fix/rest-tuple-union-shorter-contextual-params
Andarist Sep 25, 2022
bd712ab
Merge remote-tracking branch 'origin/main' into fix/rest-tuple-union-…
Andarist Dec 28, 2022
88027d5
Fixed the contextual params assignability with target params declared…
Andarist Dec 28, 2022
6c5383d
Fill the shorter target tuple with undefined when comparing signatures
Andarist Dec 28, 2022
46f2e57
Add an additional test case for mixed length tuples in the target's rest
Andarist Dec 28, 2022
0de8923
Add tests for mixed-length tuples used as rest
Andarist Dec 28, 2022
beb241d
add tests from #45972
Andarist Dec 28, 2022
388ec89
Allow rest in source
Andarist Dec 29, 2022
8753248
Merge remote-tracking branch 'origin/main' into fix/rest-tuple-union-…
Andarist Jan 15, 2023
e357450
Fixed cases involving generics and add comments
Andarist Jan 16, 2023
29979e2
Merge remote-tracking branch 'origin/main' into fix/rest-tuple-union-…
Andarist Jun 13, 2023
fd52884
Merge remote-tracking branch 'origin/main' into fix/rest-tuple-union-…
Andarist Jul 10, 2023
336288a
fix extra cases
Andarist Jul 10, 2023
92d0267
Fixed tupel structure matching in the signature-related codepath
Andarist Jul 10, 2023
1c24035
use conditional undefined instead of any
Andarist Jul 10, 2023
608f7c3
Merge remote-tracking branch 'origin/main' into fix/rest-tuple-union-…
Andarist Jan 6, 2024
61d2612
Merge remote-tracking branch 'origin/main' into fix/rest-tuple-union-…
Andarist Feb 19, 2024
919fc0e
add extra test case
Andarist Feb 19, 2024
b920e9a
Merge branch 'main' into pr-49218
jakebailey Apr 19, 2024
a8ddfc3
Update baselines
jakebailey Apr 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add tests for mixed-length tuples used as rest
  • Loading branch information
Andarist committed Dec 28, 2022
commit 0de8923abaa3424e113cc58f33c5b9480a2d9f1e
Original file line number Diff line number Diff line change
Expand Up @@ -394,4 +394,12 @@ tests/cases/conformance/controlFlow/dependentDestructuredVariables.ts(334,5): er
}
}
}

// repros from #47190#issuecomment-1339753554
const f70: (...args: [type: "one"] | [type: "two", x: string]) => void = (type, x) => {
if (type !== "one") x.toUpperCase();
}
const f71: (...args: [type: "one", x?: number] | [type: "two", x: string]) => void = (type, x) => {
if (type !== "one") x.toUpperCase();
}

19 changes: 19 additions & 0 deletions tests/baselines/reference/dependentDestructuredVariables.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,14 @@ const fa3: (...args: [true, number] | [false, string]) => void = (guard, value)
}
}
}

// repros from #47190#issuecomment-1339753554
const f70: (...args: [type: "one"] | [type: "two", x: string]) => void = (type, x) => {
if (type !== "one") x.toUpperCase();
}
const f71: (...args: [type: "one", x?: number] | [type: "two", x: string]) => void = (type, x) => {
if (type !== "one") x.toUpperCase();
}


//// [dependentDestructuredVariables.js]
Expand Down Expand Up @@ -687,6 +695,15 @@ const fa3 = (guard, value) => {
}
}
};
// repros from #47190#issuecomment-1339753554
const f70 = (type, x) => {
if (type !== "one")
x.toUpperCase();
};
const f71 = (type, x) => {
if (type !== "one")
x.toUpperCase();
};


//// [dependentDestructuredVariables.d.ts]
Expand Down Expand Up @@ -827,3 +844,5 @@ declare function fa2(x: {
value: string;
}): void;
declare const fa3: (...args: [true, number] | [false, string]) => void;
declare const f70: (...args: [type: "one"] | [type: "two", x: string]) => void;
declare const f71: (...args: [type: "one", x?: number] | [type: "two", x: string]) => void;
26 changes: 26 additions & 0 deletions tests/baselines/reference/dependentDestructuredVariables.symbols
Original file line number Diff line number Diff line change
Expand Up @@ -965,3 +965,29 @@ const fa3: (...args: [true, number] | [false, string]) => void = (guard, value)
}
}

// repros from #47190#issuecomment-1339753554
const f70: (...args: [type: "one"] | [type: "two", x: string]) => void = (type, x) => {
>f70 : Symbol(f70, Decl(dependentDestructuredVariables.ts, 389, 5))
>args : Symbol(args, Decl(dependentDestructuredVariables.ts, 389, 12))
>type : Symbol(type, Decl(dependentDestructuredVariables.ts, 389, 74))
>x : Symbol(x, Decl(dependentDestructuredVariables.ts, 389, 79))

if (type !== "one") x.toUpperCase();
>type : Symbol(type, Decl(dependentDestructuredVariables.ts, 389, 74))
>x.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(dependentDestructuredVariables.ts, 389, 79))
>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --))
}
const f71: (...args: [type: "one", x?: number] | [type: "two", x: string]) => void = (type, x) => {
>f71 : Symbol(f71, Decl(dependentDestructuredVariables.ts, 392, 5))
>args : Symbol(args, Decl(dependentDestructuredVariables.ts, 392, 12))
>type : Symbol(type, Decl(dependentDestructuredVariables.ts, 392, 86))
>x : Symbol(x, Decl(dependentDestructuredVariables.ts, 392, 91))

if (type !== "one") x.toUpperCase();
>type : Symbol(type, Decl(dependentDestructuredVariables.ts, 392, 86))
>x.toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --))
>x : Symbol(x, Decl(dependentDestructuredVariables.ts, 392, 91))
>toUpperCase : Symbol(String.toUpperCase, Decl(lib.es5.d.ts, --, --))
}

34 changes: 34 additions & 0 deletions tests/baselines/reference/dependentDestructuredVariables.types
Original file line number Diff line number Diff line change
Expand Up @@ -1115,3 +1115,37 @@ const fa3: (...args: [true, number] | [false, string]) => void = (guard, value)
}
}

// repros from #47190#issuecomment-1339753554
const f70: (...args: [type: "one"] | [type: "two", x: string]) => void = (type, x) => {
>f70 : (...args: [type: "one"] | [type: "two", x: string]) => void
>args : [type: "one"] | [type: "two", x: string]
>(type, x) => { if (type !== "one") x.toUpperCase();} : (type: "one" | "two", x: string | undefined) => void
>type : "one" | "two"
>x : string | undefined

if (type !== "one") x.toUpperCase();
>type !== "one" : boolean
>type : "one" | "two"
>"one" : "one"
>x.toUpperCase() : string
>x.toUpperCase : () => string
>x : string
>toUpperCase : () => string
}
const f71: (...args: [type: "one", x?: number] | [type: "two", x: string]) => void = (type, x) => {
>f71 : (...args: [type: "one", x?: number] | [type: "two", x: string]) => void
>args : [type: "one", x?: number | undefined] | [type: "two", x: string]
>(type, x) => { if (type !== "one") x.toUpperCase();} : (type: "one" | "two", x: string | number | undefined) => void
>type : "one" | "two"
>x : string | number | undefined

if (type !== "one") x.toUpperCase();
>type !== "one" : boolean
>type : "one" | "two"
>"one" : "one"
>x.toUpperCase() : string
>x.toUpperCase : () => string
>x : string
>toUpperCase : () => string
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,15 @@ const f2: (x: string, ...args: [string] | [number, boolean]) => void = (a, b, c)
>b : Symbol(b, Decl(restTupleUnionWithRestContextualParams.ts, 2, 74))
>c : Symbol(c, Decl(restTupleUnionWithRestContextualParams.ts, 2, 77))

const f3: (...args: [type: "one"] | [type: "two", x: string]) => void = (type, x) => {}
>f3 : Symbol(f3, Decl(restTupleUnionWithRestContextualParams.ts, 4, 5))
>args : Symbol(args, Decl(restTupleUnionWithRestContextualParams.ts, 4, 11))
>type : Symbol(type, Decl(restTupleUnionWithRestContextualParams.ts, 4, 73))
>x : Symbol(x, Decl(restTupleUnionWithRestContextualParams.ts, 4, 78))

const f4: (...args: [type: "one", x?: number] | [type: "two", x: string]) => void = (type, x) => {}
>f4 : Symbol(f4, Decl(restTupleUnionWithRestContextualParams.ts, 6, 5))
>args : Symbol(args, Decl(restTupleUnionWithRestContextualParams.ts, 6, 11))
>type : Symbol(type, Decl(restTupleUnionWithRestContextualParams.ts, 6, 85))
>x : Symbol(x, Decl(restTupleUnionWithRestContextualParams.ts, 6, 90))

Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,17 @@ const f2: (x: string, ...args: [string] | [number, boolean]) => void = (a, b, c)
>b : string | number
>c : boolean | undefined

const f3: (...args: [type: "one"] | [type: "two", x: string]) => void = (type, x) => {}
>f3 : (...args: [type: "one"] | [type: "two", x: string]) => void
>args : [type: "one"] | [type: "two", x: string]
>(type, x) => {} : (type: "one" | "two", x: string | undefined) => void
>type : "one" | "two"
>x : string | undefined

const f4: (...args: [type: "one", x?: number] | [type: "two", x: string]) => void = (type, x) => {}
>f4 : (...args: [type: "one", x?: number] | [type: "two", x: string]) => void
>args : [type: "one", x?: number | undefined] | [type: "two", x: string]
>(type, x) => {} : (type: "one" | "two", x: string | number | undefined) => void
>type : "one" | "two"
>x : string | number | undefined

Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@
const f1: (...args: [number, string, ...boolean[]] | [string, number, ...boolean[]]) => void = (a, b, c) => {};

const f2: (x: string, ...args: [string] | [number, boolean]) => void = (a, b, c) => {};

const f3: (...args: [type: "one"] | [type: "two", x: string]) => void = (type, x) => {}

const f4: (...args: [type: "one", x?: number] | [type: "two", x: string]) => void = (type, x) => {}
Original file line number Diff line number Diff line change
Expand Up @@ -390,3 +390,11 @@ const fa3: (...args: [true, number] | [false, string]) => void = (guard, value)
}
}
}

// repros from #47190#issuecomment-1339753554
const f70: (...args: [type: "one"] | [type: "two", x: string]) => void = (type, x) => {
if (type !== "one") x.toUpperCase();
}
const f71: (...args: [type: "one", x?: number] | [type: "two", x: string]) => void = (type, x) => {
if (type !== "one") x.toUpperCase();
}