Closed
Description
TypeScript Version: 1.8.34
Code
let canvas = document.createElement("canvas");
let context = canvas.getContext("2d");
let pattern: CanvasPattern = []; // !!!
context.fillStyle = pattern;
context.strokeStyle = 0; // !!!
Expected behavior:
Fails to compile due to []
and 0
not being valid CanvasPattern
s.
Actual behavior:
Successfully compiles, probably due to CanvasPattern
being declared as an empty interface
, which is obviously implemented by all objects. At runtime, the style is solid black.
// lib.d.ts
interface CanvasPattern {
}
//...
fillStyle: string | CanvasGradient | CanvasPattern;
//...
strokeStyle: string | CanvasGradient | CanvasPattern;