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

Reverse mapped type inference fails to infer from annotated parameters in partially-inferrable object types #57788

Open
Andarist opened this issue Mar 15, 2024 · 0 comments
Labels
Help Wanted You can do this Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases
Milestone

Comments

@Andarist
Copy link
Contributor

πŸ”Ž Search Terms

reverse mapped inference annotated parameters partially inferrable noninferrable object context sensitive

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.5.0-dev.20240315#code/CYUwxgNghgTiAEAzArgOzAFwJYHtXwGcQNkAHAHgBUBxZWYAgPgAoB9ALngG8AoeeAOZ0YDTr378A2gGl4WfAGsQATxyJ4NYQwC6nZpgAenNAtQ4A7qgA08UrCgBbAp030CM7QEp4AXkbwAIxwcCBAoVABuPngAXyiYzxdaNyieMDwCDEEtAl9CYjJmcWy3MWj+KD1vP3gMGGQQK3LAvVYbOxhHAmr-OoamiXgwVvb7J05UZAcAkBge2vrG6JimhNShNx4Aei34AD0AfiA

πŸ’» Code

declare function setup<TGuards>(_: {
  guards: {
    [K in keyof TGuards]: (ctx: unknown, params: TGuards[K]) => boolean;
  };
}): TGuards;

const guards = setup({
  guards: {
    a: () => true,
    b: (_, params) => true,
    c: (_, params: number) => true,
  },
});

guards
// ^? const guards: { a: unknown; b: unknown; c: unknown; }

πŸ™ Actual behavior

It infers { a: unknown; b: unknown; c: unknown; }

πŸ™‚ Expected behavior

I'd expect { a: unknown; b: unknown; c: number; } to get inferred here

Additional information about the issue

No response

@RyanCavanaugh RyanCavanaugh added Help Wanted You can do this Possible Improvement The current behavior isn't wrong, but it's possible to see that it might be better in some cases labels Mar 15, 2024
@RyanCavanaugh RyanCavanaugh added this to the Backlog milestone Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted You can do this 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
Development

No branches or pull requests

2 participants