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

RootStore type becomes "any" the moment we call a RootStore model action using yield on a child model action #2040

Open
3 tasks done
cpintos-sc opened this issue Jul 5, 2023 · 3 comments
Labels
help/PR welcome Help/Pull request from contributors to fix the issue is welcome Typescript Issue related to Typescript typings

Comments

@cpintos-sc
Copy link

cpintos-sc commented Jul 5, 2023

Bug report

  • I've checked documentation and searched for existing issues
  • I've made sure my project is based on the latest MST version
  • Fork this code sandbox or another minimal reproduction.

Sandbox link or minimal reproduction code
Here is the repro

Describe the expected behavior
The typings should not become any and there shouldn't be any circular reference error.

Describe the observed behavior
The problem starts when using yield with a RootStore action within a child model. I do not have a problem getting the RootStore or even executing it's actions, it just happens when using yield with an async function. See line 13, 14 and 15 of the RootStore.ts file.

@cpintos-sc cpintos-sc changed the title RootStore type becomes "any" the moment we execute an action using yield on a child model RootStore type becomes "any" the moment we execute a RootStore model action using yield on a child model Jul 5, 2023
@cpintos-sc cpintos-sc changed the title RootStore type becomes "any" the moment we execute a RootStore model action using yield on a child model RootStore type becomes "any" the moment we call a RootStore model action using yield on a child model action Jul 5, 2023
@coolsoftwaretyler
Copy link
Collaborator

coolsoftwaretyler commented Jul 5, 2023

Hey @cpintos-sc - thanks for filing this issue and putting together the reproduction! Very helpful.

I think this may be related to #1851 although I'm not 100% sure if it's exactly the problem.

Either way, we do know that our TypeScript updates really need to be improved. I'm not exactly sure when we'll be fixing it, but it's top of the list. Sorry for the inconvenience at the moment.

If you're interested in pitching in, we'd gladly accept some assistance. But no worries if you just wanted to let us know and hopefully we can resolve this for ya in the coming months.

@coolsoftwaretyler coolsoftwaretyler added help/PR welcome Help/Pull request from contributors to fix the issue is welcome Typescript Issue related to Typescript typings labels Jul 5, 2023
@Anoninz
Copy link

Anoninz commented Jan 19, 2024

I have a workaround to solve this issue.
It's declare StoreInstance by handwriting instead of use Instance

type RootStoreInstance = {
  SomeStore: SomeStoreInstance
}

and use this type in getRoot<RootStoreInstance>(self)

@rkz98
Copy link

rkz98 commented Jan 24, 2024

@Anoninz workaround worked for me. Thank u.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help/PR welcome Help/Pull request from contributors to fix the issue is welcome Typescript Issue related to Typescript typings
Projects
None yet
Development

No branches or pull requests

4 participants