Skip to content

Add type parameter for Id in createEntityAdapter #2098

Closed

Description

Currently createEntityAdapter provides no type checking for the id of an entity

This prevents type checking when using the selectors, and means that the return type of functions such as getAllIds returns EntityId[] rather than a type specific to the entity.

Introducing an (optional) type parameter for Id will solve all of these propblems, and also allow for the newtype pattern to ensure types between different adapters do not get mixed up

type MyIdType = string & { readonly __tag: unique symbol }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions