In TypeScript is there a way for useContext within the following to pick and return the value type from from Provider?
function Provider<Props = {value: number}>(props: Props) { }
function useContext<Value>(context: Context<Value>): Pick<Value, 'value'> { return 0 }
Such that "Consumer" will return the type: number when used as follows
function Consumer<Props>(props: Props) { return useContext(Provider) }
...For additional context:
interface Component<Props = {}> { (props: Properties<Props>): Node }
interface Context<Value> extends Component<{value: Value}> {}
Or alternatively, given
function Provider({value, children}: {value: string, children: any}) {
return h(Context, {value: 'value'}, children)
}
const value = useContext(Provider)
How would one attribute the constant "value" to the "value" found in the object {value: 'value'} assuming that the function "h" returns an interface:
interface {type: Context, props: {value: 'value}, children: children}
I've tried to Pick, props> where Type is "Provider" then Pick from the result of that Pick, props>, 'value'>.
That however didn't seem to work.