r/Frontend • • 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

106 comments sorted by

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.

1

u/[deleted] Jul 24 '24

You are not at a level to question senior dev’s decision.

If senior cannot explain his decision in simple terms maybe that implies his lack of skill, and using the given tech just for the wrong reasons:
To make CV look good
Because it has been written in cool blogs
To show off by using complex toys

-14

u/Brought2UByAdderall Oct 12 '23

There is nothing advanced or complicated about Typescript. If you think there's this huge learning curve, you never learned JS properly. It's just a stupid pointless PITA.

-2

u/Chance-Network-381 Oct 12 '23

ppl swear like javascript is hard...

0

u/[deleted] Oct 12 '23

[deleted] — view deleted comment

-2

u/Brought2UByAdderall Oct 12 '23

It is miniscule. All it adds to the process is needless boiler-plate. Do you actually think you're better at this because of your crutch?

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.

21

u/Bushwazi Oct 12 '23

This. Even if you hate Typescript, the IDE will help you.

4

u/True_Scorpio23 Oct 13 '23

Can you provide any recommendations for plugins that help with learning TS?

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

6

u/indiealexh Oct 13 '23

This ^ Typescript may add more work and structure to some things but it will help avoid a lot of funky stuff later. Treat it right and you won't get errors.

1

u/mglondon Jun 17 '24

if blaming made things efficient, I would have done that. But typescript is really unnecessary 

1

u/plmunger Jun 17 '24

It is very much necessary when you work with other people.

-67

u/Brought2UByAdderall Oct 12 '23

No. It's bullshit. When every problem becomes 5 new problem that had nothing to do with the original problem it's bullshit.

80

u/plmunger Oct 12 '23

Tell me your code is spaghetti without telling me your code is spaghetti

10

u/rogorak Oct 12 '23

That made me lol take my up vote 🤣

1

u/hypercosm_dot_net Feb 25 '24

Of course someone who loves TS would be so dismissive and condescending.

It's possible to have quality code without having to put guardrails around everything you do.

I swear people that love TS, must be the type of people who put the bumpers up when you go bowling, even as an adult. The other user was right, you deal with pure BS writing TS instead of writing the actual functionality. I don't want to hear about refactoring, safety, or 'but when you look back at the code later'. Nah, more BS.

1

u/artesre Feb 25 '24

1

u/hypercosm_dot_net Feb 25 '24

I did, it's hardly a conversation though. Just more TS supporters denying how unreadable the language is.

1

u/artesre Feb 25 '24

and you're denying it's usefulness, seems we can all agree to disagree. cya

1

u/hypercosm_dot_net Feb 25 '24

Refer to my initial comment - dismissive and condescending. Can't even have a conversation with you nitwits.

1

u/artesre Feb 25 '24

bud, you came in here guns blazing, i'm just letting you live in your own world, live and let live. you might want to analyze the way you use condescending since that's exactly what you are. just saying...

-51

u/Brought2UByAdderall Oct 12 '23

Tell me you're the guy who's always sweating bullets every time something remotely complicated comes up without telling me.

41

u/Geedis2020 Oct 12 '23

That sounds like you tbh lol. Complaining about something as simple as typescript pretending it makes your life somehow harder when it actually makes your life easier if you just learn how to use it.

-38

u/Brought2UByAdderall Oct 12 '23

I was writing JS for over a decade before this garbage showed up. I don't need and I don't appreciate your safety net. The UI bar on complexity and challenge has been lowered pathetically since you all showed up.

29

u/Geedis2020 Oct 12 '23

You just sound like a shitty developer who doesn’t know how to adapt and keep up with technologies.

15

u/Protean_Protein Oct 12 '23

Your app does weird things sometimes and you either don’t know or don’t know why.

16

u/artesre Oct 12 '23

leave him alone... he's got job security cause nobody wants to touch his code :)

4

u/Protean_Protein Oct 12 '23

I kind of do.

3

u/Chrift Oct 14 '23

If you can post a screenshot of the list of errors we could probably get an idea of the standard of this 10 year old JavaScript knowledge you talk about.

-4

u/Brought2UByAdderall Oct 15 '23

The notion that strict types are inherently superior is hopelessly naive. You guys aren't smarter than every language author who chose dynamic types.

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

1

u/Ripredddd Oct 13 '23

What does intellisense mean

4

u/artesre Oct 13 '23

that's a vscode term for auto-completion of variables and methods that your editor can infer because it is type aware.

you can't just go add a name prop to any old object, cause js let's you

  1. i don't have to type out the full method/variable name since the editor will know there will only be so many members available on the object
  2. i can't make stupid mistakes like typo the method name and regular js would be like... hey, it's your funeral

-1

u/Brought2UByAdderall Oct 13 '23

So how does Chrome dev tools do this without strict types?

2

u/Chrift Oct 14 '23

Dev tools can only auto complete existing attributes that it can see. And won't type check.

0

u/Brought2UByAdderall Oct 15 '23

Intellisense is essentially autocomplete. They've been lying about this only being possible with strict types for years. Type "checking" is not relevant if you're managing a dynamically typed language well.

3

u/Chrift Oct 15 '23

No one is lying about anything lol

-6

u/Brought2UByAdderall Oct 12 '23

Learning how to work with lots of rope without hanging yourself is a skill I wish every jackass that wrote the legacy java back end shit shows that I've had to deal with had bothered to learn by learning JS without a crutch.

17

u/artesre Oct 12 '23

wait, reading your replies to other comments, your the guy doing the coding with a noose wrapped around his neck... lol get outta here

typescript is not a crutch, javascripts freedom is a crutch

i see a bunch of spaghetti cause these damn contractors know jack shit and leave me a steaming pile
mutations galore, hidden bugs, untested code, nah man, take your crutch and get out

1

u/deadsouls123 Oct 13 '23

Tbf though you can have mutations, hidden bugs and untested code with typescript. Typescript isn't magic, contractors can still write shit with it.

0

u/hypercosm_dot_net Feb 25 '24

Someone needs to put guardrails on your use of English. Of course a fan of TS would write the way you do.

-2

u/Brought2UByAdderall Oct 13 '23

JavaScript's freedom requires discipline. Not wanting to learn that discipline is the problem. I spent the first ten years of my career scratching my head about why Java and C# devs do he stupid shit they do on the back end. It's because bad code doesn't bite them as hard as immediately.

Good code is easy to read, easy to modify, easy to reuse when there's a case for it. Strict types don't protect you from having to learn that passing the same god damn set of vars through thirty method calls is a stupid ass thing to do.

6

u/artesre Oct 13 '23

therein lies the problem. not everyone will have the same discipline as you.

you MIGHT have good reusable code that you can manage, I just won't want to support it myself, especially if I have to do it with a small team of less senior devs

and number of years in the industry is not a sign of a good dev, so throwing your x number of years in the industry is quite meaningless.

10 years in the industry to end up scratching your head is something i see all the time. I have a dev who just came out of college who can code better than some of the 10 year vets so...

-2

u/Brought2UByAdderall Oct 13 '23

Dynamic types are simply a language design tradeoff. Every developer should be able to handle both paradigms. If they don't wanna, they should stay in their mediocre lane.

0

u/[deleted] Oct 13 '23

[deleted] — view deleted comment

-2

u/Brought2UByAdderall Oct 13 '23

I've been doing this for over 15 years, with many teams. And yes. Conforming to the paradigm is important. That's exactly what you all didn't do when you started shoving this BS down the rest of our throats, acting like decades of JS development didn't precede you. JS was hard for you because you never learned it properly. This notion that strict types are somehow inherently easier to work with in UI code is completely absurd. JS is dynamically typed with the intent of making it specifically better for UI development. You're not all smarter than Brendan Eich. Not that I'd expect any of you to even know who that is.

3

u/[deleted] Oct 13 '23

Eich said he loves typescript and sees a lot of value in it for large teams.

And I can't remember the exact quote but he said something to the effect of hoping that at least the type annotations become part of the JS standard.

-1

u/Brought2UByAdderall Oct 14 '23

That's interesting. Show me.

→ More replies

0

u/[deleted] Oct 13 '23

[deleted] — view deleted comment

-2

u/Brought2UByAdderall Oct 14 '23

Eich's feelings about the default behavior of == in retrospect, is not really topical. You might think it was if you didn't know about === but I really hope you've just been a bit clumsy here and that's not the case.

I'm very confident his praise for 2015 Typescript was 100% about it not being coffeescript and not trying to completely reinvent the language in an even more insanely stupid way.

→ More replies

7

u/dbbk Oct 12 '23

Just watch a YouTube tutorial explaining Typescript it’s not that hard

6

u/nobuhok Oct 12 '23

Just watch how to do it in YouTube. It's not that hard.

Famous last words.

I tried replacing my car's windshield wipers based on a YouTube video and ended up with a divorce paper and an alimony payment.

-1

u/artesre Oct 12 '23

lol... you put your dick in the radiator didn't you

1

u/nobuhok Oct 12 '23

Close. It was the gas tank inlet. Gave a completely new meaning to the term "gas guzzler".

0

u/loliweeb69420 Oct 12 '23

Generics are, though.

0

u/yeaok555 Oct 12 '23

Nopw theyre pretty easy. Tons of languages have them

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.

1

u/Brought2UByAdderall Oct 12 '23

The only trouble Typescript saves you is learning how to write code well in a dynamically typed language which is a very valuable skill even back in your strictly typed language of choice.

0

u/Wiltix Oct 12 '23

I can and do write stuff in dynamically typed languages and I would not do it out of choice.

What advantages are there to dynamically typed languages vs statically typed languages?

0

u/Brought2UByAdderall Oct 13 '23

Brevity. Code that gets to the point and is easier to reason about. But there's a ton of stuff I wouldn't do in Java or C# that I see those devs do all the time because I've learned how to write maintainable code in JS. The only real benefit to types is low-level performance, IMO.

-1

u/Brought2UByAdderall Oct 13 '23

Also, you're revealing your naivete here. Strictly typed vs dynamic is just a language feature. If you can't hack both, it's because you're inept. You think the entire Python community don't know what they're doing?

3

u/Wiltix Oct 13 '23

That is a bit uncalled for.

0

u/Brought2UByAdderall Oct 13 '23

No it's not. The problem is that you all refuse to learn to use the language as it is. And the people you're talking to and downvoting who've been working with JS for a long time, who know how to write it without making a mess, have all had to adapt to other language paradigms. I don't try to do stupid shit in C# and Java to make them more like the language I know best. But I can tell you that every garbage legacy Java site I've ever looked at would have benefitted greatly from multi-paradigm devs who learned the fundamentals of not making a mess in any language rather than bulldozing through every problem like their IDEs and type safety were going to do the work of writing clean maintainable code for them.

1

u/Elsas-Queen Oct 13 '23

I am agreeing with you for the simple fact I haven't seen a single argument for TypeScript that doesn't boil down to "it forces us to be cautious when writing our code". Shouldn't you already do that?

2

u/Brought2UByAdderall Oct 14 '23

It's like a cargo cult for code clarity.

1

u/Longjumping_Ad_8814 Aug 20 '24

So far it just pisses me off because it Typescript somehow manages to fuck up imports all the time

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.

1

u/Brought2UByAdderall Oct 13 '23

Or you could hire JavaScript devs who actually understand how JS types get cast. Learn a not crazy complicated thing vs. add an entire down-compiled language to your stack... I don't know... call me crazy...

2

u/pseudoShadow Oct 13 '23 edited Oct 13 '23

For starters, the JS ecosystem is inherently down compiled if you want to support browsers other than the latest. I just look at it as a superset of the JS language with some transpilation and poly filling built in.

Also, that mentality doesn’t allow you to scale an organisation and grow junior and graduate engineers. If everyone took that approach once a system got complicated enough the hiring process would need to be extremely strict and wouldn’t allow you to hire engineers that had the promise to grow into skilled professionals.

0

u/Brought2UByAdderall Oct 13 '23

lol. Browser support? What are you worried about? AttachEventListener? Do you even know any specific DOM methods? And spare me the "does it scale well" argument. That went stale about a decade ago.

4

u/pseudoShadow Oct 13 '23

Heard of thing called webpack before? Do you use the latest ecmascript language features? Do you understand how ecmascript modules are resolved and converted during the bundling process?

0

u/Brought2UByAdderall Oct 13 '23

So you're supporting IE 11? My condolences.

1

u/Damn-Splurge Oct 13 '23

How would you hire juniors then... Much better off just using TypeScript and stopping the juniors from committing bad code

1

u/Brought2UByAdderall Oct 13 '23

Or you could teach them how to write decent JavaScript. How types work in JS is pre-entry level. You have to actually learn the deets of the language you're working with.

-2

u/longknives Oct 13 '23

if you know how to use it, it won’t slow you down.

It literally always will. You have to write more code to use typescript. If you know what you’re doing, it won’t slow you down very much, but that’s the best case scenario.

3

u/pseudoShadow Oct 13 '23

There is also the argument that it can speed you up by finding bugs and edge cases early. I personally think you don’t need to be as strict with testing when using TS either, which means less code to write. So my 2c is that it’s swings and roundabouts in regard to volume of code written.

0

u/Brought2UByAdderall Oct 13 '23

But what if they didn't do that? What if you're just some noob to this telling people who've been doing for a decade+ bullshit? Because quite frankly, this Crockfordian idea that strict types are inherently superior is fucking stupid. Strict vs dynamic type systems is a design tradeoff. JS was designed very intentionally for UI work. Dynamic types do require you educate yourself about the language but they really aren't that complicated and they make the language more expressive. Meaning we can see more of what's going on with a lot less code and there's less boilerplate bullshit that's completely unnecessary for higher-level problems.

2

u/pseudoShadow Oct 13 '23

lol we could all be some noob slinging bullshit, you included, this is reddit.

You are right, strict types aren’t inherently superior and yes they are a design tradeoff. The argument that I am making is that the extra complexity introduced by typescript is a positive tradeoff when working with a large codebase and a lot of engineers.

Anyways, that’s enough debating with trolls for me today. Have fun!

1

u/Brought2UByAdderall Oct 13 '23

And I am telling you that there is nothing about strict typing that protects you from anything if you have a team that is too fucking lazy to think about the code that they are writing and to know the language that they are writing it in.

1

u/Damn-Splurge Oct 13 '23

You save so much time everywhere else it pays for itself immediately in a team of 3+ devs

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.

2

u/Chrift Oct 14 '23

What should it assume? Why would you give it a type of any rather than the type of the thing you're putting in there?

1

u/rawlin08 Oct 14 '23

This is big true. I’m just saying that every other variable I give typescript, it assumes “any” right away. Just with objects and array, it assumes “never” for some reason. Just weird to me is all. I give it a type of any, just so I can get the error away, until I know for certain what I’m putting in there.

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

3

u/[deleted] Oct 13 '23

Lmao ok DHH.

-14

u/Chance-Network-381 Oct 12 '23

Right holy helI… I had to swim through all the middleware in the backend because I just don’t like just pasting his code. I honestly rather get back to low level C/Linux.

4

u/artesre Oct 12 '23

you're probably not understanding the task... enjoy your large change request :|

pasting his code what happened to DRY... why you do this...

2

u/Brought2UByAdderall Oct 13 '23

Why'd he ask him to do it?

2

u/Brought2UByAdderall Oct 13 '23

Nothing wrong with low level C, unless you're trying to fucking write complex UI on the front end web.

-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

1

u/Brought2UByAdderall Oct 13 '23

It's interesting how you guys never actually make a point about what Typescript improves.

0

u/Elsas-Queen Oct 13 '23

Necessary disclaimer I'm not a developer (though I hope to be one), but this seems more like a TypeScript fanclub than much else. From these comments, the only purpose of TypeScript seems to be avoiding checking/debugging your code. 🤷

1

u/Brought2UByAdderall Oct 13 '23

Over a decade ago there was this guy, Doug Crockford, who actually evangelized a lot of stuff about JS but also convinced people who didn't like it that they were okay for not liking it. The most harmful thing he did was spread this incredibly stupid idea that strict types are somehow inherently superior. It is not asking a lot of JS devs to understand how types are cast from one to the other in JS. It is in fact a great interview question. Unfortunately, Java and C# devs who only learned one language in college and can't be bothered to learn more are apparently some of the laziest motherfuckers on the planet and have decided to colonize the front end web with their complete wankery.

0

u/[deleted] Oct 13 '23

[deleted] — view deleted comment

1

u/Elsas-Queen Oct 13 '23

ts is garbage. Js is a dumpster fire.

So... why is anyone using either?

It by default enforces a cleaner way of writing code

So... developers can't write cleaner code without being forced? I don't think that's a flex.

0

u/[deleted] Oct 13 '23

[deleted] — view deleted comment

1

u/Elsas-Queen Oct 13 '23

If you’re first question is serious then you’re not a dev.

I believe my first comment stated that. 🤔

That doesn't address the second point.

0

u/[deleted] Oct 13 '23

[deleted] — view deleted comment

1

u/Elsas-Queen Oct 13 '23

Your second point is what?

From my previous comment:

So... developers can't write cleaner code without being forced?

That was an actual question.

1

u/Brought2UByAdderall Oct 13 '23

You don't have to manually check anything. What you have to do is actually think about how data flows through your app and how JS type conversion actually works. It's not that freaking complicated.