简体   繁体   English

错误 TS2430:接口“WebGLRenderingContext”错误地扩展了接口“WebGLRenderingContextBase”

[英]error TS2430: Interface 'WebGLRenderingContext' incorrectly extends interface 'WebGLRenderingContextBase'

When I run tsc it gives me this error output:当我运行tsc它给了我这个错误输出:

../../../AppData/Roaming/npm/node_modules/typescript/lib/lib.dom.d.ts(15340,11): error TS2430: Interface 'WebGLRenderingContext' incorrectly extends interface 'WebGLRenderingContextBase'.
  Types of property 'getExtension' are incompatible.
    Type '{ (name: "ANGLE_instanced_arrays"): ANGLEInstancedArrays; (name: "EXT_blend_minmax"): EXTBlendMinMax; (name: "EXT_color_buffer_half_float"): EXTColorBufferHalfFloat; (name: "EXT_frag_depth"): EXTFragDepth; (name: "EXT_sRGB"): EXTsRGB; (name: "EXT_shader_texture_lod"): EXTShaderTextureLOD; (name: "EXT_texture_filter_...' is not assignable to type '{ (extensionName: "EXT_blend_minmax"): EXT_blend_minmax | null; (extensionName: "EXT_texture_filter_anisotropic"): EXT_texture_filter_anisotropic | null; (extensionName: "EXT_frag_depth"): EXT_frag_depth | null; (extensionName: "EXT_shader_texture_lod"): EXT_shader_texture_lod | null; (extensionName: "EXT_sRGB"): EX...'.
      Types of parameters 'name' and 'extensionName' are incompatible.
        Type '"OES_vertex_array_object"' is not assignable to type '"ANGLE_instanced_arrays"'.

My tsconfig.json :我的tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "rootDir": "src",
    "outDir": "dist",
    "strict": true,
    "esModuleInterop": true,
    "sourceMap": true,
    "declaration": true
  },
  "exclude": [
    "node_modules",
    "dist"
  ]
}

tsc is version Version 3.1.3 . tsc是版本Version 3.1.3

Here is my package.json :这是我的package.json

{
  "name": "pupp-tf-test",
  "version": "0.0.1",
  "description": "Try to get environment set up to program using TypeScript, Puppeteer, and TensorFlow.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "xiaodeaux",
  "license": "ISC",
  "dependencies": {
    "@tensorflow/tfjs-node-gpu": "^0.1.18"
  },
  "devDependencies": {
    "@types/node": "^10.12.0"
  }
}

The the only .ts file I have is empty.我唯一的.ts文件是空的。 So this has nothing to do with the code in the file because there is none.所以这与文件中的代码无关,因为没有。 At least I assume it has nothing to do with that specific file.至少我认为它与该特定文件无关。

Also, I'm on Windows 10 and using Visual Studio Code.另外,我在 Windows 10 上使用 Visual Studio Code。 Here's vscode environment info:这是 vscode 环境信息:

Version: 1.28.1 (user setup)
Commit: 3368db6750222d319c851f6d90eb619d886e08f5
Date: 2018-10-11T18:13:53.910Z
Electron: 2.0.9
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64

It looks like the @types/webgl-ext package (an indirect dependency of @tensorflow/tfjs-node-gpu ) contains a declaration of the getExtension method of WebGLRenderingContext that is incompatible with the declaration of the getExtension method of WebGLRenderingContextBase in recent versions of the TypeScript standard library.看起来@types/webgl-ext包( @tensorflow/tfjs-node-gpu的间接依赖项)包含WebGLRenderingContextgetExtension方法的声明,该声明与最近版本的WebGLRenderingContextBasegetExtension方法的声明不兼容TypeScript 标准库。 I'm not sure what should be done about this, so I suggest you first file an issue against @types/webgl-ext .我不知道应该怎样做这件事,所以我建议你先文件中的问题@types/webgl-ext If you don't get an answer there, then you could escalate to TensorFlow.js support resources to ask if the dependency on a broken and apparently unmaintained package can be removed.如果您在那里没有得到答案,那么您可以升级到 TensorFlow.js 支持资源,询问是否可以删除对已损坏且明显未维护的包的依赖。

In the meantime, a workaround that may work is to create your own dummy version of the @types/webgl-ext package that is empty.同时,一种可行的解决方法是创建您自己的空的@types/webgl-ext包的虚拟版本。 Create a directory in your project to hold the dummy package (for example, suppose you name the directory webgl-ext ), copy the package.json from the real @types/webgl-ext package, create an empty index.d.ts file, and then register the dummy package in your main package.json using a relative path:在您的项目中创建一个目录来保存虚拟包(例如,假设您将目录命名为webgl-ext ),从真实的@types/webgl-ext包中复制package.json ,创建一个空的index.d.ts文件,然后使用相对路径在主package.json注册虚拟包:

  "dependencies": {
    "@tensorflow/tfjs-node-gpu": "^0.1.18",
    "@types/webgl-ext": "./webgl-ext"
  },

According @tafsiri on tfjs issue: Compile error with @tensorflow/tfjs-backend-webgl the issue is: "caused by a clash between the now built in types for webgl and the @types/webgl2 package we currently use" .根据@tafsiri on tfjs issue: Compile error with @tensorflow/tfjs-backend-webgl问题是: “由 webgl 现在内置类型和我们当前使用的 @types/webgl2 包之间的冲突引起”

He gives the next solution (that worked for me):他给出了下一个解决方案(对我有用):

  • Edit you file tsconfig.json and add the option skipLibCheck编辑您的文件tsconfig.json并添加选项skipLibCheck

     { "compilerOptions": { ... // skip error: Interface 'WebGL2RenderingContext' incorrectly extends interface 'WebGL2RenderingContextBase'. // https://github.com/tensorflow/tfjs/issues/4201 "skipLibCheck": true }, ... }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM