Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested inference fails if function is called inline #54184

Open
EskiMojo14 opened this issue May 8, 2023 · 0 comments Β· May be fixed by #54183
Open

Nested inference fails if function is called inline #54184

EskiMojo14 opened this issue May 8, 2023 · 0 comments Β· May be fixed by #54183
Labels
Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone

Comments

@EskiMojo14
Copy link

Bug Report

πŸ”Ž Search Terms

Nested inference, function call

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about nested function call inference

⏯ Playground Link

With libraries
Minimal reproduction

πŸ’» Code

type NoInfer<T> = [T][T extends any ? 0 : never]

type ErrorFn = (error: unknown) => void

declare const genericFn: <T>(args: {
  parser: (p: unknown, errorFn: ErrorFn) => T
  handler: (data: { body: NoInfer<T> }) => unknown
}) => T

declare const createParser: <T>(arg: T) => (p: unknown, errorFn: ErrorFn) => NoInfer<T>;

genericFn({
  parser: createParser(1 as const),
  handler: ({ body: _ }) => {
    //         ^?
    // unknown, should be 1
  }
})

πŸ™ Actual behavior

Handler body is not inferred, becomes default of unknown.

πŸ™‚ Expected behavior

Handler body should be inferred from parser, and be 1.

@RyanCavanaugh RyanCavanaugh added the Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases label May 15, 2023
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Projects
None yet
2 participants