In TypeScript, you can create a custom function to check an object's type


In TypeScript, you can create a custom function to check an object's type.

This is called a "User Defined Type Guard"

The function returns true if the argument passed appears to be the expected type.

This is a handy way to "narrow" types on plain JS objects.

#typescript

View original on X