You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: packages/documentation/copy/en/release-notes/TypeScript 5.5.md
+7-47
Original file line number
Diff line number
Diff line change
@@ -107,7 +107,7 @@ It now infers signatures with type predicates like `x is number` or `x is NonNul
107
107
Type predicates have "if and only if" semantics.
108
108
If a function returns `x is T`, then it means that:
109
109
110
-
1. If the function returns `true` then `x`is has type `T`.
110
+
1. If the function returns `true` then `x` has the type `T`.
111
111
2. If the function returns `false` then `x` does *not* have type `T`.
112
112
113
113
If you're expecting a type predicate to be inferred but it's not, then you may be running afoul of the second rule. This often comes up with "truthiness" checks:
We'd like to thank [Kevin Gibbons](https://github.com/bakkot) who not only proposed the feature in ECMAScript, but [also provided the declarations for `Set`, `ReadonlySet`, and `ReadonlySetLike` in TypeScript](https://github.com/microsoft/TypeScript/pull/57230)!
451
+
We'd like to thank [Kevin Gibbons](https://github.com/bakkot) who not only co-championed the feature in ECMAScript, but [also provided the declarations for `Set`, `ReadonlySet`, and `ReadonlySetLike` in TypeScript](https://github.com/microsoft/TypeScript/pull/57230)!
452
452
453
453
## Isolated Declarations
454
454
@@ -609,7 +609,9 @@ Keep an eye on this space, and feel free to provide us with feedback.
609
609
We also feel it is worth calling out that `isolatedDeclarations` should be adopted on a case-by-case basis.
610
610
There are some developer ergonomics that are lost when using `isolatedDeclarations`, and thus it may not be the right choice if your setup is not leveraging the two scenarios mentioned earlier.
611
611
For others, the work on `isolatedDeclarations` has already uncovered many optimizations and opportunities to unlock different parallel build strategies.
612
-
In the meantime, if you're willing to make the trade-offs, we believe `isolatedDeclarations` can be a powerful tool to speed up your build process once external tooling becomes available.
612
+
In the meantime, if you're willing to make the trade-offs, we believe `isolatedDeclarations` can be a powerful tool to speed up your build process as external tooling becomes more widely available.
613
+
614
+
For more information, read up on the [Isolated Declarations: State of the Feature](https://github.com/microsoft/TypeScript/issues/58944) discussion on the TypeScript issue tracker.
613
615
614
616
### Credit
615
617
@@ -784,7 +786,7 @@ One of the issues with these APIs is that TypeScript internally would perform a
784
786
This was necessary to collect certain information which would later be used for the emit phase.
785
787
786
788
In TypeScript 5.5, we've found a way to avoid performing a full check, only lazily collecting this information as necessary, and `transpileModule` and `transpileDeclaration` both enable this functionality by default.
787
-
As a result, tools that integrate with with these APIs, like [ts-loader](https://www.npmjs.com/package/ts-loader) with `transpileOnly` and [ts-jest](https://www.npmjs.com/package/ts-jest), should see a noticeable speedup.
789
+
As a result, tools that integrate with these APIs, like [ts-loader](https://www.npmjs.com/package/ts-loader) with `transpileOnly` and [ts-jest](https://www.npmjs.com/package/ts-jest), should see a noticeable speedup.
788
790
In our testing, [we generally witness around a 2x speed-up in build time using `transpileModule`](https://github.com/microsoft/TypeScript/pull/58364#issuecomment-2138580690).
789
791
790
792
### TypeScript Package Size Reduction
@@ -914,48 +916,6 @@ See also the [Flag Deprecation Plan](https://github.com/microsoft/TypeScript/iss
914
916
Types generated for the DOM may have an impact on type-checking your codebase.
915
917
For more information, [see the DOM updates for TypeScript 5.5](https://github.com/microsoft/TypeScript/pull/58211).
916
918
917
-
### Respecting File Extensions and `package.json` in Other Module Modes
918
-
919
-
Before Node.js implemented support for ECMAScript modules in v12, there was never a good way for TypeScript to know whether `.d.ts` files it found in `node_modules` represented JavaScript files authored as CommonJS or ECMAScript modules.
920
-
When the vast majority of npm was CommonJS-only, this didn't cause many problems - if in doubt, TypeScript could just assume that everything behaved like CommonJS.
921
-
Unfortunately, if that assumption was wrong it could allow unsafe imports:
922
-
923
-
```ts
924
-
// node_modules/dep/index.d.ts
925
-
exportdeclarefunction doSomething():void;
926
-
927
-
// index.ts
928
-
// Okay if "dep" is a CommonJS module, but fails if
929
-
// it's an ECMAScript module - even in bundlers!
930
-
importdepfrom"dep";
931
-
dep.doSomething();
932
-
```
933
-
934
-
In practice, this didn't come up very often.
935
-
But in the years since Node.js started supporting ECMAScript modules, the share of ESM on npm has grown.
936
-
Fortunately, Node.js also introduced a mechanism that can help TypeScript determine if a file is an ECMAScript module or a CommonJS module: the `.mjs` and `.cjs` file extensions and the `package.json``"type"` field.
937
-
TypeScript 4.7 added support for understanding these indicators, as well as authoring `.mts` and `.cts` files;
938
-
however, TypeScript would *only* read those indicators under `--module node16` and `--module nodenext`, so the unsafe import above was still a problem for anyone using `--module esnext` and `--moduleResolution bundler`, for example.
939
-
940
-
To solve this, TypeScript 5.5 reads and stores module format information encoded by file extensions and `package.json``"type"` in *all*`module` modes, and uses it to resolve ambiguities like the one in the example above in all modes (except for `amd`, `umd`, and `system`).
941
-
942
-
A secondary effect of respecting this format information is that the format-specific TypeScript file extensions (`.mts` and `.cts`) or an explicitly set package.json `"type"` in your own project will *override* your `--module` option if it's set to `commonjs` or `es2015` through `esnext`.
943
-
Previously, it was technically possible to produce CommonJS output into a `.mjs` file or vice versa:
Now, `.mts` files (or `.ts` files in scope of a `package.json` with `"type": "module"`) never emit CommonJS output, and `.cts` files (or `.ts` files in scope of a package.json with `"type": "commonjs"`) never emit ESM output.
956
-
957
-
More details are available [on the change here](https://github.com/microsoft/TypeScript/pull/57896).
958
-
959
919
### Stricter Parsing for Decorators
960
920
961
921
Since TypeScript originally introduced support for decorators, the specified grammar for the proposal has been tightened up.
0 commit comments