Skip to content

Nested inference fails if function is called inlineΒ #54184

@EskiMojo14

Description

@EskiMojo14

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolutionPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some cases

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions