Skip to content

Commit e5ba216

Browse files
marco-ippolitoaduh95
authored andcommitted
module: unflag --experimental-strip-types
PR-URL: #56350 Fixes: nodejs/typescript#17 Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Paolo Insogna <[email protected]> Reviewed-By: Pietro Marchini <[email protected]>
1 parent 64556ba commit e5ba216

22 files changed

+64
-114
lines changed

benchmark/ts/strip-typescript.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const bench = common.createBenchmark(main, {
1212
filepath: [ts, js],
1313
n: [1e4],
1414
}, {
15-
flags: ['--experimental-strip-types', '--disable-warning=ExperimentalWarning'],
15+
flags: ['--disable-warning=ExperimentalWarning'],
1616
});
1717

1818
async function main({ n, filepath }) {

doc/api/cli.md

+23-19
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ Any query parameter or hash in the URL will be accessible via [`import.meta.url`
779779

780780
```bash
781781
node --entry-url 'file:///path/to/file.js?queryparams=work#and-hashes-too'
782-
node --entry-url --experimental-strip-types 'file.ts?query#hash'
782+
node --entry-url 'file.ts?query#hash'
783783
node --entry-url 'data:text/javascript,console.log("Hello")'
784784
```
785785

@@ -879,8 +879,8 @@ On Windows, using `cmd.exe` a single quote will not work correctly because it
879879
only recognizes double `"` for quoting. In Powershell or Git bash, both `'`
880880
and `"` are usable.
881881

882-
It is possible to run code containing inline types by passing
883-
[`--experimental-strip-types`][].
882+
It is possible to run code containing inline types unless the
883+
[`--no-experimental-strip-types`][] flag is provided.
884884

885885
### `--experimental-addon-modules`
886886

@@ -1020,17 +1020,6 @@ added:
10201020

10211021
Use this flag to enable [ShadowRealm][] support.
10221022

1023-
### `--experimental-strip-types`
1024-
1025-
<!-- YAML
1026-
added: v22.6.0
1027-
-->
1028-
1029-
> Stability: 1.1 - Active development
1030-
1031-
Enable experimental type-stripping for TypeScript files.
1032-
For more information, see the [TypeScript type-stripping][] documentation.
1033-
10341023
### `--experimental-test-coverage`
10351024

10361025
<!-- YAML
@@ -1071,7 +1060,7 @@ added: v22.7.0
10711060
> Stability: 1.1 - Active development
10721061
10731062
Enables the transformation of TypeScript-only syntax into JavaScript code.
1074-
Implies `--experimental-strip-types` and `--enable-source-maps`.
1063+
Implies `--enable-source-maps`.
10751064

10761065
### `--experimental-vm-modules`
10771066

@@ -1382,10 +1371,10 @@ added: v12.0.0
13821371

13831372
This configures Node.js to interpret `--eval` or `STDIN` input as CommonJS or
13841373
as an ES module. Valid values are `"commonjs"`, `"module"`, `"module-typescript"` and `"commonjs-typescript"`.
1385-
The `"-typescript"` values are available only in combination with the flag `--experimental-strip-types`.
1374+
The `"-typescript"` values are not available with the flag `--no-experimental-strip-types`.
13861375
The default is `"commonjs"`.
13871376

1388-
If `--experimental-strip-types` is enabled and `--input-type` is not provided,
1377+
If `--input-type` is not provided,
13891378
Node.js will try to detect the syntax with the following steps:
13901379

13911380
1. Run the input as CommonJS.
@@ -1660,6 +1649,21 @@ changes:
16601649

16611650
Disable the experimental [`node:sqlite`][] module.
16621651

1652+
### `--no-experimental-strip-types`
1653+
1654+
<!-- YAML
1655+
added: v22.6.0
1656+
changes:
1657+
- version: REPLACEME
1658+
pr-url: https://github.com/nodejs/node/pull/56350
1659+
description: Type stripping is enabled by default.
1660+
-->
1661+
1662+
> Stability: 1.1 - Active development
1663+
1664+
Disable experimental type-stripping for TypeScript files.
1665+
For more information, see the [TypeScript type-stripping][] documentation.
1666+
16631667
### `--no-experimental-websocket`
16641668

16651669
<!-- YAML
@@ -3087,7 +3091,6 @@ one is included in the list below.
30873091
* `--experimental-require-module`
30883092
* `--experimental-shadow-realm`
30893093
* `--experimental-specifier-resolution`
3090-
* `--experimental-strip-types`
30913094
* `--experimental-test-isolation`
30923095
* `--experimental-top-level-await`
30933096
* `--experimental-transform-types`
@@ -3124,6 +3127,7 @@ one is included in the list below.
31243127
* `--no-experimental-global-navigator`
31253128
* `--no-experimental-repl-await`
31263129
* `--no-experimental-sqlite`
3130+
* `--no-experimental-strip-types`
31273131
* `--no-experimental-websocket`
31283132
* `--no-extra-info-on-fatal-exception`
31293133
* `--no-force-async-hooks-checks`
@@ -3648,10 +3652,10 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
36483652
[`--env-file`]: #--env-fileconfig
36493653
[`--experimental-addon-modules`]: #--experimental-addon-modules
36503654
[`--experimental-sea-config`]: single-executable-applications.md#generating-single-executable-preparation-blobs
3651-
[`--experimental-strip-types`]: #--experimental-strip-types
36523655
[`--experimental-wasm-modules`]: #--experimental-wasm-modules
36533656
[`--heap-prof-dir`]: #--heap-prof-dir
36543657
[`--import`]: #--importmodule
3658+
[`--no-experimental-strip-types`]: #--no-experimental-strip-types
36553659
[`--openssl-config`]: #--openssl-configfile
36563660
[`--preserve-symlinks`]: #--preserve-symlinks
36573661
[`--print`]: #-p---print-script

doc/api/process.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -2021,8 +2021,9 @@ added: v23.0.0
20212021
20222022
* {boolean|string}
20232023
2024-
A value that is `"strip"` if Node.js is run with `--experimental-strip-types`,
2025-
`"transform"` if Node.js is run with `--experimental-transform-types`, and `false` otherwise.
2024+
A value that is `"strip"` by default,
2025+
`"transform"` if Node.js is run with `--experimental-transform-types`, and `false` if
2026+
Node.js is run with `--no-experimental-strip-types`.
20262027
20272028
## `process.features.uv`
20282029

doc/api/test.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ By default, Node.js will run all files matching these patterns:
420420
* `**/test.{cjs,mjs,js}`
421421
* `**/test/**/*.{cjs,mjs,js}`
422422

423-
When [`--experimental-strip-types`][] is supplied, the following
424-
additional patterns are matched:
423+
Unless [`--no-experimental-strip-types`][] is supplied, the following
424+
additional patterns are also matched:
425425

426426
* `**/*.test.{cts,mts,ts}`
427427
* `**/*-test.{cts,mts,ts}`
@@ -3589,10 +3589,10 @@ added:
35893589
Can be used to abort test subtasks when the test has been aborted.
35903590

35913591
[TAP]: https://testanything.org/
3592-
[`--experimental-strip-types`]: cli.md#--experimental-strip-types
35933592
[`--experimental-test-coverage`]: cli.md#--experimental-test-coverage
35943593
[`--experimental-test-module-mocks`]: cli.md#--experimental-test-module-mocks
35953594
[`--import`]: cli.md#--importmodule
3595+
[`--no-experimental-strip-types`]: cli.md#--no-experimental-strip-types
35963596
[`--test-concurrency`]: cli.md#--test-concurrency
35973597
[`--test-coverage-exclude`]: cli.md#--test-coverage-exclude
35983598
[`--test-coverage-include`]: cli.md#--test-coverage-include

doc/api/typescript.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
<!-- YAML
44
changes:
5+
- version: REPLACEME
6+
pr-url: https://github.com/nodejs/node/pull/56350
7+
description: Type stripping is enabled by default.
58
- version: v22.7.0
69
pr-url: https://github.com/nodejs/node/pull/54283
710
description: Added `--experimental-transform-types` flag.
@@ -52,7 +55,7 @@ added: v22.6.0
5255

5356
> Stability: 1.1 - Active development
5457
55-
The flag [`--experimental-strip-types`][] enables Node.js to run TypeScript
58+
The flag [`--no-experimental-strip-types`][] prevents Node.js from running TypeScript
5659
files. By default Node.js will execute only files that contain no
5760
TypeScript features that require transformation, such as enums or namespaces.
5861
Node.js will replace inline type annotations with whitespace,
@@ -181,8 +184,8 @@ with `#`.
181184
[CommonJS]: modules.md
182185
[ES Modules]: esm.md
183186
[Full TypeScript support]: #full-typescript-support
184-
[`--experimental-strip-types`]: cli.md#--experimental-strip-types
185187
[`--experimental-transform-types`]: cli.md#--experimental-transform-types
188+
[`--no-experimental-strip-types`]: cli.md#--no-experimental-strip-types
186189
[`tsconfig` "paths"]: https://www.typescriptlang.org/tsconfig/#paths
187190
[`tsx`]: https://tsx.is/
188191
[`verbatimModuleSyntax`]: https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax

doc/node.1

+3-3
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,6 @@ Enable code coverage in the test runner.
186186
.It Fl -experimental-test-module-mocks
187187
Enable module mocking in the test runner.
188188
.
189-
.It Fl -experimental-strip-types
190-
Enable experimental type-stripping for TypeScript files.
191-
.
192189
.It Fl -experimental-transform-types
193190
Enable transformation of TypeScript-only syntax into JavaScript code.
194191
.
@@ -207,6 +204,9 @@ Disable top-level await keyword support in REPL.
207204
.It Fl -no-experimental-sqlite
208205
Disable the experimental node:sqlite module.
209206
.
207+
.It Fl -no-experimental-strip-types
208+
Disable experimental type-stripping for TypeScript files.
209+
.
210210
.It Fl -experimental-vm-modules
211211
Enable experimental ES module support in VM module.
212212
.

src/node_options.cc

+2-1
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
856856
AddOption("--experimental-strip-types",
857857
"Experimental type-stripping for TypeScript files.",
858858
&EnvironmentOptions::experimental_strip_types,
859-
kAllowedInEnvvar);
859+
kAllowedInEnvvar,
860+
true);
860861
AddOption("--experimental-transform-types",
861862
"enable transformation of TypeScript-only"
862863
"syntax into JavaScript code",

src/node_options.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class EnvironmentOptions : public Options {
247247

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

250-
bool experimental_strip_types = false;
250+
bool experimental_strip_types = true;
251251
bool experimental_transform_types = false;
252252

253253
std::vector<std::string> user_argv;

test/es-module/test-esm-loader-entry-url.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('--entry-url', { concurrency: true }, () => {
8484

8585
for (const url of typescriptUrls) {
8686
await assertSpawnedProcess(
87-
['--entry-url', '--experimental-strip-types', fixtures.fileURL(url)],
87+
['--entry-url', fixtures.fileURL(url)],
8888
{},
8989
{
9090
...experimentalFeatureWarning,

test/es-module/test-esm-resolve-type.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ try {
186186
[ 'qmod', 'index.js', 'imp.js', 'commonjs', 'module', 'module', '?k=v'],
187187
[ 'hmod', 'index.js', 'imp.js', 'commonjs', 'module', 'module', '#Key'],
188188
[ 'qhmod', 'index.js', 'imp.js', 'commonjs', 'module', 'module', '?k=v#h'],
189-
[ 'ts-mod-com', 'index.js', 'imp.ts', 'module', 'commonjs', undefined],
189+
[ 'ts-mod-com', 'index.js', 'imp.ts', 'module', 'commonjs', 'commonjs-typescript'],
190190
].forEach((testVariant) => {
191191
const [
192192
moduleName,

test/es-module/test-typescript-commonjs.mjs

-13
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ if (!process.config.variables.node_use_amaro) skip('Requires Amaro');
77

88
test('require a .ts file with explicit extension succeeds', async () => {
99
const result = await spawnPromisified(process.execPath, [
10-
'--experimental-strip-types',
1110
'--eval',
1211
'require("./test-typescript.ts")',
1312
'--no-warnings',
@@ -22,7 +21,6 @@ test('require a .ts file with explicit extension succeeds', async () => {
2221

2322
test('eval require a .ts file with implicit extension fails', async () => {
2423
const result = await spawnPromisified(process.execPath, [
25-
'--experimental-strip-types',
2624
'--eval',
2725
'require("./test-typescript")',
2826
'--no-warnings',
@@ -37,7 +35,6 @@ test('eval require a .ts file with implicit extension fails', async () => {
3735

3836
test('eval require a .cts file with implicit extension fails', async () => {
3937
const result = await spawnPromisified(process.execPath, [
40-
'--experimental-strip-types',
4138
'--eval',
4239
'require("./test-cts-typescript")',
4340
'--no-warnings',
@@ -52,7 +49,6 @@ test('eval require a .cts file with implicit extension fails', async () => {
5249

5350
test('require a .ts file with implicit extension fails', async () => {
5451
const result = await spawnPromisified(process.execPath, [
55-
'--experimental-strip-types',
5652
'--no-warnings',
5753
fixtures.path('typescript/cts/test-extensionless-require.ts'),
5854
]);
@@ -64,7 +60,6 @@ test('require a .ts file with implicit extension fails', async () => {
6460

6561
test('expect failure of an .mts file with CommonJS syntax', async () => {
6662
const result = await spawnPromisified(process.execPath, [
67-
'--experimental-strip-types',
6863
fixtures.path('typescript/cts/test-cts-but-module-syntax.cts'),
6964
]);
7065

@@ -75,7 +70,6 @@ test('expect failure of an .mts file with CommonJS syntax', async () => {
7570

7671
test('execute a .cts file importing a .cts file', async () => {
7772
const result = await spawnPromisified(process.execPath, [
78-
'--experimental-strip-types',
7973
'--no-warnings',
8074
fixtures.path('typescript/cts/test-require-commonjs.cts'),
8175
]);
@@ -87,7 +81,6 @@ test('execute a .cts file importing a .cts file', async () => {
8781

8882
test('execute a .cts file importing a .ts file export', async () => {
8983
const result = await spawnPromisified(process.execPath, [
90-
'--experimental-strip-types',
9184
'--no-warnings',
9285
fixtures.path('typescript/cts/test-require-ts-file.cts'),
9386
]);
@@ -99,7 +92,6 @@ test('execute a .cts file importing a .ts file export', async () => {
9992

10093
test('execute a .cts file importing a .mts file export', async () => {
10194
const result = await spawnPromisified(process.execPath, [
102-
'--experimental-strip-types',
10395
'--no-experimental-require-module',
10496
fixtures.path('typescript/cts/test-require-mts-module.cts'),
10597
]);
@@ -111,7 +103,6 @@ test('execute a .cts file importing a .mts file export', async () => {
111103

112104
test('execute a .cts file importing a .mts file export', async () => {
113105
const result = await spawnPromisified(process.execPath, [
114-
'--experimental-strip-types',
115106
'--experimental-require-module',
116107
fixtures.path('typescript/cts/test-require-mts-module.cts'),
117108
]);
@@ -122,7 +113,6 @@ test('execute a .cts file importing a .mts file export', async () => {
122113

123114
test('expect failure of a .cts file in node_modules', async () => {
124115
const result = await spawnPromisified(process.execPath, [
125-
'--experimental-strip-types',
126116
fixtures.path('typescript/cts/test-cts-node_modules.cts'),
127117
]);
128118

@@ -133,7 +123,6 @@ test('expect failure of a .cts file in node_modules', async () => {
133123

134124
test('expect failure of a .ts file in node_modules', async () => {
135125
const result = await spawnPromisified(process.execPath, [
136-
'--experimental-strip-types',
137126
fixtures.path('typescript/cts/test-ts-node_modules.cts'),
138127
]);
139128

@@ -144,7 +133,6 @@ test('expect failure of a .ts file in node_modules', async () => {
144133

145134
test('expect failure of a .cts requiring esm without default type module', async () => {
146135
const result = await spawnPromisified(process.execPath, [
147-
'--experimental-strip-types',
148136
'--no-experimental-require-module',
149137
fixtures.path('typescript/cts/test-mts-node_modules.cts'),
150138
]);
@@ -156,7 +144,6 @@ test('expect failure of a .cts requiring esm without default type module', async
156144

157145
test('expect failure of a .cts file requiring esm in node_modules', async () => {
158146
const result = await spawnPromisified(process.execPath, [
159-
'--experimental-strip-types',
160147
'--experimental-require-module',
161148
fixtures.path('typescript/cts/test-mts-node_modules.cts'),
162149
]);

0 commit comments

Comments
 (0)