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

Object literals with depth of ~10 (with arrays) stop reporting type inference #21771

Closed
kirbysayshi opened this issue Feb 8, 2018 · 0 comments
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed

Comments

@kirbysayshi
Copy link

It seems that having highly nested types eventually causes the type checker to bail and stop inference. Writing completely invalid structures is permitted at compile time. Adding array types seems integral to this issue manifesting. Perhaps there is an implicit limit of "type depth" that is forces the compiler to bail?

While the playground link below is completely synthetic, I actually ran into this issue while writing an integration test mocking a nested JSON response. Thus the arrays are important and roughly equivalent to my actual data structure.

TypeScript Version: 2.8.0-dev.20180208

Search Terms: depth, limit, type inference

Code
see playground link.

Expected behavior:
blah: true in the playground link should produce a compile-time error, as it is not specified in the interface.

Actual behavior:
No error is produced!

Playground Link: https://www.typescriptlang.org/play/index.html#src=interface%20A%20%7B%0D%0A%20%20%20%20b%3A%20B%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20B%20%7B%0D%0A%20%20%20%20c%3A%20C%5B%5D%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20C%20%7B%0D%0A%20%20%20%20d%3A%20D%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20D%20%7B%0D%0A%20%20%20%20e%3A%20E%5B%5D%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20E%20%7B%0D%0A%20%20%20%20f%3A%20F%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20F%20%7B%0D%0A%20%20%20%20g%3A%20G%5B%5D%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20G%20%7B%0D%0A%20%20%20%20h%3A%20H%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20H%20%7B%0D%0A%20%20%20%20i%3A%20I%5B%5D%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20I%20%7B%0D%0A%20%20%20%20j%3A%20J%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20J%20%7B%0D%0A%20%20%20%20k%3A%20K%5B%5D%3B%0D%0A%7D%0D%0A%0D%0Ainterface%20K%20%7B%0D%0A%20%20%20%20l%3A%20L%5B%5D%3B%20%0D%0A%7D%0D%0A%0D%0Ainterface%20L%20%7B%0D%0A%20%20%20%20hello%3A%20string%3B%0D%0A%7D%0D%0A%0D%0Aconst%20a%3A%20A%20%3D%20%7B%0D%0A%20%20%20%20b%3A%20%7B%20c%3A%20%5B%7B%20d%3A%20%7B%20e%3A%20%5B%7B%20f%3A%20%7B%20g%3A%20%5B%7B%20h%3A%20%7B%20i%3A%20%5B%7B%20j%3A%20%7B%20k%3A%20%5B%7B%20l%3A%20%5B%7B%20hello%3A%20'what'%2C%20blah%3A%20true%20%7D%5D%2C%20%7D%5D%20%7D%7D%5D%7D%7D%5D%7D%7D%5D%7D%7D%5D%7D%0D%0A%7D

Related Issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design Limitation Constraints of the existing architecture prevent this from being fixed
Projects
None yet
Development

No branches or pull requests

3 participants