I can't think of a way to destructure an object from provided argument:
type PossibleStateProperty = 'hello' | 'world'
type State = {
hello: 'welcome',
world: 'earth'
}
handleError = (name: PossibleStateProperty) => {
const { [name] } = this.state
}
Where I would destructure the state
object property based on the provided function argument.
const { [name] } = this.state
is sadly invalid