Nullable NoInfer breaks `with()` handler
**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](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbziAhjAxgCwDRwApwC+cAZlBCHAOQwDOAtGGjAKZQB2VAUFzAJ5gWcAKq02cALyI47FCBYAuOLRhRg7AOZwAPjICuAGwNEeLAB6RYpPe3QxgEdnADuwGJgByEAJLsSbAAoANxQDPUU4L19-KAAeUXFddkMDAD4dfSMASkQuOHy4KBYYPQ5kNCxg0PCsvIL6gDpXdwCkWXklPAb2Rw8UlAAjAyFCXFaZORGciXSAAwAJFiMIOAASBHaWQlmcgHpduABRKHIoOvr8hoh3NlcxAIDp9OTsgG4uQlMLaHgSGzsHE5mpgIHoYFE-IEQmEIgkoBkXgYcghzoViqUnKgMJgqjDahcCk03Di2pNOt1ev0hiMxqT5EQnnAFksDCt1pttviCXArjcoHcWA9GYisu9PkA)
**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.
```ts
const { data = null } = useQuery(getSomeQueryOptions());
// ^ NoInfer<SomeObject | null> | null
```
0 条评论