错误 TS2688:找不到 'dist' 的类型定义文件
error TS2688: Cannot find type definition file for 'dist'
出于某种原因,尽管 dist
是一个文件夹,但我收到此错误 error TS2688: Cannot find type definition file for 'dist'
。有谁知道为什么会这样,我能做些什么来解决这个问题?
tsconfig:
{
"compilerOptions": {
"target": "es5" ,
"lib": [
"es2019",
"dom"
],
"allowJs": false,
"declaration": true,
"sourceMap": true,
"outDir": "./dist/",
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true ,
"noFallthroughCasesInSwitch": true,
"typeRoots": [
"./"
],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true ,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"compileOnSave": true,
"exclude": ["node_modules/"],
"include": ["main.ts"]
}
这是我的文件夹结构:
"typeRoots": [
"./"
],
您的 typeRoots 映射到您的根文件夹,因此它会认为 ./dist
和 ./node_modules
将包含不正确的定义文件。我建议将它放在 ./typings
文件夹中以避免此问题。
- 将您的
glsl.d.ts
文件移动到名为 ./typings
的文件夹中
- 将 typeRoots 值更改为
['./typings']
- 运行
tsc
它不会再抱怨
出于某种原因,尽管 dist
是一个文件夹,但我收到此错误 error TS2688: Cannot find type definition file for 'dist'
。有谁知道为什么会这样,我能做些什么来解决这个问题?
tsconfig:
{
"compilerOptions": {
"target": "es5" ,
"lib": [
"es2019",
"dom"
],
"allowJs": false,
"declaration": true,
"sourceMap": true,
"outDir": "./dist/",
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true ,
"noFallthroughCasesInSwitch": true,
"typeRoots": [
"./"
],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true ,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"compileOnSave": true,
"exclude": ["node_modules/"],
"include": ["main.ts"]
}
这是我的文件夹结构:
"typeRoots": [
"./"
],
您的 typeRoots 映射到您的根文件夹,因此它会认为 ./dist
和 ./node_modules
将包含不正确的定义文件。我建议将它放在 ./typings
文件夹中以避免此问题。
- 将您的
glsl.d.ts
文件移动到名为./typings
的文件夹中
- 将 typeRoots 值更改为
['./typings']
- 运行
tsc
它不会再抱怨