Interface vs Type in typescript

  Рет қаралды 32,317

Hitesh Choudhary

Hitesh Choudhary

Күн бұрын

Пікірлер: 35
@SarveshKumar-08
@SarveshKumar-08 Жыл бұрын
00:01 Interfaces have similarities with types but also have their unique features. 00:42 Adding missing properties to an interface in TypeScript 01:22 Passing input parameters in TypeScript using interfaces 01:59 TypeScript interfaces allow for easy code reuse 02:37 In TypeScript, you can use the 'extends' keyword to inherit properties from another class. 03:24 TypeScript interfaces can be extended and inherited 04:01 The difference between Type and Interface in TypeScript 04:39 Interfaces in TypeScript allow for adding new fields, while types cannot be changed after creation. Great lesson sir thanks a lot.
@technicalom9359
@technicalom9359 2 жыл бұрын
Very few people but genuine audience. Thank You!!
@AbhishekShandilya-q5c
@AbhishekShandilya-q5c Жыл бұрын
When the compiler encounters multiple interface declarations with the same name, it merges them into a single interface definition that includes all the properties and methods from each declaration. Interface reopening is particularly useful when working with external libraries or modules. It allows you to extend or augment the types provided by those libraries without modifying their original definitions.
@shreyasdongare6152
@shreyasdongare6152 2 жыл бұрын
Hitesh i think this the best playlist on typescript on youtube
@ksaha9325
@ksaha9325 2 жыл бұрын
From previous video, i was searching for difference between type and interface. And now here it is. ❤️❤️
@vishalthapa3101
@vishalthapa3101 5 ай бұрын
thank you sir, finally i found the exact difference between interface and type
@sundeeep
@sundeeep 2 жыл бұрын
Keep pushing this content, I am eagerly waiting for the next video.
@HiteshCodeLab
@HiteshCodeLab 2 жыл бұрын
More to come!
@GildwareTechnologies
@GildwareTechnologies Жыл бұрын
Interface vs. Type in TypeScript TypeScript offers two main ways to define custom data structures: `interface` and `type`. While they share some similarities, they also have distinct characteristics and use cases. **Interfaces:** 1. **Object Shapes:** Interfaces are primarily used to define the shape of an object or the contract that an object must adhere to. They are ideal for defining the structure of objects, especially when modeling classes or instances. ```typescript interface Person { name: string; age: number; } ``` 2. **Class Implementations:** Interfaces can be implemented by classes, ensuring that the class adheres to the structure defined by the interface. ```typescript interface Animal { name: string; speak(): void; } class Dog implements Animal { constructor(public name: string) {} speak() { console.log(`${this.name} barks.`); } } ``` 3. **Extending Interfaces:** You can extend interfaces to create new interfaces that inherit properties and methods from existing ones. ```typescript interface Employee { name: string; } interface Manager extends Employee { department: string; } ``` **Types:** 1. **Unions and Intersections:** Types are more flexible when it comes to creating complex types by combining multiple types using union (`|`) or intersection (`&`) operators. They are useful for creating complex and flexible type compositions. ```typescript type Person = { name: string; age: number }; type Address = { city: string; postalCode: string }; type Contact = Person & Address; ``` 2. **Primitive Types:** Types are often preferred when defining simple types like strings, numbers, booleans, or literal types. ```typescript type Status = "active" | "inactive"; ``` 3. **Mapped Types:** You can create new types based on the properties of existing types using mapped types with types. ```typescript type Optional = { [P in keyof T]?: T[P] }; ``` 4. **Utility Types:** TypeScript provides built-in utility types like `Partial`, `Record`, `Pick`, and `Omit` that work naturally with types. ```typescript type PartialPerson = Partial; type RecordOfPersons = Record; ``` **Scholarship Opportunity:** If you're interested in advancing your skills in TypeScript, JavaScript, or any other programming language, consider exploring our scholarship opportunity at [www.gildware.com/scholarship](www.gildware.com/scholarship). This scholarship is designed to support and empower aspiring programmers and developers on their educational journey. In summary, the choice between `interface` and `type` in TypeScript depends on your specific use case and how you want to model your data and code structure. Both `interface` and `type` have their strengths, and understanding when to use each can help you write more maintainable and expressive TypeScript code.
@Vikas-dm9uc
@Vikas-dm9uc 2 жыл бұрын
Beautifully explained, waiting for more videos in this series bhaiya🥰🥰
@HiteshCodeLab
@HiteshCodeLab 2 жыл бұрын
Coming soon
@imamansoni
@imamansoni 2 жыл бұрын
Now i know what's different in between Interfaces and Type 👍
@HiteshCodeLab
@HiteshCodeLab 2 жыл бұрын
👍
@mdkawsarislamyeasin4040
@mdkawsarislamyeasin4040 2 жыл бұрын
Thanks.. Now all clear 🥰
@TJMcCarty
@TJMcCarty 2 жыл бұрын
So interface is sort of like 'let' and type is sort of like 'const', correct? Am I understanding that correctly?
@narendranamdev9259
@narendranamdev9259 2 жыл бұрын
Sir ineuron website pr apke course purchase karne ke liye active coopen. Bta dijiye sir
@akshayramdasi
@akshayramdasi 2 жыл бұрын
excellent content in this TS series
@HiteshCodeLab
@HiteshCodeLab 2 жыл бұрын
Thanks
@arunjoshi7885
@arunjoshi7885 2 жыл бұрын
Why no videos are coming @hitesh sir ?
@poojadeshmukh1943
@poojadeshmukh1943 2 жыл бұрын
Thanks for taking this topic
@SanthoshKumar-fg2zd
@SanthoshKumar-fg2zd 2 жыл бұрын
Hello sir, can you suggest me a good source to learn sailpoint, by the way video was so understandable as usual
@dcodgaming
@dcodgaming 2 жыл бұрын
Sir ek video banao na ki Bina degree ke software engineer kaise bante hai ? Aur kya badi badi company Leto hai kya software engineer ko Bina degree wale pas uss bande mey sab skills hai
@ankushladani496
@ankushladani496 2 жыл бұрын
Thank you sir...
@technicalom9359
@technicalom9359 2 жыл бұрын
Yup!!
@Praxss
@Praxss 2 жыл бұрын
Really helpful
@Priyanka-bd6um
@Priyanka-bd6um Жыл бұрын
Thank you
@subham_9418
@subham_9418 2 жыл бұрын
Is the course over?
@HiteshCodeLab
@HiteshCodeLab 2 жыл бұрын
Nope, more to come
@saravanan335
@saravanan335 2 жыл бұрын
Good video
@Video247
@Video247 5 ай бұрын
love you
@sandip_kanzariya8476
@sandip_kanzariya8476 2 жыл бұрын
Keep smiling 😂
@HousseinDroubi-o9i
@HousseinDroubi-o9i 6 ай бұрын
Hey man.
@Dev-Phantom
@Dev-Phantom 5 ай бұрын
kool
@arunjoshi7885
@arunjoshi7885 2 жыл бұрын
excellent content in this TS series
Private Public in Typescript
6:13
Hitesh Choudhary
Рет қаралды 14 М.
Interface in typescript
9:55
Hitesh Choudhary
Рет қаралды 21 М.
Thank you mommy 😊💝 #shorts
0:24
5-Minute Crafts HOUSE
Рет қаралды 33 МЛН
БОЙКАЛАР| bayGUYS | 27 шығарылым
28:49
bayGUYS
Рет қаралды 1,1 МЛН
Interfaces vs Type Aliases: what's the difference?
10:20
Andrew Burgess
Рет қаралды 23 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 495 М.
TypeScript: Should you use Types or Interfaces?
4:06
Matt Pocock
Рет қаралды 167 М.
Why use Type and not Interface in TypeScript
14:12
ByteGrad
Рет қаралды 220 М.
How to use TypeScript with React... But should you?
6:36
Fireship
Рет қаралды 952 М.
Learn TypeScript Generics In 13 Minutes
12:52
Web Dev Simplified
Рет қаралды 296 М.
This is the Only Right Way to Write React clean-code - SOLID
18:23
Don't put your types in .d.ts files
3:54
Matt Pocock
Рет қаралды 143 М.
any vs unknown vs never: TypeScript demystified
8:01
Andrew Burgess
Рет қаралды 25 М.
Thank you mommy 😊💝 #shorts
0:24
5-Minute Crafts HOUSE
Рет қаралды 33 МЛН