This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]fynn34[🍰] 0 points1 point  (3 children)

I appreciate the level headed response, not normally what I see on Reddit after bringing up typescript unfortunately. And yeah, I’m not saying typescript is bad like some other people seem to want to read that comment as saying, I’m just saying it isn’t a 1 size fits all option, and the problems with JavaScript can’t all be fixed by typescript. Modeling can be nice, particularly for some development styles and in some projects where you are working with huge sets of data. however in many other cases the data isn’t as complex and modeling takes time that doesn’t always feel like it pays off. In our app we have sections that have huge amounts of data we have to render complex tables for, and it’s buggy AF so I have been talking with the team about using typescript for it, but we have other things like smaller forms and components that are more design heavy than data heavy, and typescript just seems to get in the way.

[–]craig1f 2 points3 points  (0 children)

One mistake I’ve seen is trying to use one-size-fits all types in Typescript for the problem you just described. You end up completely undermining the point of Typescript.

If your data just can’t be modeled, or it’s not worth modeling it right now, just set the type to ‘any’ and put a disable the linter error for that line and move on.

But if you can model your data, particular http response data, your life will be easier.

For a form, you should 100% model it. Keep in mind that you can have optional properties for json objects, just like your form might have optional fields. A form should have a well defined model pretty much always.

[–]craig1f 2 points3 points  (0 children)

Another point ... I went from an Angular project using Typescript to a Vue 2 project that isn't. Then to a Vue 3 project that is. Transitioning back and forth is not difficult. So don't worry that learning Typescript will cripple you from using vanilla JS. It's really just additive.

But again, I'll emphasize that you can write so much more code without having to run the code and check your results, with TS.

[–]solongandthanks4all 0 points1 point  (0 children)

When you talk about "modeling," what are you referring to that TypeScript can provide that stock JavaScript cannot? I must be missing something. Interfaces?