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
As asked in two other tickets (#29742, #18497), a way to make functions arguments immutable would be really awesome. The proposal was rejected due to potential different behavior by updating the readonly modifier, which can be understood easily.
But in fact this feature can be probably added with an option to enable/disable it through tsconfig.json and then taking the time to get developers feedback about it.
A breaking change is not something bad if it improve the code quality and this feature would be really more useful than using ESLint rule for this purpose. It let you plan it quietly for the next major version and allow devs to adapt their code to deal with it.
If it's implemented i would love having an optional parameter to enforce arguments immutability without having to use explicitly readonly modifier everywhere.
Use Cases
Examples
Actual behavior
consttestFunction: number=(mutableArg: number)=>mutableArg++// ok
I don't see a reason for #18497 to have been closed, so I've reopened it.
That said, this can be implemented by a lint rule (e.g. make all params consty by default, have an opt-out through some mechanism), so the bar is a bit higher in terms of whether we would do it or defer to eslint.
Search Terms
Suggestion
As asked in two other tickets (#29742, #18497), a way to make functions arguments immutable would be really awesome. The proposal was rejected due to potential different behavior by updating the
readonly
modifier, which can be understood easily.But in fact this feature can be probably added with an option to enable/disable it through
tsconfig.json
and then taking the time to get developers feedback about it.A breaking change is not something bad if it improve the code quality and this feature would be really more useful than using ESLint rule for this purpose. It let you plan it quietly for the next major version and allow devs to adapt their code to deal with it.
If it's implemented i would love having an optional parameter to enforce arguments immutability without having to use explicitly
readonly
modifier everywhere.Use Cases
Examples
Actual behavior
Expected behavior
Checklist
My suggestion meets these guidelines:
The text was updated successfully, but these errors were encountered: