I'm writing a react component that needs a string prop with a length of less than 10 characters.
I want the compiler to throw an error if a user passes a string with a length greater than 10.
interface ComponentProps {
word: StringLessThanTenChar
}
const Component: React.FC<ComponentProps> = props => {
return <div>{props.word}</div>;
};
<Component word="thisIsAStringLongerThan10Chars" />
How do I create a custom type to check this and throw an error?