Skip to content

[Basic] Typing example for objects with a string id #247

Closed
@KitsonBroadhurst

Description

@KitsonBroadhurst

What cheatsheet is this about? (if applicable)

Basic cheatsheet

What's your issue or idea?

Add an object example to the "Basic Prop Types Examples".

I occasionally find myself in a situation where I have an object which has an id of type string with lots of varieties, but all have the same value.

e.g.

  interface HistoryItem {
    id: string;
    before: string;
    after: string;
  }

  inteface History: {
    [key: string]: HistoryItem;
  }

I always go here to find the reference and then have to google it and end up at this SO question: https://stackoverflow.com/questions/13315131/enforcing-the-type-of-the-indexed-members-of-a-typescript-object/53717982

Happy to PR something.

Metadata

Metadata

Assignees

Labels

BASICBasic Cheatsheet

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions