-
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
Array#map() is not callable on type-guarded array #40463
Comments
This fails on this morning's nightly: function foo<T>(o: T) {
if (Array.isArray(o)) {
o.map(() => {});
}
} I'm very willing to bet it's a side-effect of #39258 |
Because it's generic, we get the apparent type of the conditional, which means getting both the read-only array branch and non-readonly-array branch of the conditional (it could be either), which then fail to unify, as they have a separate set of generics. Essentially, we can't call |
👋 Hi, I'm the Repro bot. I can help narrow down and track compiler bugs across releases! This comment reflects the current state of the repro in this issue running against the nightly TypeScript. Comment by @orta 👍 Compiled Historical InformationComment by @saschanaz
|
@orta this should be "fixed" by the revert to the |
I think #41849 fixed this. |
TypeScript Version: Version 4.1.0-dev.20200909
Search Terms: map not callable
Code
Expected behavior: It should work as it does in 4.1.0-dev.20200908.
Actual behavior:
Playground Link: It somehow shows no error on playground. https://www.typescriptlang.org/play?ts=4.1.0-insiders.20200909#code/GYVwdgxgLglg9mABMOcA8AVAfACgA4CGATgQLYBciGAlIgN4CwAUIq4jMIjgIJEkCeAOhgBnXgPzEy1WoxZsFhEqUEArODDA4ARNuoBuZgoC+zY0A
Related Issues:
The text was updated successfully, but these errors were encountered: