@@ -15,6 +15,18 @@ test('execute a TypeScript file', async () => {
1515} ) ;
1616
1717test ( 'execute a TypeScript file with imports' , async ( ) => {
18+ const result = await spawnPromisified ( process . execPath , [
19+ '--experimental-strip-types' ,
20+ '--no-warnings' ,
21+ fixtures . path ( 'typescript/ts/test-import-foo.ts' ) ,
22+ ] ) ;
23+
24+ strictEqual ( result . stderr , '' ) ;
25+ match ( result . stdout , / H e l l o , T y p e S c r i p t ! / ) ;
26+ strictEqual ( result . code , 0 ) ;
27+ } ) ;
28+
29+ test ( 'execute a TypeScript file with imports with default-type module' , async ( ) => {
1830 const result = await spawnPromisified ( process . execPath , [
1931 '--experimental-strip-types' ,
2032 '--experimental-default-type=module' ,
@@ -28,6 +40,18 @@ test('execute a TypeScript file with imports', async () => {
2840} ) ;
2941
3042test ( 'execute a TypeScript file with node_modules' , async ( ) => {
43+ const result = await spawnPromisified ( process . execPath , [
44+ '--experimental-strip-types' ,
45+ '--no-warnings' ,
46+ fixtures . path ( 'typescript/ts/test-typescript-node-modules.ts' ) ,
47+ ] ) ;
48+
49+ strictEqual ( result . stderr , '' ) ;
50+ match ( result . stdout , / H e l l o , T y p e S c r i p t ! / ) ;
51+ strictEqual ( result . code , 0 ) ;
52+ } ) ;
53+
54+ test ( 'execute a TypeScript file with node_modules with default-type module' , async ( ) => {
3155 const result = await spawnPromisified ( process . execPath , [
3256 '--experimental-strip-types' ,
3357 '--experimental-default-type=module' ,
@@ -43,7 +67,6 @@ test('execute a TypeScript file with node_modules', async () => {
4367test ( 'expect error when executing a TypeScript file with imports with no extensions' , async ( ) => {
4468 const result = await spawnPromisified ( process . execPath , [
4569 '--experimental-strip-types' ,
46- '--experimental-default-type=module' ,
4770 fixtures . path ( 'typescript/ts/test-import-no-extension.ts' ) ,
4871 ] ) ;
4972
@@ -52,6 +75,19 @@ test('expect error when executing a TypeScript file with imports with no extensi
5275 strictEqual ( result . code , 1 ) ;
5376} ) ;
5477
78+ test ( 'expect error when executing a TypeScript file with imports with no extensions with default-type module' ,
79+ async ( ) => {
80+ const result = await spawnPromisified ( process . execPath , [
81+ '--experimental-strip-types' ,
82+ '--experimental-default-type=module' ,
83+ fixtures . path ( 'typescript/ts/test-import-no-extension.ts' ) ,
84+ ] ) ;
85+
86+ match ( result . stderr , / E r r o r \[ E R R _ M O D U L E _ N O T _ F O U N D \] : / ) ;
87+ strictEqual ( result . stdout , '' ) ;
88+ strictEqual ( result . code , 1 ) ;
89+ } ) ;
90+
5591test ( 'expect error when executing a TypeScript file with enum' , async ( ) => {
5692 const result = await spawnPromisified ( process . execPath , [
5793 '--experimental-strip-types' ,
@@ -99,6 +135,17 @@ test('execute a TypeScript file with type definition', async () => {
99135} ) ;
100136
101137test ( 'execute a TypeScript file with type definition but no type keyword' , async ( ) => {
138+ const result = await spawnPromisified ( process . execPath , [
139+ '--experimental-strip-types' ,
140+ fixtures . path ( 'typescript/ts/test-import-no-type-keyword.ts' ) ,
141+ ] ) ;
142+
143+ match ( result . stderr , / d o e s n o t p r o v i d e a n e x p o r t n a m e d ' M y T y p e ' / ) ;
144+ strictEqual ( result . stdout , '' ) ;
145+ strictEqual ( result . code , 1 ) ;
146+ } ) ;
147+
148+ test ( 'execute a TypeScript file with type definition but no type keyword with default-type modue' , async ( ) => {
102149 const result = await spawnPromisified ( process . execPath , [
103150 '--experimental-strip-types' ,
104151 '--experimental-default-type=module' ,
@@ -122,6 +169,18 @@ test('execute a TypeScript file with CommonJS syntax', async () => {
122169} ) ;
123170
124171test ( 'execute a TypeScript file with ES module syntax' , async ( ) => {
172+ const result = await spawnPromisified ( process . execPath , [
173+ '--experimental-strip-types' ,
174+ '--no-warnings' ,
175+ fixtures . path ( 'typescript/ts/test-module-typescript.ts' ) ,
176+ ] ) ;
177+
178+ strictEqual ( result . stderr , '' ) ;
179+ match ( result . stdout , / H e l l o , T y p e S c r i p t ! / ) ;
180+ strictEqual ( result . code , 0 ) ;
181+ } ) ;
182+
183+ test ( 'execute a TypeScript file with ES module syntax with default-type module' , async ( ) => {
125184 const result = await spawnPromisified ( process . execPath , [
126185 '--experimental-strip-types' ,
127186 '--experimental-default-type=module' ,
@@ -159,7 +218,6 @@ test('expect stack trace of a TypeScript file to be correct', async () => {
159218
160219test ( 'execute CommonJS TypeScript file from node_modules with require-module' , async ( ) => {
161220 const result = await spawnPromisified ( process . execPath , [
162- '--experimental-default-type=module' ,
163221 '--experimental-strip-types' ,
164222 fixtures . path ( 'typescript/ts/test-import-ts-node-modules.ts' ) ,
165223 ] ) ;
@@ -169,6 +227,19 @@ test('execute CommonJS TypeScript file from node_modules with require-module', a
169227 strictEqual ( result . code , 1 ) ;
170228} ) ;
171229
230+ test ( 'execute CommonJS TypeScript file from node_modules with require-module and default-type module' ,
231+ async ( ) => {
232+ const result = await spawnPromisified ( process . execPath , [
233+ '--experimental-strip-types' ,
234+ '--experimental-default-type=module' ,
235+ fixtures . path ( 'typescript/ts/test-import-ts-node-modules.ts' ) ,
236+ ] ) ;
237+
238+ match ( result . stderr , / E R R _ U N S U P P O R T E D _ N O D E _ M O D U L E S _ T Y P E _ S T R I P P I N G / ) ;
239+ strictEqual ( result . stdout , '' ) ;
240+ strictEqual ( result . code , 1 ) ;
241+ } ) ;
242+
172243test ( 'execute a TypeScript file with CommonJS syntax but default type module' , async ( ) => {
173244 const result = await spawnPromisified ( process . execPath , [
174245 '--experimental-strip-types' ,
@@ -218,7 +289,6 @@ test('execute a TypeScript file with CommonJS syntax requiring .mts with require
218289test ( 'execute a TypeScript file with CommonJS syntax requiring .mts with require-module' , async ( ) => {
219290 const result = await spawnPromisified ( process . execPath , [
220291 '--experimental-strip-types' ,
221- '--experimental-default-type=commonjs' ,
222292 '--no-warnings' ,
223293 fixtures . path ( 'typescript/ts/test-require-cts.ts' ) ,
224294 ] ) ;
@@ -227,3 +297,17 @@ test('execute a TypeScript file with CommonJS syntax requiring .mts with require
227297 match ( result . stdout , / H e l l o , T y p e S c r i p t ! / ) ;
228298 strictEqual ( result . code , 0 ) ;
229299} ) ;
300+
301+ test ( 'execute a TypeScript file with CommonJS syntax requiring .mts with require-module with default-type commonjs' ,
302+ async ( ) => {
303+ const result = await spawnPromisified ( process . execPath , [
304+ '--experimental-strip-types' ,
305+ '--experimental-default-type=commonjs' ,
306+ '--no-warnings' ,
307+ fixtures . path ( 'typescript/ts/test-require-cts.ts' ) ,
308+ ] ) ;
309+
310+ strictEqual ( result . stderr , '' ) ;
311+ match ( result . stdout , / H e l l o , T y p e S c r i p t ! / ) ;
312+ strictEqual ( result . code , 0 ) ;
313+ } ) ;
0 commit comments