Skip to content

Commit f98d9c1

Browse files
authored
process: fix process.features.typescript when Amaro is unavailable
PR-URL: #55323 Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 27f8d9e commit f98d9c1

File tree

3 files changed

+28
-25
lines changed

3 files changed

+28
-25
lines changed

lib/internal/bootstrap/node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ ObjectDefineProperty(process, 'features', {
315315
const { emitWarning, emitWarningSync } = require('internal/process/warning');
316316
const { getOptionValue } = require('internal/options');
317317

318-
let kTypeStrippingMode = null;
318+
let kTypeStrippingMode = process.config.variables.node_use_amaro ? null : false;
319319
// This must be a getter, as getOptionValue does not work
320320
// before bootstrapping.
321321
ObjectDefineProperty(process.features, 'typescript', {

test/es-module/test-typescript.mjs

+25-24
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,31 @@ import * as fixtures from '../common/fixtures.mjs';
33
import { match, strictEqual } from 'node:assert';
44
import { test } from 'node:test';
55

6+
test('expect process.features.typescript to be \'strip\' when --experimental-strip-types', async () => {
7+
const result = await spawnPromisified(process.execPath, [
8+
'--no-warnings',
9+
'--experimental-strip-types',
10+
fixtures.path('typescript/echo-process-features-typescript.cjs'),
11+
]);
12+
13+
strictEqual(result.stderr, '');
14+
strictEqual(result.stdout, process.config.variables.node_use_amaro ? 'strip\n' : 'false\n');
15+
strictEqual(result.code, 0);
16+
});
17+
18+
test('expect process.features.typescript to be \'transform\' when --experimental-transform-types', async () => {
19+
const result = await spawnPromisified(process.execPath, [
20+
'--no-warnings',
21+
'--experimental-transform-types',
22+
fixtures.path('typescript/echo-process-features-typescript.cjs'),
23+
]);
24+
25+
strictEqual(result.stderr, '');
26+
strictEqual(result.stdout, process.config.variables.node_use_amaro ? 'transform\n' : 'false\n');
27+
strictEqual(result.code, 0);
28+
});
29+
30+
631
if (!process.config.variables.node_use_amaro) skip('Requires Amaro');
732

833
test('execute a TypeScript file', async () => {
@@ -353,30 +378,6 @@ test('execute a TypeScript test mocking module', { skip: isWindows && process.ar
353378
strictEqual(result.code, 0);
354379
});
355380

356-
test('expect process.features.typescript to be \'strip\' when --experimental-strip-types', async () => {
357-
const result = await spawnPromisified(process.execPath, [
358-
'--no-warnings',
359-
'--experimental-strip-types',
360-
'-p', 'process.features.typescript',
361-
]);
362-
363-
strictEqual(result.stderr, '');
364-
strictEqual(result.stdout, 'strip\n');
365-
strictEqual(result.code, 0);
366-
});
367-
368-
test('expect process.features.typescript to be \'transform\' when --experimental-transform-types', async () => {
369-
const result = await spawnPromisified(process.execPath, [
370-
'--no-warnings',
371-
'--experimental-transform-types',
372-
'-p', 'process.features.typescript',
373-
]);
374-
375-
strictEqual(result.stderr, '');
376-
strictEqual(result.stdout, 'transform\n');
377-
strictEqual(result.code, 0);
378-
});
379-
380381
test('expect process.features.typescript to be false without type-stripping', async () => {
381382
strictEqual(process.features.typescript, false);
382383
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
'use strict';
2+
console.log(process.features.typescript);

0 commit comments

Comments
 (0)