kwhitley/itty-router-extras

Property 'project' does not exist on type 'Request'

andyjessop opened this issue · 2 comments

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 kwhitley/itty-router#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!