You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to make such a change, a bit of refactoring is needed. Instead of have a separate block for the default initializations, each field should be fully initialized in one step, either with data or with default. But such a refactoring would be nice anyways as it makes the flow easier and future optimizations possible, like this one:
We generate a lot of code like this:
in which the binary fields can be replaced with the nullish coalescing operator (??) as follows:
This output is easier to read and saves a good amount of code size that is otherwise shipped to the user.
Nullish Coalescing is available since TypeScript 3.7 and will be transpiled to a compact replacement. For targets >= es2020 it will be preserved as valid JavaScript syntax. See also JavaScript operator: Nullish coalescing operator on caniuse.com.
In order to make such a change, a bit of refactoring is needed. Instead of have a separate block for the default initializations, each field should be fully initialized in one step, either with data or with default. But such a refactoring would be nice anyways as it makes the flow easier and future optimizations possible, like this one:
I'm happy to work on this if there is general interest on the approach.
The text was updated successfully, but these errors were encountered: