Open RicardoViteriR opened 2 years ago
I ran into this problem today and solved it like this:
Create a path and a file to track custom types src/@types/itty-router/index.d.ts
:
interface Request {
content?: any;
cookies?: any;
params?: any;
}
Add this line in tsconfig.json
:
{
"compilerOptions": {
+ "typeRoots": ["./src/@types"],
},
}
For reference: https://github.com/mkuchak/cloudflare-workers-template/blob/main/src/%40types/itty-router/index.d.ts https://github.com/mkuchak/cloudflare-workers-template/blob/main/tsconfig.json#L15
Hi @mkuchak, thanks for sharing. Do you know if this solution would extend or replace the Request interface?
This extends the interface Request
I have the following function that I cannot get to recognize the request when using the withCookies and withContent middleware.
I tried using
import { Request as IttyRequest} from 'itty-router'
but I getProperty 'content' does not exist on type 'Request'
Can someone tell me how I can get the right type?