Microsoft/TypeScript

Type declaration of CanvasImageSource in lib.webworker.d.ts is incomplete.

Open

#29.970 geöffnet am 19. Feb. 2019

Auf GitHub ansehen
 (11 Kommentare) (2 Reaktionen) (0 zugewiesene Personen)TypeScript (6.726 Forks)batch import
BugDomain: lib.d.tsHelp Wanted

Repository-Metriken

Stars
 (48.455 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 6T 17h) (9 gemergte PRs in 30 T)

Beschreibung

Type declaration of CanvasImageSource in lib.webworker.d.ts is now only ImageBitMap. But that should be HTMLOrSVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap https://developer.mozilla.org/en-US/docs/Web/API/CanvasImageSource

TypeScript Version: 3.4.0-dev.201190216

Search Terms: CanvasImageSource

Code

let ctx = document.createElement("canvas").getContext("2d")
let img = new Image()
ctx.drawImage(img, 0, 0)

tsconfig.json

{
  "compilerOptions": {
    "target": "es2018",
    "module": "commonjs",
    "lib": [
      "webworker",
      "es2018",
      "dom",
    ]
  }
}

whole project in https://github.com/Muratam/yabai-sample.ts

Expected behavior: No error occurs when run webpack nor webpack --watch

Actual behavior: Following error occurs when incremental build in webpack --watch "TS2345: Argument of type 'HTMLImageElement' is not assignable to parameter of type 'ImageBitmap'. Property 'close' is missing in type 'HTMLImageElement' but required in type 'ImageBitmap'"

Playground Link:

Related Issues: #25468 In that issue, only TypeScript/src/lib/dom.generated.d.ts is referred, but lib.webworker.d.ts is also needed to be referred. Please fix type declaration of CanvasImageSource in lib.webworker.d.ts

Contributor Guide