Is it possible to destructure an object which comes from an function call without Typescript complaining?
File 1
- React Component 1
...
let obj = null // <-- object initialization
...
useEffect(() => {
obj = functionCall(...) // <-- function call that populates the object
}, [obj])
- React component 2
const { key1, key2 } = obj // <-- object destructuring
Here I get the following complain from Typescript
- Property 'key1' does not exist on type 'null'.
- Property 'key2' does not exist on type 'null'.
How can I remove those warning?