![](/img/trans.png)
[英]@typescript-eslint/no-unused-vars false positive in type declarations
[英]Typescript + Eslint false positive for imports + `declare global`
我的`.d.ts。 文件如下所示:
import type { typesAsObj } from 'entityTypes';
declare global {
type EntityType = keyof typeof typesAsObj;
}
这产生:
'typesAsObj' is not defined. eslint no-undef
但是,这有效:
import type { typesAsObj } from 'entityTypes';
type _EntityType = keyof typeof typesAsObj;
declare global {
type EntityType = _EntityType;
}
为什么第一个不起作用?
关闭 "no-undef": "off"(禁止使用未声明的变量,除非在/*global */
注释中提到)并由打字稿编译器本身处理。
或者
使用配置文件中的 "extends": "eslint:recommended" 属性
"extends": [
"eslint:recommended", //<---
'plugin:jasmine/recommended',
'plugin:jsdoc/recommended'
],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.