[英]Typescript + Eslint false positive for imports + `declare global`
My `.d.ts.我的`.d.ts。 file looks like this:
文件如下所示:
import type { typesAsObj } from 'entityTypes';
declare global {
type EntityType = keyof typeof typesAsObj;
}
This produces:这产生:
'typesAsObj' is not defined. eslint no-undef
However, this works:但是,这有效:
import type { typesAsObj } from 'entityTypes';
type _EntityType = keyof typeof typesAsObj;
declare global {
type EntityType = _EntityType;
}
Why doesn't the first one work?为什么第一个不起作用?
Turn off "no-undef": "off"(disallow the use of undeclared variables unless mentioned in /*global */
comments) and to be handled by the typescript compiler itself.关闭 "no-undef": "off"(禁止使用未声明的变量,除非在
/*global */
注释中提到)并由打字稿编译器本身处理。
or或者
Use The "extends": "eslint:recommended" property in a configuration file使用配置文件中的 "extends": "eslint:recommended" 属性
"extends": [
"eslint:recommended", //<---
'plugin:jasmine/recommended',
'plugin:jsdoc/recommended'
],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.