-
Notifications
You must be signed in to change notification settings - Fork 6
chore(deps): update dependency ts-pattern to v5.8.0 #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
902b856
to
66ea1e1
Compare
66ea1e1
to
5da84cc
Compare
5da84cc
to
218b535
Compare
218b535
to
d42c3a2
Compare
d42c3a2
to
ac5b231
Compare
ac5b231
to
8bafe2c
Compare
8bafe2c
to
5660d8c
Compare
5660d8c
to
4153956
Compare
4153956
to
12fc4f3
Compare
12fc4f3
to
db3f50e
Compare
db3f50e
to
9a11f12
Compare
This PR contains the following updates:
5.0.8
->5.8.0
Release Notes
gvergnaud/ts-pattern (ts-pattern)
v5.8.0
Compare Source
TS-Pattern v5.8.0 Release Notes
New Feature:
.narrow()
Method for Deep Type Narrowing.narrow()
gives you fine-grained control over type narrowing of deeply nested union types during pattern matching.What is
.narrow()
?The
.narrow()
method allows you to explicitly narrow the input type to exclude all values that have been handled by previous patterns. This is especially useful when working with:When to Use
.narrow()
By default, TS-Pattern automatically narrows top-level union types as you pattern match. However, for deeply nested types, this narrowing doesn't happen automatically to maintain optimal TypeScript performance. The
.narrow()
method gives you explicit control over when to perform this more computationally expensive operation.Example Usage
Additional Improvements
Full Changelog: gvergnaud/ts-pattern@v5.7.1...v5.8.0
PRs
v5.7.1
Compare Source
Type inference bug fixes
This new release fixes the following bug in exhaustiveness checking when matching on optional properties:
These two cases don't type check anymore. They fail with a
NonExhaustiveError<{ type?: undefined; }>
. To fix it, you should do:This is a purely type-level change, the runtime behavior is still the same.
What's Changed
Full Changelog: gvergnaud/ts-pattern@v5.7.0...v5.7.1
v5.7.0
Compare Source
New feature
Exhaustive callback
By default,
.exhaustive()
will throw an error if the input value wasn't handled by any.with(...)
clause. This should only happen if your types are incorrect.It is possible to pass your own handler function as a parameter to decide what should happen if an unexpected value has been received. You can for example throw your own custom error:
Or log an error and return a default value:
Improved narrowing for
isMatching
isMatching didn't have full feature parity with match in terms of type narrowing, but now does.
What's Changed
Full Changelog: gvergnaud/ts-pattern@v5.6.2...v5.7.0
v5.6.2
Compare Source
What's Changed
Full Changelog: gvergnaud/ts-pattern@v5.6.1...v5.6.2
v5.6.1
Compare Source
What's Changed
Full Changelog: gvergnaud/ts-pattern@v5.6.0...v5.6.1
v5.6.0
Compare Source
This release contains two changes:
Typecheck pattern when using isMatching with 2 parameter.
It used to be possible to pass a pattern than could never match to
isMatching
. The new version checks that the provide pattern does match the value in second parameter:Do not use
P.infer
as an inference pointWhen using
P.infer<Pattern>
to type a function argument, like in the following example:TypeScript could get confused and find type errors in the wrong spot:
This new version fixes this problem.
What's Changed
P.infer
andisMatching
by @gvergnaud in https://github.com/gvergnaud/ts-pattern/pull/302Full Changelog: gvergnaud/ts-pattern@v5.5.0...v5.6.0
v5.5.0
Compare Source
What's Changed
New Contributors
Full Changelog: gvergnaud/ts-pattern@v5.4.0...v5.5.0
v5.4.0
Compare Source
The main thing — Faster type checking 🚀
This release brings a significant perf improvement to exhaustiveness checking, which led to a ~16% decrease in the time to type-check the full test suite of TS-Pattern:
What's Changed
InvertPatternForExcludeInternal
to work with readonly array by @changwoolab in https://github.com/gvergnaud/ts-pattern/pull/284New Contributors
Full Changelog: gvergnaud/ts-pattern@v5.3.1...v5.4.0
v5.3.1
Compare Source
Pattern-matching on symbol keys
Symbols used to be ignored in object patterns. They are now taken into account:
.exhaustive
now throws a custom errorPeople have expressed the need to differentiate runtime errors that
.exhaustive()
might throw when the input is of an unexpected type from other runtime errors that could have happened in the same match expression. It's now possible witherr instanceof NonExhaustiveError
:What's Changed
ExhaustiveError
when no matched pattern by @adamhamlin in https://github.com/gvergnaud/ts-pattern/pull/270New Contributors
Full Changelog: gvergnaud/ts-pattern@v5.2.0...v5.3.1
v5.3.0
Compare Source
v5.2.0
Compare Source
The main thing
new
P.string.length(n)
patternP.string.length(len)
matches strings with exactlylen
characters.What's Changed
P.when
patterns code example by @grigorischristainas in https://github.com/gvergnaud/ts-pattern/pull/260New Contributors
Full Changelog: gvergnaud/ts-pattern@v5.1.2...v5.2.0
v5.1.2
Compare Source
The main thing
When combining
P.nonNullable
andP.nullish
, you should get an exhaustive pattern matching expression, but the following case was incorrectly considered non-exhaustive:This is fixed now.
What's Changed
New Contributors
Full Changelog: gvergnaud/ts-pattern@v5.1.1...v5.1.2
v5.1.1
Compare Source
What's Changed
Full Changelog: gvergnaud/ts-pattern@v5.1.0...v5.1.1
v5.1.0
Compare Source
New features
P.nonNullable
wildcardAdd a new
P.nonNullable
pattern that will match any value exceptnull
orundefined
.Closes #60 #154 #190 and will be a work-around for #143.
What's Changed
Full Changelog: gvergnaud/ts-pattern@v5.0.8...v5.1.0
Configuration
📅 Schedule: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).
🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.
♻ 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 was generated by Mend Renovate. View the repository job log.