Microsoft/TypeScript
Missing errors in generic functions in context-sensitive arguments
オープン
#61,979 opened on 2025/06/30
BugDomain: check: Contextual TypesHelp Wanted
Repository metrics
- Stars
- (108,860 個のスター)
- PR merge metrics
- (平均マージ 6d 17h) (30d で 9 merged PRs)
説明
🔎 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.