Skip to content

Commit d75b631

Browse files
committed
Add test
1 parent 4110b80 commit d75b631

4 files changed

+100
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//// [declarationEmitDuplicateParameterDestructuring.ts]
2+
export const fn1 = ({ prop: a, prop: b }: { prop: number }) => a + b;
3+
4+
export const fn2 = ({ prop: a }: { prop: number }, { prop: b }: { prop: number }) => a + b;
5+
6+
7+
8+
9+
//// [declarationEmitDuplicateParameterDestructuring.d.ts]
10+
export declare const fn1: ({ prop, prop }: {
11+
prop: number;
12+
}) => number;
13+
export declare const fn2: ({ prop }: {
14+
prop: number;
15+
}, { prop }: {
16+
prop: number;
17+
}) => number;
18+
19+
20+
//// [DtsFileErrors]
21+
22+
23+
tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.d.ts(1,30): error TS2300: Duplicate identifier 'prop'.
24+
tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.d.ts(1,36): error TS2300: Duplicate identifier 'prop'.
25+
tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.d.ts(4,30): error TS2300: Duplicate identifier 'prop'.
26+
tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.d.ts(6,6): error TS2300: Duplicate identifier 'prop'.
27+
28+
29+
==== tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.d.ts (4 errors) ====
30+
export declare const fn1: ({ prop, prop }: {
31+
~~~~
32+
!!! error TS2300: Duplicate identifier 'prop'.
33+
~~~~
34+
!!! error TS2300: Duplicate identifier 'prop'.
35+
prop: number;
36+
}) => number;
37+
export declare const fn2: ({ prop }: {
38+
~~~~
39+
!!! error TS2300: Duplicate identifier 'prop'.
40+
prop: number;
41+
}, { prop }: {
42+
~~~~
43+
!!! error TS2300: Duplicate identifier 'prop'.
44+
prop: number;
45+
}) => number;
46+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
=== tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.ts ===
2+
export const fn1 = ({ prop: a, prop: b }: { prop: number }) => a + b;
3+
>fn1 : Symbol(fn1, Decl(declarationEmitDuplicateParameterDestructuring.ts, 0, 12))
4+
>prop : Symbol(prop, Decl(declarationEmitDuplicateParameterDestructuring.ts, 0, 43))
5+
>a : Symbol(a, Decl(declarationEmitDuplicateParameterDestructuring.ts, 0, 21))
6+
>prop : Symbol(prop, Decl(declarationEmitDuplicateParameterDestructuring.ts, 0, 43))
7+
>b : Symbol(b, Decl(declarationEmitDuplicateParameterDestructuring.ts, 0, 30))
8+
>prop : Symbol(prop, Decl(declarationEmitDuplicateParameterDestructuring.ts, 0, 43))
9+
>a : Symbol(a, Decl(declarationEmitDuplicateParameterDestructuring.ts, 0, 21))
10+
>b : Symbol(b, Decl(declarationEmitDuplicateParameterDestructuring.ts, 0, 30))
11+
12+
export const fn2 = ({ prop: a }: { prop: number }, { prop: b }: { prop: number }) => a + b;
13+
>fn2 : Symbol(fn2, Decl(declarationEmitDuplicateParameterDestructuring.ts, 2, 12))
14+
>prop : Symbol(prop, Decl(declarationEmitDuplicateParameterDestructuring.ts, 2, 34))
15+
>a : Symbol(a, Decl(declarationEmitDuplicateParameterDestructuring.ts, 2, 21))
16+
>prop : Symbol(prop, Decl(declarationEmitDuplicateParameterDestructuring.ts, 2, 34))
17+
>prop : Symbol(prop, Decl(declarationEmitDuplicateParameterDestructuring.ts, 2, 65))
18+
>b : Symbol(b, Decl(declarationEmitDuplicateParameterDestructuring.ts, 2, 52))
19+
>prop : Symbol(prop, Decl(declarationEmitDuplicateParameterDestructuring.ts, 2, 65))
20+
>a : Symbol(a, Decl(declarationEmitDuplicateParameterDestructuring.ts, 2, 21))
21+
>b : Symbol(b, Decl(declarationEmitDuplicateParameterDestructuring.ts, 2, 52))
22+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
=== tests/cases/compiler/declarationEmitDuplicateParameterDestructuring.ts ===
2+
export const fn1 = ({ prop: a, prop: b }: { prop: number }) => a + b;
3+
>fn1 : ({ prop, prop }: { prop: number;}) => number
4+
>({ prop: a, prop: b }: { prop: number }) => a + b : ({ prop, prop }: { prop: number;}) => number
5+
>prop : any
6+
>a : number
7+
>prop : any
8+
>b : number
9+
>prop : number
10+
>a + b : number
11+
>a : number
12+
>b : number
13+
14+
export const fn2 = ({ prop: a }: { prop: number }, { prop: b }: { prop: number }) => a + b;
15+
>fn2 : ({ prop }: { prop: number;}, { prop }: { prop: number;}) => number
16+
>({ prop: a }: { prop: number }, { prop: b }: { prop: number }) => a + b : ({ prop }: { prop: number;}, { prop }: { prop: number;}) => number
17+
>prop : any
18+
>a : number
19+
>prop : number
20+
>prop : any
21+
>b : number
22+
>prop : number
23+
>a + b : number
24+
>a : number
25+
>b : number
26+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// @declaration: true
2+
// @emitDeclarationOnly: true
3+
4+
export const fn1 = ({ prop: a, prop: b }: { prop: number }) => a + b;
5+
6+
export const fn2 = ({ prop: a }: { prop: number }, { prop: b }: { prop: number }) => a + b;

0 commit comments

Comments
 (0)