Open kyscott18 opened 12 months ago
essentially a duplicate of #49618
Spent a few hours trying to work around this without success, adding my use case:
// would love for this to work: function create<T>(fn: (root: T) => T): T {}
const example = create((root) => ({
static: 10,
computed: () => root.static + 5,
}));
example.computed() // 15
🔍 Search Terms
"inferring parameters types", "infer input from output types"
✅ Viability Checklist
⭐ Suggestion
I would like to infer the types of the parameters of a function based on the return type. I have tried a few patterns and I don't think this is currently possible.
📃 Motivating Example
💻 Use Cases
Helpful for strict typings and intellisense.
None give a strict enough type.
I don't have the type safety that I want.