Search Terms
readonly parameters, readonly arguments, read only, function
Suggestion
Allow specifying a readonly modifier to function and method arguments
functionfoo(mutableString: string,readonlyimmutableString: string){mutableString='bar'// okimmutableString='bar'// not ok}With #29435 we can do this for rest arguments too:
functionfoo(readonly ...immutableStrings: string[]){}// the same asfunctionfoo(...immutableStrings: readonlystring[]){}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: