Skip to content

breaking changes from lib.d.ts being out of date with Strada #950

Closed
@controversial

Description

@controversial

The following minimal program passes tsc but fails tsgo:

function doSomething(program: WebGLProgram) { void program; }

const gl = document.createElement('canvas').getContext('webgl2');
if (!gl) { throw new Error('WebGL2 context not available'); }

const program = gl.createProgram();
doSomething(program);

tsgo fails with

src/test.ts:7:13 - error TS2345: Argument of type 'WebGLProgram | null' is not assignable to parameter of type 'WebGLProgram'.
  Type 'null' is not assignable to type 'WebGLProgram'.

7 doSomething(program);
              ~~~~~~~

Found 1 error in src/test.ts:7

compiler options looks like the following:

    "target": "es2023",
    "lib": ["esnext", "dom", "dom.iterable"],
    "strict": true,

The failure appears to be because the return type for createProgram includes null in tsgo’s lib.dom.d.ts but not in typescript’s. tsgo might bundle old lib files which predate the changes in KhronosGroup/WebGL#3642microsoft/TypeScript-DOM-lib-generator#1753microsoft/TypeScript#60061 ?

This incompatiblity results in dozens of errors when I tried tsgo in a large project at work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions