Search Terms
readonly parameters, readonly arguments, read only, function
Suggestion
Allow specifying a readonly modifier to function and method arguments
function foo(mutableString: string, readonly immutableString: string) {
mutableString = 'bar' // ok
immutableString = 'bar' // not ok
}
With #29435 we can do this for rest arguments too:
function foo(readonly ...immutableStrings: string[]) {}
// the same as
function foo(...immutableStrings: readonly string[]) {}
Use Cases
There is a ESLint rule for not allowing overriding incoming function argument no-param-reassign
Checklist
My suggestion meets these guidelines:
Search Terms
readonly parameters, readonly arguments, read only, function
Suggestion
Allow specifying a
readonlymodifier to function and method argumentsWith #29435 we can do this for rest arguments too:
Use Cases
There is a ESLint rule for not allowing overriding incoming function argument no-param-reassign
Checklist
My suggestion meets these guidelines: