File tree 6 files changed +257
-1
lines changed
tests/typescript/issue-8627
6 files changed +257
-1
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ swc_ecma_parser : patch
3
+ swc_core : patch
4
+ ---
5
+
6
+ fix(es/parser): Fix failure of TS instantiation followed by satisfies
Original file line number Diff line number Diff line change @@ -1245,7 +1245,7 @@ impl<I: Tokens> Parser<I> {
1245
1245
)
1246
1246
. map ( |expr| ( expr. into ( ) , true ) )
1247
1247
. map ( Some )
1248
- } else if is_one_of ! ( p, '=' , "as" ) {
1248
+ } else if is_one_of ! ( p, '=' , "as" , "satisfies" ) {
1249
1249
Ok ( Some ( (
1250
1250
TsInstantiation {
1251
1251
span : span ! ( p, start) ,
Original file line number Diff line number Diff line change
1
+ class Module < T > { }
2
+
3
+ export default Module < number > as unknown ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "type" : " Module" ,
3
+ "span" : {
4
+ "start" : 1 ,
5
+ "end" : 62
6
+ },
7
+ "body" : [
8
+ {
9
+ "type" : " ClassDeclaration" ,
10
+ "identifier" : {
11
+ "type" : " Identifier" ,
12
+ "span" : {
13
+ "start" : 7 ,
14
+ "end" : 13
15
+ },
16
+ "ctxt" : 0 ,
17
+ "value" : " Module" ,
18
+ "optional" : false
19
+ },
20
+ "declare" : false ,
21
+ "span" : {
22
+ "start" : 1 ,
23
+ "end" : 19
24
+ },
25
+ "ctxt" : 0 ,
26
+ "decorators" : [],
27
+ "body" : [],
28
+ "superClass" : null ,
29
+ "isAbstract" : false ,
30
+ "typeParams" : {
31
+ "type" : " TsTypeParameterDeclaration" ,
32
+ "span" : {
33
+ "start" : 13 ,
34
+ "end" : 16
35
+ },
36
+ "parameters" : [
37
+ {
38
+ "type" : " TsTypeParameter" ,
39
+ "span" : {
40
+ "start" : 14 ,
41
+ "end" : 15
42
+ },
43
+ "name" : {
44
+ "type" : " Identifier" ,
45
+ "span" : {
46
+ "start" : 14 ,
47
+ "end" : 15
48
+ },
49
+ "ctxt" : 0 ,
50
+ "value" : " T" ,
51
+ "optional" : false
52
+ },
53
+ "in" : false ,
54
+ "out" : false ,
55
+ "const" : false ,
56
+ "constraint" : null ,
57
+ "default" : null
58
+ }
59
+ ]
60
+ },
61
+ "superTypeParams" : null ,
62
+ "implements" : []
63
+ },
64
+ {
65
+ "type" : " ExportDefaultExpression" ,
66
+ "span" : {
67
+ "start" : 21 ,
68
+ "end" : 62
69
+ },
70
+ "expression" : {
71
+ "type" : " TsAsExpression" ,
72
+ "span" : {
73
+ "start" : 36 ,
74
+ "end" : 61
75
+ },
76
+ "expression" : {
77
+ "type" : " TsInstantiation" ,
78
+ "span" : {
79
+ "start" : 36 ,
80
+ "end" : 50
81
+ },
82
+ "expression" : {
83
+ "type" : " Identifier" ,
84
+ "span" : {
85
+ "start" : 36 ,
86
+ "end" : 42
87
+ },
88
+ "ctxt" : 0 ,
89
+ "value" : " Module" ,
90
+ "optional" : false
91
+ },
92
+ "typeArguments" : {
93
+ "type" : " TsTypeParameterInstantiation" ,
94
+ "span" : {
95
+ "start" : 42 ,
96
+ "end" : 50
97
+ },
98
+ "params" : [
99
+ {
100
+ "type" : " TsKeywordType" ,
101
+ "span" : {
102
+ "start" : 43 ,
103
+ "end" : 49
104
+ },
105
+ "kind" : " number"
106
+ }
107
+ ]
108
+ }
109
+ },
110
+ "typeAnnotation" : {
111
+ "type" : " TsKeywordType" ,
112
+ "span" : {
113
+ "start" : 54 ,
114
+ "end" : 61
115
+ },
116
+ "kind" : " unknown"
117
+ }
118
+ }
119
+ }
120
+ ],
121
+ "interpreter" : null
122
+ }
Original file line number Diff line number Diff line change
1
+ class Module < T > { }
2
+
3
+ export default Module < number > satisfies unknown ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "type" : " Module" ,
3
+ "span" : {
4
+ "start" : 1 ,
5
+ "end" : 69
6
+ },
7
+ "body" : [
8
+ {
9
+ "type" : " ClassDeclaration" ,
10
+ "identifier" : {
11
+ "type" : " Identifier" ,
12
+ "span" : {
13
+ "start" : 7 ,
14
+ "end" : 13
15
+ },
16
+ "ctxt" : 0 ,
17
+ "value" : " Module" ,
18
+ "optional" : false
19
+ },
20
+ "declare" : false ,
21
+ "span" : {
22
+ "start" : 1 ,
23
+ "end" : 19
24
+ },
25
+ "ctxt" : 0 ,
26
+ "decorators" : [],
27
+ "body" : [],
28
+ "superClass" : null ,
29
+ "isAbstract" : false ,
30
+ "typeParams" : {
31
+ "type" : " TsTypeParameterDeclaration" ,
32
+ "span" : {
33
+ "start" : 13 ,
34
+ "end" : 16
35
+ },
36
+ "parameters" : [
37
+ {
38
+ "type" : " TsTypeParameter" ,
39
+ "span" : {
40
+ "start" : 14 ,
41
+ "end" : 15
42
+ },
43
+ "name" : {
44
+ "type" : " Identifier" ,
45
+ "span" : {
46
+ "start" : 14 ,
47
+ "end" : 15
48
+ },
49
+ "ctxt" : 0 ,
50
+ "value" : " T" ,
51
+ "optional" : false
52
+ },
53
+ "in" : false ,
54
+ "out" : false ,
55
+ "const" : false ,
56
+ "constraint" : null ,
57
+ "default" : null
58
+ }
59
+ ]
60
+ },
61
+ "superTypeParams" : null ,
62
+ "implements" : []
63
+ },
64
+ {
65
+ "type" : " ExportDefaultExpression" ,
66
+ "span" : {
67
+ "start" : 21 ,
68
+ "end" : 69
69
+ },
70
+ "expression" : {
71
+ "type" : " TsSatisfiesExpression" ,
72
+ "span" : {
73
+ "start" : 36 ,
74
+ "end" : 68
75
+ },
76
+ "expression" : {
77
+ "type" : " TsInstantiation" ,
78
+ "span" : {
79
+ "start" : 36 ,
80
+ "end" : 50
81
+ },
82
+ "expression" : {
83
+ "type" : " Identifier" ,
84
+ "span" : {
85
+ "start" : 36 ,
86
+ "end" : 42
87
+ },
88
+ "ctxt" : 0 ,
89
+ "value" : " Module" ,
90
+ "optional" : false
91
+ },
92
+ "typeArguments" : {
93
+ "type" : " TsTypeParameterInstantiation" ,
94
+ "span" : {
95
+ "start" : 42 ,
96
+ "end" : 50
97
+ },
98
+ "params" : [
99
+ {
100
+ "type" : " TsKeywordType" ,
101
+ "span" : {
102
+ "start" : 43 ,
103
+ "end" : 49
104
+ },
105
+ "kind" : " number"
106
+ }
107
+ ]
108
+ }
109
+ },
110
+ "typeAnnotation" : {
111
+ "type" : " TsKeywordType" ,
112
+ "span" : {
113
+ "start" : 61 ,
114
+ "end" : 68
115
+ },
116
+ "kind" : " unknown"
117
+ }
118
+ }
119
+ }
120
+ ],
121
+ "interpreter" : null
122
+ }
You can’t perform that action at this time.
0 commit comments