Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding "paths" and "baseUrl" to tsconfig.json breaks module augmentations #5024

Closed
nexxeln opened this issue Jul 26, 2022 · 3 comments
Closed
Assignees
Labels
question Ask how to do something or how something works TypeScript Issues relating to TypeScript

Comments

@nexxeln
Copy link

nexxeln commented Jul 26, 2022

Question 💬

We just had this issue in create-t3-app,It seems like the declared next-auth.d.ts is overriding the initial next-auth types instead of augmenting them.

We even tried declaring the the types from next-auth/core/types but doesn't seem to work still.

Note that this problem only occurs when we use path aliases.

How to reproduce ☕️

To Reproduce
Steps to reproduce the behavior:

  1. npx create-t3-app@next
  2. Select all packages
  3. Set up path aliases like so path aliases
  4. See src/pages/api/auth/[...nextauth].ts file

Contributing 🙌🏽

Yes, I am willing to help answer this question in a PR

@nexxeln nexxeln added question Ask how to do something or how something works TypeScript Issues relating to TypeScript labels Jul 26, 2022
@nexxeln
Copy link
Author

nexxeln commented Jul 26, 2022

Update: Apparently moving the next-auth.d.ts file to a subfolder fixes it.

Is there a better solution?

@balazsorban44
Copy link
Member

balazsorban44 commented Jul 26, 2022

AFAIK, TypeScript does not concern itself where you declare a Module Augmentation in your project, as long as the file is included in your tsconfig's includes array.

UPDATE:
Well, maybe it does, since you are setting basePath: "./" so you basically tell TS to resolve next-auth to the .d.ts file instead. 🤔

@riolly
Copy link

riolly commented Aug 2, 2022

Update: Apparently moving the next-auth.d.ts file to a subfolder fixes it.

Is there a better solution?

Yeah, I do the same thing. Is there any better solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Ask how to do something or how something works TypeScript Issues relating to TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants