Skip to content

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Dec 23, 2024

Bumps ts-pattern from 5.5.0 to 5.6.0.

Release notes

Sourced from ts-pattern's releases.

v5.6.0

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:

type Pizza = { type: 'pizza'; topping: string };
type Sandwich = { type: 'sandwich'; condiments: string[] };
type Food = Pizza | Sandwich;
const fn = (food: Pizza | Sandwich) => {
if (isMatching({ type: 'oops' }, food)) {
//                  👆 used to type-check, now doesn't!
}
}

Do not use P.infer as an inference point

When using P.infer<Pattern> to type a function argument, like in the following example:

const getWithDefault = <T extends P.Pattern>(
  input: unknown,
  pattern: T,
  defaultValue: P.infer<T> //  👈
): P.infer<T> =>
  isMatching(pattern, input) ? input : defaultValue

TypeScript could get confused and find type errors in the wrong spot:

const res = getWithDefault(null, { x: P.string }, 'oops') 
//                                     👆           👆 type error should be here
//                                 but it's here 😬

This new version fixes this problem.

What's Changed

Full Changelog: gvergnaud/ts-pattern@v5.5.0...v5.6.0

Commits
  • d68fbcf 5.6.0
  • e35de42 fix: prevent NoInfer from showing up in display types
  • 514057f Merge pull request #289 from gvergnaud/dependabot/npm_and_yarn/rollup-2.79.2
  • ba71cf1 Merge pull request #302 from gvergnaud/P-infer-improvement
  • a009d89 feat(P.Pattern): support no type param
  • 16e2b2c feat(isMatching): Typecheck pattern when using isMatching wth 2 parameters
  • b6d791a feat(P.infer): Remove inference point
  • b5aa458 Remove lock files in examples
  • 94ee35d feat: Add jsr support
  • 91f32aa build(deps-dev): bump rollup from 2.79.1 to 2.79.2
  • See full diff in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Bumps [ts-pattern](https://github.com/gvergnaud/ts-pattern) from 5.5.0 to 5.6.0.
- [Release notes](https://github.com/gvergnaud/ts-pattern/releases)
- [Commits](gvergnaud/ts-pattern@v5.5.0...v5.6.0)

---
updated-dependencies:
- dependency-name: ts-pattern
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
@dependabot dependabot bot added dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code labels Dec 23, 2024
Copy link
Contributor Author

dependabot bot commented on behalf of github Jan 20, 2025

Superseded by #1189.

@dependabot dependabot bot closed this Jan 20, 2025
@dependabot dependabot bot deleted the dependabot/npm_and_yarn/ts-pattern-5.6.0 branch January 20, 2025 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file javascript Pull requests that update Javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants