Skip to content
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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lkeff
Copy link
Owner

@lkeff lkeff commented Oct 24, 2024

snyk-top-banner

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
  • 5.4.0 - 2024-09-25

    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:

    Category Before After Evolution (%)
    Instantiations 6,735,991 4,562,378 -32.33%
    Memory used 732,233K 746,454K 1.95%
    Assignability cache size 209,959 205,926 -1.92%
    Identity cache size 28,093 28,250 0.56%
    Check time 5.78s 4.83s -16.44%

    What's Changed

    • build(deps-dev): bump braces from 3.0.2 to 3.0.3 by @ dependabot in #273
    • build(deps-dev): bump webpack from 5.91.0 to 5.94.0 in /examples/gif-fetcher by @ dependabot in #276
    • build(deps): bump serve-static and express in /examples/gif-fetcher by @ dependabot in #283
    • perf: improve type checking performance of BuildMany by @ gvergnaud in #286
    • Fixes type InvertPatternForExcludeInternal to work with readonly array by @ changwoolab in #284

    New Contributors

    Full Changelog: v5.3.1...v5.4.0

  • 5.3.1 - 2024-08-11

    Pattern-matching on symbol keys

    Symbols used to be ignored in object patterns. They are now taken into account:

    const symbolA = Symbol('symbol-a');
    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 error

    People 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 with err instanceof NonExhaustiveError:

    import { match, P, NonExhaustiveError } from 'ts-pattern';

    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

    • build(deps-dev): bump braces from 3.0.2 to 3.0.3 in /examples/gif-fetcher by @ dependabot in #262
    • feat: throw custom ExhaustiveError when no matched pattern by @ adamhamlin in #270
    • Symbols as keys by @ Ayc0 in #272

    New Contributors

    Full Changelog: v5.2.0...v5.3.1

  • 5.3.0 - 2024-08-11
  • 5.2.0 - 2024-06-12

    The main thing

    new P.string.length(n) pattern

    P.string.length(len) matches strings with exactly len characters.

    const fn = (input: string) =>
    match(input)
    .with(P.string.length(2), () => '🎉')
    .otherwise(() => '❌');

    console.log(fn('ok')); // logs '🎉'

    What's Changed

    New Contributors

    Full Changelog: v5.1.2...v5.2.0

  • 5.1.2 - 2024-05-23

    The main thing

    When combining P.nonNullable and P.nullish, you should get an exhaustive pattern matching expression, but the following case was incorrectly considered non-exhaustive:

    declare const input: {
    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

    • build(deps): bump postcss and react-scripts in /examples/gif-fetcher by @ dependabot in #243
    • build(deps): bump loader-utils and react-scripts in /examples/gif-fetcher by @ dependabot in #242
    • build(deps): bump jsdom and react-scripts in /examples/gif-fetcher by @ dependabot in #241
    • build(deps): bump tough-cookie and react-scripts in /examples/gif-fetcher by @ dependabot in #240
    • build(deps): bump shell-quote and react-scripts in /examples/gif-fetcher by @ dependabot in #239
    • chore: add P.map specific jsdoc for P.map by @ momentiris in #245
    • build(deps-dev): bump ejs from 3.1.9 to 3.1.10 in /examples/gif-fetcher by @ dependabot in #249
    • build(deps-dev): bump ejs from 3.1.9 to 3.1.10 by @ dependabot in #248
    • fix: exhaustive checking with nested P.nonNullable patterns by @ gvergnaud in #252

    New Contributors

    Full Changelog: v5.1.1...v5.1.2

  • 5.1.1 - 2024-04-06

    What's Changed

    • Fix(P.nonNullable): narrowing of unions of objects by @ gvergnaud in #237

    Full Changelog: v5.1.0...v5.1.1

  • 5.1.1-rc.0 - 2024-04-06
  • 5.1.0 - 2024-03-31

    New features

    P.nonNullable wildcard

    Add a new P.nonNullable pattern that will match any value except null or undefined.

    import { match, P } from 'ts-pattern';

    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

  • 5.0.8 - 2024-02-15

    The main thing

    This release includes type narrowing improvement to isMatching when used in its curried form:

    type Pizza = { type: 'pizza', topping: string };
    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 as Food, no infers Pizza
    }

    This also improves type checking performance for complex patterns and fixes a small bug in the ES5 build of TS-Pattern.

    What's Changed

    • perf: support exhaustive match on larger unions by @ gvergnaud in #214
    • fix: make isMatching(p) infer the pattern as a const type parameter by @ gvergnaud in #221
    • fix: Make sure regeneratorRuntime isn't included in the cjs build by @ gvergnaud in #224

    Full Changelog: v5.0.6...v5.0.8

from ts-pattern GitHub release notes

Important

  • Check the changes in this PR to ensure they won't cause issues with your project.
  • This PR was automatically created by Snyk using the credentials of a real user.

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:

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
Copy link

sourcery-ai bot commented Oct 24, 2024

🧙 Sourcery is reviewing your pull request!


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

2 similar comments
Copy link

sourcery-ai bot commented Oct 24, 2024

🧙 Sourcery is reviewing your pull request!


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

sourcery-ai bot commented Oct 24, 2024

🧙 Sourcery is reviewing your pull request!


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add __.valued wildcard
2 participants