-
Notifications
You must be signed in to change notification settings - Fork 12.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(31388): allow variables starting with an underscore in array des…
…tructuring
- Loading branch information
1 parent
9871b5f
commit 406f130
Showing
23 changed files
with
326 additions
and
144 deletions.
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
20 changes: 20 additions & 0 deletions
20
tests/baselines/reference/unusedVariablesWithUnderscoreInDestructuringArray1.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,20 @@ | ||
//// [unusedVariablesWithUnderscoreInDestructuringArray1.ts] | ||
function test() { | ||
const [_a1, b1] = [1, 2]; | ||
console.log(b1); | ||
|
||
const [a2, _b2] = [1, 2]; | ||
console.log(a2); | ||
|
||
const [_a3, _b3] = [1, 2]; | ||
} | ||
|
||
|
||
//// [unusedVariablesWithUnderscoreInDestructuringArray1.js] | ||
function test() { | ||
var _a = [1, 2], _a1 = _a[0], b1 = _a[1]; | ||
console.log(b1); | ||
var _b = [1, 2], a2 = _b[0], _b2 = _b[1]; | ||
console.log(a2); | ||
var _c = [1, 2], _a3 = _c[0], _b3 = _c[1]; | ||
} |
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/unusedVariablesWithUnderscoreInDestructuringArray1.symbols
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,29 @@ | ||
=== tests/cases/compiler/unusedVariablesWithUnderscoreInDestructuringArray1.ts === | ||
function test() { | ||
>test : Symbol(test, Decl(unusedVariablesWithUnderscoreInDestructuringArray1.ts, 0, 0)) | ||
|
||
const [_a1, b1] = [1, 2]; | ||
>_a1 : Symbol(_a1, Decl(unusedVariablesWithUnderscoreInDestructuringArray1.ts, 1, 11)) | ||
>b1 : Symbol(b1, Decl(unusedVariablesWithUnderscoreInDestructuringArray1.ts, 1, 15)) | ||
|
||
console.log(b1); | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>b1 : Symbol(b1, Decl(unusedVariablesWithUnderscoreInDestructuringArray1.ts, 1, 15)) | ||
|
||
const [a2, _b2] = [1, 2]; | ||
>a2 : Symbol(a2, Decl(unusedVariablesWithUnderscoreInDestructuringArray1.ts, 4, 11)) | ||
>_b2 : Symbol(_b2, Decl(unusedVariablesWithUnderscoreInDestructuringArray1.ts, 4, 14)) | ||
|
||
console.log(a2); | ||
>console.log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>console : Symbol(console, Decl(lib.dom.d.ts, --, --)) | ||
>log : Symbol(Console.log, Decl(lib.dom.d.ts, --, --)) | ||
>a2 : Symbol(a2, Decl(unusedVariablesWithUnderscoreInDestructuringArray1.ts, 4, 11)) | ||
|
||
const [_a3, _b3] = [1, 2]; | ||
>_a3 : Symbol(_a3, Decl(unusedVariablesWithUnderscoreInDestructuringArray1.ts, 7, 11)) | ||
>_b3 : Symbol(_b3, Decl(unusedVariablesWithUnderscoreInDestructuringArray1.ts, 7, 15)) | ||
} | ||
|
40 changes: 40 additions & 0 deletions
40
tests/baselines/reference/unusedVariablesWithUnderscoreInDestructuringArray1.types
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,40 @@ | ||
=== tests/cases/compiler/unusedVariablesWithUnderscoreInDestructuringArray1.ts === | ||
function test() { | ||
>test : () => void | ||
|
||
const [_a1, b1] = [1, 2]; | ||
>_a1 : number | ||
>b1 : number | ||
>[1, 2] : [number, number] | ||
>1 : 1 | ||
>2 : 2 | ||
|
||
console.log(b1); | ||
>console.log(b1) : void | ||
>console.log : (...data: any[]) => void | ||
>console : Console | ||
>log : (...data: any[]) => void | ||
>b1 : number | ||
|
||
const [a2, _b2] = [1, 2]; | ||
>a2 : number | ||
>_b2 : number | ||
>[1, 2] : [number, number] | ||
>1 : 1 | ||
>2 : 2 | ||
|
||
console.log(a2); | ||
>console.log(a2) : void | ||
>console.log : (...data: any[]) => void | ||
>console : Console | ||
>log : (...data: any[]) => void | ||
>a2 : number | ||
|
||
const [_a3, _b3] = [1, 2]; | ||
>_a3 : number | ||
>_b3 : number | ||
>[1, 2] : [number, number] | ||
>1 : 1 | ||
>2 : 2 | ||
} | ||
|
21 changes: 21 additions & 0 deletions
21
tests/baselines/reference/unusedVariablesWithUnderscoreInDestructuringArray2.errors.txt
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,21 @@ | ||
tests/cases/compiler/unusedVariablesWithUnderscoreInDestructuringArray2.ts(2,17): error TS6133: 'b1' is declared but its value is never read. | ||
tests/cases/compiler/unusedVariablesWithUnderscoreInDestructuringArray2.ts(3,12): error TS6133: 'a2' is declared but its value is never read. | ||
tests/cases/compiler/unusedVariablesWithUnderscoreInDestructuringArray2.ts(4,12): error TS6133: 'a3' is declared but its value is never read. | ||
tests/cases/compiler/unusedVariablesWithUnderscoreInDestructuringArray2.ts(4,16): error TS6133: 'b3' is declared but its value is never read. | ||
|
||
|
||
==== tests/cases/compiler/unusedVariablesWithUnderscoreInDestructuringArray2.ts (4 errors) ==== | ||
function f() { | ||
const [_a1, b1] = [1, 2]; | ||
~~ | ||
!!! error TS6133: 'b1' is declared but its value is never read. | ||
const [a2, _b2] = [1, 2]; | ||
~~ | ||
!!! error TS6133: 'a2' is declared but its value is never read. | ||
const [a3, b3] = [1, 2]; | ||
~~ | ||
!!! error TS6133: 'a3' is declared but its value is never read. | ||
~~ | ||
!!! error TS6133: 'b3' is declared but its value is never read. | ||
} | ||
|
14 changes: 14 additions & 0 deletions
14
tests/baselines/reference/unusedVariablesWithUnderscoreInDestructuringArray2.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,14 @@ | ||
//// [unusedVariablesWithUnderscoreInDestructuringArray2.ts] | ||
function f() { | ||
const [_a1, b1] = [1, 2]; | ||
const [a2, _b2] = [1, 2]; | ||
const [a3, b3] = [1, 2]; | ||
} | ||
|
||
|
||
//// [unusedVariablesWithUnderscoreInDestructuringArray2.js] | ||
function f() { | ||
var _a = [1, 2], _a1 = _a[0], b1 = _a[1]; | ||
var _b = [1, 2], a2 = _b[0], _b2 = _b[1]; | ||
var _c = [1, 2], a3 = _c[0], b3 = _c[1]; | ||
} |
17 changes: 17 additions & 0 deletions
17
tests/baselines/reference/unusedVariablesWithUnderscoreInDestructuringArray2.symbols
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,17 @@ | ||
=== tests/cases/compiler/unusedVariablesWithUnderscoreInDestructuringArray2.ts === | ||
function f() { | ||
>f : Symbol(f, Decl(unusedVariablesWithUnderscoreInDestructuringArray2.ts, 0, 0)) | ||
|
||
const [_a1, b1] = [1, 2]; | ||
>_a1 : Symbol(_a1, Decl(unusedVariablesWithUnderscoreInDestructuringArray2.ts, 1, 11)) | ||
>b1 : Symbol(b1, Decl(unusedVariablesWithUnderscoreInDestructuringArray2.ts, 1, 15)) | ||
|
||
const [a2, _b2] = [1, 2]; | ||
>a2 : Symbol(a2, Decl(unusedVariablesWithUnderscoreInDestructuringArray2.ts, 2, 11)) | ||
>_b2 : Symbol(_b2, Decl(unusedVariablesWithUnderscoreInDestructuringArray2.ts, 2, 14)) | ||
|
||
const [a3, b3] = [1, 2]; | ||
>a3 : Symbol(a3, Decl(unusedVariablesWithUnderscoreInDestructuringArray2.ts, 3, 11)) | ||
>b3 : Symbol(b3, Decl(unusedVariablesWithUnderscoreInDestructuringArray2.ts, 3, 14)) | ||
} | ||
|
26 changes: 26 additions & 0 deletions
26
tests/baselines/reference/unusedVariablesWithUnderscoreInDestructuringArray2.types
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,26 @@ | ||
=== tests/cases/compiler/unusedVariablesWithUnderscoreInDestructuringArray2.ts === | ||
function f() { | ||
>f : () => void | ||
|
||
const [_a1, b1] = [1, 2]; | ||
>_a1 : number | ||
>b1 : number | ||
>[1, 2] : [number, number] | ||
>1 : 1 | ||
>2 : 2 | ||
|
||
const [a2, _b2] = [1, 2]; | ||
>a2 : number | ||
>_b2 : number | ||
>[1, 2] : [number, number] | ||
>1 : 1 | ||
>2 : 2 | ||
|
||
const [a3, b3] = [1, 2]; | ||
>a3 : number | ||
>b3 : number | ||
>[1, 2] : [number, number] | ||
>1 : 1 | ||
>2 : 2 | ||
} | ||
|
28 changes: 0 additions & 28 deletions
28
tests/baselines/reference/unusedVariablesWithUnderscoreInForOfLoop.js
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
tests/baselines/reference/unusedVariablesWithUnderscoreInForOfLoop.symbols
This file was deleted.
Oops, something went wrong.
45 changes: 0 additions & 45 deletions
45
tests/baselines/reference/unusedVariablesWithUnderscoreInForOfLoop.types
This file was deleted.
Oops, something went wrong.
14 changes: 10 additions & 4 deletions
14
tests/baselines/reference/unusedVariablesWithUnderscoreInForOfLoop1.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 |
---|---|---|
@@ -1,22 +1,28 @@ | ||
//// [unusedVariablesWithUnderscoreInForOfLoop1.ts] | ||
function f() { | ||
for (const [_a, b] of [['key', 1]]) {} | ||
for (const [_a, b] of [['key', 1]]) { | ||
console.log(b); | ||
} | ||
|
||
for (const [a, _b] of [['key', 1]]) {} | ||
for (const [a, _b] of [['key', 1]]) { | ||
console.log(a); | ||
} | ||
|
||
for (const [a, b] of [['key', 1]]) {} | ||
for (const [_a, _b] of [['key', 1]]) {} | ||
} | ||
|
||
|
||
//// [unusedVariablesWithUnderscoreInForOfLoop1.js] | ||
function f() { | ||
for (var _i = 0, _c = [['key', 1]]; _i < _c.length; _i++) { | ||
var _d = _c[_i], _a = _d[0], b = _d[1]; | ||
console.log(b); | ||
} | ||
for (var _e = 0, _f = [['key', 1]]; _e < _f.length; _e++) { | ||
var _g = _f[_e], a = _g[0], _b = _g[1]; | ||
console.log(a); | ||
} | ||
for (var _h = 0, _j = [['key', 1]]; _h < _j.length; _h++) { | ||
var _k = _j[_h], a = _k[0], b = _k[1]; | ||
var _k = _j[_h], _a = _k[0], _b = _k[1]; | ||
} | ||
} |
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
Oops, something went wrong.