Skip to content

Commit 7c8b50f

Browse files
committed
process: add process.features.typescript
1 parent 4557c13 commit 7c8b50f

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

lib/internal/bootstrap/node.js

+12
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,18 @@ ObjectDefineProperty(process, 'features', {
319319
}
320320

321321
const { emitWarning, emitWarningSync } = require('internal/process/warning');
322+
const { getOptionValue } = require('internal/options');
323+
324+
let hasTypeScriptSupport;
325+
ObjectDefineProperty(process.features, 'typescript', {
326+
__proto__: null,
327+
get() {
328+
return hasTypeScriptSupport ??= getOptionValue('--experimental-strip-types');
329+
},
330+
configurable: false,
331+
enumerable: true
332+
})
333+
322334
process.emitWarning = emitWarning;
323335
internalBinding('process_methods').setEmitWarningSync(emitWarningSync);
324336

test/es-module/test-typescript.mjs

+10
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,13 @@ test('execute a TypeScript file with CommonJS syntax requiring .mts with require
313313
match(result.stdout, /Hello, TypeScript!/);
314314
strictEqual(result.code, 0);
315315
});
316+
317+
test('expect process.features.typescript to be true', async () => {
318+
const result = await spawnPromisified(process.execPath, [
319+
'--experimental-strip-types',
320+
'-p', 'process.features.typescript'
321+
]);
322+
323+
strictEqual(result.stdout, 'true\n');
324+
strictEqual(result.code, 0);
325+
});

0 commit comments

Comments
 (0)