Skip to content

Commit

Permalink
add test case for array destructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
uhyo committed Oct 18, 2021
1 parent f9c30bc commit 15a3683
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 26 deletions.
@@ -1,13 +1,15 @@
tests/cases/compiler/unusedParameterInFunctionType1.ts(2,12): error TS6133: 'string' is declared but its value is never read.
tests/cases/compiler/unusedParameterInFunctionType1.ts(4,17): error TS6133: 'string' is declared but its value is never read.
tests/cases/compiler/unusedParameterInFunctionType1.ts(7,16): error TS6133: 'string' is declared but its value is never read.
tests/cases/compiler/unusedParameterInFunctionType1.ts(9,21): error TS6133: 'string' is declared but its value is never read.
tests/cases/compiler/unusedParameterInFunctionType1.ts(13,11): error TS6133: 'string' is declared but its value is never read.
tests/cases/compiler/unusedParameterInFunctionType1.ts(16,4): error TS6133: 'string' is declared but its value is never read.
tests/cases/compiler/unusedParameterInFunctionType1.ts(19,8): error TS6133: 'string' is declared but its value is never read.
tests/cases/compiler/unusedParameterInFunctionType1.ts(5,12): error TS6198: All destructured elements are unused.
tests/cases/compiler/unusedParameterInFunctionType1.ts(8,16): error TS6133: 'string' is declared but its value is never read.
tests/cases/compiler/unusedParameterInFunctionType1.ts(10,21): error TS6133: 'string' is declared but its value is never read.
tests/cases/compiler/unusedParameterInFunctionType1.ts(11,16): error TS6198: All destructured elements are unused.
tests/cases/compiler/unusedParameterInFunctionType1.ts(15,11): error TS6133: 'string' is declared but its value is never read.
tests/cases/compiler/unusedParameterInFunctionType1.ts(18,4): error TS6133: 'string' is declared but its value is never read.
tests/cases/compiler/unusedParameterInFunctionType1.ts(21,8): error TS6133: 'string' is declared but its value is never read.


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

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

interface I {
method1(arg: number): any;
Expand Down
2 changes: 2 additions & 0 deletions tests/baselines/reference/unusedParameterInFunctionType1.js
Expand Up @@ -3,11 +3,13 @@ type F1 = (arg: number) => any;
type F2 = ({ a: string }) => any;
type F3 = ({ a: string }) => typeof string;
type F4 = ({ a: string, b: number }) => typeof number;
type F5 = ([a, b, c]) => void;

type G1 = new (arg: number) => any;
type G2 = new ({ a: string }) => any;
type G3 = new ({ a: string }) => typeof string;
type G4 = new ({ a: string, b: number }) => typeof number;
type G5 = new ([a, b, c]) => void;

interface I {
method1(arg: number): any;
Expand Down
52 changes: 32 additions & 20 deletions tests/baselines/reference/unusedParameterInFunctionType1.symbols
Expand Up @@ -22,52 +22,64 @@ type F4 = ({ a: string, b: number }) => typeof number;
>number : Symbol(number, Decl(unusedParameterInFunctionType1.ts, 3, 23))
>number : Symbol(number, Decl(unusedParameterInFunctionType1.ts, 3, 23))

type F5 = ([a, b, c]) => void;
>F5 : Symbol(F5, Decl(unusedParameterInFunctionType1.ts, 3, 54))
>a : Symbol(a, Decl(unusedParameterInFunctionType1.ts, 4, 12))
>b : Symbol(b, Decl(unusedParameterInFunctionType1.ts, 4, 14))
>c : Symbol(c, Decl(unusedParameterInFunctionType1.ts, 4, 17))

type G1 = new (arg: number) => any;
>G1 : Symbol(G1, Decl(unusedParameterInFunctionType1.ts, 3, 54))
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 5, 15))
>G1 : Symbol(G1, Decl(unusedParameterInFunctionType1.ts, 4, 30))
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 6, 15))

type G2 = new ({ a: string }) => any;
>G2 : Symbol(G2, Decl(unusedParameterInFunctionType1.ts, 5, 35))
>G2 : Symbol(G2, Decl(unusedParameterInFunctionType1.ts, 6, 35))
>a : Symbol(a)
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 6, 16))
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 7, 16))

type G3 = new ({ a: string }) => typeof string;
>G3 : Symbol(G3, Decl(unusedParameterInFunctionType1.ts, 6, 37))
>G3 : Symbol(G3, Decl(unusedParameterInFunctionType1.ts, 7, 37))
>a : Symbol(a)
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 7, 16))
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 7, 16))
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 8, 16))
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 8, 16))

type G4 = new ({ a: string, b: number }) => typeof number;
>G4 : Symbol(G4, Decl(unusedParameterInFunctionType1.ts, 7, 47))
>G4 : Symbol(G4, Decl(unusedParameterInFunctionType1.ts, 8, 47))
>a : Symbol(a)
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 8, 16))
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 9, 16))
>b : Symbol(b)
>number : Symbol(number, Decl(unusedParameterInFunctionType1.ts, 8, 27))
>number : Symbol(number, Decl(unusedParameterInFunctionType1.ts, 8, 27))
>number : Symbol(number, Decl(unusedParameterInFunctionType1.ts, 9, 27))
>number : Symbol(number, Decl(unusedParameterInFunctionType1.ts, 9, 27))

type G5 = new ([a, b, c]) => void;
>G5 : Symbol(G5, Decl(unusedParameterInFunctionType1.ts, 9, 58))
>a : Symbol(a, Decl(unusedParameterInFunctionType1.ts, 10, 16))
>b : Symbol(b, Decl(unusedParameterInFunctionType1.ts, 10, 18))
>c : Symbol(c, Decl(unusedParameterInFunctionType1.ts, 10, 21))

interface I {
>I : Symbol(I, Decl(unusedParameterInFunctionType1.ts, 8, 58))
>I : Symbol(I, Decl(unusedParameterInFunctionType1.ts, 10, 34))

method1(arg: number): any;
>method1 : Symbol(I.method1, Decl(unusedParameterInFunctionType1.ts, 10, 13))
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 11, 10))
>method1 : Symbol(I.method1, Decl(unusedParameterInFunctionType1.ts, 12, 13))
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 13, 10))

method2({ a: string }): any;
>method2 : Symbol(I.method2, Decl(unusedParameterInFunctionType1.ts, 11, 28))
>method2 : Symbol(I.method2, Decl(unusedParameterInFunctionType1.ts, 13, 28))
>a : Symbol(a)
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 12, 11))
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 14, 11))

(arg: number): any;
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 14, 3))
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 16, 3))

({ a: string }): any;
>a : Symbol(a)
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 15, 4))
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 17, 4))

new (arg: number): any;
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 17, 7))
>arg : Symbol(arg, Decl(unusedParameterInFunctionType1.ts, 19, 7))

new ({ a: string }): any;
>a : Symbol(a)
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 18, 8))
>string : Symbol(string, Decl(unusedParameterInFunctionType1.ts, 20, 8))
}
12 changes: 12 additions & 0 deletions tests/baselines/reference/unusedParameterInFunctionType1.types
Expand Up @@ -22,6 +22,12 @@ type F4 = ({ a: string, b: number }) => typeof number;
>number : any
>number : any

type F5 = ([a, b, c]) => void;
>F5 : F5
>a : any
>b : any
>c : any

type G1 = new (arg: number) => any;
>G1 : G1
>arg : number
Expand All @@ -45,6 +51,12 @@ type G4 = new ({ a: string, b: number }) => typeof number;
>number : any
>number : any

type G5 = new ([a, b, c]) => void;
>G5 : G5
>a : any
>b : any
>c : any

interface I {
method1(arg: number): any;
>method1 : (arg: number) => any
Expand Down
2 changes: 2 additions & 0 deletions tests/cases/compiler/unusedParameterInFunctionType1.ts
Expand Up @@ -5,11 +5,13 @@ type F1 = (arg: number) => any;
type F2 = ({ a: string }) => any;
type F3 = ({ a: string }) => typeof string;
type F4 = ({ a: string, b: number }) => typeof number;
type F5 = ([a, b, c]) => void;

type G1 = new (arg: number) => any;
type G2 = new ({ a: string }) => any;
type G3 = new ({ a: string }) => typeof string;
type G4 = new ({ a: string, b: number }) => typeof number;
type G5 = new ([a, b, c]) => void;

interface I {
method1(arg: number): any;
Expand Down

0 comments on commit 15a3683

Please sign in to comment.