We are using a cleanNullOrUndefined function in our codebase, which gets rid of keys in an object if the value of the key is null or undefined. This is not well-typed and just returns a Partial of the original object which gives some errors in other places.
What we need is to type the function to return the object, with keys that are null or undefined removed and inferred types for the other keys.
Example:
const obj = {
a: 1,
b: 'string',
c: false,
d: null,
e: undefined
}
// Desired return type
interface ReturnType {
a: number,
b: string,
c: boolean
}
I can't seem to get my head around how to do this.