-
Notifications
You must be signed in to change notification settings - Fork 118
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
DeepReadonly: Type instantiation is excessively deep and possibly infinite #276
Comments
Hey Budi @budiirawanrapid! Thank you for the report! I also could reproduce it here – https://tsplay.dev/WvYnrm Looks like recursive calls are not properly handled with this declaration of types I will try to come up with a workaround or a solution and will let you know |
I found interesting answer on Stackoverflow about unbinding keys from original type, making it non-homomorphic – https://stackoverflow.com/a/67040809/3745332 e.g. https://tsplay.dev/W4yZKw It helps but we lose the info about keys: they aren't optional, readonly or required anymore Looking for other ideas |
That I can suggest at the moment: you can add From our side it's quite difficult to identify infinite objects That's why we don't support it at the moment I will mention it in our README, but thank you anyway for your finding! 🚀 |
Hi @Beraliv, thank you so much for your response. 😄
Yes, I noticed the difficulty. For JSONObject, there's no base scenario that could stop the recursion.
👍 definitely will apply the Feel free to close this PR if no longer valid. Thank you. |
Setup
ts-essentials 9.0.0
typescript 4.5.4
Problem
I have this TS definition
Then I tried to make the typing immutable
But I got error in Typescript
I'm sure this is because of JSONObject that could have JSONObject as the value, so it'll become infinite. Is there a better way for this scenario?
Here is the link to replicate the issue https://stackblitz.com/edit/typescript-6dunp8?file=index.ts
The text was updated successfully, but these errors were encountered: