forked from raycast/extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
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
[Snyk] Upgrade ts-pattern from 5.0.8 to 5.4.0 #7
Open
lkeff
wants to merge
1
commit into
main
Choose a base branch
from
snyk-upgrade-05bcee7d8466aa6afc64c32a5d9dcfc7
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Snyk has created this PR to upgrade ts-pattern from 5.0.8 to 5.4.0. See this package in npm: ts-pattern See this project in Snyk: https://app.snyk.io/org/lkeff/project/f3d5f326-cdc8-493b-8f81-4b7a08bdc6c9?utm_source=github&utm_medium=referral&page=upgrade-pr
🧙 Sourcery is reviewing your pull request! Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
2 similar comments
🧙 Sourcery is reviewing your pull request! Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
🧙 Sourcery is reviewing your pull request! Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Snyk has created this PR to upgrade ts-pattern from 5.0.8 to 5.4.0.
ℹ️ Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project.
The recommended version is 8 versions ahead of your current version.
The recommended version was released on a month ago.
Release notes
Package name: ts-pattern
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 #284New Contributors
Full Changelog: v5.3.1...v5.4.0
Pattern-matching on symbol keys
Symbols used to be ignored in object patterns. They are now taken into account:
const symbolB = Symbol('symbol-b');
const obj = { [symbolA]: { [symbolB]: 'foo' } };
if (isMatching({ [symbolA]: { [symbolB]: 'bar' } }, obj)) {
// 👆 Used to return true, now returns false!
// Since TS-Pattern wasn't reading symbols, this pattern used to be equivalent
// to the
{}
pattern that matches any value except null and undefined.}
.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
:const fn = (input: string | number) => {
return match(input)
.with(P.string, () => "string!")
.with(P.number, () => "number!")
.exhaustive()
}
try {
fn(null as string) // 👈 💥
} catch (e) {
if (e instanceof NonExhaustiveError) {
// The input was invalid
} else {
// something else happened
}
}
What's Changed
ExhaustiveError
when no matched pattern by @ adamhamlin in #270New Contributors
Full Changelog: v5.2.0...v5.3.1
The main thing
new
P.string.length(n)
patternP.string.length(len)
matches strings with exactlylen
characters.match(input)
.with(P.string.length(2), () => '🎉')
.otherwise(() => '❌');
console.log(fn('ok')); // logs '🎉'
What's Changed
P.when
patterns code example by @ grigorischristainas in #260New Contributors
Full Changelog: v5.1.2...v5.2.0
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:nested: string | number | null | undefined;
};
const res = match(input)
.with({ nested: P.nonNullable }, (x) => {/* ... /})
.with({ nested: P.nullish }, (x) => {/ ... */})
// should type-check
.exhaustive();
This is fixed now.
What's Changed
New Contributors
Full Changelog: v5.1.1...v5.1.2
What's Changed
Full Changelog: v5.1.0...v5.1.1
New features
P.nonNullable
wildcardAdd a new
P.nonNullable
pattern that will match any value exceptnull
orundefined
.const input = null;
const output = match<number | null | undefined>(input)
.with(P.nonNullable, () => 'it is a number!')
.otherwise(() => 'it is either null or undefined!');
console.log(output);
// => 'it is either null or undefined!'
Closes #60 #154 #190 and will be a work-around for #143.
What's Changed
Full Changelog: v5.0.8...v5.1.0
The main thing
This release includes type narrowing improvement to
isMatching
when used in its curried form:type Sandwich = { type: 'sandwich', condiments: string[] }
type Food = Pizza | Sandwich;
declare const food: Food
const isPizza = isMatching({ type: 'pizza' })
if (isPizza(food)) {
x // Used to infer
food
asFood
, no infersPizza
}
This also improves type checking performance for complex patterns and fixes a small bug in the ES5 build of TS-Pattern.
What's Changed
Full Changelog: v5.0.6...v5.0.8
Important
Note: You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs.
For more information: