Skip to content

Instantly share code, notes, and snippets.

@basarat
Created August 22, 2016 22:44
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save basarat/3f2bbfacd22b1c5bfe7f8151575f2cb3 to your computer and use it in GitHub Desktop.
[] + []; // JavaScript will give you "" (which makes little sense), TypeScript will error
//
// other things that are nonsensical in JavaScript
// - don't give a runtime error (making debugging hard)
// - but TypeScript will give a compile time error (making debugging unnecessary)
//
{} + []; // JS : 0, TS Error
[] + {}; // JS : "[object Object]", TS Error
{} + {}; // JS : NaN, TS Error
"hello" - 1; // JS : NaN, TS Error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment