Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
bagfox8724yTypescript 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”
-
@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
-
Voxera113884yI agree.
And it also helps intellisence in vscode.
Even if not perfect its lessen the burden a lot. -
atheist99314yIt 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... -
If you like Typescript, you will love Purescript. It is more strict FP. iamgine haskell but with better ux and compiles to js.
-
@bagfox Prefering static typing has absolutely nothing to do with not understanding types, quite the opposite if anything
-
bagfox8724y@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. -
Xoka12784yTypescript is good but so many libraries when works fine in JS but works poorly in TS makes me sad :(
-
Voxera113884y@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. -
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.
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
random