Closed
Description
π Search Terms
contextual parameter filtering mapped type inference generic
π Version & Regression Information
- This is the behavior in every version I tried
β― Playground Link
π» Code
declare function f1<T extends object>(
data: T,
handlers: { [P in keyof T as P]: (value: T[P], prop: P) => void },
): void;
f1(
{
foo: 0,
bar: "",
},
{
foo: (value, key) => {},
bar: (value, key) => {},
},
);
declare function f2<T extends object>(
data: T,
handlers: { [P in keyof T as T[P] extends string ? P : never]: (value: T[P], prop: P) => void },
): void;
f2(
{
foo: 0,
bar: "",
},
{
bar: (value, key) => {},
},
);
π Actual behavior
All of those functions report:
Parameter 'value' implicitly has an 'any' type.(7006)
π Expected behavior
I'd expect all of those parameters to be contextually typed without problems.
Additional information about the issue
No response