Skip to content
2 changes: 1 addition & 1 deletion src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
"Type-stripping for TypeScript files.",
&EnvironmentOptions::strip_types,
kAllowedInEnvvar,
true);
HAVE_AMARO);
AddAlias("--experimental-strip-types", "--strip-types");
AddOption("--experimental-transform-types",
"enable transformation of TypeScript-only"
Expand Down
2 changes: 1 addition & 1 deletion src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ class EnvironmentOptions : public Options {

std::vector<std::string> preload_esm_modules;

bool strip_types = true;
bool strip_types = HAVE_AMARO;
bool experimental_transform_types = false;

std::vector<std::string> user_argv;
Expand Down
8 changes: 5 additions & 3 deletions test/es-module/test-esm-import-meta-main-eval.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ function wrapScriptInUrlWorker(script) {
`;
}

const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };

describe('import.meta.main in evaluated scripts', () => {
const importMetaMainScript = `
import assert from 'node:assert/strict';
Expand Down Expand Up @@ -85,7 +87,7 @@ const { isMain: importedModuleIsMain } = await import(
assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluate false in imported module');
`;

it('should evaluate true in evaluated script', async () => {
it('should evaluate true in evaluated script', onlyWithAmaro, async () => {
const result = await spawnPromisified(
process.execPath,
['--input-type=module-typescript', '--disable-warning=ExperimentalWarning', '--eval', importMetaMainTSScript],
Expand All @@ -98,7 +100,7 @@ assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluat
});
});

it('should evaluate true in worker instantiated with module source by evaluated script', async () => {
it('should evaluate true in worker instantiated with module source by evaluated script', onlyWithAmaro, async () => {
const result = await spawnPromisified(
process.execPath,
['--input-type=module-typescript',
Expand All @@ -114,7 +116,7 @@ assert.strictEqual(importedModuleIsMain, false, 'import.meta.main should evaluat
});
});

it('should evaluate true in worker instantiated with `data:` URL by evaluated script', async () => {
it('should evaluate true in worker instantiated with `data:` URL by evaluated script', onlyWithAmaro, async () => {
const result = await spawnPromisified(
process.execPath,
['--input-type=module',
Expand Down
4 changes: 3 additions & 1 deletion test/es-module/test-esm-loader-entry-url.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ async function assertSpawnedProcess(args, options = {}, expected = {}) {
// Common expectation for experimental feature warning in stderr
const experimentalFeatureWarning = { stderr: /--entry-url is an experimental feature/ };

const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };

describe('--entry-url', { concurrency: true }, () => {
it('should reject loading a path that contains %', async () => {
await assertSpawnedProcess(
Expand Down Expand Up @@ -76,7 +78,7 @@ describe('--entry-url', { concurrency: true }, () => {
);
});

it('should support loading TypeScript URLs', { skip: !process.config.variables.node_use_amaro }, async () => {
it('should support loading TypeScript URLs', onlyWithAmaro, async () => {
const typescriptUrls = [
'typescript/cts/test-require-ts-file.cts',
'typescript/mts/test-import-ts-file.mts',
Expand Down
4 changes: 4 additions & 0 deletions test/es-module/test-esm-resolve-type.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ try {
subdirPackageType,
expectedResolvedFormat,
mainSuffix = '' ] = testVariant;
const skip = mainImportScript.endsWith('.ts') && !process.config.variables.node_use_amaro;
if (skip) {
return;
}

const mDir = rel(`node_modules/${moduleName}`);
const subDir = rel(`node_modules/${moduleName}/subdir`);
Expand Down
5 changes: 5 additions & 0 deletions test/parallel/test-cli-node-options-docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ for (const [, envVar, config] of nodeOptionsCC.matchAll(addOptionRE)) {
hasTrueAsDefaultValue = true;
}

// Exception for HAVE_AMARO conditional default (defaults to true when Amaro is available)
if (config.includes('HAVE_AMARO')) {
hasTrueAsDefaultValue = true;
}

if (
envVar.startsWith('[') ||
deprecated.includes(envVar) ||
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-compile-cache-typescript-commonjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

// This tests NODE_COMPILE_CACHE works for CommonJS with types.

require('../common');
const common = require('../common');
if (!process.config.variables.node_use_amaro) {
common.skip('Requires Amaro');
}
const { spawnSyncAndAssert } = require('../common/child_process');
const assert = require('assert');
const tmpdir = require('../common/tmpdir');
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-compile-cache-typescript-esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

// This tests NODE_COMPILE_CACHE works for ESM with types.

require('../common');
const common = require('../common');
if (!process.config.variables.node_use_amaro) {
common.skip('Requires Amaro');
}
const { spawnSyncAndAssert } = require('../common/child_process');
const assert = require('assert');
const tmpdir = require('../common/tmpdir');
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-compile-cache-typescript-strip-miss.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
// This tests NODE_COMPILE_CACHE can handle cache invalidation
// between strip-only TypeScript and transformed TypeScript.

require('../common');
const common = require('../common');
if (!process.config.variables.node_use_amaro) {
common.skip('Requires Amaro');
}
const { spawnSyncAndAssert } = require('../common/child_process');
const assert = require('assert');
const tmpdir = require('../common/tmpdir');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
// This tests NODE_COMPILE_CACHE can be used for type stripping and ignores
// --enable-source-maps as there's no difference in the code generated.

require('../common');
const common = require('../common');
if (!process.config.variables.node_use_amaro) {
common.skip('Requires Amaro');
}
const { spawnSyncAndAssert } = require('../common/child_process');
const assert = require('assert');
const tmpdir = require('../common/tmpdir');
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-compile-cache-typescript-transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

// This tests NODE_COMPILE_CACHE works with --experimental-transform-types.

require('../common');
const common = require('../common');
if (!process.config.variables.node_use_amaro) {
common.skip('Requires Amaro');
}
const { spawnSyncAndAssert } = require('../common/child_process');
const assert = require('assert');
const tmpdir = require('../common/tmpdir');
Expand Down
11 changes: 6 additions & 5 deletions test/parallel/test-config-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const { test, it, describe } = require('node:test');
const { chmodSync, writeFileSync, constants } = require('node:fs');
const { join } = require('node:path');

const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };

test('should handle non existing json', async () => {
const result = await spawnPromisified(process.execPath, [
'--experimental-config-file',
Expand Down Expand Up @@ -49,7 +51,7 @@ test('should handle empty object json', async () => {
assert.strictEqual(result.code, 0);
});

test('should parse boolean flag', async () => {
test('should parse boolean flag', onlyWithAmaro, async () => {
const result = await spawnPromisified(process.execPath, [
'--experimental-config-file',
fixtures.path('rc/transform-types.json'),
Expand Down Expand Up @@ -83,8 +85,7 @@ test('should throw an error when a flag is declared twice', async () => {
assert.strictEqual(result.code, 9);
});


test('should override env-file', async () => {
test('should override env-file', onlyWithAmaro, async () => {
const result = await spawnPromisified(process.execPath, [
'--no-warnings',
'--experimental-config-file',
Expand All @@ -97,7 +98,7 @@ test('should override env-file', async () => {
assert.strictEqual(result.code, 0);
});

test('should not override NODE_OPTIONS', async () => {
test('should not override NODE_OPTIONS', onlyWithAmaro, async () => {
const result = await spawnPromisified(process.execPath, [
'--no-warnings',
'--experimental-config-file',
Expand All @@ -114,7 +115,7 @@ test('should not override NODE_OPTIONS', async () => {
assert.strictEqual(result.code, 1);
});

test('should not override CLI flags', async () => {
test('should not override CLI flags', onlyWithAmaro, async () => {
const result = await spawnPromisified(process.execPath, [
'--no-warnings',
'--no-experimental-transform-types',
Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-node-output-eval.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import '../common/index.mjs';
import * as common from '../common/index.mjs';
if (!process.config.variables.node_use_amaro) {
common.skip('Requires Amaro');
}
import * as fixtures from '../common/fixtures.mjs';
import * as snapshot from '../common/assertSnapshot.js';
import { basename } from 'node:path';
Expand Down
3 changes: 2 additions & 1 deletion test/parallel/test-node-output-sourcemaps.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ describe('sourcemaps output', { concurrency: !process.env.TEST_PARALLEL }, () =>
{ name: 'source-map/output/source_map_throw_set_immediate.js' },
];
for (const { name, transform } of tests) {
it(name, async () => {
const skip = name.endsWith('.ts') && !process.config.variables.node_use_amaro;
it(name, { skip }, async () => {
await snapshot.spawnAndAssert(fixtures.path(name), transform ?? defaultTransform);
});
}
Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-runner-global-setup-teardown.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { join } from 'node:path';

const testFixtures = fixtures.path('test-runner');

const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };

async function runTest(
{
isolation,
Expand Down Expand Up @@ -256,7 +258,7 @@ async function runTest(
'Teardown should not run after setup fails');
});

it('should run TypeScript globalSetup and globalTeardown functions', async () => {
it('should run TypeScript globalSetup and globalTeardown functions', onlyWithAmaro, async () => {
const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp');
const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp');

Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-runner-run-global-hooks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import path from 'node:path';
import { spawn } from 'node:child_process';
import { once } from 'node:events';

const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };

const testFixtures = fixtures.path('test-runner', 'global-setup-teardown');
const runnerFixture = fixtures.path('test-runner', 'test-runner-global-hooks.mjs');

Expand Down Expand Up @@ -162,7 +164,7 @@ describe('require(\'node:test\').run with global hooks', { concurrency: false },
assert.strictEqual(content, 'Setup part, Teardown part');
});

it('should run TypeScript globalSetup and globalTeardown functions', async () => {
it('should run TypeScript globalSetup and globalTeardown functions', onlyWithAmaro, async () => {
const setupFlagPath = tmpdir.resolve('setup-executed-ts.tmp');
const teardownFlagPath = tmpdir.resolve('teardown-executed-ts.tmp');

Expand Down
4 changes: 3 additions & 1 deletion test/parallel/test-util-getcallsites.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'use strict';

const common = require('../common');

if (!process.config.variables.node_use_amaro) {
common.skip('Requires Amaro');
}
const fixtures = require('../common/fixtures');
const file = fixtures.path('get-call-sites.js');

Expand Down
14 changes: 8 additions & 6 deletions test/parallel/test-worker-eval-typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,20 @@ const cjsHelloWorld = `

const disableTypeScriptWarningFlag = '--disable-warning=ExperimentalWarning';

test('Worker eval module typescript without input-type', async () => {
const onlyWithAmaro = { skip: !process.config.variables.node_use_amaro };

test('Worker eval module typescript without input-type', onlyWithAmaro, async () => {
const w = new Worker(esmHelloWorld, { eval: true, execArgv: [disableTypeScriptWarningFlag] });
assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']);
});

test('Worker eval module typescript with --input-type=module-typescript', async () => {
test('Worker eval module typescript with --input-type=module-typescript', onlyWithAmaro, async () => {
const w = new Worker(esmHelloWorld, { eval: true, execArgv: ['--input-type=module-typescript',
disableTypeScriptWarningFlag] });
assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']);
});

test('Worker eval module typescript with --input-type=commonjs-typescript', async () => {
test('Worker eval module typescript with --input-type=commonjs-typescript', onlyWithAmaro, async () => {
const w = new Worker(esmHelloWorld, { eval: true, execArgv: ['--input-type=commonjs-typescript',
disableTypeScriptWarningFlag] });

Expand All @@ -47,18 +49,18 @@ test('Worker eval module typescript with --input-type=module', async () => {
assert.match(err.message, /Missing initializer in const declaration/);
});

test('Worker eval commonjs typescript without input-type', async () => {
test('Worker eval commonjs typescript without input-type', onlyWithAmaro, async () => {
const w = new Worker(cjsHelloWorld, { eval: true, execArgv: [disableTypeScriptWarningFlag] });
assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']);
});

test('Worker eval commonjs typescript with --input-type=commonjs-typescript', async () => {
test('Worker eval commonjs typescript with --input-type=commonjs-typescript', onlyWithAmaro, async () => {
const w = new Worker(cjsHelloWorld, { eval: true, execArgv: ['--input-type=commonjs-typescript',
disableTypeScriptWarningFlag] });
assert.deepStrictEqual(await once(w, 'message'), ['Hello, World!']);
});

test('Worker eval commonjs typescript with --input-type=module-typescript', async () => {
test('Worker eval commonjs typescript with --input-type=module-typescript', onlyWithAmaro, async () => {
const w = new Worker(cjsHelloWorld, { eval: true, execArgv: ['--input-type=module-typescript',
disableTypeScriptWarningFlag] });
const [err] = await once(w, 'error');
Expand Down
3 changes: 3 additions & 0 deletions test/test-runner/test-output-typescript-coverage.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// Test that the output of test-runner/output/typescript-coverage.mts matches
// test-runner/output/typescript-coverage.snapshot
import * as common from '../common/index.mjs';
if (!process.config.variables.node_use_amaro) {
common.skip('Requires Amaro');
}
import * as fixtures from '../common/fixtures.mjs';
import { spawnAndAssert, defaultTransform, ensureCwdIsProjectRoot } from '../common/assertSnapshot.js';

Expand Down
Loading