3 ms·
Missing one (two) of the best additions: optional chaining. Per their first example return (value != null && typeof value === "object" && "message" in value
by benoau 2y ago
Missing one (two) of the best additions: optional chaining.
Per their first example
return (value != null && typeof value === "object" && "message" in value && typeof value.message === "string");
can be expressed as just: "return typeof value?.message === 'string'"
I think with #4 unnecessary types there is some great promise with Pick and a few other methods too. In their example they go from too-many declarations to a generic declaration that encompasses three different scenarios but now you need to check what you actually received. With `Pick` you get a middle-ground of the properties you want with less boilerplate and what's really cool is things like comment descriptions get inherited:
type EmailOnly = Pick<Person, 'email'>