Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
TypeScript Type vs. Interface: Which Should You Use in 2023? (totaltypescript.com)
16 points by fagnerbrack on Nov 21, 2023 | hide | past | favorite | 1 comment


I previously came to the same conclusion.

From the article:

> When you're working with objects that inherit from each other, use interfaces. extends makes TypeScript's type checker run slightly faster than using &.

In my case however I argue for much stricter designs and only use type even in case of “inheritance” (more accurately composition).

Having such overlapping and for all practical purposes identical behaviour across two keywords feels totally redundant. So I always use type, which is a more natural fit anyway.

I imagine a lot of people are going to disagree with both posts.

(Strangely he posted that article just weeks after I posted mine… https://www.lloydatkinson.net/posts/2023/favour-typescript-t...)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: