Closed
Description
TypeScript Version: 3.4.0-dev.201xxxxx
Search Terms:
Code
this code work at 3.5.2
and 3.6.0-dev.20190704
but fail at 3.6.0-dev.20190725
import Bluebird = require('bluebird');
let a: string[] = [];
Bluebird.resolve(a as string[])
.mapSeries(async function (vvvv)
{
console.log(vvvv.toUpperCase())
return vvvv;
})
;
Bluebird.resolve(a as string[])
.mapSeries(function (vvvv)
{
console.log(vvvv.toUpperCase())
return vvvv;
})
;
Bluebird.resolve(a as string[])
.mapSeries((vvvv) =>
{
console.log(vvvv.toUpperCase())
return vvvv;
})
;
Expected behavior:
no error and infer to string
Actual behavior:
vvvv infer to unknown
Playground Link:
Related Issues:
Activity
jcalz commentedon Jul 26, 2019
Ideally bug reports will have a completely self-contained example that you don't need external libraries to reproduce. Like maybe this:
Playground (but there's no error in v3.5.1)
Something about
this
and not being able to inferQ
from the typeT & Iterable<Q>
in this scenario. (Workaround: replaceQ
with or constrainQ
to(T extends Iterable<infer I> ? I : never)
)Not sure if this is really a bug or what. Seems like it might be a breaking change for Bluebird, though.
Caused by #32386/#32460? (🃏wild guess❓)
ahejlsberg commentedon Jul 26, 2019
This is caused by #32460. Consider the following simplified example:
With 3.5.x we produced the following results:
It's pretty clear that
x1
andy2
are inconsistent, andunknown
would be a better inference forx2
.With 3.6.0-dev.20190725 we produce:
This has the better inference for
x2
and it makesx1
andy1
consistent, butunknown
is really not a good inference here. I think the desired outcome is:I have updated #32558 to implement this and I'm currently checking for effects on the DT tests.