16

Why is Typescript such a snarky fuck?

a: number = 2;

tYpE Is TrIviAlLy InFeRReD fRoM NuMbeR lItERaL

Shut the fuck up you barely turing complete piece of digital refuse. Why does it bother you so much if I leave the fucking type on for clarity? This is almost as bad as my ex.

Comments
  • 1
    Yeah, it is a terrible default.
  • 6
    I’m siding with TS on this one. You should type your variables on declaration and not on assignment.
  • 6
    If it a warning I guess its tslint or prettier or similar and if so you can most likely configure it.

    The language has no problem with explicit typing if you want to but some linters/formaters have defaults set to suggest you skip the obvious types to make the code smaller.

    But You can usually change which such rules they should apply or not based on team or personal preference.

    And yes, such rulesets can often be opinionated ;)
  • 1
    @Voxera this! 💘
  • 3
    Inferred strong types are better, unless you need a strictly specific type. In which case you should have an explicit call to a converter function in the first place.
    There's no clarity in labeling it "number" when it is obviously instantiated as a number
Add Comment