Skip to content

Instantly share code, notes, and snippets.

@robertpenner
Forked from basarat/nonsense.ts
Created February 6, 2017 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertpenner/c2bd733fd936be07de636161a1c2e031 to your computer and use it in GitHub Desktop.
Save robertpenner/c2bd733fd936be07de636161a1c2e031 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