TypeScript icon indicating copy to clipboard operation
TypeScript copied to clipboard

setTimeout defined in lib.dom.d.ts is not type safe

Open yw662 opened this issue 6 years ago • 7 comments

TypeScript Version: 3.5.2

Search Terms: settimeout type safe Code

// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
const f = (foo: number) => console.log(foo + 1);
setTimeout(f, 0, 'a');

Expected behavior: It shall not pass thanks to the type error. Actual behavior: It passes. Playground Link: https://www.typescriptlang.org/play/#code/MYewdgzgLgBAZjAvDAFHEIBcMwFcC2ARgKYBOAlEgHwyiQgA2xAdAyAOZoYwDUMAjOQDcAKAjEoAFQCW+YiFxQ0AGhgAGVQHIAhoULBgAE0PFNWwpuFA Related Issues: emm, maybe not.

yw662 avatar Jul 01 '19 00:07 yw662