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
Today we can ignore prefix on interface members using readonly-keyword with ignore-prefix. Sometimes (for performance reasons) I would like to create an interface where all members are mutable. In those cases it might be helpful to be able to prefix the interface name with something that is ignored (instead of prefixing each member). For example:
Currently readonly-keyword will warn on this interface. My suggestion is that we add an option like ignore-interface-prefix for the readonly-keyword and if I set that to Mutable the above will not warn.
I'm not sure this is a totally good idea since it will be easier to write mutable interfaces using this option. However I find some parts of my code needs to be in fully mutable mode in order to get good performance.
Another way around this is to have a Mutable<T> type mapping that removes the readonly attributes:
A dedicated type for mutable versions of interfaces is perhaps not very meaningful.
function myFunction(person: MutablePerson){}
vs
function myFunction(person: Mutable<Person>){}
Explicitly using Mutable<Person> also ensures and makes clear that it will always exactly mirror Person. Without context, MutablePerson could be anything.
But it would be great to write something about this solution in the manual, since I'm guessing many users will run into the same issue.
Perhaps a better lint rule would be to prevent Mutable<> in the arguments and return type of functions, but permit it in the function body, just like ignore-local does for arrays.
Today we can ignore prefix on interface members using
readonly-keyword
withignore-prefix
. Sometimes (for performance reasons) I would like to create an interface where all members are mutable. In those cases it might be helpful to be able to prefix the interface name with something that is ignored (instead of prefixing each member). For example:Currently
readonly-keyword
will warn on this interface. My suggestion is that we add an option likeignore-interface-prefix
for thereadonly-keyword
and if I set that toMutable
the above will not warn.I'm not sure this is a totally good idea since it will be easier to write mutable interfaces using this option. However I find some parts of my code needs to be in fully mutable mode in order to get good performance.
Another way around this is to have a
Mutable<T>
type mapping that removes the readonly attributes:The text was updated successfully, but these errors were encountered: