GetStream / react-activity-feed

Stream React Activity Feed Components
https://getstream.io/react-activity-feed/
BSD 3-Clause "New" or "Revised" License
137 stars 83 forks source link

Typescript Types hard to extend properly #348

Closed valoricDe closed 2 years ago

valoricDe commented 2 years ago

Hey there. After building my app I would like to strengthen the types I'm using to get away from 'any's.

My types are looking like:

export interface IFeedUserType {
  name?: string
  displayName?: string
  profileImage: UrlString
  followerCount: number
}

I want to give it to EnrichedUser<IFeedUserType> but EnrichedUser is expecting to extend a generic record which has no fixed property key set. export type UR = Record<string, unknown>;

Bildschirmfoto 2022-04-07 um 11 53 18

I tried to used EnrichedUser<Partial<IFeedUserType>> but then I loose all autocompletion in Intellij

To Reproduce

Import react-acitivty-feed create fixed type and feed into Enriched*

Expected behavior

I would expect to clarify the data structure buy creating types

Additional context

"react-activity-feed": "1.4.0",

Any help is highly welcome :)

MartinCupela commented 2 years ago

Hey @valoricDe, thank you for the question. Try to change the interface IFeeduserType to type IFeedUserType.

This discussion may be related to your question:

https://github.com/microsoft/TypeScript/issues/15300#issuecomment-332366024

Did this answer help you?

valoricDe commented 2 years ago

Interesting. Yes, switching to types helped. Thank you for the pointer 👍