Skip to content

Commit 0655d3a

Browse files
committed
process: fix process.features.typescript when Amaro is unavailable
PR-URL: #55323 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
1 parent 3273707 commit 0655d3a

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
@@ -321,7 +321,7 @@ ObjectDefineProperty(process, 'features', {
321321
const { emitWarning, emitWarningSync } = require('internal/process/warning');
322322
const { getOptionValue } = require('internal/options');
323323

324-
let kTypeStrippingMode = null;
324+
let kTypeStrippingMode = process.config.variables.node_use_amaro ? null : false;
325325
// This must be a getter, as getOptionValue does not work
326326
// before bootstrapping.
327327
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 () => {
@@ -354,30 +379,6 @@ test('execute a TypeScript test mocking module', { skip: isWindows && process.ar
354379
strictEqual(result.code, 0);
355380
});
356381

357-
test('expect process.features.typescript to be \'strip\' when --experimental-strip-types', async () => {
358-
const result = await spawnPromisified(process.execPath, [
359-
'--no-warnings',
360-
'--experimental-strip-types',
361-
'-p', 'process.features.typescript',
362-
]);
363-
364-
strictEqual(result.stderr, '');
365-
strictEqual(result.stdout, 'strip\n');
366-
strictEqual(result.code, 0);
367-
});
368-
369-
test('expect process.features.typescript to be \'transform\' when --experimental-transform-types', async () => {
370-
const result = await spawnPromisified(process.execPath, [
371-
'--no-warnings',
372-
'--experimental-transform-types',
373-
'-p', 'process.features.typescript',
374-
]);
375-
376-
strictEqual(result.stderr, '');
377-
strictEqual(result.stdout, 'transform\n');
378-
strictEqual(result.code, 0);
379-
});
380-
381382
test('expect process.features.typescript to be false without type-stripping', async () => {
382383
strictEqual(process.features.typescript, false);
383384
});
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)