Live data from Hacker News

Stop giving code examples in TypeScript

steverydz.com

1–10 of 14 posts

Re: Stop giving code examples in TypeScript

#2
The ecosystem is largely adopting Typescript as the canonical way to write javascript applications now, and having types makes the code more readable. I feel like it makes a lot more sense for tutorials to show things in Typescript, which is what most devs would actually use, rather than lose that type context with pure JS.

Re: Stop giving code examples in TypeScript

#5
I'm going to drop a spicy hot take here... no one should be using typescript unless they actually understand javascript first. And I agree with the author. There's no good reason why JS code examples should all be in typescript, and more than when they were all written in JQuery. It speaks to a fundamental lack of knowledge within the JS community of anything beyond the surface level.

This pathological drive in the JS dev community to pretend the language they're working with doesn't exist is counterproductive - what happens when no one in the javascript development community actually knows javascript, and the standard tool for generating javascript moves on to something other than typescript?

Re: Stop giving code examples in TypeScript

#6
post #2

The ecosystem is largely adopting Typescript as the canonical way to write javascript applications now, and having types makes the code more readable. I feel like it makes a lot more sense for tutorials to show things in Typescript, which is what most devs would actually use, rather than lose that type context with pure JS.

I wouldn't be so sure that MOST devs would use TS. It certainly is popular and dare I say trendy, but I know more people and projects that don't use it over those that do.

Re: Stop giving code examples in TypeScript

#7
post #5

I'm going to drop a spicy hot take here... no one should be using typescript unless they actually understand javascript first. And I agree with the author. There's no good reason why JS code examples should all be in typescript, and more than when they were all written in JQuery. It speaks to a fundamental lack of knowledge within the JS community of anything beyond the surface level. This pathological drive in the J…

I couldn't agree more. I see this with React too. You can go a long way without knowing much about JS as a language. You can also get a lot more out of tools and frameworks once you understand what problems they are solving.

Re: Stop giving code examples in TypeScript

#8
> About 10 years ago we had a similar problem with jQuery. Often you would go to Stack Overflow to find the answer to a JavaScript problem you were having only to find the answer was given in jQuery.

I don't understand this argument. TypeScript is just JS + type annotations — you should be able to boil away any fluff and be left with functioning JS. Whereas jQuery has actual runtime logic that would need to be reworked if you wanted a $-free solution.

The author goes on to say:

> This was even worse when the question was along the lines of “How do you do (jQuery thing) in JavaScript?”.

When would anyone ask "How do you do (TypeScript thing) in JavaScript"?

Re: Stop giving code examples in TypeScript

#9
> TypeScript has a steep learning curve

Does TS have a steep learning curve, or just a steep config curve? I personally feel that once a project has TS up & running, the actual use of it can be straightforward. Inference is so good these days, you shouldn't see many actual types at all in your code.

Have I just been using it too long, and I've forgotten the initial pain?

Re: Stop giving code examples in TypeScript

#10
post #9

> TypeScript has a steep learning curve Does TS have a steep learning curve, or just a steep config curve? I personally feel that once a project has TS up & running, the actual use of it can be straightforward. Inference is so good these days, you shouldn't see many actual types at all in your code. Have I just been using it too long, and I've forgotten the initial pain?

I'd say it depends on your JavaScript experience prior to learning TS. It will be easier for some than others. I don't think it's fair to assume that most people will find it straightforward.
Post reply on HN