Commit adde78c
authored
fix(openapi): preserve event iterator return type in JsonifiedClient (#1797)
`JsonifiedClient` was losing an event iterator's return type: a contract
with `eventIterator(z.number(), z.number())` produced
`AsyncIteratorObject<number, any, unknown>` instead of a properly typed
iterator. `AsyncIteratorClass`'s `return(value?: any)` signature made
TypeScript infer `TReturn` as `any` when matched against
`AsyncIteratorObject<infer U, infer V>`, since inference works off
actual method signatures rather than the `implements` clause.
## Fixes
- `JsonifiedValue` now matches `AsyncIteratorClass` directly (its own
case, ahead of the generic `AsyncIteratorObject` branch), so the return
type inference is no longer poisoned.
- Jsonified iterator outputs are now typed as `AsyncIteratorClass`,
matching what clients actually receive at runtime.
## Testing
- New type tests cover `JsonifiedValue` over `AsyncIteratorClass` and
the issue's end-to-end reproduction through `JsonifiedClient`; all three
assertions fail with `TReturn = any` before the fix and pass after.
- Root `tsc` and eslint are clean.1 parent 324bd7a commit adde78c
2 files changed
Lines changed: 20 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
| 5 | + | |
| 6 | + | |
3 | 7 | | |
4 | 8 | | |
5 | 9 | | |
| |||
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
21 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
22 | 28 | | |
23 | 29 | | |
24 | 30 | | |
| |||
41 | 47 | | |
42 | 48 | | |
43 | 49 | | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
44 | 58 | | |
45 | 59 | | |
46 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | | - | |
25 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
0 commit comments