Add generic type to return of json
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 126
- Forks
- 7
- Avg merge
- 6h 30m
- Merged PRs (30d)
- 15
Description
🆒 Your use case
The behaviour of
event.req.json<{ key: string }>()
should be
json: <T = any>() => Promise<T>
🆕 The solution you'd like
event.req.json() returns Promise<Body> where Body is inferred from EventHandlerRequest["body"] via TypedServerRequest → fetchdts's TypedRequest<Body, Headers>
🔍 Alternatives you've considered
No response
ℹ️ Additional info
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing EventHandlerRequest["body"] through TypedServerRequest to fetchdts's TypedRequest<Body, Headers>, focusing on the json() type shown in the issue. Confirm how the generic should interact with the inferred Body type. Done when event.req.json<{ key: string }>() is typed as Promise<{ key: string }> while the existing inferred return remains supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100