Compile error with @tensorflow/tfjs-backend-webgl for TS target > ES5
See original GitHub issueSystem information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: -
- TensorFlow.js installed from (npm or script link): npm
- TensorFlow.js version: 2.7.0
- CUDA/cuDNN version: -
Describe the problem
When trying to build a typescript code that depends on @tensorflow/tfjs-backend-webgl
, if the compilerOptions.target
is above ES5 (i.e “ES2015”,“ES2016”,“ES2017”,“ES2018”,“ES2019”,“ES2020” or “ESNext”), you get the following compilation errors:
node_modules/typescript/lib/lib.dom.d.ts:16532:11 - error TS2430: Interface 'WebGL2RenderingContext' incorrectly extends interface 'WebGL2RenderingContextBase'.
Types of property 'clearBufferfv' are incompatible.
Type '(buffer: number, drawbuffer: number, values: ArrayLike<number> | Float32Array, srcOffset?: number) => void' is not assignable to type '{ (buffer: number, drawbuffer: number, values: Float32List, srcOffset?: number): void; (buffer: number, drawbuffer: number, values: Iterable<number>, srcOffset?: number): void; }'.
Types of parameters 'values' and 'values' are incompatible.
Type 'Iterable<number>' is not assignable to type 'ArrayLike<number> | Float32Array'.
Type 'Iterable<number>' is missing the following properties from type 'Float32Array': BYTES_PER_ELEMENT, buffer, byteLength, byteOffset, and 25 more.
16532 interface WebGL2RenderingContext extends WebGL2RenderingContextBase, WebGL2RenderingContextOverloads, WebGLRenderingContextBase {
~~~~~~~~~~~~~~~~~~~~~~
node_modules/typescript/lib/lib.dom.d.ts:16532:11 - error TS2430: Interface 'WebGL2RenderingContext' incorrectly extends interface 'WebGL2RenderingContextOverloads'.
Types of property 'uniform1fv' are incompatible.
Type '(location: WebGLUniformLocation, data: ArrayLike<number> | Float32Array, srcOffset?: number, srcLength?: number) => void' is not assignable to type '{ (location: WebGLUniformLocation, data: Float32List, srcOffset?: number, srcLength?: number): void; (location: WebGLUniformLocation, data: Iterable<...>, srcOffset?: number, srcLength?: number): void; }'.
Types of parameters 'data' and 'data' are incompatible.
Type 'Iterable<number>' is not assignable to type 'ArrayLike<number> | Float32Array'.
Type 'Iterable<number>' is not assignable to type 'Float32Array'.
16532 interface WebGL2RenderingContext extends WebGL2RenderingContextBase, WebGL2RenderingContextOverloads, WebGLRenderingContextBase {
~~~~~~~~~~~~~~~~~~~~~~
node_modules/typescript/lib/lib.dom.d.ts:16532:11 - error TS2430: Interface 'WebGL2RenderingContext' incorrectly extends interface 'WebGLRenderingContext'.
Types of property 'uniform1fv' are incompatible.
Type '(location: WebGLUniformLocation, data: ArrayLike<number> | Float32Array, srcOffset?: number, srcLength?: number) => void' is not assignable to type '{ (location: WebGLUniformLocation, v: Float32List): void; (location: WebGLUniformLocation, v: Iterable<number>): void; }'.
Types of parameters 'data' and 'v' are incompatible.
Type 'Iterable<number>' is not assignable to type 'ArrayLike<number> | Float32Array'.
Type 'Iterable<number>' is not assignable to type 'Float32Array'.
16532 interface WebGL2RenderingContext extends WebGL2RenderingContextBase, WebGL2RenderingContextOverloads, WebGLRenderingContextBase {
~~~~~~~~~~~~~~~~~~~~~~
Found 3 errors.
Provide the exact sequence of commands / steps that you executed before running into the problem The error is easily reconstructed with the following:
- package.json:
{
"name": "tfjs-ts-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc"
},
"author": "",
"license": "ISC",
"dependencies": {
"@tensorflow/tfjs-backend-webgl": "^2.7.0",
"@tensorflow/tfjs-core": "^2.7.0",
"typescript": "^4.0.5"
}
}
- tsconfig.json:
{
"compilerOptions": {
"target": "ES2015"
}
}
- An empty index.ts
- npm install
- npm run build
Any other info / logs This partially relates to https://github.com/tensorflow/tfjs/issues/2007 but not the same issue
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:11 (4 by maintainers)
Top Results From Across the Web
tsconfig for typescript to support es5 target throws error
My tsConfig.json is as below: { "compilerOptions": { "target":"es5", "module":"system", "emitDecoratorMetadata": true, ...
Read more >Compiler Options - Microsoft Open Source
The target setting changes which JS features are downleveled or left intact. For example, an arrow function () => this will be turned...
Read more >TSConfig Option: target - TypeScript
The target setting changes which JS features are downleveled and which are left intact. For example, an arrow function () => this will...
Read more >Typescript - selecting proper target version - Dancing with CRM
ES5 vs ES2017. Let's review how the change only in the target version will improve our code. Below you can find sample ts...
Read more >tsconfig.json - TypeScript Deep Dive - Gitbook
This way TypeScript will include all the .ts files in this directory (and sub ... "target": "es5", /* Specify ECMAScript target version: 'ES3'...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The errors still occur with the latest version of
@tensorflow/tfjs-node
and@tensorflow/tfjs-node-gpu
.The errors are the same as in the first post.
About the `long` module
Note that I also added `long` module and types because otherwise I get these errors:Are you satisfied with the resolution of your issue? Yes No