Skip to content
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

Getter/Setter, inheritance and $ReadOnly interacting incorrectly #380

Open
paul23-git opened this issue Jan 10, 2023 · 1 comment
Open

Comments

@paul23-git
Copy link

Whenever you inherit from a class (doesn't matter what the parent class contains. And use getter/setter - or even just a getter- you cannot access these functions when passing the object with $ReadOnly

export class SomeThing{
}

class Test extends SomeThing {
    get name(): string {
        return "test";
    }
}

function test(data: $ReadOnly<Test>) {
    console.log(data.name)
}

Gives this error:

Error:(28, 22) Cannot get data.name because property name is missing in Test [1].

Removing the inheritance - or removing the $ReadOnly<> modifier makes it work. While i expect it to just work

Flow-bin version: 0.196.3

@paul23-git
Copy link
Author

PS: try-flow is not working on my system right now, but the example is simple enough to check directly I think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant