Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DeepWritable - Mostly for testing purposes #197

Open
FranciscoKloganB opened this issue May 4, 2024 · 0 comments
Open

DeepWritable - Mostly for testing purposes #197

FranciscoKloganB opened this issue May 4, 2024 · 0 comments

Comments

@FranciscoKloganB
Copy link

FranciscoKloganB commented May 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant