itty-router-extras
itty-router-extras copied to clipboard
Property 'project' does not exist on type 'Request'
I'm unable to get type inference working on the withParams
helper:
import { Router } from 'itty-router';
import { withParams } from 'itty-router-extras';
export default {
fetch
};
const router = Router();
router.get('/projects/:project/deployments', withParams, async ({ project }) => {
console.log(project);
return new Response();
});
Gives me this error:
Property 'project' does not exist on type 'Request'. ts(2339)
you can extend the Request interface and add 'project' type and assign it to 'any' and make it optional
In the middle of https://github.com/kwhitley/itty-router/pull/121, where I may be rewriting all the types for core (I'm certainly doing it for extras, that are being brought into core), so this is helpful, thanks!