reduxjs / rtk-github-issues-example

Source code for the Redux Toolkit Advanced Tutorial
214 stars 97 forks source link

[Question] Why use Interfaces instead of Types #4

Closed tian-yi closed 5 years ago

tian-yi commented 5 years ago

From Typescript cheatsheet,

consider using type for your React Component Props and State, because it is more constrained.

So I just wonder why in the example, most the places using Interfaces. I am not saying it's right or wrong, just want know the thinking behind it so I can apply the same to my own code base.

Thanks!

P.S. The documentation is super helpful and easy to follow.

markerikson commented 5 years ago

I hadn't seen that particular line. The advice I've seen is that it's basically 50/50 either way, and I've just defaulted to writing interfaces as I learned.

And thanks, glad it's been helpful!