mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
process: fix process.features.typescript
when Amaro is unavailable
PR-URL: https://github.com/nodejs/node/pull/55323 Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com>
This commit is contained in:
parent
27f8d9e9d2
commit
f98d9c125c
@ -315,7 +315,7 @@ ObjectDefineProperty(process, 'features', {
|
||||
const { emitWarning, emitWarningSync } = require('internal/process/warning');
|
||||
const { getOptionValue } = require('internal/options');
|
||||
|
||||
let kTypeStrippingMode = null;
|
||||
let kTypeStrippingMode = process.config.variables.node_use_amaro ? null : false;
|
||||
// This must be a getter, as getOptionValue does not work
|
||||
// before bootstrapping.
|
||||
ObjectDefineProperty(process.features, 'typescript', {
|
||||
|
@ -3,6 +3,31 @@ import * as fixtures from '../common/fixtures.mjs';
|
||||
import { match, strictEqual } from 'node:assert';
|
||||
import { test } from 'node:test';
|
||||
|
||||
test('expect process.features.typescript to be \'strip\' when --experimental-strip-types', async () => {
|
||||
const result = await spawnPromisified(process.execPath, [
|
||||
'--no-warnings',
|
||||
'--experimental-strip-types',
|
||||
fixtures.path('typescript/echo-process-features-typescript.cjs'),
|
||||
]);
|
||||
|
||||
strictEqual(result.stderr, '');
|
||||
strictEqual(result.stdout, process.config.variables.node_use_amaro ? 'strip\n' : 'false\n');
|
||||
strictEqual(result.code, 0);
|
||||
});
|
||||
|
||||
test('expect process.features.typescript to be \'transform\' when --experimental-transform-types', async () => {
|
||||
const result = await spawnPromisified(process.execPath, [
|
||||
'--no-warnings',
|
||||
'--experimental-transform-types',
|
||||
fixtures.path('typescript/echo-process-features-typescript.cjs'),
|
||||
]);
|
||||
|
||||
strictEqual(result.stderr, '');
|
||||
strictEqual(result.stdout, process.config.variables.node_use_amaro ? 'transform\n' : 'false\n');
|
||||
strictEqual(result.code, 0);
|
||||
});
|
||||
|
||||
|
||||
if (!process.config.variables.node_use_amaro) skip('Requires Amaro');
|
||||
|
||||
test('execute a TypeScript file', async () => {
|
||||
@ -353,30 +378,6 @@ test('execute a TypeScript test mocking module', { skip: isWindows && process.ar
|
||||
strictEqual(result.code, 0);
|
||||
});
|
||||
|
||||
test('expect process.features.typescript to be \'strip\' when --experimental-strip-types', async () => {
|
||||
const result = await spawnPromisified(process.execPath, [
|
||||
'--no-warnings',
|
||||
'--experimental-strip-types',
|
||||
'-p', 'process.features.typescript',
|
||||
]);
|
||||
|
||||
strictEqual(result.stderr, '');
|
||||
strictEqual(result.stdout, 'strip\n');
|
||||
strictEqual(result.code, 0);
|
||||
});
|
||||
|
||||
test('expect process.features.typescript to be \'transform\' when --experimental-transform-types', async () => {
|
||||
const result = await spawnPromisified(process.execPath, [
|
||||
'--no-warnings',
|
||||
'--experimental-transform-types',
|
||||
'-p', 'process.features.typescript',
|
||||
]);
|
||||
|
||||
strictEqual(result.stderr, '');
|
||||
strictEqual(result.stdout, 'transform\n');
|
||||
strictEqual(result.code, 0);
|
||||
});
|
||||
|
||||
test('expect process.features.typescript to be false without type-stripping', async () => {
|
||||
strictEqual(process.features.typescript, false);
|
||||
});
|
||||
|
2
test/fixtures/typescript/echo-process-features-typescript.cjs
vendored
Normal file
2
test/fixtures/typescript/echo-process-features-typescript.cjs
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
'use strict';
|
||||
console.log(process.features.typescript);
|
Loading…
Reference in New Issue
Block a user