Skip to content

Improve HTMLCanvasElement and OffscreenCanvas types #52851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Improve HTMLCanvasElement and OffscreenCanvas types #52851

wants to merge 1 commit into from

Conversation

TomasHubelbauer
Copy link

I changed HTMLCanvasElement.getContext to follow the pattern set by OffscreenCanvas where the context ID is a string union so we get autocompletion for it in IDEs using LSP.

In the other direction, I changed OffscreenCanvas.getContext to follow HTMLCanvasElement's pattern with overloads for the individual context IDs as literal string parameters and return types being the specific types of context corresponding to that context ID.

I have also added OffscreenCanvas.convertToBlob which was missing altogether: https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/convertToBlob


Please verify that:

Fixes #52831

I changed `HTMLCanvasElement.getContext` to follow the pattern set by `OffscreenCanvas` where the context ID is a string union so we get autocompletion for it in IDEs using LSP.

In the other direction, I changed `OffscreenCanvas.getContext` to follow `HTMLCanvasElement`'s pattern with overloads for the individual context IDs as literal string parameters and return types being the specific types of context corresponding to that context ID.

I have also added `OffscreenCanvas.convertToBlob` which was missing altogether:
https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas/convertToBlob
@typescript-bot
Copy link
Collaborator

It looks like you've sent a pull request to update our 'lib' files. These files aren't meant to be edited by hand, as they consist of last-known good states of the compiler and are generated from 'src/lib' or possibly our lib generator. Unless this is necessary, consider closing the pull request and sending a separate PR to update 'src/lib' or https://github.com/microsoft/TypeScript-DOM-lib-generator

@typescript-bot typescript-bot added the lib update PR modifies files in the `lib` folder label Feb 19, 2023
@typescript-bot
Copy link
Collaborator

It looks like you've sent a pull request to update some generated declaration files related to the DOM. These files aren't meant to be edited by hand, as they are synchronized with files in the TSJS-lib-generator repository. You can read more here. For house-keeping purposes, this pull request will be closed.

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Feb 19, 2023
@TomasHubelbauer TomasHubelbauer deleted the improve-canvas-types branch February 19, 2023 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug lib update PR modifies files in the `lib` folder
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lib.dom.d.ts OffscreenCanvas.getContext() not returning type based on context ID
2 participants