TypeScript Version: 2.1.0-dev.20160829
With @types/react@0.14.41 and "strictNullChecks": true.
Code
// with @types/react@0.14.41
// SFC returns null: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/11912
import * as React from 'react';
const CustomComponent = (props: { flag: boolean }) => props.flag ? React.createElement('div') : null;
const UseComponent = () => React.createElement(CustomComponent); // works
const UseComponent2 = () => <CustomComponent />; // throws
Expected behavior:
TSX behaves like plain TS.
Actual behavior:
TSX throws
[ts] JSX element type 'DOMElement<{}, Element> | null' is not a constructor function for JSX elements.
Type 'null' is not assignable to type 'ElementClass'.
TypeScript Version: 2.1.0-dev.20160829
With
@types/react@0.14.41and"strictNullChecks": true.Code
Expected behavior:
TSX behaves like plain TS.
Actual behavior:
TSX throws