File tree 4 files changed +56
-1
lines changed
bindings/binding_typescript_wasm/__tests__
crates/swc_fast_ts_strip/tests/errors
4 files changed +56
-1
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,18 @@ exports[`transform in strip-only mode should throw an error when it encounters a
129
129
}
130
130
` ;
131
131
132
+ exports [` transform in strip-only mode should throw an error when it encounters a module 2` ] = `
133
+ {
134
+ " code" : " UnsupportedSyntax" ,
135
+ " message" : " x \` module\` keyword is not supported. Use \` namespace\` instead.
136
+ ,----
137
+ 1 | declare module foo { }
138
+ : ^^^^^^
139
+ \` ----
140
+ ",
141
+ }
142
+ ` ;
143
+
132
144
exports [` transform in strip-only mode should throw an error when it encounters a namespace 1` ] = `
133
145
{
134
146
" code" : " UnsupportedSyntax" ,
@@ -153,6 +165,15 @@ exports[`transform in strip-only mode should throw an error when it encounters a
153
165
}
154
166
` ;
155
167
168
+ exports [` transform in transform mode should throw an error when it encounters a declared module 1` ] = `
169
+ " x \` module\` keyword is not supported. Use \` namespace\` instead.
170
+ ,----
171
+ 1 | declare module foo { }
172
+ : ^^^^^^
173
+ \` ----
174
+ "
175
+ ` ;
176
+
156
177
exports [` transform in transform mode should throw an error when it encounters a module 1` ] = `
157
178
" x \` module\` keyword is not supported. Use \` namespace\` instead.
158
179
,----
Original file line number Diff line number Diff line change @@ -132,6 +132,15 @@ describe("transform", () => {
132
132
) . rejects . toMatchSnapshot ( ) ;
133
133
} ) ;
134
134
135
+ it ( "should throw an error when it encounters a module" , async ( ) => {
136
+ await expect (
137
+ swc . transform ( "declare module foo { }" , {
138
+ mode : "strip-only" ,
139
+ deprecatedTsModuleAsError : true ,
140
+ } ) ,
141
+ ) . rejects . toMatchSnapshot ( ) ;
142
+ } ) ;
143
+
135
144
it ( "should not emit 'Caused by: failed to parse'" , async ( ) => {
136
145
await expect (
137
146
swc . transform ( "function foo() { await Promise.resolve(1); }" , {
@@ -171,5 +180,14 @@ describe("transform", () => {
171
180
} ) ,
172
181
) . rejects . toMatchSnapshot ( ) ;
173
182
} ) ;
183
+
184
+ it ( "should throw an error when it encounters a declared module" , async ( ) => {
185
+ await expect (
186
+ swc . transform ( "declare module foo { }" , {
187
+ mode : "transform" ,
188
+ deprecatedTsModuleAsError : true ,
189
+ } ) ,
190
+ ) . rejects . toMatchSnapshot ( ) ;
191
+ } ) ;
174
192
} ) ;
175
193
} ) ;
Original file line number Diff line number Diff line change 5
5
: ^^^^^^
6
6
4 | export const foo = 1;
7
7
`----
8
+ x `module` keyword is not supported. Use `namespace` instead.
9
+ ,-[7:1]
10
+ 6 |
11
+ 7 | module Foo { }
12
+ : ^^^^^^
13
+ 8 | declare module Bar { }
14
+ `----
15
+ x `module` keyword is not supported. Use `namespace` instead.
16
+ ,-[8:1]
17
+ 7 | module Foo { }
18
+ 8 | declare module Bar { }
19
+ : ^^^^^^
20
+ `----
8
21
x TypeScript namespace declaration is not supported in strip-only mode
9
22
,-[3:1]
10
23
2 |
Original file line number Diff line number Diff line change 2
2
3
3
module Foo {
4
4
export const foo = 1 ;
5
- }
5
+ }
6
+
7
+ module Foo { }
8
+ declare module Bar { }
You can’t perform that action at this time.
0 commit comments