Skip to content

Argument of type 'ImageBitmap' is not assignable to parameter of type 'HTMLCanvasElement | HTMLImageElement | HTMLVideoElement' #25468

Closed
@jtenner

Description

@jtenner

Hello! I am a very huge fan of typescript, and I'm sure adding ImageBitmap to the d.ts file responsible for canvas definitions should work.

Just to be clear, MDN lists the following things for CanvasRenderingContext2D.protortype.createPattern

A CanvasImageSource to be used as the image to repeat. It can be an:

- HTMLImageElement (<img>)
- HTMLVideoElement (<video>, by using the capture of the video)
- HTMLCanvasElement (<canvas>)
- CanvasRenderingContext2D
- ImageBitmap
- ImageData
- Blob

TypeScript Version: 2.9.2

Search Terms: Canvas. ImageBitmap, createPattern

Code

const image = await createImageBitmap(blob);
const pattern = ctx.createPattern(image);

Expected behavior:

Well I expect typescript to not report this as a problem.

Actual behavior:

Currently reported like this in my IDE.

Argument of type 'ImageBitmap' is not assignable to parameter of type 'HTMLCanvasElement | HTMLImageElement | HTMLVideoElement'.
  Type 'ImageBitmap' is not assignable to type 'HTMLVideoElement'.
    Property 'msHorizontalMirror' is missing in type 'ImageBitmap'.

Playground Link:
http://www.typescriptlang.org/play/#src=%0D%0Afetch("path%2Fto%2Fimg.png")%0D%0A%20%20%20%20.then(e%20%3D>%20e.blob())%0D%0A%20%20%20%20.then(e%20%3D>%20createImageBitmap(e))%0D%0A%20%20%20%20.then(e%20%3D>%20document.createElement("canvas")%0D%0A%20%20%20%20%20%20%20%20.getContext("2d")%0D%0A%20%20%20%20%20%20%20%20.createPattern(e%2C%20"repeat-x"))%3B%0D%0A%0D%0A

Related Issues: There are a few issues that involve definitions, not sure where to put this.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueHelp WantedYou can do this

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions