microsoft / microsoft/TypeScript

texSubImage2D missing WebGL2 syntax

Open
#58,695 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: lib.d.ts Help Wanted Needs Human Review Needs More Info
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔎 Search Terms

texSubImage2D WebGL2

🕗 Version & Regression Information
  • I was unable to test this on prior versions because I used gl.texSubImage2D with ImageBitmap as source only just now
⏯ Playground Link

No response

💻 Code
gl.texSubImage2D(
  gl.TEXTURE_2D,
  0,
  0,
  0,
  100,
  100,
  gl.RGBA,
  gl.UNSIGNED_BYTE,
  data // <----- instanceof ImageBitmap
);
🙁 Actual behavior

Error:

Argument of type 'ImageBitmap' is not assignable to parameter of type 'ArrayBufferView'.
Type 'ImageBitmap' is missing the following properties from type 'ArrayBufferView': buffer, byteLength, byteOffset

🙂 Expected behavior

The code actually works fine, but I expect TS to not complain about the type.

Additional information about the issue

I am using a worker to gradually create the texture by creating the tiles and sending them back. The data comes from createImageBitmap metod as ImageBitmap and then pass it to texSubImage2D

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by searching the WebGL2 texSubImage2D declarations, using the reported call signature and ImageBitmap error as the entry point. Compare the available overloads with the WebGL2 syntax and verify that this exact ImageBitmap call type-checks without breaking the existing ArrayBufferView form.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.