Skip to content

Commit ea22e3e

Browse files
module: unflag --experimental-strip-types
PR-URL: nodejs#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 2896760 commit ea22e3e

22 files changed

+69
-127
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
@@ -777,7 +777,7 @@ Any query parameter or hash in the URL will be accessible via [`import.meta.url`
777777

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

@@ -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-async-context-frame`
886886

@@ -1119,17 +1119,6 @@ added:
11191119

11201120
Use this flag to enable [ShadowRealm][] support.
11211121

1122-
### `--experimental-strip-types`
1123-
1124-
<!-- YAML
1125-
added: v22.6.0
1126-
-->
1127-
1128-
> Stability: 1.1 - Active development
1129-
1130-
Enable experimental type-stripping for TypeScript files.
1131-
For more information, see the [TypeScript type-stripping][] documentation.
1132-
11331122
### `--experimental-test-coverage`
11341123

11351124
<!-- YAML
@@ -1189,7 +1178,7 @@ added: v22.7.0
11891178
> Stability: 1.1 - Active development
11901179
11911180
Enables the transformation of TypeScript-only syntax into JavaScript code.
1192-
Implies `--experimental-strip-types` and `--enable-source-maps`.
1181+
Implies `--enable-source-maps`.
11931182

11941183
### `--experimental-vm-modules`
11951184

@@ -1486,9 +1475,10 @@ added: v12.0.0
14861475

14871476
This configures Node.js to interpret `--eval` or `STDIN` input as CommonJS or
14881477
as an ES module. Valid values are `"commonjs"`, `"module"`, `"module-typescript"` and `"commonjs-typescript"`.
1489-
The `"-typescript"` values are available only in combination with the flag `--experimental-strip-types`.
1490-
The default is `"commonjs"` unless [`--experimental-default-type=module`][] is used.
1491-
If `--experimental-strip-types` is enabled and `--input-type` is not provided,
1478+
The `"-typescript"` values are not available with the flag `--no-experimental-strip-types`.
1479+
The default is `"commonjs"`.
1480+
1481+
If `--input-type` is not provided,
14921482
Node.js will try to detect the syntax with the following steps:
14931483

14941484
1. Run the input as CommonJS.
@@ -1783,6 +1773,21 @@ changes:
17831773

17841774
Disable the experimental [`node:sqlite`][] module.
17851775

1776+
### `--no-experimental-strip-types`
1777+
1778+
<!-- YAML
1779+
added: v22.6.0
1780+
changes:
1781+
- version: REPLACEME
1782+
pr-url: https://github.com/nodejs/node/pull/56350
1783+
description: Type stripping is enabled by default.
1784+
-->
1785+
1786+
> Stability: 1.1 - Active development
1787+
1788+
Disable experimental type-stripping for TypeScript files.
1789+
For more information, see the [TypeScript type-stripping][] documentation.
1790+
17861791
### `--no-experimental-websocket`
17871792

17881793
<!-- YAML
@@ -3278,7 +3283,6 @@ one is included in the list below.
32783283
* `--experimental-require-module`
32793284
* `--experimental-shadow-realm`
32803285
* `--experimental-specifier-resolution`
3281-
* `--experimental-strip-types`
32823286
* `--experimental-top-level-await`
32833287
* `--experimental-transform-types`
32843288
* `--experimental-vm-modules`
@@ -3317,6 +3321,7 @@ one is included in the list below.
33173321
* `--no-experimental-global-webcrypto`
33183322
* `--no-experimental-repl-await`
33193323
* `--no-experimental-sqlite`
3324+
* `--no-experimental-strip-types`
33203325
* `--no-experimental-websocket`
33213326
* `--no-extra-info-on-fatal-exception`
33223327
* `--no-force-async-hooks-checks`
@@ -3851,10 +3856,10 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
38513856
[`--env-file`]: #--env-fileconfig
38523857
[`--experimental-default-type=module`]: #--experimental-default-typetype
38533858
[`--experimental-sea-config`]: single-executable-applications.md#generating-single-executable-preparation-blobs
3854-
[`--experimental-strip-types`]: #--experimental-strip-types
38553859
[`--experimental-wasm-modules`]: #--experimental-wasm-modules
38563860
[`--heap-prof-dir`]: #--heap-prof-dir
38573861
[`--import`]: #--importmodule
3862+
[`--no-experimental-strip-types`]: #--no-experimental-strip-types
38583863
[`--openssl-config`]: #--openssl-configfile
38593864
[`--preserve-symlinks`]: #--preserve-symlinks
38603865
[`--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.
@@ -52,7 +55,7 @@ To use TypeScript with full support for all TypeScript features, including
5255
added: v22.6.0
5356
-->
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.
5861
Node.js will replace inline type annotations with whitespace,
@@ -206,8 +209,8 @@ with `#`.
206209
[CommonJS]: modules.md
207210
[ES Modules]: esm.md
208211
[Full TypeScript support]: #full-typescript-support
209-
[`--experimental-strip-types`]: cli.md#--experimental-strip-types
210212
[`--experimental-transform-types`]: cli.md#--experimental-transform-types
213+
[`--no-experimental-strip-types`]: cli.md#--no-experimental-strip-types
211214
[`ERR_UNSUPPORTED_TYPESCRIPT_SYNTAX`]: errors.md#err_unsupported_typescript_syntax
212215
[`tsconfig` "paths"]: https://www.typescriptlang.org/tsconfig/#paths
213216
[`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)