Skip to content

Commit d45fcfa

Browse files
module: unflag --experimental-strip-types
PR-URL: nodejs#56350 Fixes: nodejs/typescript#17 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: Pietro Marchini <pietro.marchini94@gmail.com>
1 parent 30b26b9 commit d45fcfa

22 files changed

+81
-139
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: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ Any query parameter or hash in the URL will be accessible via [`import.meta.url`
789789

790790
```bash
791791
node --entry-url 'file:///path/to/file.js?queryparams=work#and-hashes-too'
792-
node --entry-url --experimental-strip-types 'file.ts?query#hash'
792+
node --entry-url 'file.ts?query#hash'
793793
node --entry-url 'data:text/javascript,console.log("Hello")'
794794
```
795795

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

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

897897
### `--experimental-async-context-frame`
898898

@@ -1131,17 +1131,6 @@ added:
11311131

11321132
Use this flag to enable [ShadowRealm][] support.
11331133

1134-
### `--experimental-strip-types`
1135-
1136-
<!-- YAML
1137-
added: v22.6.0
1138-
-->
1139-
1140-
> Stability: 1.1 - Active development
1141-
1142-
Enable experimental type-stripping for TypeScript files.
1143-
For more information, see the [TypeScript type-stripping][] documentation.
1144-
11451134
### `--experimental-test-coverage`
11461135

11471136
<!-- YAML
@@ -1201,7 +1190,7 @@ added: v22.7.0
12011190
> Stability: 1.1 - Active development
12021191
12031192
Enables the transformation of TypeScript-only syntax into JavaScript code.
1204-
Implies `--experimental-strip-types` and `--enable-source-maps`.
1193+
Implies `--enable-source-maps`.
12051194

12061195
### `--experimental-vm-modules`
12071196

@@ -1506,9 +1495,10 @@ added: v12.0.0
15061495

15071496
This configures Node.js to interpret `--eval` or `STDIN` input as CommonJS or
15081497
as an ES module. Valid values are `"commonjs"`, `"module"`, `"module-typescript"` and `"commonjs-typescript"`.
1509-
The `"-typescript"` values are available only in combination with the flag `--experimental-strip-types`.
1510-
The default is `"commonjs"` unless [`--experimental-default-type=module`][] is used.
1511-
If `--experimental-strip-types` is enabled and `--input-type` is not provided,
1498+
The `"-typescript"` values are not available with the flag `--no-experimental-strip-types`.
1499+
The default is `"commonjs"`.
1500+
1501+
If `--input-type` is not provided,
15121502
Node.js will try to detect the syntax with the following steps:
15131503

15141504
1. Run the input as CommonJS.
@@ -1803,6 +1793,21 @@ changes:
18031793

18041794
Disable the experimental [`node:sqlite`][] module.
18051795

1796+
### `--no-experimental-strip-types`
1797+
1798+
<!-- YAML
1799+
added: v22.6.0
1800+
changes:
1801+
- version: REPLACEME
1802+
pr-url: https://github.com/nodejs/node/pull/56350
1803+
description: Type stripping is enabled by default.
1804+
-->
1805+
1806+
> Stability: 1.1 - Active development
1807+
1808+
Disable experimental type-stripping for TypeScript files.
1809+
For more information, see the [TypeScript type-stripping][] documentation.
1810+
18061811
### `--no-experimental-websocket`
18071812

18081813
<!-- YAML
@@ -3304,7 +3309,6 @@ one is included in the list below.
33043309
* `--experimental-require-module`
33053310
* `--experimental-shadow-realm`
33063311
* `--experimental-specifier-resolution`
3307-
* `--experimental-strip-types`
33083312
* `--experimental-top-level-await`
33093313
* `--experimental-transform-types`
33103314
* `--experimental-vm-modules`
@@ -3343,6 +3347,7 @@ one is included in the list below.
33433347
* `--no-experimental-global-webcrypto`
33443348
* `--no-experimental-repl-await`
33453349
* `--no-experimental-sqlite`
3350+
* `--no-experimental-strip-types`
33463351
* `--no-experimental-websocket`
33473352
* `--no-extra-info-on-fatal-exception`
33483353
* `--no-force-async-hooks-checks`
@@ -3877,10 +3882,10 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
38773882
[`--env-file`]: #--env-fileconfig
38783883
[`--experimental-default-type=module`]: #--experimental-default-typetype
38793884
[`--experimental-sea-config`]: single-executable-applications.md#generating-single-executable-preparation-blobs
3880-
[`--experimental-strip-types`]: #--experimental-strip-types
38813885
[`--experimental-wasm-modules`]: #--experimental-wasm-modules
38823886
[`--heap-prof-dir`]: #--heap-prof-dir
38833887
[`--import`]: #--importmodule
3888+
[`--no-experimental-strip-types`]: #--no-experimental-strip-types
38843889
[`--openssl-config`]: #--openssl-configfile
38853890
[`--preserve-symlinks`]: #--preserve-symlinks
38863891
[`--print`]: #-p---print-script

doc/api/process.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,8 +2040,9 @@ added: v22.10.0
20402040
20412041
* {boolean|string}
20422042
2043-
A value that is `"strip"` if Node.js is run with `--experimental-strip-types`,
2044-
`"transform"` if Node.js is run with `--experimental-transform-types`, and `false` otherwise.
2043+
A value that is `"strip"` by default,
2044+
`"transform"` if Node.js is run with `--experimental-transform-types`, and `false` if
2045+
Node.js is run with `--no-experimental-strip-types`.
20452046
20462047
## `process.features.uv`
20472048

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}`
@@ -3679,10 +3679,10 @@ Can be used to abort test subtasks when the test has been aborted.
36793679

36803680
[TAP]: https://testanything.org/
36813681
[TTY]: tty.md
3682-
[`--experimental-strip-types`]: cli.md#--experimental-strip-types
36833682
[`--experimental-test-coverage`]: cli.md#--experimental-test-coverage
36843683
[`--experimental-test-module-mocks`]: cli.md#--experimental-test-module-mocks
36853684
[`--import`]: cli.md#--importmodule
3685+
[`--no-experimental-strip-types`]: cli.md#--no-experimental-strip-types
36863686
[`--test-concurrency`]: cli.md#--test-concurrency
36873687
[`--test-coverage-include`]: cli.md#--test-coverage-include
36883688
[`--test-name-pattern`]: cli.md#--test-name-pattern

doc/api/typescript.md

Lines changed: 5 additions & 2 deletions
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.
@@ -54,7 +57,7 @@ added: v22.6.0
5457

5558
> Stability: 1.1 - Active development
5659
57-
The flag [`--experimental-strip-types`][] enables Node.js to run TypeScript
60+
The flag [`--no-experimental-strip-types`][] prevents Node.js from running TypeScript
5861
files. By default Node.js will execute only files that contain no
5962
TypeScript features that require transformation, such as enums.
6063
Node.js will replace inline type annotations with whitespace,
@@ -208,8 +211,8 @@ with `#`.
208211
[CommonJS]: modules.md
209212
[ES Modules]: esm.md
210213
[Full TypeScript support]: #full-typescript-support
211-
[`--experimental-strip-types`]: cli.md#--experimental-strip-types
212214
[`--experimental-transform-types`]: cli.md#--experimental-transform-types
215+
[`--no-experimental-strip-types`]: cli.md#--no-experimental-strip-types
213216
[`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`]: errors.md#err_unsupported_typescript_syntax
214217
[`tsconfig` "paths"]: https://www.typescriptlang.org/tsconfig/#paths
215218
[`tsx`]: https://tsx.is/

doc/node.1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,6 @@ Configures the type of test isolation used in the test runner.
197197
.It Fl -experimental-test-module-mocks
198198
Enable module mocking in the test runner.
199199
.
200-
.It Fl -experimental-strip-types
201-
Enable experimental type-stripping for TypeScript files.
202-
.
203200
.It Fl -experimental-transform-types
204201
Enable transformation of TypeScript-only syntax into JavaScript code.
205202
.
@@ -227,6 +224,9 @@ Disable top-level await keyword support in REPL.
227224
.It Fl -no-experimental-sqlite
228225
Disable the experimental node:sqlite module.
229226
.
227+
.It Fl -no-experimental-strip-types
228+
Disable experimental type-stripping for TypeScript files.
229+
.
230230
.It Fl -experimental-vm-modules
231231
Enable experimental ES module support in VM module.
232232
.

src/node_options.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
896896
AddOption("--experimental-strip-types",
897897
"Experimental type-stripping for TypeScript files.",
898898
&EnvironmentOptions::experimental_strip_types,
899-
kAllowedInEnvvar);
899+
kAllowedInEnvvar,
900+
true);
900901
Implies("--experimental-strip-types", "--experimental-detect-module");
901902

902903
AddOption("--experimental-transform-types",

src/node_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class EnvironmentOptions : public Options {
250250

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

253-
bool experimental_strip_types = false;
253+
bool experimental_strip_types = true;
254254
bool experimental_transform_types = false;
255255

256256
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
@@ -188,7 +188,7 @@ try {
188188
[ 'qmod', 'index.js', 'imp.js', 'commonjs', 'module', 'module', '?k=v'],
189189
[ 'hmod', 'index.js', 'imp.js', 'commonjs', 'module', 'module', '#Key'],
190190
[ 'qhmod', 'index.js', 'imp.js', 'commonjs', 'module', 'module', '?k=v#h'],
191-
[ 'ts-mod-com', 'index.js', 'imp.ts', 'module', 'commonjs', undefined],
191+
[ 'ts-mod-com', 'index.js', 'imp.ts', 'module', 'commonjs', 'commonjs-typescript'],
192192
].forEach((testVariant) => {
193193
const [
194194
moduleName,

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

Lines changed: 1 addition & 14 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
]);
@@ -66,7 +62,7 @@ test('expect failure of an .mts file with CommonJS syntax', async () => {
6662
const testFilePath = fixtures.path(
6763
'typescript/cts/test-cts-but-module-syntax.cts'
6864
);
69-
const result = await spawnPromisified(process.execPath, ['--experimental-strip-types', testFilePath]);
65+
const result = await spawnPromisified(process.execPath, [testFilePath]);
7066

7167
assert.strictEqual(result.stdout, '');
7268

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

9793
test('execute a .cts file importing a .cts file', async () => {
9894
const result = await spawnPromisified(process.execPath, [
99-
'--experimental-strip-types',
10095
'--no-warnings',
10196
fixtures.path('typescript/cts/test-require-commonjs.cts'),
10297
]);
@@ -108,7 +103,6 @@ test('execute a .cts file importing a .cts file', async () => {
108103

109104
test('execute a .cts file importing a .ts file export', async () => {
110105
const result = await spawnPromisified(process.execPath, [
111-
'--experimental-strip-types',
112106
'--no-warnings',
113107
fixtures.path('typescript/cts/test-require-ts-file.cts'),
114108
]);
@@ -120,7 +114,6 @@ test('execute a .cts file importing a .ts file export', async () => {
120114

121115
test('execute a .cts file importing a .mts file export', async () => {
122116
const result = await spawnPromisified(process.execPath, [
123-
'--experimental-strip-types',
124117
'--no-experimental-require-module',
125118
fixtures.path('typescript/cts/test-require-mts-module.cts'),
126119
]);
@@ -132,7 +125,6 @@ test('execute a .cts file importing a .mts file export', async () => {
132125

133126
test('execute a .cts file importing a .mts file export', async () => {
134127
const result = await spawnPromisified(process.execPath, [
135-
'--experimental-strip-types',
136128
'--experimental-require-module',
137129
fixtures.path('typescript/cts/test-require-mts-module.cts'),
138130
]);
@@ -143,7 +135,6 @@ test('execute a .cts file importing a .mts file export', async () => {
143135

144136
test('execute a .cts file with default type module', async () => {
145137
const result = await spawnPromisified(process.execPath, [
146-
'--experimental-strip-types',
147138
'--experimental-default-type=module', // Keeps working with commonjs
148139
'--no-warnings',
149140
fixtures.path('typescript/cts/test-require-commonjs.cts'),
@@ -156,7 +147,6 @@ test('execute a .cts file with default type module', async () => {
156147

157148
test('expect failure of a .cts file in node_modules', async () => {
158149
const result = await spawnPromisified(process.execPath, [
159-
'--experimental-strip-types',
160150
fixtures.path('typescript/cts/test-cts-node_modules.cts'),
161151
]);
162152

@@ -167,7 +157,6 @@ test('expect failure of a .cts file in node_modules', async () => {
167157

168158
test('expect failure of a .ts file in node_modules', async () => {
169159
const result = await spawnPromisified(process.execPath, [
170-
'--experimental-strip-types',
171160
fixtures.path('typescript/cts/test-ts-node_modules.cts'),
172161
]);
173162

@@ -178,7 +167,6 @@ test('expect failure of a .ts file in node_modules', async () => {
178167

179168
test('expect failure of a .cts requiring esm without default type module', async () => {
180169
const result = await spawnPromisified(process.execPath, [
181-
'--experimental-strip-types',
182170
'--no-experimental-require-module',
183171
fixtures.path('typescript/cts/test-mts-node_modules.cts'),
184172
]);
@@ -190,7 +178,6 @@ test('expect failure of a .cts requiring esm without default type module', async
190178

191179
test('expect failure of a .cts file requiring esm in node_modules', async () => {
192180
const result = await spawnPromisified(process.execPath, [
193-
'--experimental-strip-types',
194181
'--experimental-require-module',
195182
fixtures.path('typescript/cts/test-mts-node_modules.cts'),
196183
]);

0 commit comments

Comments
 (0)