-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do this
Milestone
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;
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueHelp WantedYou can do thisYou can do this