Closed
Description
TypeScript Version: 2.3.2
Code
// strictNullCheck: true
namespace React {
interface StatelessComponent<P> {
(props: P & { children?: ReactNode }, context?: any): ReactElement<any> | null;
propTypes?: ValidationMap<P>;
contextTypes?: ValidationMap<any>;
defaultProps?: Partial<P>;
displayName?: string;
}
}
// All this is valid JSX
const Foo: React.StatelessComponent<any> = () => null
const bar = <Foo/>
Expected behavior:
JSX compilation should allow proper types (including null return).
Actual behavior:
Setting the proper return type for stateless components in @types/react yields a lot of failing other types as seen in this build fail: DefinitelyTyped/DefinitelyTyped#17021
Metadata
Metadata
Assignees
Labels
No labels