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

Tuples within objects not selected properly #67

Closed
zbjornson opened this issue Dec 24, 2021 · 1 comment
Closed

Tuples within objects not selected properly #67

zbjornson opened this issue Dec 24, 2021 · 1 comment

Comments

@zbjornson
Copy link

Describe the bug

import {match, select} from "ts-pattern";

const r1 = match({$not: ["B"]})
	.with({$not: [select("term")]}, ({term}) => term)
	.run()
console.log(r1); // [ "B" ]

const r2 = match({a: [{$not: ["B"]}]})
	.with({a: [{$not: [select("term")]}]}, ({term}) => term)
	.run()
console.log(r2); // [ [ "B" ] ]

I was expecting these to both log "B". Is this correct? Thanks!

Code Sandbox with a minimal reproduction case
https://codesandbox.io/s/bitter-moon-hwnzz

Versions

  • TypeScript version: 4.5.4
  • ts-pattern version: 3.3.4
  • environment: Node.js v 14.18.1
@gvergnaud
Copy link
Owner

gvergnaud commented Dec 24, 2021

Hey, that's expected. This is a duplicate of #62 and #46.

Here is the relevant doc section: https://github.com/gvergnaud/ts-pattern#lists-arrays

This will probably change in the next major version, see: #46 (comment)

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

2 participants