Bug Report
🔎 Search Terms
generic function infer unknown type without specifying parameter type
🕗 Version & Regression Information
Faced it with 4.3.5, but it still occurs in 4.6.3 and Nightly (v4.7.0-dev.20220302)
⏯ Playground Link
Playground link with relevant code
💻 Code
interface Options<TParams, TDone, TMapped> {
fetch: (params: TParams, foo: number) => TDone,
map: (data: TDone) => TMapped
}
function example<TParams, TDone, TMapped>(options: Options<TParams, TDone, TMapped>) {
return (params: TParams) => {
const data = options.fetch(params, 123)
return options.map(data)
}
}
interface Params {
one: number
two: string
}
example({
// WORKS
fetch: (params: Params) => 123,
map: (number) => String(number)
})
example({
// WORKS
fetch: (params: Params, foo: number) => 123,
map: (number) => String(number)
})
example({
// INFERS "unknown"
fetch: (params: Params, foo) => 123,
map: (number) => String(number)
})
🙁 Actual behavior
In 3rd example, without explicitly specifying foo parameter type, the return type of fetch function infers as unknown.
FYI: foo type infers correctly from Options inferface.
🙂 Expected behavior
The code 3rd example works like the first two examples, correctly infering the fetch function's return type.
Bug Report
🔎 Search Terms
generic function infer unknown type without specifying parameter type
🕗 Version & Regression Information
Faced it with 4.3.5, but it still occurs in 4.6.3 and Nightly (v4.7.0-dev.20220302)
⏯ Playground Link
Playground link with relevant code
💻 Code
🙁 Actual behavior
In 3rd example, without explicitly specifying
fooparameter type, the return type offetchfunction infers asunknown.FYI:
footype infers correctly fromOptionsinferface.🙂 Expected behavior
The code 3rd example works like the first two examples, correctly infering the
fetchfunction's return type.