Here's an example that works fine with versions prior to 16.4.8
MyComponent.tsx
import * as React from "react";
import * as PropsTypes from "prop-types";
interface IProps {
hello?: string;
world?: boolean;
}
export const MyComponent: React.SFC<IProps> = props => <div>Hello World!</div>;
MyComponent.propTypes = {
hello: PropsTypes.string,
world: PropsTypes.bool
};
I'm not 100% sure where exactly the issue is coming from but downgrading to 16.4.7 makes everything work.
With 16.4.8 I get this error:
[ts]
Type '{ hello: Requireable<string>; world: Requireable<boolean>; }' is not assignable to type 'ValidationMap<IProps> | undefined'.
Type '{ hello: Requireable<string>; world: Requireable<boolean>; }' is not assignable to type 'ValidationMap<IProps>'.
Types of property 'hello' are incompatible.
Type 'Requireable<string>' is not assignable to type 'Validator<string | undefined>'.
Types of property '[nominalTypeHack]' are incompatible.
Type 'string | null | undefined' is not assignable to type 'string | undefined'.
Type 'null' is not assignable to type 'string | undefined'.
Adding .isRequired to all props makes the error go away, but... why?
MyComponent.propTypes = {
hello: PropsTypes.string.isRequired,
world: PropsTypes.bool.isRequired
};
Here's an example that works fine with versions prior to 16.4.8
MyComponent.tsx
I'm not 100% sure where exactly the issue is coming from but downgrading to 16.4.7 makes everything work.
With 16.4.8 I get this error:
Adding
.isRequiredto all props makes the error go away, but... why?