Nullable NoInfer breaks `with()` handler

Author: rothsandroCreated Jun 10, 2026Updated Jun 10, 2026

Describe the bug If the matched value's type is NoInfer<SomeObject | null> | null, matching properties of SomeObject results in a TS error when trying to access the matched property.

TypeScript playground with a minimal reproduction case

Example: Playground

Versions

  • TypeScript version: 6.0.3
  • ts-pattern version: 5.9.0
  • environment: Chrome 149

Use Case We use TanStack Query and one of our queries returns SomeObject | null and TanStack Query applies NoInfer on the query data. We then destructure data = null to have null as default while in pending state.

typescript
const { data = null } = useQuery(getSomeQueryOptions());
//      ^ NoInfer<SomeObject | null> | null