4 ms·
It's JavaScript; you can't really know. Math.round = () => "haha"; Now `Math.round(3)` is a string.
by millstone 6y ago
It's JavaScript; you can't really know.
Math.round = () => "haha";
Now `Math.round(3)` is a string.
- SahAssar 6y agoNo, when TS checks js it will check types for built-ins too: npm i typescript echo 'Math.round = () => "haha";' > test.js ./node_modules/.bin/tsc --allowJs --checkJs --noEmit test.js And you get: test.js:1:20 - error TS2322: Type 'string' is not assignable to type 'number'. 1 Math.round = () => "haha"; ~~~~~~ node_modules/typescript/lib/lib.es5.d.ts:708:5 708 round(x: number): number; ~~~~~~~~~~~~~~~~~~~~~~~~~ The expected type comes from the return type of this signature. Found 1 error.