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

match.with should match static field value #300

Open
wenerme opened this issue Nov 25, 2024 · 0 comments
Open

match.with should match static field value #300

wenerme opened this issue Nov 25, 2024 · 0 comments

Comments

@wenerme
Copy link

wenerme commented Nov 25, 2024

Describe the bug

When using the match function from ts-pattern with a class that has a static Schema property, the expected result is true, but the actual result is false.

To Reproduce

Steps to reproduce the behavior:

  1. Define a class with a static Schema property.
  2. Use the match function to match the class against the schema pattern.
  3. Observe the output.
class X2 {
  static Schema = {
    kind: 'x',
  };
}

test('X', () => {
  console.log(
    match(X2)
      .with(
        {
          Schema: { kind: 'x' },
        },
        (v) => {
          return true;
        },
      )
      .otherwise(() => false),
  );
});

Expected behavior

The output of the match function should be true, but it is false.

Versions

  • TypeScript version: 5.7.2
  • ts-pattern version: 5.5.0
  • Environment: Node.js 20

Feel free to review and submit the bug report with the refined description.

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

No branches or pull requests

1 participant