Skip to content

Inference from annotated parameters of context-sensitive functions is order dependent Β #56459

@Andarist

Description

@Andarist

πŸ”Ž Search Terms

inference annotated parameters context sensitive order

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.4.0-dev.20231118#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXwxAGcMAeAFQBp4BBagIQD4AKHAIwCsAueAbwCh48TAA8e5ANyD4UHs1m1qo8QEp4AXkbwAbjizApQtnOPx6SjGPhUZPGms069B-gF8VPXfqn9CJZgJCyvAA5Ig4OCGU0gryPCQwWKgA5hYiDlq8rtFGJvEYiSlp1FAZfNluKj5+GAHSwWERUdKmzKYJSanCliVlWTm28HHwHUXd6RqZFe5SQA

πŸ’» Code

declare function test<T, A, B>(obj: {
  ctx: T;
  a: (a: A, ctx: T) => void;
  b: (b: B, ctx: T, a: A) => void;
}): void;

test({
  ctx: 'foo',
  a: (a: string, ctx) => {},
  b: (b: string, ctx, a) => {},
});

test({
  ctx: 'foo',
  b: (b: string, ctx, a) => {},
  a: (a: string, ctx) => {},
});

πŸ™ Actual behavior

The second call doesn't infer properly

πŸ™‚ Expected behavior

I'd expect the second call to be inferred as good as the first one

Additional information about the issue

related to #47599

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: check: Type InferenceRelated to type inference performed during signature resolution or `infer` type resolution

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions