Consider the following code in TS playground here
In line 14, is it possible to throw error for "tree" variable, i.e. it does not exist in the returned object for it to be destructured ?
const foo = () => ({
bar: {
hi: 5
},
six: {
max: 10
}
})
function test(fn: () => Record<string, Object>) {
return fn()
}
const {six, tree } = test(foo) // <- line 14
console.log(tree)