Add test case for destructured unused parameter

This commit is contained in:
Sheetal Nandi 2016-10-24 10:58:51 -07:00
parent a8db81393f
commit 1e32b6742e
4 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,15 @@
//// [unusedDestructuringParameters.ts]
const f = ([a]) => { };
f([1]);
const f2 = ({a}) => { };
f2({ a: 10 });
//// [unusedDestructuringParameters.js]
var f = function (_a) {
var a = _a[0];
};
f([1]);
var f2 = function (_a) {
var a = _a.a;
};
f2({ a: 10 });

View File

@ -0,0 +1,16 @@
=== tests/cases/compiler/unusedDestructuringParameters.ts ===
const f = ([a]) => { };
>f : Symbol(f, Decl(unusedDestructuringParameters.ts, 0, 5))
>a : Symbol(a, Decl(unusedDestructuringParameters.ts, 0, 12))
f([1]);
>f : Symbol(f, Decl(unusedDestructuringParameters.ts, 0, 5))
const f2 = ({a}) => { };
>f2 : Symbol(f2, Decl(unusedDestructuringParameters.ts, 2, 5))
>a : Symbol(a, Decl(unusedDestructuringParameters.ts, 2, 13))
f2({ a: 10 });
>f2 : Symbol(f2, Decl(unusedDestructuringParameters.ts, 2, 5))
>a : Symbol(a, Decl(unusedDestructuringParameters.ts, 3, 4))

View File

@ -0,0 +1,24 @@
=== tests/cases/compiler/unusedDestructuringParameters.ts ===
const f = ([a]) => { };
>f : ([a]: [any]) => void
>([a]) => { } : ([a]: [any]) => void
>a : any
f([1]);
>f([1]) : void
>f : ([a]: [any]) => void
>[1] : [number]
>1 : 1
const f2 = ({a}) => { };
>f2 : ({a}: { a: any; }) => void
>({a}) => { } : ({a}: { a: any; }) => void
>a : any
f2({ a: 10 });
>f2({ a: 10 }) : void
>f2 : ({a}: { a: any; }) => void
>{ a: 10 } : { a: number; }
>a : number
>10 : 10

View File

@ -0,0 +1,5 @@
//@noUnusedParameters: true
const f = ([a]) => { };
f([1]);
const f2 = ({a}) => { };
f2({ a: 10 });