-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Needs InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.
Description
I don't recognize any examples of this in the docs. Can we map to a type that holds the return types of key-indexed functions? Is there a syntax for that?
var ex = {
One<S>(x : S) { return x; }
Two<T>(y : T) { return "foo"; }
Three() { return false; }
}
// Bad because all return types would have to be the same `T`
type BadMappedOutputs<T, O extends { [k : string] : () => T }> = {
[K in keyof O] : T
}
// Something like this?
type MappedOutputs<O> = {
<T>[K in keyof O where O[K] extends () => T] : T
}
var baz = MappedOutputs<typeof ex>;
baz.One; // any
baz.Two; // string
baz.Three; // boolean
Metadata
Metadata
Assignees
Labels
Needs InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.