TypeScript
TypeScript copied to clipboard
setTimeout defined in lib.dom.d.ts is not type safe
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.