When destructuring a readonly object with the rest operator, the new object that is created keeps the readonly flag on it's properties. Rest operator creates a new object the same way that spread operator does, so i assume it should not keep any flags.
For reference:
Issues #14058 and #19178 target the same problem with spread operator and have both been fixed.
TypeScript Version: 2.8.3
Search Terms: rest readonly, destructuring readonly
Code
type ObjType = {
foo: string
baz: string
quux: string
}
const obj: Readonly<ObjType> = {
foo: 'bar',
baz: 'qux',
quux: 'quuz',
}
const { foo, ...rest } = obj
delete rest.baz
Expected behavior:
Successful compilation
Actual behavior:
test.ts(15,8): error TS2704: The operand of a delete operator cannot be a read-only property.
When destructuring a readonly object with the rest operator, the new object that is created keeps the readonly flag on it's properties. Rest operator creates a new object the same way that spread operator does, so i assume it should not keep any flags.
For reference:
Issues #14058 and #19178 target the same problem with spread operator and have both been fixed.
TypeScript Version: 2.8.3
Search Terms: rest readonly, destructuring readonly
Code
Expected behavior:
Successful compilation
Actual behavior:
test.ts(15,8): error TS2704: The operand of a delete operator cannot be a read-only property.