我正在使用以下文件结构在 Webstorm 中开发一个项目
| src
| ...
| many files
| types
| SomeInterface
| index.d.ts
| AnotherInterface
| index.d.ts
| index.d.ts
我想让SomeInterface
全球可用(使用接口而不需要导入)。
我的主要index.d.ts
内容如下:
import { SomeInterface } from './SomeInterface'
import { AnotherInterface} from './AnotherInterface'
declare global {
interface MainInterface extends SomeInterface {
someAttribute?: number[]
names: SomeInterface[]
contactData: AnotherInterface[]
}
}
每当我尝试在以下位置实现类型定义时src/some/path/to/file.ts
:
function someFunctionName(parsedData: MainInterface):void{...}
我收到以下消息:
ESLint: 'MainInterface' is not defined.(no-undef)
这是我当前的 tsconfig.json
{
"compilerOptions": {
"target": "esnext",
"allowJs": true,
"checkJs": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"noImplicitAny": false,
"baseUrl": "./",
"paths": {
"*": ["src/*"]
}
},
"include": ["src", "types/index.d.ts"],
"exclude": ["node_modules"]
}
我错过了什么吗?我知道不建议让东西在全球范围内可用,但是我被要求以这种方式专门这样做。