Skip to content

Commit

Permalink
process: add process.features.typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
RedYetiDev committed Aug 10, 2024
1 parent 4557c13 commit 7c8b50f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,18 @@ ObjectDefineProperty(process, 'features', {
}

const { emitWarning, emitWarningSync } = require('internal/process/warning');
const { getOptionValue } = require('internal/options');

let hasTypeScriptSupport;
ObjectDefineProperty(process.features, 'typescript', {
__proto__: null,
get() {
return hasTypeScriptSupport ??= getOptionValue('--experimental-strip-types');
},
configurable: false,
enumerable: true

Check failure on line 331 in lib/internal/bootstrap/node.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing trailing comma
})

Check failure on line 332 in lib/internal/bootstrap/node.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing semicolon

process.emitWarning = emitWarning;
internalBinding('process_methods').setEmitWarningSync(emitWarningSync);

Expand Down
10 changes: 10 additions & 0 deletions test/es-module/test-typescript.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,13 @@ test('execute a TypeScript file with CommonJS syntax requiring .mts with require
match(result.stdout, /Hello, TypeScript!/);
strictEqual(result.code, 0);
});

test('expect process.features.typescript to be true', async () => {
const result = await spawnPromisified(process.execPath, [

Check failure on line 318 in test/es-module/test-typescript.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected indentation of 2 spaces but found 0
'--experimental-strip-types',

Check failure on line 319 in test/es-module/test-typescript.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected indentation of 4 spaces but found 2
'-p', 'process.features.typescript'

Check failure on line 320 in test/es-module/test-typescript.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected indentation of 4 spaces but found 2

Check failure on line 320 in test/es-module/test-typescript.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Missing trailing comma
]);

Check failure on line 321 in test/es-module/test-typescript.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected indentation of 2 spaces but found 0

strictEqual(result.stdout, 'true\n');

Check failure on line 323 in test/es-module/test-typescript.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected indentation of 2 spaces but found 0
strictEqual(result.code, 0);

Check failure on line 324 in test/es-module/test-typescript.mjs

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected indentation of 2 spaces but found 0
});

0 comments on commit 7c8b50f

Please sign in to comment.