Skip to content

readonly modifier is ignored in unions #9108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zpdDG4gta8XKpMCd opened this issue Jun 12, 2016 · 1 comment
Closed

readonly modifier is ignored in unions #9108

zpdDG4gta8XKpMCd opened this issue Jun 12, 2016 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue

Comments

@zpdDG4gta8XKpMCd
Copy link

zpdDG4gta8XKpMCd commented Jun 12, 2016

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
@sandersn
Copy link
Member

#9167 fixes this for unions and intersections.

@mhegazy mhegazy added the Fixed A PR has been merged for this issue label Jun 24, 2016
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug A bug in TypeScript Fixed A PR has been merged for this issue
Projects
None yet
Development

No branches or pull requests

4 participants