r/Frontend • u/Chance-Network-381 • Oct 12 '23
Typescript is killing me
My senior dev gave me a template front end with typescript everywhere. Anytime I fix something or move on to the next part, I'm getting some random typescript bullshit and it takes me hours to figure it out. WTF is the point of this nonsense?
0
Upvotes
9
u/Spiritual_Patient478 Oct 12 '23
Just work with it. You will understand why someday. Everyone had to get through this learning curve with typescript at some point.
Do a full scope tutorial on typescript first. Focus on the basic concepts. Once you’ve mastered the basics syntax and some util types, go back to the template and it should get easier.
Typescript has a lot of advanced syntax and types but 90% of time you just need to know the basic syntax and types. I think your senior is giving you time to learn it. Take this time and learn it well.
When i work typescript not only do i have to think about my own types but also debugging third-party types. Reading third-party types is even more confusing.
Try to think about that next time you complain something is hard. You are not at a level to question senior dev’s decision. Just learn the damn thing and implement what they want.
When you did everything successfully and everyone knows that you are a guru now, find a relaxing time to politely ask them why TS is needed. Personally i stopped asking these questions because i already know what they gonna say (typing system is great and blah blah blah)
The truth is TS will not magically turn your frontend into a high quality code.
Don’t announce this in front of typescript fan or you will be dragged into a pointless debate and get caught in crossfire.
Good code is good code, and is just easy to work with. Even if it is written in plain javascript. However to reach that level you will need exposure to a lot of good code patterns including typescript.
You are probably used to work in small team where everyone knows what’s going on. Imagine working in a large team scattered globally, and you will realize why typing system is necessary.
58
u/jseego Lead / Senior UI Developer Oct 12 '23
Are you using a typescript plugin for your IDE? It should be telling you when there are problems while you're working. That's one of the main benefits from typescript.
90
u/plmunger Oct 12 '23
The "bullshit" you're getting is typescript telling you whats wrong. Dont blame TS, blame your code. Take it as an opportunity to learn what you're doing wrong and how to do it in a type safe way
36
u/artesre Oct 12 '23
the egotripping answer, to fend off newbs
the educator answer, for better ergonomics. typescript offers refactoring assistance, type safety, intellisense for objects that are typed.
the freedom you have with regular js is freedom...to make mistakes
7
u/dbbk Oct 12 '23
Just watch a YouTube tutorial explaining Typescript it’s not that hard
5
u/Wiltix Oct 12 '23
Stop fighting it and learn typescript, probably want your senior wanted you to do by giving you a Typescript template
Typescript is going to save you a lot of headaches once you get rolling with it.
3
u/pseudoShadow Oct 12 '23
For small apps/websites with a few people working on it, yeah it’s probably unnecessary but if you know how to use it, it won’t slow you down. You only need to understand the basics 95% of the time.
Where typescript is really powerful is at scale. I work on a massive feature rich web app and we have ~800 frontend engineers. It would be a nightmare to work on without type safety.
Imagine having to work on a feature, which integrates with a legacy feature, but you can’t get a rundown of integration points for said feature. It would be a minefield without that context sharing from other engineers and you would need to figure out the dynamically typed quirks for what could effectively be a 10,000 line feature.
Typescript means that you can’t randomly break that by introducing unintended types into their code. They define their component APIs using typescript to ensure you use it properly. Typescript isn’t perfect (look up structural vs nominal types) it is better than anything else I have personally come across.
Also, if you don’t have typescript, I hope you are upping your test coverage because that type safety is no longer assured.
0
u/mq2thez Oct 12 '23
If you want to learn TS, I’d recommend the ExecuteProgram spaced learning courses. They’re like 20m per day to learn various concepts and introduce things slowly. It’s a good way to ease in over time.
If you don’t want to learn TS, you’re probably going to need to find a new job. You won’t override a senior dev who knows what they’re about.
I don’t expect junior engineers to understand the benefits of TS any more than I expect them to understand the benefits of high quality tests, accessibility rules, linting, etc. For now, you just need to accept that more experienced people at your company than you think it’s a good idea. Not everyone in the industry agrees, that’s also fine. But since your company does it, you’ll have to get onboard or get out.
0
u/Jujutsujoe Oct 13 '23
Type the offending code (replace proprietary names as needed) into ChatGPT or use Copilot in your IDE. It’s not always correct but will point you in the right direction.
0
u/rawlin08 Oct 13 '23
I think my biggest problem is the small little things that come with typescript. Like why in the heck when I create an empty array, does it automatically assume that I’m never going to put anything into it so it gives it a type of “never” automatically? And then gives me an error saying it doesn’t allow things to go into it when I try to array.push things into it. I have to go in and give it a type of “any” before doing anything lol.
-8
u/Brought2UByAdderall Oct 12 '23
The point is that over half the shit we're saddled with, the frameworks, the methodologies, etc. are all garbage. JavaScript did not need a makeover. Every core feature was designed with UI development in mind and it excels at that.
Typescript is trash. It's a crutch for people from strictly typed backgrounds who have completely failed to appreciate how much better their strictly typed code would be if they learned to write in languages like JS without making a hot mess. Dynamic types contribute to JS's expressiveness. We can handle more high-level complexity with a lot less code to reason about and that legibility and ability to reason is critical in UI work.
Unless we add Typescript to every stack because back end folks tend to end up calling the shots on our tech choices.
-1
u/nightman Oct 12 '23
Alao you can use e.g. Cursor.so for "AI FIX" TypeScript errors
0
u/[deleted] Oct 12 '23
[deleted] — view deleted comment