next-type-safe-routes icon indicating copy to clipboard operation
next-type-safe-routes copied to clipboard

Bug: fails when `/api` isn't defined

Open kopach opened this issue 1 year ago • 2 comments

I have a simple project with no API. When this plugin added I'm getting this error

no such file or directory, lstat '<project-path>/pages/api`

As a workaround – I've just created api/index.ts

kopach avatar May 08 '23 14:05 kopach

seems like fixed long time ago but not released to NPM

kopach avatar May 10 '23 10:05 kopach

Anyway, bug found in this "unreleased" version. When there is no /api folder TypeSafeApiRoute is not created but still referenced in typeSafeUrl which causes TS to do not work.

it should be done like this

  export type TypeSafeApiRoute = never;

or TypeSafeApiRoute should not be mentioned at all

kopach avatar May 10 '23 10:05 kopach