TypeScript Version: 3.6.3
Search Terms:
Code
type EditablePerson = {
name: string
}
type ReadonlyPerson = {
readonly name: string
}
const editablecotne: EditablePerson = {
name: 'cotne'
}
const readonlycotne: ReadonlyPerson = {
name: 'cotne'
}
function updateName (person: EditablePerson, newName: string) {
person.name = newName
}
//ok
editablecotne.name = 'not so cotne'
updateName(editablecotne, 'not so cotne')
//err
readonlycotne.name = 'not so cotne'// ok
updateName(readonlycotne, 'not so cotne')//fuck!
Expected behavior:
you can't modify readonly property of object
Actual behavior:
you can pass object to function and edit it there
Playground Link: try
Related Issues:
TypeScript Version: 3.6.3
Search Terms:
Code
Expected behavior:
you can't modify readonly property of object
Actual behavior:
you can pass object to function and edit it there
Playground Link: try
Related Issues: