gpt4 book ai didi

typescript - 如何在 Next.js 中使用 next-env.d.ts 文件?

转载 作者:行者123 更新时间:2023-12-03 13:53:23 25 4
gpt4 key购买 nike

我注意到我的 Next.js typescript 项目中有一个名为 next-env.d.ts 的文件。我想声明一些可以在我的 Next.js 文件中使用的枚举。如何执行此操作,然后在整个项目中访问这些枚举?

最佳答案

next-env.d.ts 文件在这里解释: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).



对于您试图通过枚举实现的目标,您可以将枚举导出为常规 ES 模块,以便您可以随时在代码中导入它。

希望有帮助。

关于typescript - 如何在 Next.js 中使用 next-env.d.ts 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61420392/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com