kwhitley / itty-router

A little router.
MIT License
1.71k stars 77 forks source link

Typescript Error with ES6 Module Syntax: how to solve? #128

Closed osseonews closed 1 year ago

osseonews commented 1 year ago

If you use the ES6 Module Syntax for the itty router per the documentation, the line, .handle(...args) throws an error: A spread argument must either have a tuple type or be passed to a rest parameter - any idea how to fix this?

alexgleason commented 1 year ago

Simply don't use the spread syntax the README recommends.

export default {
  async fetch(
    request: Request,
    env: Env,
    ctx: ExecutionContext
  ): Promise<Response> {
    return router.handle(request, env, ctx);
  },
};
kwhitley commented 1 year ago

Exactly as @alexgleason (thanks Alex!) recommends - I've run into the same recently... just need to update the README!