gvergnaud/ts-pattern
### [`v3.3.5`](https://togithub.com/gvergnaud/ts-pattern/releases/tag/v3.3.5)
[Compare Source](https://togithub.com/gvergnaud/ts-pattern/compare/v3.3.4...v3.3.5)
#### Bug fixes
This fixes a type inference bug impacting handler functions with explicit type annotations.
It used to be possible to annotate the handler function with an invalid type annotation. Thanks to this commit, it no longer type-checks https://github.com/gvergnaud/ts-pattern/commit/2d750742d95d38e4cab5ff1f2915050f2081441a.
See the related issue for more details: [#73](https://togithub.com/gvergnaud/ts-pattern/issues/73)
### [`v3.3.4`](https://togithub.com/gvergnaud/ts-pattern/releases/tag/v3.3.4)
[Compare Source](https://togithub.com/gvergnaud/ts-pattern/compare/407e62e2ae53a13c70d7cfd153b1e52d1604630e...v3.3.4)
##### Bug fixes
This release fixes a type inference bug specific to Error sub classes. See the related issue for more details: [https://github.com/gvergnaud/ts-pattern/issues/63](https://togithub.com/gvergnaud/ts-pattern/issues/63)
### [`v3.3.3`](https://togithub.com/gvergnaud/ts-pattern/compare/v3.3.2...407e62e2ae53a13c70d7cfd153b1e52d1604630e)
[Compare Source](https://togithub.com/gvergnaud/ts-pattern/compare/v3.3.2...407e62e2ae53a13c70d7cfd153b1e52d1604630e)
### [`v3.3.2`](https://togithub.com/gvergnaud/ts-pattern/releases/tag/v3.3.2)
[Compare Source](https://togithub.com/gvergnaud/ts-pattern/compare/v3.3.1...v3.3.2)
This patch contains some compile time perf improvements.
[@ahejlsberg](https://togithub.com/ahejlsberg) recently implemented tail call elimination for recursive conditional types ([https://github.com/microsoft/TypeScript/pull/45711](https://togithub.com/microsoft/TypeScript/pull/45711)). This release is preparation work to take advantage of this new feature by making most type helper functions tail recursive. From the non scientific tests I made on my machine, this also improves the compilation time of the `tests/` folder quite significantly on our current TS version (4.4). Compilation is ~ 20% faster.
### [`v3.3.1`](https://togithub.com/gvergnaud/ts-pattern/releases/tag/v3.3.1)
[Compare Source](https://togithub.com/gvergnaud/ts-pattern/compare/v3.2.5...v3.3.1)
##### Features
Add a `__.NaN` pattern, matching only `NaN`s values. Thanks [@mhintz](https://togithub.com/mhintz) for adding this
```ts
const res = match(NaN)
.with(null, () => 'null!')
.with(__.NaN, () => 'NaN!')
.with(__.number, (x) => 'a number!')
.exhaustive();
console.log(res)
// => 'NaN!'
```
##### Bugfix
Update the `__.number` pattern to also match on `NaN` values.
Since `NaN` has type `number` in TypeScript, there is no way to distinguish a `NaN` from a regular number at the type level. This was causing an issue where `.exhaustive()` considered all numbers handled by the `__.number` pattern even though `NaN` wasn't matched by it, resulting in possible runtime errors.
```ts
const res = match(NaN)
.with(null, () => 'null!')
.with(__.number, (x) => 'a number!')
// This used to throw at runtime because NaN wasn't matched by __.number
.exhaustive();
console.log(res)
// => 'a number!'
```
### [`v3.2.5`](https://togithub.com/gvergnaud/ts-pattern/releases/tag/v3.2.5)
[Compare Source](https://togithub.com/gvergnaud/ts-pattern/compare/v3.2.4...v3.2.5)
##### Bugfixes
- Fix a bug with exhaustiveness checking, where a case could wrongfully be considered handled even if the pattern was containing additional keys that aren't present in the input type. This can happen when making a typo when declaring your pattern for instance, as demonstrated in the issue [#44](https://togithub.com/gvergnaud/ts-pattern/issues/44) .
```ts
type Person = {
sex: "Male" | "Female";
age: "Adult" | "Child";
};
function summary(person: Person): string {
return (
match(person)
// Typo β "agf" should be "age"
.with({ sex: "Female", agf: "Adult" }, () => "Woman")
.with({ sex: "Female", age: "Child" }, () => "Girl")
.with({ sex: "Male", age: "Adult" }, () => "Man")
.with({ sex: "Male", age: "Child" }, () => "Boy")
// Bugfix: This pattern is no longer considered exhaustive!
.exhaustive()
);
}
```
Configuration
π Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
π¦ Automerge: Enabled.
β» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
π Ignore: Close this PR and you won't be reminded about this update again.
[ ] If you want to rebase/retry this PR, click this checkbox.
This PR has been generated by Mend Renovate. View repository job log here.
This PR contains the following updates:
3.2.4
->3.3.5
Release Notes
gvergnaud/ts-pattern
### [`v3.3.5`](https://togithub.com/gvergnaud/ts-pattern/releases/tag/v3.3.5) [Compare Source](https://togithub.com/gvergnaud/ts-pattern/compare/v3.3.4...v3.3.5) #### Bug fixes This fixes a type inference bug impacting handler functions with explicit type annotations. It used to be possible to annotate the handler function with an invalid type annotation. Thanks to this commit, it no longer type-checks https://github.com/gvergnaud/ts-pattern/commit/2d750742d95d38e4cab5ff1f2915050f2081441a. See the related issue for more details: [#73](https://togithub.com/gvergnaud/ts-pattern/issues/73) ### [`v3.3.4`](https://togithub.com/gvergnaud/ts-pattern/releases/tag/v3.3.4) [Compare Source](https://togithub.com/gvergnaud/ts-pattern/compare/407e62e2ae53a13c70d7cfd153b1e52d1604630e...v3.3.4) ##### Bug fixes This release fixes a type inference bug specific to Error sub classes. See the related issue for more details: [https://github.com/gvergnaud/ts-pattern/issues/63](https://togithub.com/gvergnaud/ts-pattern/issues/63) ### [`v3.3.3`](https://togithub.com/gvergnaud/ts-pattern/compare/v3.3.2...407e62e2ae53a13c70d7cfd153b1e52d1604630e) [Compare Source](https://togithub.com/gvergnaud/ts-pattern/compare/v3.3.2...407e62e2ae53a13c70d7cfd153b1e52d1604630e) ### [`v3.3.2`](https://togithub.com/gvergnaud/ts-pattern/releases/tag/v3.3.2) [Compare Source](https://togithub.com/gvergnaud/ts-pattern/compare/v3.3.1...v3.3.2) This patch contains some compile time perf improvements. [@ahejlsberg](https://togithub.com/ahejlsberg) recently implemented tail call elimination for recursive conditional types ([https://github.com/microsoft/TypeScript/pull/45711](https://togithub.com/microsoft/TypeScript/pull/45711)). This release is preparation work to take advantage of this new feature by making most type helper functions tail recursive. From the non scientific tests I made on my machine, this also improves the compilation time of the `tests/` folder quite significantly on our current TS version (4.4). Compilation is ~ 20% faster. ### [`v3.3.1`](https://togithub.com/gvergnaud/ts-pattern/releases/tag/v3.3.1) [Compare Source](https://togithub.com/gvergnaud/ts-pattern/compare/v3.2.5...v3.3.1) ##### Features Add a `__.NaN` pattern, matching only `NaN`s values. Thanks [@mhintz](https://togithub.com/mhintz) for adding this ```ts const res = matchConfiguration
π Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
π¦ Automerge: Enabled.
β» Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.
π Ignore: Close this PR and you won't be reminded about this update again.
This PR has been generated by Mend Renovate. View repository job log here.