File tree 5 files changed +75
-18
lines changed
crates/oxc_isolated_declarations
5 files changed +75
-18
lines changed Original file line number Diff line number Diff line change @@ -117,8 +117,8 @@ impl<'a> IsolatedDeclarations<'a> {
117
117
FunctionType :: TSEmptyBodyFunctionExpression ,
118
118
function. span ,
119
119
self . ast . copy ( & function. id ) ,
120
- function . generator ,
121
- function . r#async ,
120
+ false ,
121
+ false ,
122
122
false ,
123
123
self . ast . copy ( & function. type_parameters ) ,
124
124
self . ast . copy ( & function. this_param ) ,
Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ const asyncFunctionGoo2 = async (): Promise<number> => {
5
5
}
6
6
7
7
8
+ class AsyncClassGood {
9
+ async method ( ) : number {
10
+ return 42 ;
11
+ }
12
+ }
13
+
8
14
// Need to explicit return type for async functions
9
15
// Incorrect
10
16
async function asyncFunction ( ) {
@@ -13,4 +19,10 @@ async function asyncFunction() {
13
19
14
20
const asyncFunction2 = async ( ) => {
15
21
return "Hello, World!" ;
22
+ }
23
+
24
+ class AsyncClassBad {
25
+ async method ( ) {
26
+ return 42 ;
27
+ }
16
28
}
Original file line number Diff line number Diff line change 1
1
// Correct
2
2
function * generatorGood ( ) : Generator < number > { }
3
3
4
+ class GeneratorClassGood {
5
+ * method ( ) : Generator < number > {
6
+ yield 50 ;
7
+ return 42 ;
8
+ }
9
+ }
10
+
11
+
4
12
5
13
// Need to explicit return type for async functions
6
14
// Incorrect
7
- function * generatorGoodBad ( ) {
15
+ function * generatorBad ( ) {
8
16
yield 50 ;
9
17
return 42 ;
18
+ }
19
+
20
+ class GeneratorClassBad {
21
+ * method ( ) {
22
+ yield 50 ;
23
+ return 42 ;
24
+ }
10
25
}
Original file line number Diff line number Diff line change @@ -6,26 +6,41 @@ input_file: crates/oxc_isolated_declarations/tests/fixtures/async-function.ts
6
6
7
7
declare function asyncFunctionGood(): Promise <number >;
8
8
declare const asyncFunctionGoo2: () => Promise <number >;
9
+ declare class AsyncClassGood {
10
+ method(): number ;
11
+ }
9
12
declare function asyncFunction();
10
13
declare const asyncFunction2: unknown ;
14
+ declare class AsyncClassBad {
15
+ method();
16
+ }
11
17
12
18
13
19
==================== Errors ====================
14
20
15
21
x TS9007 : Function must have an explicit return type annotation with
16
22
| --isolatedDeclarations .
17
- ,-[10 :16 ]
18
- 9 | // Incorrect
19
- 10 | async function asyncFunction() {
23
+ ,-[16 :16 ]
24
+ 15 | // Incorrect
25
+ 16 | async function asyncFunction() {
20
26
: ^^^^^^^^^^^^^
21
- 11 | return 42 ;
27
+ 17 | return 42 ;
22
28
` ----
23
29
24
30
x TS9007: Function must have an explicit return type annotation with
25
31
| --isolatedDeclarations.
26
- ,-[14 :30]
27
- 13 |
28
- 14 | const asyncFunction2 = async () => {
32
+ ,-[20 :30]
33
+ 19 |
34
+ 20 | const asyncFunction2 = async () => {
29
35
: ^^^^^^^
30
- 15 | return " Hello, World!" ;
36
+ 21 | return " Hello, World!" ;
37
+ ` ----
38
+
39
+ x TS9008: Method must have an explicit return type annotation with
40
+ | --isolatedDeclarations.
41
+ ,-[25:9]
42
+ 24 | class AsyncClassBad {
43
+ 25 | async method () {
44
+ : ^^^^^^
45
+ 26 | return 42;
31
46
`----
Original file line number Diff line number Diff line change @@ -5,16 +5,31 @@ input_file: crates/oxc_isolated_declarations/tests/fixtures/generator.ts
5
5
==================== .D .TS ====================
6
6
7
7
declare function generatorGood(): Generator <number >;
8
- declare function generatorGoodBad();
8
+ declare class GeneratorClassGood {
9
+ method(): Generator <number >;
10
+ }
11
+ declare function generatorBad();
12
+ declare class GeneratorClassBad {
13
+ method();
14
+ }
9
15
10
16
11
17
==================== Errors ====================
12
18
13
19
x TS9007 : Function must have an explicit return type annotation with
14
20
| --isolatedDeclarations .
15
- ,-[7 :11 ]
16
- 6 | // Incorrect
17
- 7 | function * generatorGoodBad() {
18
- : ^^^^^^^^^^^^^^^^
19
- 8 | yield 50 ;
20
- ` ----
21
+ ,-[15 :11 ]
22
+ 14 | // Incorrect
23
+ 15 | function * generatorBad() {
24
+ : ^^^^^^^^^^^^
25
+ 16 | yield 50 ;
26
+ ` ----
27
+
28
+ x TS9008: Method must have an explicit return type annotation with
29
+ | --isolatedDeclarations.
30
+ ,-[21:4]
31
+ 20 | class GeneratorClassBad {
32
+ 21 | * method () {
33
+ : ^^^^^^
34
+ 22 | yield 50;
35
+ `----
You can’t perform that action at this time.
0 commit comments