Skip to content
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

CanvasRenderingContext2D#drawImage overloading problem #3501

Closed
NekR opened this issue Jun 13, 2015 · 1 comment
Closed

CanvasRenderingContext2D#drawImage overloading problem #3501

NekR opened this issue Jun 13, 2015 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@NekR
Copy link

NekR commented Jun 13, 2015

This code:

var canvas = document.createElement('canvas');
var context = canvas.getContext('2d');
var drawThing:HTMLImageElement|HTMLCanvasElement;

context.drawImage(drawThing, 0, 0);

fails with error:

2345 Argument of type 'HTMLCanvasElement | HTMLImageElement' is not assignable to parameter of type 'HTMLVideoElement'.
  Type 'HTMLCanvasElement' is not assignable to type 'HTMLVideoElement'.

But I thought drawImage accepts one of HTMLCanvasElement | HTMLImageElement | HTMLVideoElement, isn't it?

@danquirk
Copy link
Member

Unfortunately while drawImage does have 3 overloads which cover the three types you mention, that is not the same as actually accepting a union of those 3 types. See #1805 for some more discussion, these DOM APIs are certainly motivating examples for why we should consider the solution in that issue where we would special case single argument functions.

@danquirk danquirk added the Duplicate An existing issue was already created label Jun 15, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants