3 ms·
No, 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 -
by SahAssar 6y ago
No, 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.