-
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.
Allow of in
await using
declarations in for-of loops (#55558)
- Loading branch information
Showing
9 changed files
with
84 additions
and
26 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
13 changes: 13 additions & 0 deletions
13
tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf.2.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,13 @@ | ||
awaitUsingDeclarationsInForAwaitOf.2.ts(4,32): error TS2448: Block-scoped variable 'of' used before its declaration. | ||
|
||
|
||
==== awaitUsingDeclarationsInForAwaitOf.2.ts (1 errors) ==== | ||
// https://github.com/microsoft/TypeScript/issues/55555 | ||
|
||
async function test() { | ||
for await (await using of of of) {}; | ||
~~ | ||
!!! error TS2448: Block-scoped variable 'of' used before its declaration. | ||
!!! related TS2728 awaitUsingDeclarationsInForAwaitOf.2.ts:4:26: 'of' is declared here. | ||
} | ||
|
16 changes: 16 additions & 0 deletions
16
tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf.2.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,16 @@ | ||
//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForAwaitOf.2.ts] //// | ||
|
||
//// [awaitUsingDeclarationsInForAwaitOf.2.ts] | ||
// https://github.com/microsoft/TypeScript/issues/55555 | ||
|
||
async function test() { | ||
for await (await using of of of) {}; | ||
} | ||
|
||
|
||
//// [awaitUsingDeclarationsInForAwaitOf.2.js] | ||
// https://github.com/microsoft/TypeScript/issues/55555 | ||
async function test() { | ||
for await (await using of of of) { } | ||
; | ||
} |
20 changes: 0 additions & 20 deletions
20
tests/baselines/reference/awaitUsingDeclarationsInForOf.2.errors.txt
This file was deleted.
Oops, something went wrong.
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
16 changes: 16 additions & 0 deletions
16
tests/baselines/reference/awaitUsingDeclarationsInForOf.4.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,16 @@ | ||
awaitUsingDeclarationsInForOf.4.ts(4,8): error TS2853: 'await using' statements are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. | ||
awaitUsingDeclarationsInForOf.4.ts(4,26): error TS2448: Block-scoped variable 'of' used before its declaration. | ||
|
||
|
||
==== awaitUsingDeclarationsInForOf.4.ts (2 errors) ==== | ||
// https://github.com/microsoft/TypeScript/issues/55555 | ||
|
||
{ | ||
for (await using of of of) {}; | ||
~~~~~ | ||
!!! error TS2853: 'await using' statements are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. | ||
~~ | ||
!!! error TS2448: Block-scoped variable 'of' used before its declaration. | ||
!!! related TS2728 awaitUsingDeclarationsInForOf.4.ts:4:20: 'of' is declared here. | ||
} | ||
|
16 changes: 16 additions & 0 deletions
16
tests/baselines/reference/awaitUsingDeclarationsInForOf.4.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,16 @@ | ||
//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.4.ts] //// | ||
|
||
//// [awaitUsingDeclarationsInForOf.4.ts] | ||
// https://github.com/microsoft/TypeScript/issues/55555 | ||
|
||
{ | ||
for (await using of of of) {}; | ||
} | ||
|
||
|
||
//// [awaitUsingDeclarationsInForOf.4.js] | ||
// https://github.com/microsoft/TypeScript/issues/55555 | ||
{ | ||
for (await using of of of) { } | ||
; | ||
} |
10 changes: 10 additions & 0 deletions
10
...e/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForAwaitOf.2.ts
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,10 @@ | ||
// @target: esnext | ||
// @module: esnext | ||
// @lib: esnext | ||
// @noTypesAndSymbols: true | ||
|
||
// https://github.com/microsoft/TypeScript/issues/55555 | ||
|
||
async function test() { | ||
for await (await using of of of) {}; | ||
} |
10 changes: 10 additions & 0 deletions
10
...rmance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.4.ts
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,10 @@ | ||
// @target: esnext | ||
// @module: esnext | ||
// @lib: esnext | ||
// @noTypesAndSymbols: true | ||
|
||
// https://github.com/microsoft/TypeScript/issues/55555 | ||
|
||
{ | ||
for (await using of of of) {}; | ||
} |