9

typescript is awesome. it brings type safety into javascript which speeds up my workflow because I always find myself running into typing issues at runtime

Comments
  • 3
    Typescript is only a tool to maintain type safety. If you struggle with types in vanilla js, you probably should revisit the types basics before blindly trusting typescripts “type assurance”
  • 2
    @bagfox it was more of an exaggeration. i do occasionally run into type issues, but for the most part it's not bad. I also like TS because i used to work a lot with .net and it feels kinda similar to me
  • 3
    I agree.
    And it also helps intellisence in vscode.

    Even if not perfect its lessen the burden a lot.
  • 1
    It doesn't bring type safety, only suggests it. Soon as your input doesn't match what's expected, shit explodes. TS just kinda assumes it's right.

    ... Speaking as a C++ dev...
  • 1
    If you like Typescript, you will love Purescript. It is more strict FP. iamgine haskell but with better ux and compiles to js.
  • 5
    @bagfox Prefering static typing has absolutely nothing to do with not understanding types, quite the opposite if anything
  • 1
    @12bitfloat I guess you haven’t seen those typescript projects where every second variable is implicitly any to make anything work.

    If you can’t make typesafe vanilla js, typescript can also be counter productive. It is js after all. Any statically types value can be a different type at runtime.

    It’s no use when you define an api respone property as number when in reality it returns a string-number and you may never even notice.
  • 1
    Same Situation to what exactly what those code in Kotlin will say about Java.
  • 1
    Typescript is good but so many libraries when works fine in JS but works poorly in TS makes me sad :(
  • 1
    @atheist it assures it within your code.

    Outside input must always be verified or parsed but that is always important.

    And if you do not verify it you still have exactly the same security as in plain js.

    It still can work if any discrepancies are either irrelevant or does not trigger a fault.

    But with ts you at least know your own code follows the intended typing.

    Same as in C. If you within your code always use and match types you know your code will be correct but if you get data from the outside you either just trust the sender or you test and verify it.

    And yes both C and ts offers ways to circumvent the protections ;)

    But then you have elected to skip the protection, maybe for convenience or performance.
  • 1
    Typescript's type system is designed to express all valid JS. It doesn't force you to code differently but allows you to add type checks to JS. I like it because in vanilla JS a typo doesn't necessarily invalidate your code and IMO human input should always have 1 error detection.
Add Comment