【问题标题】:error TS2688: Cannot find type definition file for 'dist'错误 TS2688:找不到“dist”的类型定义文件
【发布时间】:2021-05-14 01:11:38
【问题描述】:

由于某种原因,我收到此错误error TS2688: Cannot find type definition file for 'dist',尽管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"]
}

这是我的文件夹结构:

【问题讨论】:

    标签: typescript tsconfig


    【解决方案1】:
    "typeRoots": [
         "./"
    ],
    

    您的 typeRoots 已映射到您的根文件夹,因此它会认为 ./dist./node_modules 将包含不正确的定义文件。我建议将其放在./typings 文件夹中以避免此问题。

    • glsl.d.ts 文件移动到名为./typings 的文件夹中
    • 将 typeRoots 值更改为 ['./typings']
    • 运行tsc,它将不再抱怨

    【讨论】:

      猜你喜欢
      • 2019-07-10
      • 1970-01-01
      • 2022-10-20
      • 2018-02-24
      • 2018-03-09
      • 2019-05-11
      • 2018-07-23
      • 2017-09-08
      • 2019-10-10
      相关资源
      最近更新 更多