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

types.late always typed as any #400

Open
sebikap-gm2 opened this issue Nov 8, 2022 · 1 comment
Open

types.late always typed as any #400

sebikap-gm2 opened this issue Nov 8, 2022 · 1 comment
Assignees
Labels
Discussion question Further information is requested

Comments

@sebikap-gm2
Copy link

Hi there!
I'm having an issue, where all the generated models which reference other models are typed as
someProp: types.union(types.undefined, types.late((): any => SomeNameModel))
The issue I'm having is with the "any" literal typing, which instead of typing "someProp" as being of type "SomeNameModel", it gets typed as "any".

While digging into the code, I understand that when generated with the command gets run with "--format ts" attribute, ": any" type is hardcoded. Link to file.

I'm not sure if this was intended to solve this issue, but it does not seems to be causing that problem.

Could that "any" typing be removed?

@Benz19 Benz19 added question Further information is requested Discussion labels Nov 9, 2022
@KashubaK
Copy link

My assumption is that it's to work around circular dependencies, as recommended in mobx-state-tree's docs: https://mobx-state-tree.js.org/tips/circular-deps

Their reasoning is that since the data is type-safe at runtime, casting the any back into your model type is OK. Though from a cleanliness perspective it's not ideal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Discussion question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants