cloudflare / cloudflare/chanfana

DataOf not really working?

Open
#148 3 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
766
Forks
70
Avg merge
25m
Merged PRs (30d)
4

Description

I'm trying to use DataOf on a project, and TypeScript keeps resolving everything to `any`.

For example, I have:
```
requestBody: z.object({
address: z.string(),
chainId: z.string(),
token: z.string(),
}),
```

And then I do:
```
data: DataOf
```

But the resolved types are always:
![image](https://github.com/cloudflare/itty-router-openapi/assets/1970424/b2c9e4b9-4257-48e9-b1e3-a2a213ce6aaa)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the TypeScript inference issue with the provided requestBody schema and `DataOf` example. Inspect the definition and uses of `DataOf` and compare the inferred result with the schema; done means the resulting fields are no longer resolved to `any`.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.