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

Add a "DeepMutable<T>" type #158

Open
JShabtai opened this issue Oct 26, 2020 · 0 comments
Open

Add a "DeepMutable<T>" type #158

JShabtai opened this issue Oct 26, 2020 · 0 comments

Comments

@JShabtai
Copy link

JShabtai commented Oct 26, 2020

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

An existing (possibly third party) type has nested readonly elements, but it would be handy to re-use that type and build up the final object which can only be done if the nested fields are updateable (i.e. not read only)

e.g.

interface MyInterface {
foo: {
readonly bar?: string;
}
}

It would be nice to be able to do something like

let x: MyInterface = {
foo: {
}
};

if (someCondition) {
x.foo.bar = 'someValue';
}

Describe a solution including usage in code example

Should work just like the other Deep* types, but making nested elements mutable like Mutable already does.

Who does this impact? Who is this for?

All users who might be working with nested readonly types outside of their control (i.e. third party code)

Describe alternatives you've considered (optional)

Manually recreate the original type as non-readonly, but that's certainly not ideal.

Additional context (optional)

Could potentially use the features described in #151 and serve as a template/example for that refactoring.

Also, just want to say thanks for making and maintaining this library!

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