File tree Expand file tree Collapse file tree 4 files changed +56
-1
lines changed
bindings/binding_typescript_wasm/__tests__
crates/swc_fast_ts_strip/tests/errors Expand file tree Collapse file tree 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
129129}
130130` ;
131131
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+
132144exports [` transform in strip-only mode should throw an error when it encounters a namespace 1` ] = `
133145{
134146 " code" : " UnsupportedSyntax" ,
@@ -153,6 +165,15 @@ exports[`transform in strip-only mode should throw an error when it encounters a
153165}
154166` ;
155167
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+
156177exports [` transform in transform mode should throw an error when it encounters a module 1` ] = `
157178" x \` module\` keyword is not supported. Use \` namespace\` instead.
158179 ,----
Original file line number Diff line number Diff line change @@ -132,6 +132,15 @@ describe("transform", () => {
132132 ) . rejects . toMatchSnapshot ( ) ;
133133 } ) ;
134134
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+
135144 it ( "should not emit 'Caused by: failed to parse'" , async ( ) => {
136145 await expect (
137146 swc . transform ( "function foo() { await Promise.resolve(1); }" , {
@@ -171,5 +180,14 @@ describe("transform", () => {
171180 } ) ,
172181 ) . rejects . toMatchSnapshot ( ) ;
173182 } ) ;
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+ } ) ;
174192 } ) ;
175193} ) ;
Original file line number Diff line number Diff line change 55 : ^^^^^^
66 4 | export const foo = 1;
77 `----
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+ `----
821 x TypeScript namespace declaration is not supported in strip-only mode
922 ,-[3:1]
1023 2 |
Original file line number Diff line number Diff line change 22
33module Foo {
44 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