Node.js   发布时间:2022-04-24  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了node.js – 错误TS2430:接口’WebGLRenderingContext’错误地扩展了接口’WebGLRenderingContextBase’大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
当我运行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"'.

我的tsconfig.json:

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

tsc是版本3.1.3.

这是我的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"
  }
}

我唯一的.ts文件是空的.所以这与文件中的代码无关,因为没有.至少我认为它与该特定文件无关.

另外,我在Windows 10上并使用Visual Studio Code.这是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

解决方法

看起来@ types / webgl-ext包(@ tensorflow / tfjs-node-gpu的间接依赖)包含WebGLRenderingContext的getExtension方法的声明,该声明与最近版本的WebGLRenderingContextBase的getExtension方法的声明不兼容. TypeScript标准库.我不确定应该怎么做,所以我建议你首先对阵@ types / webgl-ext file an issue.如果你没有在那里得到答案,那么你可以升级tensorflow.js支持资源,询问是否可以删除对破坏且显然未维护的包的依赖性.

与此同时,可能有效的解决方法是创建自己的虚拟版本的@ types / webgl-ext包为空.在项目中创建一个目录来保存虚拟包(例如,假设您将目录命名为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"
  },

大佬总结

以上是大佬教程为你收集整理的node.js – 错误TS2430:接口’WebGLRenderingContext’错误地扩展了接口’WebGLRenderingContextBase’全部内容,希望文章能够帮你解决node.js – 错误TS2430:接口’WebGLRenderingContext’错误地扩展了接口’WebGLRenderingContextBase’所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: