vscode/eslint抱怨解析错误:在声明模块内部只允许声明和类型导入 [英] vscode/eslint complaining Parsing error: Only declares and type imports are allowed inside declare module
本文介绍了vscode/eslint抱怨解析错误:在声明模块内部只允许声明和类型导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下 index.d.ts
文件:
declare module 'mytypes' {
interface Constructor<T> {
new (...args: any[]): T;
}
//etc.
VSCode突出显示了界面关键字:
VSCode highlights the interface keyword:
Parsing error: Only declares and type imports are allowed inside declare module
1 | declare module 'someproject' {
> 2 | interface Constructor<T> {
| ^
3 | new (...args: any[]): T;
4 | }
5 |eslint
看起来像是错误,但我无法从错误消息中分辨出哪个
Looks like an eslint error but I cannot tell which from the error message
推荐答案
您可以添加.eslintignore
You can add .eslintignore
/**/*.d.ts
eslint规则错误地将d.ts视为js
The eslint rule mistakenly treats d.ts as js
这篇关于vscode/eslint抱怨解析错误:在声明模块内部只允许声明和类型导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文