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

Difference of Type and Interface #117

Open
dzintars opened this issue Aug 27, 2020 · 1 comment
Open

Difference of Type and Interface #117

dzintars opened this issue Aug 27, 2020 · 1 comment
Assignees
Labels
question Further information is requested

Comments

@dzintars
Copy link
Owner

dzintars commented Aug 27, 2020

Hi all. Could someone explain me an difference of:

export type FeatureState = Readonly<{
  entities: { [id: string]: Entity }
  ids: string[]
}>

and

interface FeatureState {
  readonly entities: { [id: string]: Entity }
  readonly ids: string[]
}

?

phryneasToday at 10:48 AM
@dzintars There is none. Readonly is a mapped type that creates the second type
Well, minor differences. One is an interface and one is a type.
https://twitter.com/phry/status/1222241038884048896

Lenz Weber (@phry)
This #TypeScriptTuesday, we're going to take a look at #TypeScript's interfaces.
Interfaces are different from types and both have their strengths in different situations.
Let's take a look.
This is just some interface definition - again an example from the #redux types:
🧵👇

But in this situation that probably should not concern you, apart from the different "mouseover" behaviour

DzintarsToday at 11:00 AM
Thank you! Then.. what does the "industry" chooses in this context? Just interfaces?

phryneasToday at 11:02 AM
I've not seen any preference for one or the other really.

DzintarsToday at 11:35 AM
That tweet is really good. Thank you.

@dzintars dzintars added the question Further information is requested label Aug 27, 2020
@dzintars dzintars self-assigned this Aug 27, 2020
@dzintars
Copy link
Owner Author

dzintars commented Dec 9, 2021

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

No branches or pull requests

1 participant