Closed
Description
Bug Report
π Search Terms
callback, block, inference, double
π Version & Regression Information
This is the behavior in every version I tried, and I reviewed the FAQ for entries about arrow functions
β― Playground Link
π» Code
function repro<T>(_config: {
params: T;
callback: (params: T) => (params: T) => number;
}): void { return }
repro({
params: 1,
callback: () => { return a => a + 1 }, // a is unknown
});
repro({
params: 1,
callback: _b => { return a => a + 1 }, // a is a number, only difference is the ignored outer param
});
repro({
params: 1,
callback: () => a => a + 1, // a is a number, only difference is the lack of `{ return ... }`
});
π Actual behavior
The type of a
ends up being unknown
, but only if no parameter is declared and a block is used in the outer callback.
π Expected behavior
The type of the inner callback parameter a
should be known in all 3 cases.
Activity
Urtgard commentedon Sep 9, 2022
In my project I stumbled over a similiar case:
Let me know if this is different problem, then I'll open a new issue.
Andarist commentedon Sep 17, 2022
@Urtgard your problem is different and it's a not a bug, take a look at the inline explanation that I have added in this TS playground
nix6839 commentedon Oct 24, 2022
Same issue here... I hope it will be fixed at v4.9.2