Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor improvements to block-scoping/tdz (#6782)
* Add test case for simple reference in tdz * Add more examples from old issues as test cases * Fix two testcases by excluding function declarations from being tdz checked * Document the option for block-scoping * Add test cases with destructuring assignments * Remove failing test cases * [skip ci] Include type and default value for options
- Loading branch information
1 parent
e9ed687
commit 0a9f136
Showing
16 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...es/babel-plugin-transform-block-scoping/test/fixtures/tdz/block-ref-function-call/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
f(); | ||
|
||
const f = function f() {} |
3 changes: 3 additions & 0 deletions
3
...bel-plugin-transform-block-scoping/test/fixtures/tdz/block-ref-function-call/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"throws": "f is not defined - temporal dead zone" | ||
} |
1 change: 1 addition & 0 deletions
1
...abel-plugin-transform-block-scoping/test/fixtures/tdz/destructured-self-reference/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let {聽b: d }聽= {聽d } |
3 changes: 3 additions & 0 deletions
3
...plugin-transform-block-scoping/test/fixtures/tdz/destructured-self-reference/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"throws": "d is not defined - temporal dead zone" | ||
} |
5 changes: 5 additions & 0 deletions
5
...ges/babel-plugin-transform-block-scoping/test/fixtures/tdz/function-call-no-throw/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function f() { | ||
x; | ||
} | ||
let x; | ||
f(); |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/hoisted-function/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
f(); | ||
|
||
function f() {} |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/hoisted-var/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
x = 3; | ||
|
||
var x; |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"plugins": [["transform-block-scoping",{"tdz": true}]] | ||
} |
1 change: 1 addition & 0 deletions
1
packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/self-reference/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let x = x; |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/self-reference/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"throws": "x is not defined - temporal dead zone" | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/shadow-outer-var/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
var a = 5; | ||
if (a){ console.log(a); let a = 2; } | ||
console.log(a); |
3 changes: 3 additions & 0 deletions
3
...ages/babel-plugin-transform-block-scoping/test/fixtures/tdz/shadow-outer-var/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"throws": "a is not defined - temporal dead zone" | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/babel-plugin-transform-block-scoping/test/fixtures/tdz/simple-reference/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
i | ||
let i |
3 changes: 3 additions & 0 deletions
3
...ages/babel-plugin-transform-block-scoping/test/fixtures/tdz/simple-reference/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"throws": "i is not defined - temporal dead zone" | ||
} |