Skip to content

readonly modifier is ignored in unions #9108

Closed
@zpdDG4gta8XKpMCd

Description

@zpdDG4gta8XKpMCd
interface X {
    readonly value: 'x';
}
interface Y {
    value: 'y';
}
type Z = X | Y;
var z: Z = <Z>{ value: 'y' };
z.value = 'x'; // expected an error saying that value: 'x' is readonly and cannot be set, actual OK

UPDATE:

even this example doesn't work (with both possible options being readonly)

interface X {
    readonly value: 'x';
}
interface Y {
    readonly value: 'y';
}
type Z = X | Y;
var z: Z = <Z>{ value: 'y' };
z.value = 'x'; // expected an error saying that value: 'x' is readonly and cannot be set, actual OK

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions