Skip to content
0:00 / 0:00

#typescript#interfaces#typealiases

Types vs Interfaces: What I Got Wrong In 2022

Matt Pocock

429K subscribers • 8 videos on Hallway

YouTube
  • Recommended by 4 people: 4 in engineering communities.
  • Presented by Matt Pocock, TypeScript educator
  • An opinion. It argues one side of a question engineers disagree on.

Intermediate. Assumes working knowledge.

97K views1 year ago4 recommendations

Programming languagesTypeScript

Matt Pocock explains why he changed his mind on using types versus interfaces in TypeScript, focusing on performance and usability.

AI Hero: aihero.dev/ Total TypeScript: totaltypescript.com/ Types Vs Interfaces: totaltypescript.com/type-vs-interface-which-should-you-use Become a TypeScript Wizard with my free beginners TypeScript Course: totaltypescript.com/tutorials/beginners-typescript Follow Matt on Twitter twitter.com/mattpocockuk Join the Discord: mattpocock.com/discord

Why it's here

4 people recommend this

What people say. Recommended as an updated guide on when to use interfaces instead of type aliases in TypeScript.

Moments people linked to

u/carlos-algmsin r/typescript • Recommends

On “Trying to come up with a good, clear, one sentence rule for when to use interfaces vs type-aliases.”

Go with interfaces, unless they can't represent what you need, like unions. interfaces are faster and recommended by TS team. [video

u/CodeAndBiscuitsin r/typescript • Recommends

On “Can you distribute and use TS sources as declarations and avoid generating d.ts files?”

…ce. 40? It's fine. Get a few hundred in there especially with some discriminated unions, template literal types, and other more intricate logic-based elements and suddenly your code base can be crawling. The TS team is constantly working on improving performance but it's challenging. Even folks like Matt Pocock are always putting out videos like [video talking about how some subtle detail had a much bigger performance impact than they thought. Absolutely does not mean it's wrong to do this. As others noted, I, too, prefer a jump-to-definition to take me to the real thing, not an exported declaration. But you asked, so that would be the biggest reason I can think of :) (Declarations can…

u/jarzebowskyin r/typescript • Recommends

On “Coding in Typescript”

About the topic „type vs interface” there is a great video from Matt Pocock. You should check it out. link to this video

u/ORCANZin r/typescript • Recommends

On “Has the debate settled between types and interfaces? Are there any concrete rules of thumb about use cases?”

This is where I got it from [video haven't benchmarked it myself. In react it is quite a common problem, when you want to create a component that takes the same props as another and adds some props [video
1View on Reddit

u/Caramel_Lastin r/typescript • Mentions

On “TypeScript Interface vs Type: Differences and Best Use Cases”

Wake up, new 'I changed my mind' video dropped [video

u/Merry-Lanein r/typescript • Mentions

On “Trying to come up with a good, clear, one sentence rule for when to use interfaces vs type-aliases.”

link to this video