ckastbjerg / next-type-safe-routes

Never should your users experience broken links again!
MIT License
70 stars 5 forks source link

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

Open kopach opened 1 year ago

kopach commented 1 year ago

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 commented 1 year ago

seems like fixed long time ago but not released to NPM

kopach commented 1 year ago

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