first of all pardon me, I am quite new to Typescript. I’ve been trying to find a solution for this but am unable to do so.
I have a nestedObj type which uses indexed signature as so:
type nestedObj = {[key: string]: nestedObj} | {[key: string]: number}
Question is, how would I create a type guard for this nestedObj type?
const isNestedObj = (obj: any): obj is nestedObj => {
if (obj === null || obj === undefined)
return false;
??????
return true;
}
I’m at a lost to how to proceed, any help or relevant documentation would be much appreciated!