Here is my current code:
interface ObjectIsEmptyProps {
[index: string]: number | string;
}
export const objectIsEmpty = (a: ObjectIsEmptyProps) => a &&
Object.keys(a).length >
I need to check an object that might have any number properties provided to it. So 3 examples of possible function calls are:
objectIsEmpty({}) //true
objectIsEmpty({ jamie: 'hutber' }) //false
objectIsEmpty({fank: 'skinner', jamie: 'hutber' }) //false
objectIsEmpty({anArray: [], aBoolie: false, chickenSkin: 'isGreat'}) //false
So my function can take an object with an undetermined set of properties. Currently the only way I can TS to be happy is to use any
as the type of the argument.
How can I support any number of object properties without using any?