Skip to content

Removed optional parameter from Window.createImageBitmap factory #27475

Closed
@Mirovsky

Description

@Mirovsky

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions