Compile error with TypeScript 3.6
See original GitHub issueTensorFlow.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 https://github.com/DefinitelyTyped/DefinitelyTyped/pull/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"
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:7 (3 by maintainers)
Top Results From Across the Web
ERROR in The Angular Compiler requires TypeScript >=3.6.4 ...
If you get an error message saying The Angular Compiler requires TypeScript >=3.4. 0 and <3.5. 0 but x.x.x was found instead, please...
Read more >ERROR in The Angular Compiler requires TypeScript >=3.6.4 ...
This issue is completely unrelated to TypeScript. Perhaps you should file an issue in the Angular repository. It's the Angular tool that updated ......
Read more >TypeScript Compiling with Visual Studio Code
Compiling TypeScript. TypeScript is a typed superset of JavaScript that transpiles to plain JavaScript. It offers classes, modules, and interfaces to help ...
Read more >Documentation - TypeScript 3.6
TypeScript 3.6 now exposes two sets of APIs to operate on project references and incremental program building.
Read more >ts-loader - npm
TypeScript : 3.6.3+; webpack: 5.x+ (please use ts-loader 8.x if ... The build should fail on TypeScript compilation errors as of webpack 2....
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
Thanks for the info. FYI we usually suggest people add skipLibCheck to their tsconfig. https://www.tensorflow.org/js/tutorials/setup#typescript
npm i --save @types/webgl2 works for me