Closed
Description
TypeScript Version: 3.6.3 - 3.8.0-dev.20191031
Search Terms: parameter, inference, order, generic, function expression, function declaration
Code
interface IData {
bar: boolean
}
declare function test<TDependencies>(
getter: (deps: TDependencies, data: IData) => any,
deps: TDependencies,
): any
const DEPS = {
foo: 1
}
// negative test
test(
(deps, data) => ({
fn1: function() { return deps.foo },
fn2: data.bar
}),
DEPS
);
// positive tests
test(
(deps: typeof DEPS, data) => ({
fn1: function() { return deps.foo },
fn2: data.bar
}),
DEPS
);
test(
(deps, data) => ({
fn1: () => deps.foo,
fn2: data.bar
}),
DEPS
);
test(
(deps, data) => {
return {
fn1() { return deps.foo },
fn2: data.bar
}
},
DEPS
);
test(
(deps) => ({
fn1() { return deps.foo },
fn2: 1
}),
DEPS
);
Expected behavior: deps
should be inferred as typeof DEPS
in negative test
Actual behavior: deps
inferred as unknown
Playground Link: link
Related Issues: I guess, the fix of #32230 bug led to the appearance of this bug