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

[Bug] 2022-03 decorators doesn't support inheritance with @computed #3949

Open
jzhan-canva opened this issue Oct 22, 2024 · 1 comment · May be fixed by #3950
Open

[Bug] 2022-03 decorators doesn't support inheritance with @computed #3949

jzhan-canva opened this issue Oct 22, 2024 · 1 comment · May be fixed by #3950
Labels

Comments

@jzhan-canva
Copy link
Contributor

jzhan-canva commented Oct 22, 2024

Intended outcome:

test(`inheritance should work with computed`, () => {
    class Store {
        @computed
        get getNumber() {
            return 1
        }
    }

    class SubStore extends Store {
        @computed
        override get getNumber() {
            return super.getNumber + 1
        }
    }

    const store = new SubStore()
    expect(store.getNumber).toBe(2)
})

Actual outcome:

[MobX] Cycle detected in computation SubStore@1.getNumber: get getNumber() {
                        return super.getNumber + 1;
                    }

How to reproduce the issue:

As per unit test. Can see the error in stackblitz link

Versions

^6.12.3

@jzhan-canva
Copy link
Contributor Author

jzhan-canva commented Oct 22, 2024

A potential fix, not sure if this will break anything. PR passes all tests
image

@jzhan-canva jzhan-canva linked a pull request Oct 22, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant