High Definition Standard Definition Theater
Video id : jJGzYdS4ZfY
ImmersiveAmbientModecolor: #a99181 (color 2)
Video Format : (720p) openh264 ( https://github.com/cisco/openh264) mp4a.40.2 | 44100Hz
Audio Format: 140 ( High )
PokeEncryptID: 24fe04c30b7828aa29f21ebead4286edb055ebc9473a4e502bfcceb10272ed269e83c914e0ab5fd18e53676974b6ea14
Proxy : eu-proxy.poketube.fun - refresh the page to change the proxy location
Date : 1731843770617 - unknown on Apple WebKit
Mystery text : akpHellkUzRaZlkgaSAgbG92ICB1IGV1LXByb3h5LnBva2V0dWJlLmZ1bg==
143 : true
You Should Be Using Types Instead Of Interfaces In TypeScript
 60 FPS video
56,097 Views • Dec 21, 2023 • Click to toggle off description
Metadata And Engagement

Views : 56,097
Genre: Education
License: Standard YouTube License
Uploaded At Dec 21, 2023 ^^


warning: returnyoutubedislikes may not be accurate, this is just an estiment ehe :3
Rating : 4.912 (65/2,886 LTDR)

97.80% of the users lieked the video!!
2.20% of the users dislieked the video!!
User score: 96.70- Overwhelmingly Positive

RYD date created : 2024-09-30T16:35:11.836997Z
See in json

60 Comments

Top Comments of this video!! :3

@fabien-bouvier

10 months ago

The semantic behind interfaces is to describe an object behavior contract. It's an OOP concept. A class can implement several interfaces. It kinda solves the unique inheritance limitation and allows to write very generic code by expanding Liskov Substitution capabilities in OOP.

This why you should use interfaces. For everything else, use types. The right tool for the right job. Both have their purpose.

13 |

@ChrisVisserDev

10 months ago

Conclusion. Use the right tool for the job. There are situations where interfaces make more sense and situations where types make more sense. However types are best as default unless you need specific features from the interfaces

22 |

@harleyspeedthrust4013

4 months ago

interface declaration merging goes hand in hand with module augmentation. some examples:
- defining custom matchers in jest
- correcting a type in an upstream package
- defining custom jsx elements
- convenient global types for modules - e.x. Express.User, which is the type of req.user in an express app. You can extend this type to add your own properties to req.user. This is similar to the jest example

IMO types are usually better but sometimes your problem can only be solved with an interface, and sometimes you are defining some type that classes shoulr conform to (a proper OOP "interface").

1 |

@md.redwanhossain6288

10 months ago

Interfaces are for OOP , types are for making types. Don't mix and match both.

109 |

@Saru-Dono

10 months ago

Don't approach this as black and white, it's fine to use both. I personally use Interfaces for defining objects(ie. React component's props) and Types for pretty much everything else.

8 |

@nomadshiba

10 months ago

also interfaces lets you use the `this` keyword.
which is useful sometimes

11 |

@StefanoV827

10 months ago

I use interfaces for functional components props, and type for the rest (rtkq api requests/responses, etc)

3 |

10 months ago

This is something like; don't wear sweater. wear shirt instead.

9 |

@agiamahprecious9901

10 months ago

eslint would scream at seeing two interfaces with same name

1 |

@hugodsa89

10 months ago

Interfaces can be extended. They are also technically not as heavy on the ts server

14 |

@HaiNguyen-cf1ji

4 months ago

Interface can use union as well. In fact typescript docs it self said that you should perfer interface over type since it give more info when you hover over the thing that use interface, I think typescript should merge the two to remove these kind of debate

|

@EddieVillamor

10 months ago

Interface for object definitions, types for declaring object instance types.

3 |

@jackdavenport5011

10 months ago

I mainly use interfaces for defining objects but types for defining literals or tuples. They both have their uses :)

|

@dommy2245

4 months ago

Idk why it took so long for my eyes to read anything but “mamma1” 😂

|

@BeeBeeEight

10 months ago

I used to think types were the be-all and end-all for typescript. But after evaluating some blog articles in favor of interfaces, I now understand why the typescript team decided to put both in the TS ecosystem. They both have good use cases and we can't really say one is definitely better than the other. So, on this one, I'm going to have to disagree.

3 |

@HussainFazaal

10 months ago

To define React props which is better? interfaces or types? I think semantically interface fits better and since it's usually defined in the same file as the component definition there's less chance it will be redefined. For rest of the types in for example a types.ts file I think it's better to go with types.

1 |

@blenderpanzi

10 months ago

You can do unions like that with interfaces, too. WTF are you talking about? The adding props thing is valid.

4 |

@NuncNuncNuncNunc

2 months ago

Huge debate among YouTubers. Take a look at widely used production code and you will see both used, sometimes even in the same file. No confusion.

The "debate" feels like telling a carpenter not to use a hammer because screws exist..

|

@DaaWood998

10 months ago

I only use types when I have to. In 90% of cases in frontend components

1 |

@sircharlesross537

10 months ago

Use interfaces until you need types (eg extends or literal values)

|

Go To Top