Closed
Description
TensorFlow.js version
1.2.8
Browser version
node
12.6.0
Describe the problem or feature request
Packages using @tensorflow/tfjs-core
fail to compile with TypeScript 3.6 because of a conflict between @types/webgl2@0.0.4
and the built-in webgl2 types added in TS 3.6.
node_modules/@types/webgl2/index.d.ts:582:13 - error TS2403: Subsequent variable declarations must have the same type. Variable 'WebGL2RenderingContext' must be of type '{ new (): WebGL2RenderingContext; prototype: WebGL2RenderingContext; readonly ACTIVE_ATTRIBUTES: number; readonly ACTIVE_TEXTURE: number; readonly ACTIVE_UNIFORMS: number; readonly ALIASED_LINE_WIDTH_RANGE: number; ... 554 more ...; readonly WAIT_FAILED: number; }', but here has type '{ new (): WebGL2RenderingContext; prototype: WebGL2RenderingContext; readonly ACTIVE_ATTRIBUTES: number; readonly ACTIVE_TEXTURE: number; readonly ACTIVE_UNIFORMS: number; readonly ALIASED_LINE_WIDTH_RANGE: number; ... 555 more ...; readonly MAX_CLIENT_WAIT_TIMEOUT_WEBGL: number; }'.
582 declare var WebGL2RenderingContext: {
~~~~~~~~~~~~~~~~~~~~~~
node_modules/typescript/lib/lib.dom.d.ts:16450:13
16450 declare var WebGL2RenderingContext: {
~~~~~~~~~~~~~~~~~~~~~~
'WebGL2RenderingContext' was also declared here.
This conflict was resolved in DefinitelyTyped/DefinitelyTyped#36837 which created @types/webgl2@0.0.5
.
The only change is the removal of STENCIL_INDEX
which does not appear to be used in this repo.
Updating to @types/webgl2@0.0.5
should allow projects with TS 3.6 to use @tensorflow/tfjs-core
again.
Code to reproduce the bug / link to feature request
package.json
{
"scripts": {
"compile": "tsc"
},
"dependencies": {
"@tensorflow/tfjs-core": "^1.2.8",
"typescript": "^3.6.2"
}
}
tsconfig.json
{
"compilerOptions": {
"jsx": "preserve",
"allowJs": true,
"noEmit": true,
"strict": true,
"lib": ["dom", "esnext"]
},
"include": ["src"]
}
Create an empty src/index.ts
and run yarn && yarn compile
.
The fix can be confirmed with a resolution in the package.json
:
"resolutions": {
"@types/webgl2": "0.0.5"
}