Skip to content

Commit 8d1f5df

Browse files
marco-ippolitoRafaelGSS
authored andcommitted
module: unflag --experimental-strip-types
PR-URL: #56350 Backport-PR-URL: #57298 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 7f0560d commit 8d1f5df

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

@@ -1497,9 +1486,10 @@ added: v12.0.0
14971486

14981487
This configures Node.js to interpret `--eval` or `STDIN` input as CommonJS or
14991488
as an ES module. Valid values are `"commonjs"`, `"module"`, `"module-typescript"` and `"commonjs-typescript"`.
1500-
The `"-typescript"` values are available only in combination with the flag `--experimental-strip-types`.
1501-
The default is `"commonjs"` unless [`--experimental-default-type=module`][] is used.
1502-
If `--experimental-strip-types` is enabled and `--input-type` is not provided,
1489+
The `"-typescript"` values are not available with the flag `--no-experimental-strip-types`.
1490+
The default is `"commonjs"`.
1491+
1492+
If `--input-type` is not provided,
15031493
Node.js will try to detect the syntax with the following steps:
15041494

15051495
1. Run the input as CommonJS.
@@ -1794,6 +1784,21 @@ changes:
17941784

17951785
Disable the experimental [`node:sqlite`][] module.
17961786

1787+
### `--no-experimental-strip-types`
1788+
1789+
<!-- YAML
1790+
added: v22.6.0
1791+
changes:
1792+
- version: REPLACEME
1793+
pr-url: https://github.com/nodejs/node/pull/56350
1794+
description: Type stripping is enabled by default.
1795+
-->
1796+
1797+
> Stability: 1.1 - Active development
1798+
1799+
Disable experimental type-stripping for TypeScript files.
1800+
For more information, see the [TypeScript type-stripping][] documentation.
1801+
17971802
### `--no-experimental-websocket`
17981803

17991804
<!-- YAML
@@ -3297,7 +3302,6 @@ one is included in the list below.
32973302
* `--experimental-require-module`
32983303
* `--experimental-shadow-realm`
32993304
* `--experimental-specifier-resolution`
3300-
* `--experimental-strip-types`
33013305
* `--experimental-top-level-await`
33023306
* `--experimental-transform-types`
33033307
* `--experimental-vm-modules`
@@ -3336,6 +3340,7 @@ one is included in the list below.
33363340
* `--no-experimental-global-webcrypto`
33373341
* `--no-experimental-repl-await`
33383342
* `--no-experimental-sqlite`
3343+
* `--no-experimental-strip-types`
33393344
* `--no-experimental-websocket`
33403345
* `--no-extra-info-on-fatal-exception`
33413346
* `--no-force-async-hooks-checks`
@@ -3870,10 +3875,10 @@ node --stack-trace-limit=12 -p -e "Error.stackTraceLimit" # prints 12
38703875
[`--env-file`]: #--env-fileconfig
38713876
[`--experimental-default-type=module`]: #--experimental-default-typetype
38723877
[`--experimental-sea-config`]: single-executable-applications.md#generating-single-executable-preparation-blobs
3873-
[`--experimental-strip-types`]: #--experimental-strip-types
38743878
[`--experimental-wasm-modules`]: #--experimental-wasm-modules
38753879
[`--heap-prof-dir`]: #--heap-prof-dir
38763880
[`--import`]: #--importmodule
3881+
[`--no-experimental-strip-types`]: #--no-experimental-strip-types
38773882
[`--openssl-config`]: #--openssl-configfile
38783883
[`--preserve-symlinks`]: #--preserve-symlinks
38793884
[`--print`]: #-p---print-script

doc/api/process.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,8 +2067,9 @@ added: v22.10.0
20672067
20682068
* {boolean|string}
20692069
2070-
A value that is `"strip"` if Node.js is run with `--experimental-strip-types`,
2071-
`"transform"` if Node.js is run with `--experimental-transform-types`, and `false` otherwise.
2070+
A value that is `"strip"` by default,
2071+
`"transform"` if Node.js is run with `--experimental-transform-types`, and `false` if
2072+
Node.js is run with `--no-experimental-strip-types`.
20722073
20732074
## `process.features.uv`
20742075

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

36903690
[TAP]: https://testanything.org/
36913691
[TTY]: tty.md
3692-
[`--experimental-strip-types`]: cli.md#--experimental-strip-types
36933692
[`--experimental-test-coverage`]: cli.md#--experimental-test-coverage
36943693
[`--experimental-test-module-mocks`]: cli.md#--experimental-test-module-mocks
36953694
[`--import`]: cli.md#--importmodule
3695+
[`--no-experimental-strip-types`]: cli.md#--no-experimental-strip-types
36963696
[`--test-concurrency`]: cli.md#--test-concurrency
36973697
[`--test-coverage-include`]: cli.md#--test-coverage-include
36983698
[`--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
@@ -899,7 +899,8 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
899899
AddOption("--experimental-strip-types",
900900
"Experimental type-stripping for TypeScript files.",
901901
&EnvironmentOptions::experimental_strip_types,
902-
kAllowedInEnvvar);
902+
kAllowedInEnvvar,
903+
true);
903904
Implies("--experimental-strip-types", "--experimental-detect-module");
904905

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

src/node_options.h

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

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

254-
bool experimental_strip_types = false;
254+
bool experimental_strip_types = true;
255255
bool experimental_transform_types = false;
256256

257257
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,

0 commit comments

Comments
 (0)