-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Nested array/object types 6+ deep can break typechecking for smaller nested types across the entire file #42070
Comments
Please let me know if I should split this into two separate issues ("5D arrays can be assigned to 6+D array types" vs "6D array types can break uses of unrelated 2+D array types elsewhere in the file"). |
Playing around some more I noticed some extra nuance that might help track down the bug. Observe the difference in behavior between these two scenarios: |
any workaround? |
@zifahm I believe this was fixed by #46599 which was included in TypeScript 4.5.3, so if you can upgrade your compiler that might help. I haven't done extensive testing yet but at least the playground links above now exhibit correct behavior when using 4.5.3. Let me know if you upgrade and still see problems, if not I'll probably close this issue. |
@mkantor I'm trying to do something like this, still, seems to show an error? or am I doing something wrong? |
@zifahm your Your playground has an error for the same reason that |
@mkantor yeah just got it thanks :) 😅 |
Since I haven't been able to reproduce this issue since 4.5.3, I'm closing it. I'm very happy to see the depth limiter getting smarter! 🎉 |
I noticed that you can assign a 5D array value to an array type that requires 6 or more dimensions. That's unfortunate, but the more concerning thing is how doing so can apparently break typechecks for nested arrays of any depth across the whole file.
A similar thing happens with deeply-nested object types.
The depth limiter for nested instantiations seems relevant, especially since the magic number here is 6 (or really "anything more than 5").
TypeScript Version: 4.5.2, 4.2.0-dev.20201221 and all other versions tested (3.3.3-4.1.2)
Search Terms: "multidimensional array" "deep array" "nested array" 6D "six-dimensional" "nested object" "deep object" "depth limiter" "deeply-nested" isDeeplyNestedType
Code
Expected behavior:
Those mis-typed variable assignments should be flagged by the typechecker. More importantly, typechecking for each term should not be affected by the presence/absence/source order of unrelated code.
Actual behavior:
TypeScript doesn't complain about anything unless you uncomment the first block of code or comment out the second one.
Playground Link:
https://www.typescriptlang.org/play?#code/PTAEEEBtNBDBneBLA5gOwLYFM0Bd6hJqi4AWSBAZkpFnAE51EBuskSAJgDSgBGArrgY4A5EMYArLAGNcWDnwCeJUnVyKADjNXSA1lnoA6AFDGQoAKpppAewzY8KinDQL4-DhxyRlZOo3ghG0oVOmpaQgJ1LWkdfQVbekZZHwBCMzBbNEC4ACYALlBA+iIUAG0AXUrQAF5QMsqKjNAsnNhcgGVSG35IDgAxWBpC4tLquvbm1qF2rp6+qHgbQeGi3BK0cqrt2rzTcwBhOwchMmcemddQ0ACgkL9QcKYozW0ZeJabJJlcNONpuAANhG6zG20qEJ2dQaMMaFXhTQBsEBc16AyGkBBGy2kMhu2R-xs2RmKO6aMWywxWLBuPBUKBpgBvAKa2xeOhjUJxL4nTJfRWmNZYN2zK5OWZqIWkCWAupm1pIty+zAgIA1KAvBoyEUsFgMFEbHw1KoSEgNBpSqANDYiLgANw6uhsJaFUi4XAaeD5ED4DSQWCKQxeZjARQAOVgAE4AEJhoA
Related Issues:
The text was updated successfully, but these errors were encountered: