-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Mutable type guards #25679
Comments
you can achieve a similar pattern by slightly reordering your code to use immutable objects instead of mutations, e.g. const el = setExtra(document.createElement('div')); you can also achieve that using type assertions: const el = <HTMLDivElement & { extra: { stuff: {} }}> document.createElement('div') That siad, i do not think we have any plans to model side effects in the type system in the time being. |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
@mhegazy : I have run into the same problem again, this time with
For now, I have to manually retype values after each What solution do you propose to this problem? |
See #10421 and its linked issues |
Thank you. If I am not mistaken, the link you sent discusses block scope type assertions. What I would like to do is to mutate the type of variables that are sent into a function as function parameters from inside of the function. That would probably break the "block scope" rule discussed in the provided link, right? Then I would have to do
Which is probably not optimal either. Basically I would like to have type guards without the |
See also #8655 |
Search Terms
mutable type guards
Suggestion
Allow for mutable type guards (i.e. type guards that are always true).
Use Cases
I would like to extend HTMLElements without wrapping them. So basically I would add "extra" property to a HTMLElement that would extend its capabilities.
Examples
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: