代码之家  ›  专栏  ›  技术社区  ›  Jeff Saremi

TypeScript在@types中找不到类型

  •  0
  • Jeff Saremi  · 技术社区  · 8 年前

    我正试图从 @types/webgl2 在我的项目中。 TypeScript typings give me "index.d.ts is not a module"

    将此添加到顶部: import 'webgl2';

    • modeResolution “是” true “在 tsconfig.json
    • 我加了一行 "types":["webgl2"] 给我的
    • 补充 "@types/webgl2": "0.0.4" 对双方 devDependencies dependencies 在里面 package.json
    • 是否在我的项目文件夹中安装了npm:
    npm WARN package.json webgl@0.0.1 No README data
    npm WARN package.json Dependency '@types/webgl2' exists in both dependencies and devDependencies, using '@types/webgl2@0.0.4' from  dependencies
    

    我看得很清楚 webgl2 node_modules/@types 我还可以在下面看到所有错误符号的声明:

    declare var WebGl2RenderingContext {
    

    (multiple lines)
    Cannot find name 'WebGl2RenderingContext'. Did you mean 'WebGL2RenderingContext'?
    

    对应于:

    const format = WebGl2RenderingContext.RED;
    
    2 回复  |  直到 8 年前
        1
  •  3
  •   Jeff Saremi    8 年前

    通过拼写错误解决。

        2
  •  1
  •   NoobTW    8 年前

    {
         "typeRoots": ["node_modules/@types"]
    }