-
Notifications
You must be signed in to change notification settings - Fork 12.8k
T wider in lazy branch of T | (() => T) for known T #55277
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
Comments
|
Discussed in some detail here #55113 Objects are allowed to have additional properties, however special checks are applied in some locations just to catch probable bugs. As said in other places, this is more of a warning than a type error. |
Ahh, appreciate the notes. I wish the error message for those checks were more clear they are a lint, and not a type system property. I've been operating under this misunderstanding for years writing TS! Any known good workarounds? I guess I can write a Lint rule to require annotation of a lazy value? This caused a very insidious misspelling bug. Thanks again. |
I don't see any option other than explicit typings. There is an open suggestion (#12936) for Exact types that are always checked this way, maybe one day that will happen. |
You’re certainly not alone. Thats why I’m glad for #55152. |
🔎 Search Terms
T | (() => T)
"T | (() => T)" inference
inference of lazy generic type
lazy generic inferred too wide
🕗 Version & Regression Information
⏯ Playground Link
https://www.typescriptlang.org/play?#code/C4TwDgpgBA8mwEsD2A7AhgGwyAMmgXiADwAqAfFALxQlQA+UAFIwJRUUksBQokUAsiBLho1AN5Q0ALigAjJEgwQ0KKAF8uAY1QBnYFABmq6o2Ay4iVJmx5CRQcMhk2lCmI1cjjCdKjAATgCuEAA0UDoAFkiBGAAmAGJoCBgyAIxqbAD0mVAAIhA6CP5oskqeKMwuFN6SMgHBYZHRcQZJKVAA5MARCDpQsUgFUChI+q3JYQDuPZoRUL1yaLEd6ixZOQBCS0A
💻 Code
🙁 Actual behavior
No type error for
shouldFail
on last line above.🙂 Expected behavior
Type error for
shouldFail
on last line above, same as line above it.The text was updated successfully, but these errors were encountered: