Commit 17551f0
authored
fix(openapi): preserve event iterator return type in JsonifiedClient (#1798)
v1 port of #1797. `JsonifiedClient` was losing an event iterator's
return type: a contract with `eventIterator(z.number(), z.number())`
produced an iterator with `TReturn = any` instead of the jsonified
return type. `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 #1796
## Fixes
- `JsonifiedValue` now matches `AsyncIteratorClass` directly (its own
case, ahead of the generic `AsyncIteratorObject` branch), so the return
type inference is no longer poisoned.
- `AsyncGenerator` and plain `AsyncIteratorObject` values now keep their
own shape instead of being widened, matching the updated #1797.
## Testing
- New type tests cover `JsonifiedValue` over
`AsyncIteratorClass`/`AsyncGenerator`/`AsyncIteratorObject` and the
end-to-end reproduction through `JsonifiedClient` (using v1's
`eventIterator` + `ContractRouterClient`); three assertions fail before
the fix and pass after.
- Root `tsc -b`, `tsc --noEmit`, and eslint are clean.1 parent 08a3cad commit 17551f0
2 files changed
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
2 | 4 | | |
| 5 | + | |
3 | 6 | | |
4 | 7 | | |
5 | 8 | | |
| |||
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
21 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
22 | 27 | | |
23 | 28 | | |
24 | 29 | | |
| |||
41 | 46 | | |
42 | 47 | | |
43 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
44 | 57 | | |
45 | 58 | | |
46 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
0 commit comments