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

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

Open
Andarist opened this issue Nov 19, 2023 · 0 comments Β· May be fixed by #56460
Open

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

Andarist opened this issue Nov 19, 2023 · 0 comments Β· May be fixed by #56460
Labels
Bug A bug in TypeScript
Milestone

Comments

@Andarist
Copy link
Contributor

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

@andrewbranch andrewbranch added the Bug A bug in TypeScript label Nov 20, 2023
@andrewbranch andrewbranch added this to the Backlog milestone Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
2 participants