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
import.meta.env类型造成歧义 #6930
Labels
Comments
@bluwy would it make sense to keep this topic in an issue instead of a discussion? |
There was a PR to fix it at #4415 but was closed due to #4415 (comment). It seems like it make sense to type is as |
As far as I know, we can just obtain a boolean env var via define which is compatible with esbuild. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
尽管在
env.d.ts
中ImportMetaEnv
interface中 定义了环境变量 booblean 或者其他非 string 类型在客户端使用import.meta.env仍得到一个string类型的值,但得到的 typescript 的类型提示确是自己定义过的
这可能会引起一个隐藏错误或歧义!
目前解决方案是所有
ImportMetaEnv
内属性均定义为 string , 自己手动转换为对应类型。这样不会导致直接使用 import.meta.env 得到一个与值不对应类型的类型提示。我觉得这点需要在文档中标注出来!
Reproduction
System Info
Used Package Manager
pnpm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: