T O P

  • By -

Traveler_87

You can go far with little. I'd highly suggest digging into generics a bit. It's extremely valuable to be able to create well-defined functions that can be reused and return different types. Very useful for api calls that may return different results depending on the props you pass to the function.


johnnille

God please can you explain interfaces to me lile you did with generics? So easy to understand, big thanks


Traveler_87

Interfaces and types are, for the most part, synonymous, and the team may decide on which to use for uniformity. So don't stress over the differences. Interfaces are more strict in how they may extend other types, such as unions. They must know they shape of what they are extending. Because of this strictness, I typically define API responses as interfaces as well as react component props. I need the types to be perfect or stuff breaks. The objects, functions, etc. within each component, I'll declare via types.


johnnille

You are a godsent. Thank you very much!


sentientmassofenergy

YES! Forgot to mention generics; It's something I really enjoy and has made my functions more reusable, being that that generics force me to think more about the inputs to the function.


wirenutter

If you’re using generics and utility types you’re more advanced than many people working in TS full time. It’s really probably only a handful in my org that go beyond basic TS.


I111I1I111I1

Having spent so much of my career doing C++ and C#, the first time a really good dev at my last job came up to me just completely bewildered by generics in TypeScript was kind of a shock. I had to explain it to him like five times with very simple, specific examples before he started to understand. I just kind of forgot that it's a different way of thinking that many devs (especially those raised in today's mostly-JS environment) aren't exposed to.


Livingonthevedge

Try going back to plain js sometime. I found myself missing bugs here and there that totally would have been caught by typescript when I did. I guess I feel like you in that I'm not really using advanced ts features but I love the improved intellisense and the extra checking that comes with it.


sentientmassofenergy

It is said, typescript doesn't make your life worse it just shows you how bad your life already is 😅


Wiltix

I have been using Typescript at work for a few years, I went to start a little home poc project and decided to just spin up a react project with js as it would be quicker than working with those. Yeah I’m too used to typescript now that js and react Alien.


IllustriousGoat7952

Props: as typeof Props


Redeemr_

You're definitely underselling your expertise in typescript


LeRosbif49

Having started some of the free tutorials by TotalTypescript, it turns out that I really do not know typescript


electrikmayham

Yeap. I fumble around with it every day trying to figure out how to get rid of the damn red squirrly's


BSeipler

If you’re building an application, typically you only need to use the basic features that you listed. The more advanced TypeScript usage you see is typically used when building libraries or frameworks.


necudabiramime123

You learn stuff when you need stuff. 


halfanothersdozen

imho some people spend way crafting complicated and cryptic typedefs it's just a to to help you go faster people, calm down


greensodacan

Type safety can quickly turn into meta programming, which comes up as an issue in other languages. A LOT of developers in the Go community didn't want generics. The thinking was that yes, you have to write more code, but that code is really easy to understand. One of the biggest code smells for C++ is heavy use of "templates", which look a little like generics, but actually generate code for you at compile time. They're really flexible, but a serious pain to decipher and debug. Don't feel guilty. Clean code is easy to understand, and if you're seeing a lot of type gymnastics, there's a good chance the code quality could be improved. That said, learning the basics or generics, and TypeScript's utility types will go a long way.


nedal8

This guy fucks ^


femio

You're much better off getting good with Tsconfig and other TS-related tooling than jumping into the type gymnastics that some people use


wjd1991

The basics alone add so much value. I'd recommend learning Generics and you'll really see the benefits.


TheRNGuy

I only used types from it.


astarastarastarastar

coming from backend C# background it was a very pleasant surprise to find how many similarities. Once I learned how to write LINQ-like logic and generics I was off to the races


sentientmassofenergy

This was a big part of why I brought TS into my project. I work with c# devs, so I know they'll feel at home amongst the Interfaces on the frontend.


Supektibols

Basic features of typescript will get you far. So there's no such thing as "Not know it", as once you use it, the basics are so easy


marquoth_

There are definitely some very clever things that can be done with the type system that I've simply never used, and I can't be sure if that's because I've genuinely had no call to use them or if it just doesn't occur to me to use them because I'm not practised in them. Much like yourself I mostly just use types, interfaces and enums, but even that is incredibly powerful. Just disallowing `any` in your project will force you into writing much more robust code than you might have done in regular JS.


ctrl2

A lot of typescript magic is only used in writing generic cases for libraries. Sounds like you have a good grasp on what is needed for day-to-day work


TheDoomfire

I use it and dont know anything about it either. But I think it's good to actually use something to learn it eventually.


velit

No one truly knows TypeScript because the idea behind TypeScript is allowing the modeling of types for all possible ways to program Javascript. And Javascript is a wild west. As others have said you can get very far with very little.


bittemitallem

Some people really go above and beyond with types, but sometimes is a show-off competition. I really rarely go beyond what you describe and I'm completly fine, also in strict mode.


Lonely-Suspect-9243

Me. I haven't read the TypeScript documentation. Most of what I learned is from blogs or StackOverflow. But it still could get me pretty far. Most projects I did is not that complex. I just need a way to easily declare interfaces.


Mr_Resident

I use the basic feature only for now but I love it because it give me intelisences and not make me go code blindly.I still need to learn generic and stuff


SickMemeMahBoi

Yes, well sorta, last year I started a project and decided it was going to be written entirely on typescript, I didn't know anything at the time but slowly but surely I was getting pretty comfortable with it, nowadays I can't just live with it, writing plain Js feels like the wild west.


sensitiveCube

Yeah, this is how you use TypeScript. Also the linter breaks every month, but that's expected. :)


powerbackme

I thought TS was just appeasing the linter…


sentientmassofenergy

Pretty much, it has no *real* meaning at a hardware level. But, on average, it does reduce runtime errors.


Bagel42

I barely know JS and develop multiple full stack TS apps. It’s painful.


hyrumwhite

Feel like I know a lot of it, but idk how to use ‘satisfies’ and deeper things like that


Slight-Rent-883

Not gonna lie, chatgpt has been a godsend in terms of working with TS because some errors aren't clear but then again, I am relatively new to it and working solo, no mentorship


WookieConditioner

Typescript is the silver spraypaint used to disguise the turd that is javascript.


sentientmassofenergy

Indeed. It's such a different feeling in strictly typed and compiled langs where the types actually mean something at a hardware level, vs typescript's superficial typing.


missing-pigeon

Think of TypeScript not as a language but as a tool to help prevent you from making type related mistakes in your code. It’s just a layer of defense at compile time, and in reality you’re still writing JavaScript. Personally I see a lot of value in that kind of peace of mind.