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

with(P.not([]) with readonly array #231

Open
JUSTIVE opened this issue Mar 20, 2024 · 0 comments
Open

with(P.not([]) with readonly array #231

JUSTIVE opened this issue Mar 20, 2024 · 0 comments

Comments

@JUSTIVE
Copy link
Contributor

JUSTIVE commented Mar 20, 2024

Describe the bug
not able to match the empty array pattern with readonly array.
from the code below, a must not inferred as empty array

of course I could match .with([], ...) before P.not([]), but seems this case is broken.
awkwardly, the runtime evaluates b in this case.

Code Sandbox with a minimal reproduction case

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

const x:readonly number[] = []

match(x)
.with(P.not([]),(a)=>a)
//               ^? [] | readonly [number, ...number[]]
.otherwise(b=>b)

Versions

  • TypeScript version: 5.5.0-dev-20240319
  • ts-pattern version: 5.0.8
  • environment: node version : 20.10
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