Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types vs Interfaces #16

Closed
tsiq-swyx opened this issue Jun 4, 2018 · 2 comments
Closed

Types vs Interfaces #16

tsiq-swyx opened this issue Jun 4, 2018 · 2 comments

Comments

@tsiq-swyx
Copy link
Contributor

tsiq-swyx commented Jun 4, 2018

Spectrum discussion here brought up the Types vs Interfaces discussion. as far as I can tell there is no real difference between them. I personally always use interfaces but i dont have a strong reason apart from I can extend them if i need to. Should we recommend one or the other? anyone have a source?

@jamonholmgren
Copy link

I would always use interface for public API definitions. I usually use interface for internal types, but it’s less critical. In most cases they are functionally similar.

If you want one simple heuristic, just use interfaces everywhere. (Types can look and feel better in the case of unions though!)

Good resource here: https://medium.com/@martin_hotell/interface-vs-type-alias-in-typescript-2-7-2a8f1777af4c

@tsiq-swyx
Copy link
Contributor Author

ah yes i forgot to mention i already merged in a bit about that here: https://github.com/sw-yx/react-typescript-cheatsheet#types-or-interfaces

that article is doing very well in SEO, it's come up 3 separate times :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants