It's probably worth taking a step back and interrogating why the actual "Why was I Anti-TypeScript?" a little bit more and use it as an opportunity for broader self development. The author didn't use and understand something, and rather than trying to they instead just defaulted to rejection. It's midly disapointing seeing this in people who label themselves as "Senior".
How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan
121–130 of 400 posts
Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan
#122It's probably worth taking a step back and interrogating why the actual "Why was I Anti-TypeScript?" a little bit more and use it as an opportunity for broader self development. The author didn't use and understand something, and rather than trying to they instead just defaulted to rejection. It's midly disapointing seeing this in people who label themselves as "Senior".
type Thing = {
name: string,
};
function getThing(): Thing {
return JSON.parse('{"error": "invalid id"}')
}
const thing: Thing = getThing(); // lie to me!
console.log(thing.name);
This is a trivial example to illustrate the idea that it's relatively easy to make a type that cascades through a very large app but which is backed by a complete lie.I definitely think that there's also something to be said about meta-programming yak shaving (e.g. people wasting hours trying to write a "function" that takes an enum and outputs another enum w/ a fixed prefix, when simply writing out the enums would've taken 30 seconds w/ VSCode's multiple cursor feature)
Personally, the value I see in TS is in cementing documentable facts about a system: e.g. such and such function takes such and such well-defined entity, dot not treat this `options` argument as a generic bucket for pass-through garbage.
Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan
#123Earlier quoted context omitted.
About 95% of React components I see in the wild are in TypeScript. The most rapidly growing JS backend framework (Nest) is in TS. Deno, the evolution of Node, is based on TS. Pretty much everything in the JavaScript OSS world has TS options or is based on TS. I doubt Coffeescript ever saw this scale of adoption.
We only use TypeScript on frameworks that make it a requirement, the language is starting to look like Haskell. As much as I like Anders work, it is impossible to understand modern TypeScript without looking into tsconfig.json before looking into source code.
Many toolings make it so you don't even need to worry about the tsconfig anymore (though in reality it is very helpful to understand it).
Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan
#124Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan
#125Earlier quoted context omitted.
I think the skepticism of new shiny things is healthy. Of the set of things that exist, most things are worse than the things one already uses/prefers. Most new things solve a specific problem that may not overlap with the problems one is trying to solve. With software development, a huge part of the puzzle is tooling (as the article points out), so even if typescript is obviously superior as a language, the tooling…
Strong typing is not shiny or new and, even if you're a javascript guy, not being remotely familiar with any strongly-typed language (or generics?!) is a red flag. (edit: red flag is a bad description, because he ended up being self-reflective and looking deeper, which is just about the furthest thing from a red flag.)
Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan
#126It's probably worth taking a step back and interrogating why the actual "Why was I Anti-TypeScript?" a little bit more and use it as an opportunity for broader self development. The author didn't use and understand something, and rather than trying to they instead just defaulted to rejection. It's midly disapointing seeing this in people who label themselves as "Senior".
Ironically, as someone who has experience w/ both fast-and-loose JS and with "properly" statically typed languages, my beef with typescript is precisely that it allows people to be fast and loose, sometimes in ways that are not super obvious. For example: type Thing = { name: string, }; function getThing(): Thing { return JSON.parse('{"error": "invalid id"}') } const thing: Thing = getThing(); // lie to me! console.l…
Typescript isn’t perfect by any means but it does a good job keeping code based easier to work with in a larger team. Much better than vanilla JavaScript
Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan
#127For me, I can handle the lack of static typing when I'm doing small scripts, like if it's going to be 100 lines or so of Python (my go-to language if I need to test some math out in a sandbox or do some file manipulation on my system). I might actually be a little faster in writing those scripts because of the lack of typing. Once it starts getting any bigger than that, though, static typing really catches and points…
I guess static first is a chore because at that point you have no idea what invariant or structure is required for the task. After prototyping you know where to tighten the bolts.
Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan
#128For me, I can handle the lack of static typing when I'm doing small scripts, like if it's going to be 100 lines or so of Python (my go-to language if I need to test some math out in a sandbox or do some file manipulation on my system). I might actually be a little faster in writing those scripts because of the lack of typing. Once it starts getting any bigger than that, though, static typing really catches and points…
I guess static first is a chore because at that point you have no idea what invariant or structure is required for the task. After prototyping you know where to tighten the bolts.
In the early days of a new app or feature, you have no idea what the correct data/type shapes are.
In TypeScript you can define the types and then easily do major refactors even if you have 1000's of lines already written.
It becomes so tedious to do the same refactoring in JavaScript.
TypeScript makes it trivial to change an object or function signature when developing new code (or old code).
Refactors that take 3 minutes in TypeScript take 3 days in JavaScript and you better hope you catch all the uses.
The refactor ability that TypeScript gives you makes it so much easier to change data types and function signatures dozens of times until you get things right.
Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan
#129It's probably worth taking a step back and interrogating why the actual "Why was I Anti-TypeScript?" a little bit more and use it as an opportunity for broader self development. The author didn't use and understand something, and rather than trying to they instead just defaulted to rejection. It's midly disapointing seeing this in people who label themselves as "Senior".
Ironically, as someone who has experience w/ both fast-and-loose JS and with "properly" statically typed languages, my beef with typescript is precisely that it allows people to be fast and loose, sometimes in ways that are not super obvious. For example: type Thing = { name: string, }; function getThing(): Thing { return JSON.parse('{"error": "invalid id"}') } const thing: Thing = getThing(); // lie to me! console.l…
I'm working through the very lie you're showing now because the disclipline wasnt established from the start to avoid these anti-patterns. Typescript isnt the perfect magic bullet that will disappear all your problems - you still need to have good developers writing good code, but TS will make it easier.
Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan
#130Earlier quoted context omitted.
I’d consider myself senior. I’ve been using Javascript since it was beta. I like Javascript. I don’t mind TypeScript. I mean, it’s nice and all but it doesn’t strike me as the be-all that others make it out to be. Maybe I just don’t use it for the types of project for which it was designed. It’s like I’m a metal worker and I get along fine with a ball peen hammer. You come along and give me your claw hammer with grea…
I understand the sentiment, but a better comparison would be if your tool of choice had to be shared between everyone on your team.