Skip to content

Removed optional parameter from Window.createImageBitmap factory #27475

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
Mirovsky opened this issue Oct 1, 2018 · 3 comments
Closed

Removed optional parameter from Window.createImageBitmap factory #27475

Mirovsky opened this issue Oct 1, 2018 · 3 comments
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Milestone

Comments

@Mirovsky
Copy link

Mirovsky commented Oct 1, 2018

TypeScript Version: 3.1.1

Search Terms:
createImageBitmap, ImageBitmapOptions, Image Bitmap, lib.dom

Code

const bitmap1 = createImageBitmap(img, { premultiplyAlpha: 'none' })
const bitmap2 = createImageBitmap(img, 0, 0, img.width, img.height, { premultiplyAlpha: 'none' })

Expected behavior:
Should compile and create Promise<ImageBitmap> in both cases.

Actual behavior:
Doesn't compile since last optional options param was removed from lib.dom.d.ts between 3.0.3 and 3.1.0. Although ImageBitmapOptions are still present in lib.dom.d.ts.

Playground Link:
http://www.typescriptlang.org/play/#src=new%20Promise%3CHTMLImageElement%3E((resolve)%20%3D%3E%20%7B%0D%0A%20%20%20%20const%20image%20%3D%20new%20Image()%0D%0A%20%20%20%20image.src%20%3D%20'http%3A%2F%2Fwww.typescriptlang.org%2Fassets%2Fimages%2Flogo_nocircle.svg'%0D%0A%20%20%20%20image.onload%20%3D%20()%20%3D%3E%20%7B%20resolve(image)%20%7D%0D%0A%7D).then((image)%20%3D%3E%20%7B%0D%0A%20%20%20%20return%20createImageBitmap(image%2C%200%2C%200%2C%20image.width%2C%20image.height%2C%20%7B%0D%0A%20%20%20%20%20%20%20%20premultiplyAlpha%3A%20'none'%0D%0A%20%20%20%20%7D)%0D%0A%7D)

It was removed in commit ee25cde with vendor specific types (even though it's not vendor-specific).
Even though not all browsers supports last optional param, it's still part of living standard.

@RyanCavanaugh RyanCavanaugh added Bug A bug in TypeScript Help Wanted You can do this Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript labels Oct 1, 2018
@RyanCavanaugh RyanCavanaugh added this to the Community milestone Oct 1, 2018
@hexrcs
Copy link

hexrcs commented Oct 2, 2018

Created a PR in TSJS-lib-generator, I think it should fix this problem.

@RyanCavanaugh RyanCavanaugh modified the milestones: Community, Backlog Mar 7, 2019
@s4m0r4m4
Copy link

This seems to be working for me now, no more errors when I run the following (at least in a web worker):

const cImageData: ImageData = ...;
const cOpts: ImageBitmapOptions = { ... };

const cRenderedImage: ImageBitmap = await createImageBitmap(
                cImageData,
                0,
                0,
                10,
                10,
                cOpts);

@jakebailey
Copy link
Member

Just looking at old issues; this was fixed in #37464.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

5 participants