@@ -17,6 +17,18 @@ test('execute a TypeScript file', async () => {
17
17
} ) ;
18
18
19
19
test ( 'execute a TypeScript file with imports' , async ( ) => {
20
+ const result = await spawnPromisified ( process . execPath , [
21
+ '--experimental-strip-types' ,
22
+ '--no-warnings' ,
23
+ fixtures . path ( 'typescript/ts/test-import-foo.ts' ) ,
24
+ ] ) ;
25
+
26
+ strictEqual ( result . stderr , '' ) ;
27
+ match ( result . stdout , / H e l l o , T y p e S c r i p t ! / ) ;
28
+ strictEqual ( result . code , 0 ) ;
29
+ } ) ;
30
+
31
+ test ( 'execute a TypeScript file with imports with default-type module' , async ( ) => {
20
32
const result = await spawnPromisified ( process . execPath , [
21
33
'--experimental-strip-types' ,
22
34
'--experimental-default-type=module' ,
@@ -30,6 +42,18 @@ test('execute a TypeScript file with imports', async () => {
30
42
} ) ;
31
43
32
44
test ( 'execute a TypeScript file with node_modules' , async ( ) => {
45
+ const result = await spawnPromisified ( process . execPath , [
46
+ '--experimental-strip-types' ,
47
+ '--no-warnings' ,
48
+ fixtures . path ( 'typescript/ts/test-typescript-node-modules.ts' ) ,
49
+ ] ) ;
50
+
51
+ strictEqual ( result . stderr , '' ) ;
52
+ match ( result . stdout , / H e l l o , T y p e S c r i p t ! / ) ;
53
+ strictEqual ( result . code , 0 ) ;
54
+ } ) ;
55
+
56
+ test ( 'execute a TypeScript file with node_modules with default-type module' , async ( ) => {
33
57
const result = await spawnPromisified ( process . execPath , [
34
58
'--experimental-strip-types' ,
35
59
'--experimental-default-type=module' ,
@@ -45,7 +69,6 @@ test('execute a TypeScript file with node_modules', async () => {
45
69
test ( 'expect error when executing a TypeScript file with imports with no extensions' , async ( ) => {
46
70
const result = await spawnPromisified ( process . execPath , [
47
71
'--experimental-strip-types' ,
48
- '--experimental-default-type=module' ,
49
72
fixtures . path ( 'typescript/ts/test-import-no-extension.ts' ) ,
50
73
] ) ;
51
74
@@ -54,6 +77,19 @@ test('expect error when executing a TypeScript file with imports with no extensi
54
77
strictEqual ( result . code , 1 ) ;
55
78
} ) ;
56
79
80
+ test ( 'expect error when executing a TypeScript file with imports with no extensions with default-type module' ,
81
+ async ( ) => {
82
+ const result = await spawnPromisified ( process . execPath , [
83
+ '--experimental-strip-types' ,
84
+ '--experimental-default-type=module' ,
85
+ fixtures . path ( 'typescript/ts/test-import-no-extension.ts' ) ,
86
+ ] ) ;
87
+
88
+ 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 \] : / ) ;
89
+ strictEqual ( result . stdout , '' ) ;
90
+ strictEqual ( result . code , 1 ) ;
91
+ } ) ;
92
+
57
93
test ( 'expect error when executing a TypeScript file with enum' , async ( ) => {
58
94
const result = await spawnPromisified ( process . execPath , [
59
95
'--experimental-strip-types' ,
@@ -101,6 +137,17 @@ test('execute a TypeScript file with type definition', async () => {
101
137
} ) ;
102
138
103
139
test ( 'execute a TypeScript file with type definition but no type keyword' , async ( ) => {
140
+ const result = await spawnPromisified ( process . execPath , [
141
+ '--experimental-strip-types' ,
142
+ fixtures . path ( 'typescript/ts/test-import-no-type-keyword.ts' ) ,
143
+ ] ) ;
144
+
145
+ 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 ' / ) ;
146
+ strictEqual ( result . stdout , '' ) ;
147
+ strictEqual ( result . code , 1 ) ;
148
+ } ) ;
149
+
150
+ test ( 'execute a TypeScript file with type definition but no type keyword with default-type modue' , async ( ) => {
104
151
const result = await spawnPromisified ( process . execPath , [
105
152
'--experimental-strip-types' ,
106
153
'--experimental-default-type=module' ,
@@ -124,6 +171,18 @@ test('execute a TypeScript file with CommonJS syntax', async () => {
124
171
} ) ;
125
172
126
173
test ( 'execute a TypeScript file with ES module syntax' , async ( ) => {
174
+ const result = await spawnPromisified ( process . execPath , [
175
+ '--experimental-strip-types' ,
176
+ '--no-warnings' ,
177
+ fixtures . path ( 'typescript/ts/test-module-typescript.ts' ) ,
178
+ ] ) ;
179
+
180
+ strictEqual ( result . stderr , '' ) ;
181
+ match ( result . stdout , / H e l l o , T y p e S c r i p t ! / ) ;
182
+ strictEqual ( result . code , 0 ) ;
183
+ } ) ;
184
+
185
+ test ( 'execute a TypeScript file with ES module syntax with default-type module' , async ( ) => {
127
186
const result = await spawnPromisified ( process . execPath , [
128
187
'--experimental-strip-types' ,
129
188
'--experimental-default-type=module' ,
@@ -161,7 +220,6 @@ test('expect stack trace of a TypeScript file to be correct', async () => {
161
220
162
221
test ( 'execute CommonJS TypeScript file from node_modules with require-module' , async ( ) => {
163
222
const result = await spawnPromisified ( process . execPath , [
164
- '--experimental-default-type=module' ,
165
223
'--experimental-strip-types' ,
166
224
fixtures . path ( 'typescript/ts/test-import-ts-node-modules.ts' ) ,
167
225
] ) ;
@@ -171,6 +229,19 @@ test('execute CommonJS TypeScript file from node_modules with require-module', a
171
229
strictEqual ( result . code , 1 ) ;
172
230
} ) ;
173
231
232
+ test ( 'execute CommonJS TypeScript file from node_modules with require-module and default-type module' ,
233
+ async ( ) => {
234
+ const result = await spawnPromisified ( process . execPath , [
235
+ '--experimental-strip-types' ,
236
+ '--experimental-default-type=module' ,
237
+ fixtures . path ( 'typescript/ts/test-import-ts-node-modules.ts' ) ,
238
+ ] ) ;
239
+
240
+ 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 / ) ;
241
+ strictEqual ( result . stdout , '' ) ;
242
+ strictEqual ( result . code , 1 ) ;
243
+ } ) ;
244
+
174
245
test ( 'execute a TypeScript file with CommonJS syntax but default type module' , async ( ) => {
175
246
const result = await spawnPromisified ( process . execPath , [
176
247
'--experimental-strip-types' ,
@@ -220,7 +291,6 @@ test('execute a TypeScript file with CommonJS syntax requiring .mts with require
220
291
test ( 'execute a TypeScript file with CommonJS syntax requiring .mts with require-module' , async ( ) => {
221
292
const result = await spawnPromisified ( process . execPath , [
222
293
'--experimental-strip-types' ,
223
- '--experimental-default-type=commonjs' ,
224
294
'--no-warnings' ,
225
295
fixtures . path ( 'typescript/ts/test-require-cts.ts' ) ,
226
296
] ) ;
@@ -229,3 +299,17 @@ test('execute a TypeScript file with CommonJS syntax requiring .mts with require
229
299
match ( result . stdout , / H e l l o , T y p e S c r i p t ! / ) ;
230
300
strictEqual ( result . code , 0 ) ;
231
301
} ) ;
302
+
303
+ test ( 'execute a TypeScript file with CommonJS syntax requiring .mts with require-module with default-type commonjs' ,
304
+ async ( ) => {
305
+ const result = await spawnPromisified ( process . execPath , [
306
+ '--experimental-strip-types' ,
307
+ '--experimental-default-type=commonjs' ,
308
+ '--no-warnings' ,
309
+ fixtures . path ( 'typescript/ts/test-require-cts.ts' ) ,
310
+ ] ) ;
311
+
312
+ strictEqual ( result . stderr , '' ) ;
313
+ match ( result . stdout , / H e l l o , T y p e S c r i p t ! / ) ;
314
+ strictEqual ( result . code , 0 ) ;
315
+ } ) ;
0 commit comments