Skip to content

DeepWritable - Mostly for testing purposes #197

@FranciscoKloganB

Description

@FranciscoKloganB

Is your feature request related to a real problem or use-case?

Yes. Often times, we create Readonly or DeepReadonly objects in code. However, during tests one might use test factories that return concrete implementations of those objects. After that, we might want to modify a single property, add additional properties or remove properties from those objects for testing purposes. At this point we are forced to cast objects to "any", which isn't nice when using strict projects.

Describe a solution including usage in code example

I have been using this on my projects successfully. But I have been copy pasting them everywhere. Might as well ask for it to be integrated in utility-types.

type DeepWritable<T> = { -readonly [P in keyof T]: DeepWriteable<T[P]> };

Who does this impact? Who is this for?

TypeScript users; Or at least myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions