我正在尝试做类似的事情:
interface Props extends RouteComponentProps {
country: 'ONE' | 'OTHER;
}
MyComponent.propTypes = {
country: PropTypes.oneOf(['ONE', 'OTHER']).isRequired,
};
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Type 'Validator<string>' is not assignable to type 'Validator<"ONE" | "OTHER">'.
Type 'string' is not assignable to type '"ONE" | "OTHER"'.ts(2322)
Run Code Online (Sandbox Code Playgroud)
两个疑问: