We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
在声明文件中声明了一个接口如下 src/types/some-type.ts
export interface IXxx {}
并在typeRoots中配置了声明文件的位置
typeRoots: ["src/types"]
但是代码依然报错 cannot find name IXxx
问题出在export关键字上. 如果在类型声明文件中加上export, 编译器会认为这是一个module, 所以想要使用这个文件中声明的类型, 需要显式导入
import { IXxx } from 'types/some-type';
这样做显然是很恶心的. 所以不应该在类型声明文件中添加export. 这样编译器就会把声明文件中声明的接口全部编译成全局接口
另一种情况, 本地对第三方包做的声明, 需要将声明文件路径添加到配置文件中的paths
paths
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在声明文件中声明了一个接口如下
src/types/some-type.ts
并在typeRoots中配置了声明文件的位置
但是代码依然报错 cannot find name IXxx
问题出在export关键字上. 如果在类型声明文件中加上export, 编译器会认为这是一个module, 所以想要使用这个文件中声明的类型, 需要显式导入
这样做显然是很恶心的. 所以不应该在类型声明文件中添加export. 这样编译器就会把声明文件中声明的接口全部编译成全局接口
另一种情况, 本地对第三方包做的声明, 需要将声明文件路径添加到配置文件中的
paths
参考资料
The text was updated successfully, but these errors were encountered: