Skip to content

Commit 7505688

Browse files
module: unflag --experimental-strip-types
1 parent ec519b5 commit 7505688

22 files changed

+57
-114
lines changed

benchmark/ts/strip-typescript.js

Lines changed: 1 addition & 1 deletion
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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ Any query parameter or hash in the URL will be accessible via [`import.meta.url`
780780

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

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

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

886886
### `--experimental-addon-modules`
887887

@@ -1008,17 +1008,6 @@ added:
10081008

10091009
Use this flag to enable [ShadowRealm][] support.
10101010

1011-
### `--experimental-strip-types`
1012-
1013-
<!-- YAML
1014-
added: v22.6.0
1015-
-->
1016-
1017-
> Stability: 1.1 - Active development
1018-
1019-
Enable experimental type-stripping for TypeScript files.
1020-
For more information, see the [TypeScript type-stripping][] documentation.
1021-
10221011
### `--experimental-test-coverage`
10231012

10241013
<!-- YAML
@@ -1059,7 +1048,7 @@ added: v22.7.0
10591048
> Stability: 1.1 - Active development
10601049
10611050
Enables the transformation of TypeScript-only syntax into JavaScript code.
1062-
Implies `--experimental-strip-types` and `--enable-source-maps`.
1051+
Implies `--enable-source-maps`.
10631052

10641053
### `--experimental-vm-modules`
10651054

@@ -1370,10 +1359,10 @@ added: v12.0.0
13701359

13711360
This configures Node.js to interpret `--eval` or `STDIN` input as CommonJS or
13721361
as an ES module. Valid values are `"commonjs"`, `"module"`, `"module-typescript"` and `"commonjs-typescript"`.
1373-
The `"-typescript"` values are available only in combination with the flag `--experimental-strip-types`.
1362+
The `"-typescript"` values not available with the flag `--no-experimental-strip-types`.
13741363
The default is `"commonjs"`.
13751364

1376-
If `--experimental-strip-types` is enabled and `--input-type` is not provided,
1365+
If `--input-type` is not provided,
13771366
Node.js will try to detect the syntax with the following steps:
13781367

13791368
1. Run the input as CommonJS.
@@ -1663,6 +1652,17 @@ changes:
16631652

16641653
Disable the experimental [`node:sqlite`][] module.
16651654

1655+
### `--no-experimental-strip-types`
1656+
1657+
<!-- YAML
1658+
added: REPLACEME
1659+
-->
1660+
1661+
> Stability: 1.1 - Active development
1662+
1663+
Disable experimental type-stripping for TypeScript files.
1664+
For more information, see the [TypeScript type-stripping][] documentation.
1665+
16661666
### `--no-experimental-websocket`
16671667

16681668
<!-- YAML
@@ -3089,7 +3089,6 @@ one is included in the list below.
30893089
* `--experimental-require-module`
30903090
* `--experimental-shadow-realm`
30913091
* `--experimental-specifier-resolution`
3092-
* `--experimental-strip-types`
30933092
* `--experimental-test-isolation`
30943093
* `--experimental-top-level-await`
30953094
* `--experimental-transform-types`
@@ -3127,6 +3126,7 @@ one is included in the list below.
31273126
* `--no-experimental-global-navigator`
31283127
* `--no-experimental-repl-await`
31293128
* `--no-experimental-sqlite`
3129+
* `--no-experimental-strip-types`
31303130
* `--no-experimental-websocket`
31313131
* `--no-extra-info-on-fatal-exception`
31323132
* `--no-force-async-hooks-checks`
@@ -3651,10 +3651,10 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
36513651
[`--env-file`]: #--env-fileconfig
36523652
[`--experimental-addon-modules`]: #--experimental-addon-modules
36533653
[`--experimental-sea-config`]: single-executable-applications.md#generating-single-executable-preparation-blobs
3654-
[`--experimental-strip-types`]: #--experimental-strip-types
36553654
[`--experimental-wasm-modules`]: #--experimental-wasm-modules
36563655
[`--heap-prof-dir`]: #--heap-prof-dir
36573656
[`--import`]: #--importmodule
3657+
[`--no-experimental-strip-types`]: #--no-experimental-strip-types
36583658
[`--openssl-config`]: #--openssl-configfile
36593659
[`--preserve-symlinks`]: #--preserve-symlinks
36603660
[`--print`]: #-p---print-script

doc/api/process.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2025,8 +2025,9 @@ added:
20252025
20262026
* {boolean|string}
20272027
2028-
A value that is `"strip"` if Node.js is run with `--experimental-strip-types`,
2029-
`"transform"` if Node.js is run with `--experimental-transform-types`, and `false` otherwise.
2028+
A value that is `"strip"` by default,
2029+
`"transform"` if Node.js is run with `--experimental-transform-types`, and `false` if
2030+
Node.js is run with `--no-experimental-strip-types`.
20302031
20312032
## `process.features.uv`
20322033

doc/api/test.md

Lines changed: 3 additions & 3 deletions
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}`
@@ -3591,10 +3591,10 @@ added:
35913591
Can be used to abort test subtasks when the test has been aborted.
35923592

35933593
[TAP]: https://testanything.org/
3594-
[`--experimental-strip-types`]: cli.md#--experimental-strip-types
35953594
[`--experimental-test-coverage`]: cli.md#--experimental-test-coverage
35963595
[`--experimental-test-module-mocks`]: cli.md#--experimental-test-module-mocks
35973596
[`--import`]: cli.md#--importmodule
3597+
[`--no-experimental-strip-types`]: cli.md#--no-experimental-strip-types
35983598
[`--test-concurrency`]: cli.md#--test-concurrency
35993599
[`--test-coverage-exclude`]: cli.md#--test-coverage-exclude
36003600
[`--test-coverage-include`]: cli.md#--test-coverage-include

doc/api/typescript.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ added: v22.6.0
5252

5353
> Stability: 1.1 - Active development
5454
55-
The flag [`--experimental-strip-types`][] enables Node.js to run TypeScript
55+
The flag [`--no-experimental-strip-types`][] prevents Node.js from running TypeScript
5656
files. By default Node.js will execute only files that contain no
5757
TypeScript features that require transformation, such as enums or namespaces.
5858
Node.js will replace inline type annotations with whitespace,
@@ -181,8 +181,8 @@ with `#`.
181181
[CommonJS]: modules.md
182182
[ES Modules]: esm.md
183183
[Full TypeScript support]: #full-typescript-support
184-
[`--experimental-strip-types`]: cli.md#--experimental-strip-types
185184
[`--experimental-transform-types`]: cli.md#--experimental-transform-types
185+
[`--no-experimental-strip-types`]: cli.md#--no-experimental-strip-types
186186
[`tsconfig` "paths"]: https://www.typescriptlang.org/tsconfig/#paths
187187
[`tsx`]: https://tsx.is/
188188
[`verbatimModuleSyntax`]: https://www.typescriptlang.org/tsconfig/#verbatimModuleSyntax

doc/node.1

Lines changed: 3 additions & 3 deletions
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

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

src/node_options.h

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 13 deletions
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)