Simple and expressive type checks as a component, adapted from npm's is-type module.