Skip to content

Commit 15a3683

Browse files
committed
add test case for array destructuring
1 parent f9c30bc commit 15a3683

File tree

5 files changed

+62
-26
lines changed

5 files changed

+62
-26
lines changed

tests/baselines/reference/unusedParameterInFunctionType1.errors.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
tests/cases/compiler/unusedParameterInFunctionType1.ts(2,12): error TS6133: 'string' is declared but its value is never read.
22
tests/cases/compiler/unusedParameterInFunctionType1.ts(4,17): error TS6133: 'string' is declared but its value is never read.
3-
tests/cases/compiler/unusedParameterInFunctionType1.ts(7,16): error TS6133: 'string' is declared but its value is never read.
4-
tests/cases/compiler/unusedParameterInFunctionType1.ts(9,21): error TS6133: 'string' is declared but its value is never read.
5-
tests/cases/compiler/unusedParameterInFunctionType1.ts(13,11): error TS6133: 'string' is declared but its value is never read.
6-
tests/cases/compiler/unusedParameterInFunctionType1.ts(16,4): error TS6133: 'string' is declared but its value is never read.
7-
tests/cases/compiler/unusedParameterInFunctionType1.ts(19,8): error TS6133: 'string' is declared but its value is never read.
3+
tests/cases/compiler/unusedParameterInFunctionType1.ts(5,12): error TS6198: All destructured elements are unused.
4+
tests/cases/compiler/unusedParameterInFunctionType1.ts(8,16): error TS6133: 'string' is declared but its value is never read.
5+
tests/cases/compiler/unusedParameterInFunctionType1.ts(10,21): error TS6133: 'string' is declared but its value is never read.
6+
tests/cases/compiler/unusedParameterInFunctionType1.ts(11,16): error TS6198: All destructured elements are unused.
7+
tests/cases/compiler/unusedParameterInFunctionType1.ts(15,11): error TS6133: 'string' is declared but its value is never read.
8+
tests/cases/compiler/unusedParameterInFunctionType1.ts(18,4): error TS6133: 'string' is declared but its value is never read.
9+
tests/cases/compiler/unusedParameterInFunctionType1.ts(21,8): error TS6133: 'string' is declared but its value is never read.
810

911

10-
==== tests/cases/compiler/unusedParameterInFunctionType1.ts (7 errors) ====
12+
==== tests/cases/compiler/unusedParameterInFunctionType1.ts (9 errors) ====
1113
type F1 = (arg: number) => any;
1214
type F2 = ({ a: string }) => any;
1315
~~~~~~~~~~~~~
@@ -16,6 +18,9 @@ tests/cases/compiler/unusedParameterInFunctionType1.ts(19,8): error TS6133: 'str
1618
type F4 = ({ a: string, b: number }) => typeof number;
1719
~~~~~~
1820
!!! error TS6133: 'string' is declared but its value is never read.
21+
type F5 = ([a, b, c]) => void;
22+
~~~~~~~~~
23+
!!! error TS6198: All destructured elements are unused.
1924

2025
type G1 = new (arg: number) => any;
2126
type G2 = new ({ a: string }) => any;
@@ -25,6 +30,9 @@ tests/cases/compiler/unusedParameterInFunctionType1.ts(19,8): error TS6133: 'str
2530
type G4 = new ({ a: string, b: number }) => typeof number;
2631
~~~~~~
2732
!!! error TS6133: 'string' is declared but its value is never read.
33+
type G5 = new ([a, b, c]) => void;
34+
~~~~~~~~~
35+
!!! error TS6198: All destructured elements are unused.
2836

2937
interface I {
3038
method1(arg: number): any;

tests/baselines/reference/unusedParameterInFunctionType1.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ type F1 = (arg: number) => any;
33
type F2 = ({ a: string }) => any;
44
type F3 = ({ a: string }) => typeof string;
55
type F4 = ({ a: string, b: number }) => typeof number;
6+
type F5 = ([a, b, c]) => void;
67

78
type G1 = new (arg: number) => any;
89
type G2 = new ({ a: string }) => any;
910
type G3 = new ({ a: string }) => typeof string;
1011
type G4 = new ({ a: string, b: number }) => typeof number;
12+
type G5 = new ([a, b, c]) => void;
1113

1214
interface I {
1315
method1(arg: number): any;

tests/baselines/reference/unusedParameterInFunctionType1.symbols

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,52 +22,64 @@ type F4 = ({ a: string, b: number }) => typeof number;
2222
>number : Symbol(number, Decl(unusedParameterInFunctionType1.ts, 3, 23))
2323
>number : Symbol(number, Decl(unusedParameterInFunctionType1.ts, 3, 23))
2424

25+
type F5 = ([a, b, c]) => void;
26+
>F5 : Symbol(F5, Decl(unusedParameterInFunctionType1.ts, 3, 54))
27+
>a : Symbol(a, Decl(unusedParameterInFunctionType1.ts, 4, 12))
28+
>b : Symbol(b, Decl(unusedParameterInFunctionType1.ts, 4, 14))
29+
>c : Symbol(c, Decl(unusedParameterInFunctionType1.ts, 4, 17))
30+
2531
type G1 = new (arg: number) => any;
26-
>G1 : Symbol(G1, Decl(unusedParameterInFunctionType1.ts, 3, 54))
27-
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 5, 15))
32+
>G1 : Symbol(G1, Decl(unusedParameterInFunctionType1.ts, 4, 30))
33+
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 6, 15))
2834

2935
type G2 = new ({ a: string }) => any;
30-
>G2 : Symbol(G2, Decl(unusedParameterInFunctionType1.ts, 5, 35))
36+
>G2 : Symbol(G2, Decl(unusedParameterInFunctionType1.ts, 6, 35))
3137
>a : Symbol(a)
32-
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 6, 16))
38+
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 7, 16))
3339

3440
type G3 = new ({ a: string }) => typeof string;
35-
>G3 : Symbol(G3, Decl(unusedParameterInFunctionType1.ts, 6, 37))
41+
>G3 : Symbol(G3, Decl(unusedParameterInFunctionType1.ts, 7, 37))
3642
>a : Symbol(a)
37-
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 7, 16))
38-
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 7, 16))
43+
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 8, 16))
44+
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 8, 16))
3945

4046
type G4 = new ({ a: string, b: number }) => typeof number;
41-
>G4 : Symbol(G4, Decl(unusedParameterInFunctionType1.ts, 7, 47))
47+
>G4 : Symbol(G4, Decl(unusedParameterInFunctionType1.ts, 8, 47))
4248
>a : Symbol(a)
43-
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 8, 16))
49+
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 9, 16))
4450
>b : Symbol(b)
45-
>number : Symbol(number, Decl(unusedParameterInFunctionType1.ts, 8, 27))
46-
>number : Symbol(number, Decl(unusedParameterInFunctionType1.ts, 8, 27))
51+
>number : Symbol(number, Decl(unusedParameterInFunctionType1.ts, 9, 27))
52+
>number : Symbol(number, Decl(unusedParameterInFunctionType1.ts, 9, 27))
53+
54+
type G5 = new ([a, b, c]) => void;
55+
>G5 : Symbol(G5, Decl(unusedParameterInFunctionType1.ts, 9, 58))
56+
>a : Symbol(a, Decl(unusedParameterInFunctionType1.ts, 10, 16))
57+
>b : Symbol(b, Decl(unusedParameterInFunctionType1.ts, 10, 18))
58+
>c : Symbol(c, Decl(unusedParameterInFunctionType1.ts, 10, 21))
4759

4860
interface I {
49-
>I : Symbol(I, Decl(unusedParameterInFunctionType1.ts, 8, 58))
61+
>I : Symbol(I, Decl(unusedParameterInFunctionType1.ts, 10, 34))
5062

5163
method1(arg: number): any;
52-
>method1 : Symbol(I.method1, Decl(unusedParameterInFunctionType1.ts, 10, 13))
53-
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 11, 10))
64+
>method1 : Symbol(I.method1, Decl(unusedParameterInFunctionType1.ts, 12, 13))
65+
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 13, 10))
5466

5567
method2({ a: string }): any;
56-
>method2 : Symbol(I.method2, Decl(unusedParameterInFunctionType1.ts, 11, 28))
68+
>method2 : Symbol(I.method2, Decl(unusedParameterInFunctionType1.ts, 13, 28))
5769
>a : Symbol(a)
58-
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 12, 11))
70+
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 14, 11))
5971

6072
(arg: number): any;
61-
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 14, 3))
73+
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 16, 3))
6274

6375
({ a: string }): any;
6476
>a : Symbol(a)
65-
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 15, 4))
77+
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 17, 4))
6678

6779
new (arg: number): any;
68-
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 17, 7))
80+
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 19, 7))
6981

7082
new ({ a: string }): any;
7183
>a : Symbol(a)
72-
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 18, 8))
84+
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 20, 8))
7385
}

tests/baselines/reference/unusedParameterInFunctionType1.types

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ type F4 = ({ a: string, b: number }) => typeof number;
2222
>number : any
2323
>number : any
2424

25+
type F5 = ([a, b, c]) => void;
26+
>F5 : F5
27+
>a : any
28+
>b : any
29+
>c : any
30+
2531
type G1 = new (arg: number) => any;
2632
>G1 : G1
2733
>arg : number
@@ -45,6 +51,12 @@ type G4 = new ({ a: string, b: number }) => typeof number;
4551
>number : any
4652
>number : any
4753

54+
type G5 = new ([a, b, c]) => void;
55+
>G5 : G5
56+
>a : any
57+
>b : any
58+
>c : any
59+
4860
interface I {
4961
method1(arg: number): any;
5062
>method1 : (arg: number) => any

tests/cases/compiler/unusedParameterInFunctionType1.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ type F1 = (arg: number) => any;
55
type F2 = ({ a: string }) => any;
66
type F3 = ({ a: string }) => typeof string;
77
type F4 = ({ a: string, b: number }) => typeof number;
8+
type F5 = ([a, b, c]) => void;
89

910
type G1 = new (arg: number) => any;
1011
type G2 = new ({ a: string }) => any;
1112
type G3 = new ({ a: string }) => typeof string;
1213
type G4 = new ({ a: string, b: number }) => typeof number;
14+
type G5 = new ([a, b, c]) => void;
1315

1416
interface I {
1517
method1(arg: number): any;

0 commit comments

Comments
 (0)