Skip to content

Commit 2edb5c8

Browse files
committed
Added tests for let/const variable declarations in catch clause (with the same name)
1 parent 129ef72 commit 2edb5c8

3 files changed

Lines changed: 95 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
tests/cases/compiler/redeclareParameterInCatchBlock.ts(5,11): error TS2492: Cannot redeclare identifier 'e' in catch clause
2+
tests/cases/compiler/redeclareParameterInCatchBlock.ts(11,9): error TS2492: Cannot redeclare identifier 'e' in catch clause
3+
4+
5+
==== tests/cases/compiler/redeclareParameterInCatchBlock.ts (2 errors) ====
6+
7+
try {
8+
9+
} catch(e) {
10+
const e = null;
11+
~
12+
!!! error TS2492: Cannot redeclare identifier 'e' in catch clause
13+
}
14+
15+
try {
16+
17+
} catch(e) {
18+
let e;
19+
~
20+
!!! error TS2492: Cannot redeclare identifier 'e' in catch clause
21+
}
22+
23+
try {
24+
25+
} catch(e) {
26+
function test() {
27+
let e;
28+
}
29+
}
30+
31+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//// [redeclareParameterInCatchBlock.ts]
2+
3+
try {
4+
5+
} catch(e) {
6+
const e = null;
7+
}
8+
9+
try {
10+
11+
} catch(e) {
12+
let e;
13+
}
14+
15+
try {
16+
17+
} catch(e) {
18+
function test() {
19+
let e;
20+
}
21+
}
22+
23+
24+
25+
//// [redeclareParameterInCatchBlock.js]
26+
try {
27+
}
28+
catch (e) {
29+
const e = null;
30+
}
31+
try {
32+
}
33+
catch (e) {
34+
let e;
35+
}
36+
try {
37+
}
38+
catch (e) {
39+
function test() {
40+
let e;
41+
}
42+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// @target: es6
2+
3+
try {
4+
5+
} catch(e) {
6+
const e = null;
7+
}
8+
9+
try {
10+
11+
} catch(e) {
12+
let e;
13+
}
14+
15+
try {
16+
17+
} catch(e) {
18+
function test() {
19+
let e;
20+
}
21+
}
22+

0 commit comments

Comments
 (0)