@@ -15,6 +15,18 @@ test('execute a TypeScript file', async () => {
15
15
} ) ;
16
16
17
17
test ( '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 ( ) => {
18
30
const result = await spawnPromisified ( process . execPath , [
19
31
'--experimental-strip-types' ,
20
32
'--experimental-default-type=module' ,
@@ -28,6 +40,18 @@ test('execute a TypeScript file with imports', async () => {
28
40
} ) ;
29
41
30
42
test ( '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 ( ) => {
31
55
const result = await spawnPromisified ( process . execPath , [
32
56
'--experimental-strip-types' ,
33
57
'--experimental-default-type=module' ,
@@ -43,7 +67,6 @@ test('execute a TypeScript file with node_modules', async () => {
43
67
test ( 'expect error when executing a TypeScript file with imports with no extensions' , async ( ) => {
44
68
const result = await spawnPromisified ( process . execPath , [
45
69
'--experimental-strip-types' ,
46
- '--experimental-default-type=module' ,
47
70
fixtures . path ( 'typescript/ts/test-import-no-extension.ts' ) ,
48
71
] ) ;
49
72
@@ -52,6 +75,19 @@ test('expect error when executing a TypeScript file with imports with no extensi
52
75
strictEqual ( result . code , 1 ) ;
53
76
} ) ;
54
77
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
+
55
91
test ( 'expect error when executing a TypeScript file with enum' , async ( ) => {
56
92
const result = await spawnPromisified ( process . execPath , [
57
93
'--experimental-strip-types' ,
@@ -99,6 +135,17 @@ test('execute a TypeScript file with type definition', async () => {
99
135
} ) ;
100
136
101
137
test ( '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 ( ) => {
102
149
const result = await spawnPromisified ( process . execPath , [
103
150
'--experimental-strip-types' ,
104
151
'--experimental-default-type=module' ,
@@ -122,6 +169,18 @@ test('execute a TypeScript file with CommonJS syntax', async () => {
122
169
} ) ;
123
170
124
171
test ( '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 ( ) => {
125
184
const result = await spawnPromisified ( process . execPath , [
126
185
'--experimental-strip-types' ,
127
186
'--experimental-default-type=module' ,
@@ -159,7 +218,6 @@ test('expect stack trace of a TypeScript file to be correct', async () => {
159
218
160
219
test ( 'execute CommonJS TypeScript file from node_modules with require-module' , async ( ) => {
161
220
const result = await spawnPromisified ( process . execPath , [
162
- '--experimental-default-type=module' ,
163
221
'--experimental-strip-types' ,
164
222
fixtures . path ( 'typescript/ts/test-import-ts-node-modules.ts' ) ,
165
223
] ) ;
@@ -169,6 +227,19 @@ test('execute CommonJS TypeScript file from node_modules with require-module', a
169
227
strictEqual ( result . code , 1 ) ;
170
228
} ) ;
171
229
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
+
172
243
test ( 'execute a TypeScript file with CommonJS syntax but default type module' , async ( ) => {
173
244
const result = await spawnPromisified ( process . execPath , [
174
245
'--experimental-strip-types' ,
@@ -218,7 +289,6 @@ test('execute a TypeScript file with CommonJS syntax requiring .mts with require
218
289
test ( 'execute a TypeScript file with CommonJS syntax requiring .mts with require-module' , async ( ) => {
219
290
const result = await spawnPromisified ( process . execPath , [
220
291
'--experimental-strip-types' ,
221
- '--experimental-default-type=commonjs' ,
222
292
'--no-warnings' ,
223
293
fixtures . path ( 'typescript/ts/test-require-cts.ts' ) ,
224
294
] ) ;
@@ -227,3 +297,17 @@ test('execute a TypeScript file with CommonJS syntax requiring .mts with require
227
297
match ( result . stdout , / H e l l o , T y p e S c r i p t ! / ) ;
228
298
strictEqual ( result . code , 0 ) ;
229
299
} ) ;
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