You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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?
The text was updated successfully, but these errors were encountered: