File tree Expand file tree Collapse file tree 9 files changed +463
-7
lines changed
arrow-function_type_test_async_generic_after_import
arrow-function_type_test_async_generic_empty_params Expand file tree Collapse file tree 9 files changed +463
-7
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @sveltejs/acorn-typescript ' : patch
3
+ ---
4
+
5
+ fix: correctly parse async arrow functions with generics
Original file line number Diff line number Diff line change @@ -430,7 +430,7 @@ export function tsPlugin(options?: {
430
430
return (
431
431
base . type === 'Identifier' &&
432
432
base . name === 'async' &&
433
- this . lastTokEndLoc . column === base . end &&
433
+ this . lastTokEnd === base . end &&
434
434
! this . canInsertSemicolon ( ) &&
435
435
base . end - base . start === 5 &&
436
436
base . start === this . potentialArrowAt
@@ -3228,7 +3228,9 @@ export function tsPlugin(options?: {
3228
3228
return node . expression ;
3229
3229
}
3230
3230
3231
- toAssignableList ( exprList : any [ ] , isBinding : boolean ) : any {
3231
+ toAssignableList ( exprList : any [ ] | null , isBinding : boolean ) : any {
3232
+ if ( ! exprList ) exprList = [ ] ;
3233
+
3232
3234
for ( let i = 0 ; i < exprList . length ; i ++ ) {
3233
3235
const expr = exprList [ i ] ;
3234
3236
@@ -4163,7 +4165,7 @@ export function tsPlugin(options?: {
4163
4165
override = modified . override ;
4164
4166
readonly = modified . readonly ;
4165
4167
if ( allowModifiers === false && ( accessibility || readonly || override ) ) {
4166
- this . raise ( startLoc . start , TypeScriptError . UnexpectedParameterModifier ) ;
4168
+ this . raise ( startLoc . column , TypeScriptError . UnexpectedParameterModifier ) ;
4167
4169
}
4168
4170
}
4169
4171
Original file line number Diff line number Diff line change @@ -47,11 +47,11 @@ export declare class AcornParseClass extends Parser {
47
47
scopeStack : any [ ] ;
48
48
inModule : any ;
49
49
undefinedExports : any ;
50
- lastTokEndLoc : any ;
51
- lastTokStartLoc : any ;
50
+ lastTokEndLoc : Position ;
51
+ lastTokStartLoc : Position ;
52
52
context : any [ ] ;
53
- endLoc : any ;
54
- startLoc : any ;
53
+ endLoc : Position ;
54
+ startLoc : Position ;
55
55
potentialArrowInForAwait : boolean ;
56
56
type : TokenType & Record < string , any > ;
57
57
start : number ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "type" : " Program" ,
3
+ "start" : 0 ,
4
+ "end" : 73 ,
5
+ "loc" : {
6
+ "start" : {
7
+ "line" : 1 ,
8
+ "column" : 0
9
+ },
10
+ "end" : {
11
+ "line" : 3 ,
12
+ "column" : 46
13
+ }
14
+ },
15
+ "body" : [
16
+ {
17
+ "type" : " ImportDeclaration" ,
18
+ "start" : 0 ,
19
+ "end" : 25 ,
20
+ "loc" : {
21
+ "start" : {
22
+ "line" : 1 ,
23
+ "column" : 0
24
+ },
25
+ "end" : {
26
+ "line" : 1 ,
27
+ "column" : 25
28
+ }
29
+ },
30
+ "importKind" : " value" ,
31
+ "specifiers" : [],
32
+ "source" : {
33
+ "type" : " Literal" ,
34
+ "start" : 15 ,
35
+ "end" : 25 ,
36
+ "loc" : {
37
+ "start" : {
38
+ "line" : 1 ,
39
+ "column" : 15
40
+ },
41
+ "end" : {
42
+ "line" : 1 ,
43
+ "column" : 25
44
+ }
45
+ },
46
+ "value" : " ./config" ,
47
+ "raw" : " './config'"
48
+ }
49
+ },
50
+ {
51
+ "type" : " VariableDeclaration" ,
52
+ "start" : 27 ,
53
+ "end" : 73 ,
54
+ "loc" : {
55
+ "start" : {
56
+ "line" : 3 ,
57
+ "column" : 0
58
+ },
59
+ "end" : {
60
+ "line" : 3 ,
61
+ "column" : 46
62
+ }
63
+ },
64
+ "declarations" : [
65
+ {
66
+ "type" : " VariableDeclarator" ,
67
+ "start" : 33 ,
68
+ "end" : 72 ,
69
+ "loc" : {
70
+ "start" : {
71
+ "line" : 3 ,
72
+ "column" : 6
73
+ },
74
+ "end" : {
75
+ "line" : 3 ,
76
+ "column" : 45
77
+ }
78
+ },
79
+ "id" : {
80
+ "type" : " Identifier" ,
81
+ "start" : 33 ,
82
+ "end" : 52 ,
83
+ "loc" : {
84
+ "start" : {
85
+ "line" : 3 ,
86
+ "column" : 6
87
+ },
88
+ "end" : {
89
+ "line" : 3 ,
90
+ "column" : 25
91
+ }
92
+ },
93
+ "name" : " loadDataWithGeneric"
94
+ },
95
+ "init" : {
96
+ "type" : " ArrowFunctionExpression" ,
97
+ "start" : 55 ,
98
+ "end" : 72 ,
99
+ "loc" : {
100
+ "start" : {
101
+ "line" : 3 ,
102
+ "column" : 28
103
+ },
104
+ "end" : {
105
+ "line" : 3 ,
106
+ "column" : 45
107
+ }
108
+ },
109
+ "typeParameters" : {
110
+ "type" : " TSTypeParameterDeclaration" ,
111
+ "start" : 61 ,
112
+ "end" : 64 ,
113
+ "loc" : {
114
+ "start" : {
115
+ "line" : 3 ,
116
+ "column" : 34
117
+ },
118
+ "end" : {
119
+ "line" : 3 ,
120
+ "column" : 37
121
+ }
122
+ },
123
+ "params" : [
124
+ {
125
+ "type" : " TSTypeParameter" ,
126
+ "start" : 62 ,
127
+ "end" : 63 ,
128
+ "loc" : {
129
+ "start" : {
130
+ "line" : 3 ,
131
+ "column" : 35
132
+ },
133
+ "end" : {
134
+ "line" : 3 ,
135
+ "column" : 36
136
+ }
137
+ },
138
+ "name" : " T"
139
+ }
140
+ ]
141
+ },
142
+ "params" : [],
143
+ "id" : null ,
144
+ "expression" : false ,
145
+ "generator" : false ,
146
+ "async" : true ,
147
+ "body" : {
148
+ "type" : " BlockStatement" ,
149
+ "start" : 70 ,
150
+ "end" : 72 ,
151
+ "loc" : {
152
+ "start" : {
153
+ "line" : 3 ,
154
+ "column" : 43
155
+ },
156
+ "end" : {
157
+ "line" : 3 ,
158
+ "column" : 45
159
+ }
160
+ },
161
+ "body" : []
162
+ }
163
+ }
164
+ }
165
+ ],
166
+ "kind" : " const"
167
+ }
168
+ ],
169
+ "sourceType" : " module"
170
+ }
Original file line number Diff line number Diff line change
1
+ import { } from './config'
2
+
3
+ const loadDataWithGeneric = async < T > ( ) => { } ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "type" : " Program" ,
3
+ "start" : 0 ,
4
+ "end" : 46 ,
5
+ "loc" : {
6
+ "start" : {
7
+ "line" : 1 ,
8
+ "column" : 0
9
+ },
10
+ "end" : {
11
+ "line" : 1 ,
12
+ "column" : 46
13
+ }
14
+ },
15
+ "body" : [
16
+ {
17
+ "type" : " VariableDeclaration" ,
18
+ "start" : 0 ,
19
+ "end" : 46 ,
20
+ "loc" : {
21
+ "start" : {
22
+ "line" : 1 ,
23
+ "column" : 0
24
+ },
25
+ "end" : {
26
+ "line" : 1 ,
27
+ "column" : 46
28
+ }
29
+ },
30
+ "declarations" : [
31
+ {
32
+ "type" : " VariableDeclarator" ,
33
+ "start" : 6 ,
34
+ "end" : 45 ,
35
+ "loc" : {
36
+ "start" : {
37
+ "line" : 1 ,
38
+ "column" : 6
39
+ },
40
+ "end" : {
41
+ "line" : 1 ,
42
+ "column" : 45
43
+ }
44
+ },
45
+ "id" : {
46
+ "type" : " Identifier" ,
47
+ "start" : 6 ,
48
+ "end" : 25 ,
49
+ "loc" : {
50
+ "start" : {
51
+ "line" : 1 ,
52
+ "column" : 6
53
+ },
54
+ "end" : {
55
+ "line" : 1 ,
56
+ "column" : 25
57
+ }
58
+ },
59
+ "name" : " loadDataWithGeneric"
60
+ },
61
+ "init" : {
62
+ "type" : " ArrowFunctionExpression" ,
63
+ "start" : 28 ,
64
+ "end" : 45 ,
65
+ "loc" : {
66
+ "start" : {
67
+ "line" : 1 ,
68
+ "column" : 28
69
+ },
70
+ "end" : {
71
+ "line" : 1 ,
72
+ "column" : 45
73
+ }
74
+ },
75
+ "typeParameters" : {
76
+ "type" : " TSTypeParameterDeclaration" ,
77
+ "start" : 34 ,
78
+ "end" : 37 ,
79
+ "loc" : {
80
+ "start" : {
81
+ "line" : 1 ,
82
+ "column" : 34
83
+ },
84
+ "end" : {
85
+ "line" : 1 ,
86
+ "column" : 37
87
+ }
88
+ },
89
+ "params" : [
90
+ {
91
+ "type" : " TSTypeParameter" ,
92
+ "start" : 35 ,
93
+ "end" : 36 ,
94
+ "loc" : {
95
+ "start" : {
96
+ "line" : 1 ,
97
+ "column" : 35
98
+ },
99
+ "end" : {
100
+ "line" : 1 ,
101
+ "column" : 36
102
+ }
103
+ },
104
+ "name" : " T"
105
+ }
106
+ ]
107
+ },
108
+ "params" : [],
109
+ "id" : null ,
110
+ "expression" : false ,
111
+ "generator" : false ,
112
+ "async" : true ,
113
+ "body" : {
114
+ "type" : " BlockStatement" ,
115
+ "start" : 43 ,
116
+ "end" : 45 ,
117
+ "loc" : {
118
+ "start" : {
119
+ "line" : 1 ,
120
+ "column" : 43
121
+ },
122
+ "end" : {
123
+ "line" : 1 ,
124
+ "column" : 45
125
+ }
126
+ },
127
+ "body" : []
128
+ }
129
+ }
130
+ }
131
+ ],
132
+ "kind" : " const"
133
+ }
134
+ ],
135
+ "sourceType" : " module"
136
+ }
Original file line number Diff line number Diff line change
1
+ const loadDataWithGeneric = async < T > ( ) => { } ;
You can’t perform that action at this time.
0 commit comments