Microsoft/TypeScript
View on GitHubMissing errors in generic functions in context-sensitive arguments
Open
#61,979 opened on Jun 30, 2025
BugDomain: check: Contextual TypesHelp Wanted
Description
🔎 Search Terms
error generic type parameter inferred context senstivie contextual parameter
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
declare function fn<P>(config: {
callback: (params: P) => (context: number, params: P) => number;
unrelated?: (arg: string) => void;
}): (params: P) => number;
export const result = fn({
callback: <T,>(params: T) => {
return (a: boolean, b) => (a ? 1 : 0); // this should error somewhere, boolean !== number
},
unrelated: (_) => {},
});
🙁 Actual behavior
No error
🙂 Expected behavior
It should error
Additional information about the issue
By hovering => we can see function<T>(params: T): {}. This indicates anyFunctionType leaked into .resolvedReturnType of that signature.