At my first few programming jobs I worked on Java projects. It is here that I first learned to appreciate, but also hate strict typing.
Fast-forward and Angular 2.0 dropped which was exclusively Typescript. A bold move at the time! I had heard about TS prior to that, but ignored it because it came out of Microsoft (Sorry MS! I really had no patience with anything MS back in those days, but things have since improved in Redmond).
Time went on and Typescript became popular. In fact, it's so popular that some people are simply using it because it seems "everyone uses it". I revisited Typescript (a couple times!) in hopes of being more mentally prepared for the Javaness and seeing past initial hurdles and finding its real value. I was underwhelmed. Here's why I'm not a fan:
I know technologies can be misused, but I've seen a lot of Typescript written just to comply with the other Typescript that was written. You might be thinking, "Duh! That's the whole point!" and I know that, but what it means in practice is unless your custom types are truly something special (much of what I've seen are meaningless wrappers around the primitives), then those custom types beget more mostly meaningless Typescript code, which renders the exercise pointless.
The issues I most often need to deal with can't be solved with Typescript:
- Network and environment-related issues
- API call failures
- AuthN, AuthZ stuff
- CSS not rendering the way I expected
- Events not behaving the way I expected
- Copy/pasted the wrong value, like
/foourl instead of
foostorage key instead of
- I goofed and used the wrong method, like
filter()when I should have
I would love to see some good data on non-Typescript projects and their percentage of production issues that would have been prevented with Typescript. Please share if you have a resource.
Also, my IDE is smart enough to do what Typescript enables in regards to intellisense, so there's no benefit there.
I remember one of my teams was investigating a production issue and eventually found the root cause was their custom type. Yes, a production issue caused by Typescript, not prevented by it.
Their code expected an object that came back from one of our APIs to have everything dictated by the type. Well, the API sent back the object without an optional property and the resulting code from Typescript crashed because heaven forbid the object didn't have all the properties Typescript thought it should have even though the object did have all the properties needed by the application.
Other benefits you get are:
- less configuration (I've wasted hours doing this for Typescript)
- less false errors ("Sorry Typescript, but it is you who are wrong, not my code. Here, have another
@ts-ignoreand be quiet.")
- faster builds
- less compatibility issues when using 3rd-party stuff
- smaller payloads
So, is Typescript bad. No.
Is it a must-have that provides tons of value. No.
Should everyone Typescript because [current year]. No.
Should you use it? If you have found a genuine need, yes.
I did not realize religious wars were still a thing in front-end development. I thought the community grew out of that a few years ago and it seems most have. Many commenters have graciously shared constructive comments, like @flaviomh , who I learned something from. Some comments are in support of my reasons, and some disagreed with my reasons without implying I'm a moron. All of it is appreciated!
So, if you're gonna comment PLEASE contribute to the discussion in a constructive way. If I'm wrong about a point, avoid implying things and just articulate your constructive thoughts and it will be reciprocated by myself and others.
Been working in Rust lately. At least in the context of web endpoints, it is borderline comical to work with.
Spent an entire afternoon trying to compare two "strings". Yes, compare two strings! And that was with the help of several people who are familiar with the language. Try it yourself:
/// See https://docs.rs/warp/0.3.1/warp/filters/header/fn.exact.html .and(warp::header::exact_ignore_case("Authorization", secret_string)) // <-- Good luck converting your String to a &'static str