typescript-go icon indicating copy to clipboard operation
typescript-go copied to clipboard

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

Open controversial opened this issue 6 months ago • 3 comments

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 https://github.com/KhronosGroup/WebGL/pull/3642 → https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1753 → https://github.com/microsoft/TypeScript/pull/60061 ?

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

controversial avatar May 27 '25 15:05 controversial

This is to be expected; our lib files come from a "random revision from last fall": https://github.com/microsoft/typescript-go/tree/main/_submodules

We're intending on bumping this, doing so will just mean we need to also start backporting all of the checker changes since then.

jakebailey avatar May 27 '25 15:05 jakebailey

sounds good!

do more recent lib files depend on checker changes? or is it just that the lib files and the strada checker changes both come from the same submodule?

controversial avatar May 27 '25 16:05 controversial

Mainly, bumping the submodule brings in all of the new tests from all of the changes since then, all of the message changes, new compiler options, etc.

jakebailey avatar May 27 '25 16:05 jakebailey

Fixed by #1019; should be published within an hour.

jakebailey avatar Jun 04 '25 06:06 jakebailey