Content-Length: 273467 | pFad | https://github.com/microsoft/TypeScript/issues/61979

4C Missing errors in generic functions in context-sensitive arguments Β· Issue #61979 Β· microsoft/TypeScript Β· GitHub
Skip to content

Missing errors in generic functions in context-sensitive argumentsΒ #61979

@Andarist

Description

@Andarist

πŸ”Ž 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

https://www.typescriptlang.org/play/?ts=5.9.0-dev.20250627#code/CYUwxgNghgTiAEAzArgOzAFwJYHtVNQB4AFAPgAow9EsBzALngG8AoeeMKCCAIyjADWjcgAdYUALYBnRsQCU8ALyl4lPBhAAPDI1TIJPEDAA08MTEkz48pSr0GjAbjbw0caBuAB+YbAbwpDBgsVFoFZXgANxwsYGcAXzlhc0tZcLt9QxhnFi0RHBgMDjxA+DgpZAgixQJyVnZObj5BRkIAFWMKFOlGNvTmF3Y4DGQYfHIoRh4cHAgQKFRTHn6J+C94AEZ4RgAGOUd4AHpD+AwACywpALOcSuB4IxgCgJwJEAB3M6MQJZm5hfgAEJFDV7FkXPFjC43CAPCBgMIAPr9JiQliJZxAA

πŸ’» 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions









      ApplySandwichStrip

      pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


      --- a PPN by Garber Painting Akron. With Image Size Reduction included!

      Fetched URL: https://github.com/microsoft/TypeScript/issues/61979

      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy