-
-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(isolated-declarations): should stripe async and generator keyword…
… after transformed
- Loading branch information
Showing
6 changed files
with
79 additions
and
6 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
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
crates/oxc_isolated_declarations/tests/fixtures/async-function.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,16 @@ | ||
// Correct | ||
async function asyncFunctionGood(): Promise<number> {} | ||
const asyncFunctionGoo2 = async (): Promise<number> => { | ||
return Promise.resolve(0); | ||
} | ||
|
||
|
||
// Need to explicit return type for async functions | ||
// Incorrect | ||
async function asyncFunction() { | ||
return 42; | ||
} | ||
|
||
const asyncFunction2 = async () => { | ||
return "Hello, World!"; | ||
} |
10 changes: 10 additions & 0 deletions
10
crates/oxc_isolated_declarations/tests/fixtures/generator.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 @@ | ||
// Correct | ||
function *generatorGood(): Generator<number> {} | ||
|
||
|
||
// Need to explicit return type for async functions | ||
// Incorrect | ||
function *generatorGoodBad() { | ||
yield 50; | ||
return 42; | ||
} |
31 changes: 31 additions & 0 deletions
31
crates/oxc_isolated_declarations/tests/snapshots/async-function.snap
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,31 @@ | ||
--- | ||
source: crates/oxc_isolated_declarations/tests/mod.rs | ||
input_file: crates/oxc_isolated_declarations/tests/fixtures/async-function.ts | ||
--- | ||
==================== .D.TS ==================== | ||
|
||
declare function asyncFunctionGood(): Promise<number>; | ||
declare const asyncFunctionGoo2: () => Promise<number>; | ||
declare function asyncFunction(); | ||
declare const asyncFunction2: unknown; | ||
|
||
|
||
==================== Errors ==================== | ||
|
||
x TS9007: Function must have an explicit return type annotation with | ||
| --isolatedDeclarations. | ||
,-[10:16] | ||
9 | // Incorrect | ||
10 | async function asyncFunction() { | ||
: ^^^^^^^^^^^^^ | ||
11 | return 42; | ||
`---- | ||
x TS9007: Function must have an explicit return type annotation with | ||
| --isolatedDeclarations. | ||
,-[14:30] | ||
13 | | ||
14 | const asyncFunction2 = async () => { | ||
: ^^^^^^^ | ||
15 | return "Hello, World!"; | ||
`---- |
20 changes: 20 additions & 0 deletions
20
crates/oxc_isolated_declarations/tests/snapshots/generator.snap
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 @@ | ||
--- | ||
source: crates/oxc_isolated_declarations/tests/mod.rs | ||
input_file: crates/oxc_isolated_declarations/tests/fixtures/generator.ts | ||
--- | ||
==================== .D.TS ==================== | ||
|
||
declare function generatorGood(): Generator<number>; | ||
declare function generatorGoodBad(); | ||
|
||
|
||
==================== Errors ==================== | ||
|
||
x TS9007: Function must have an explicit return type annotation with | ||
| --isolatedDeclarations. | ||
,-[7:11] | ||
6 | // Incorrect | ||
7 | function *generatorGoodBad() { | ||
: ^^^^^^^^^^^^^^^^ | ||
8 | yield 50; | ||
`---- |