gvergnaud / ts-pattern

🎨 The exhaustive Pattern Matching library for TypeScript, with smart type inference.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

P.nonNullable behaves differently than P.not(P.nullish)

zoontek opened this issue · comments

Describe the bug

P.nonNullable is not able to properly discriminate unions where a property might exists (or not).

Code Sandbox with a minimal reproduction case

https://codesandbox.io/p/sandbox/serene-wind-nfckr2?file=%2Fsrc%2Findex.ts%3A45%2C1

Versions

  • TypeScript version: 5.4.3
  • ts-pattern version: 5.1.0
  • environment: node v20.11.1

Thanks for reporting! fixed in v5.1.1

@gvergnaud there are still some issues:
#247