我的`.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;
}
为什么第一个不起作用?
答案 0 :(得分:2)
关闭“ no-undef”:“ off”(除非使用/*global */
注释,否则禁止使用未声明的变量),并由打字稿编译器本身处理。
或
使用 配置文件中的“ extends”:“ eslint:recommended”属性
"extends": [
"eslint:recommended", //<---
'plugin:jasmine/recommended',
'plugin:jsdoc/recommended'
],