kwhitley / itty-router

A little router.
MIT License
1.78k stars 78 forks source link

Property 'json' does not exist on type 'Request' #47

Closed shrmnk closed 3 years ago

shrmnk commented 3 years ago
import { Request } from 'itty-router';

const Update = async (request: Request) => {
  const inputData = await request.json();
  console.log(inputData);
};

Typescript will flag out Line 4 , citing that Property 'json' does not exist on type 'Request'

My quick workaround was to // @ts-ignore the line before

kwhitley commented 3 years ago

So itty doesn't require a real Request object (keeps it as agnostic/non-prescriptive as possible), but I'll add the basic methods from the native Request as optional methods into the interface file (including json()) to alleviate this... should be publishing in the next few days with a bit of changes, including this.

kwhitley commented 3 years ago

Should be fixed as of 2.4 :)

Thanks for your patience!