Normally, to determine variable type in TypeScript, I can do something like this:
if (typeof payload === 'string') {
console.log(payload) // const payload: string
}
But this one doesn't work:
if (typeof payload === 'object') {
console.log(payload) // const payload: any
}
Here's typescript playground with some non-working examples I ended up
Question:
How do I make a type guard for an object?
Question*:
How do I make a type guard for a specific shape of object?