Microsoft/TypeScript
Ver no GitHubReverse mapped type inference fails to infer from annotated parameters in partially-inferrable object types
Open
#57.788 aberto em 15 de mar. de 2024
Domain: Mapped TypesHelp WantedPossible Improvement
Métricas do repositório
- Stars
- (48.455 stars)
- Métricas de merge de PR
- (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)
Description
🔎 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
💻 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