dzintars / front

Test setup (Don't use!) Dev server URL available while i'm developing.
https://front.oswee.dev
1 stars 1 forks source link

Difference of Type and Interface #117

Open dzintars opened 4 years ago

dzintars commented 4 years ago

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: :thread::point_down:

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 commented 2 years ago

https://youtu.be/hGdx0hpZsvs