TypeScript Version: 2.1.0-dev.20160829
With @types/[email protected] and "strictNullChecks": true.
Code
// with @types/[email protected]
// 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/[email protected]and"strictNullChecks": true.Code
Expected behavior:
TSX behaves like plain TS.
Actual behavior:
TSX throws