问题
I noticed a file called next-env.d.ts in my Next.js typescript project. I wanted to declare some enums that I can use throughout my Next.js files. How do I do this and then access these enums throughout my project?
回答1:
next-env.d.ts file is explained here: https://nextjs.org/docs/basic-features/typescript
A file named next-env.d.ts will be created in the root of your project. This file ensures Next.js types are picked up by the TypeScript compiler. You cannot remove it, however, you can edit it (but you don't need to).
For what your are trying to achieve with the enums, you can export your enum as a regular ES Module, so you can import it whenever you want in your code.
Hope that helps.
来源:https://stackoverflow.com/questions/61420392/how-do-i-use-the-next-env-d-ts-file-in-next-js