next-auth icon indicating copy to clipboard operation
next-auth copied to clipboard

Setting a baseUrl in example app's .tsconfig causes an error in vscode

Open nickretallack opened this issue 2 years ago • 3 comments

Question 💬

I want to set a typescript baseUrl so I can do imports relative to the package base instead of the current file, as described here: https://nextjs.org/docs/advanced-features/module-path-aliases

How to reproduce ☕️

  • Clone the example app
  • Add "baseUrl": ".", to the .tsconfig.json file
  • View [...nextauth].ts in vscode

It's now failing to import the types for NextAuth.

import NextAuth
This expression is not callable.
  Type 'typeof import("/Users/nicholasretallack/Documents/artstream/next-auth")' has no call signatures

Perhaps this is because of the next-auth.d.ts file?

Contributing 🙌🏽

No, I am afraid I cannot help regarding this

nickretallack avatar May 21 '22 17:05 nickretallack

I could not reproduce this. Do you have a repo I can look at?

balazsorban44 avatar May 31 '22 14:05 balazsorban44

Yes, this is caused by the next-auth.d.ts file. If you put *.d.ts file inside a directory like types/next-auth.d.ts ad be sure it is included with you ts compiler, things should run fine.

Cause is a module naming conflict overwriting and not extending the Next-Auth Package.

HXavS avatar Jun 26 '22 20:06 HXavS

The Next-Auth Documentation recommends putting the any Next-Auth Model Augmentations inside of a types directory and not in the project root directory.

HXavS avatar Jun 26 '22 20:06 HXavS

It looks like this issue did not receive any activity for 60 days. It will be closed in 7 days if no further activity occurs. If you think your issue is still relevant, commenting will keep it open. Thanks!

stale[bot] avatar Sep 08 '22 16:09 stale[bot]

To keep things tidy, we are closing this issue for now. If you think your issue is still relevant, leave a comment and we might reopen it. Thanks!

stale[bot] avatar Sep 17 '22 00:09 stale[bot]

For anyone having this same problem, I had this problem because I added "next-auth.d.ts" in the include array of the tsconfig.json file. Remove it and follow @HXavS instructions.

Synkied avatar Feb 14 '23 21:02 Synkied