Live data from Hacker News

How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

chiragswadia.medium.com

101–110 of 400 posts

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#101
post #94

I have a theory that TypeScript was not actually invented for frontend developers, it was created for non-frontend developers who were forced to deal with the frontend, and hated JavaScript. That's also why I think it's very funny that JavaScript developers are starting to use TypeScript on be backend, i.e. Deno. You are using the patch to JavaScript that backend devs needed to make JavaScript more like backend langu…

Yes.

I write large Node projects and Electron apps and TS has been a huge help.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#102
Not much said on the category of bugs caught by Typescript. That would have been an interesting discussion.

I dip between javascript and typescript and hesitate recommending it for large scale project for a large team as much as I would like to, coming from a background of typed languages on the backend. There appears to be a need for experienced senior typescripters on the team to prevent falling into certain traps and onboarding [1].

I do wonder though how he saw typing as over-engineering. It may cause intertia which he hints at in the next sentence but over-engineering is a bit uncharitable.

[1] https://medium.com/javascript-scene/the-typescript-tax-132ff...

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#103
post #66
post #33

Earlier quoted context omitted.

Typescript is not accepted. How AngularJS stuck on 1.* is the best proof, and an illustration for the problem. Pretty serious people are working in Angular community, it's immensely popular in the enterprise webapp space, so I will not take the "Ah, it's just amateurs who are stuck there." It adds to countless attempts of other transpiled *scripts to extend Javascript. They, and Coffeescript in particular, are good h…

I wrote AngularJS 1.x in TypeScript in an enterprise application. Being "stuck there" ("there" meaning pure JS for Angular 1.x) is a choice.

I took over a legacy AngularJS 1.x MEAN app early last year. One of the first things I did was to convert it from using Gulp to building the client with Create-React-App's build tooling:

https://blog.isquaredsoftware.com/2020/03/codebase-conversio...

That unlocked the ability to add React and TypeScript code embedded directly in the existing AngularJS UI, using the `react2angular` library, as a short-term migration approach. I was also able to migrate some of our existing AngularJS controllers and client logic to TS to get a bit more safety.

Since then, I've set up a new Next.js subproject that sits behind the existing Express app server, and was able to show content from Next by inserting iframes into the AngularJS templates and proxying those URLs from the Express app to the Next app. That's let us build new features from scratch inside of the Next codebase while showing them seamlessly in the AngularJS UI, giving us a long-term migration path.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#104

I was hesitantly open to TS when the hype was first ramping up. The team I was on (and I've seen this in lots of code elsewhere too) was doing stuff like this: declare let myColor: Color | undefined; Suddenly everything turned into Java with signatures cascading endlessly. I'm not blaming TS, it's more of a.. lack of faith to make the full jump? Or limitation of the underlying Javascript? This problem should be solve…

If "| undefined" is spreading through your code like a virus in cases where it's not actually optional, then I'd argue that the problem is upstream where the data is ingested, and the code should be enforcing "must be defined" at input validation so that you can carry a clean "Color" type everywhere else.

If it's about optional parameter weirdness and TypeScript's lack of method overloading, I suspect that's inherited from JavaScript's laxness with method signatures. I don't like it either.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#105

I had the opposite experience. I like languages with static types a lot and I used to be a fan of TypeScript. After using it for a few OSS projects and professionally, I came to the conclusion that, if I need types, I'll use a real statically typed language if I need types and JS for what doesn't matter. TypeScript works but: - it's a major pain to work with if your dependencies don't have type definitions - if anoth…

Yep. My experience as well. In a large project, the types often end up being pointless since you can easily just ignore them at any time, and the "compiled" JS will just happily go along with it all. Eventually I hit a point where I wonder why we're even bothering using types.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#106
I often write Typescript and don't mind it; type safety is neat. But my personal take is that if I can't drop code into a webpage/console and have it execute immediately, it's not a "real" part of the web stack. It's a very useful abstraction for large projects, but it's still an abstraction from the actual syntax of the web.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#107
post #94

I have a theory that TypeScript was not actually invented for frontend developers, it was created for non-frontend developers who were forced to deal with the frontend, and hated JavaScript. That's also why I think it's very funny that JavaScript developers are starting to use TypeScript on be backend, i.e. Deno. You are using the patch to JavaScript that backend devs needed to make JavaScript more like backend langu…

Looking at the Internet Archive for typescriptlang.org, most (but not all) of their original samples are doing something in a browser[0], so while it definitely became popular with backend developers, I don't know if I would go so far as to say it was created for non-frontend developers who were forced to deal with the frontend.

[0] https://web.archive.org/web/20121004030106/http://www.typesc...

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#108

>> satisfying the TypeScript compiler is an over-engineering and not providing any meaningful benefits I tend to rail quite hard against the “type everything” world view but I’ve always been crystal clear on the benefits of types at boundaries between components. They can be a succinct way to codify the invariants and contract between components in a software architecture - with a nice quick feedback loop when you ap…

Yep, I'm a firm believer in using TS pragmatically. Type the obvious code (React component props, API responses, function arguments), and start by aiming for an "80% sweet spot" of type coverage. Don't get into arguments with the compiler, and avoid writing really complex types unless you've got a key spot in your code where adding that type now makes it a lot easier to infer types in other places:

https://blog.isquaredsoftware.com/2019/11/blogged-answers-le...

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#109

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".

Agreed. A senior engineer should know when they don't understand something and keep an open mind about it rather than rejecting it outright.

If this article started with legitimate reasons for not wanting to adopt TS it would be different. "It is hard for people to learn" is actually a legit reason but "I don't understand it" is probably not!

That doesn't imply all new things are good or that senior engineers need to understand all new things either. I think there is some confusion about this.

Skepticism !== reject everything without grokking.

Re: How an Anti-TypeScript “JavaScript developer” like me became a TypeScript fan

#110

Two downsides to TS: an extra step to transpile, and having to write shims when it bugs out and can't verify an external declaration. Upsides? When tuned to its most pedantic settings I've uncovered a handful of bugs that would have otherwise launched. That's worth far more than a few tiny annoyances. tslint > jslint.

If you are working on the server side, ts-node has been a huge timesaver. It removes the extra step of compiling and lets you just run your script with `ts-node script.ts` or even `#!/usr/bin/env ts-node` at the top of your file works.

https://github.com/TypeStrong/ts-node

Post reply on HN