TypeScript Version: @3.2.0-dev.20181116
Search Terms: jsx invocations function calls resolution
Code
import * as React from 'react';
declare const Radio: () => React.ReactElement<{}>;
declare const Checkbox: React.FC;
declare const condition1: boolean;
declare const condition2: boolean;
declare const condition3: boolean;
const RandomComponent: React.FC = () => {
if (condition1) {
return <Radio />; // No problem
}
if (condition2) {
return <Checkbox />; // No problem
}
const Component =
condition3
? Radio
: Checkbox;
return <Component />; // Error: JSX element type 'Component' does not have any construct or call signatures.
};
Expected behavior:
Compiles without error.
Actual behavior:
Error: JSX element type 'Component' does not have any construct or call signatures. is reported next to return <Component />. While any of them is callable, the union of them is not.
Playground Link:
Related Issues:
Changes to JSX resolution were described in https://blogs.msdn.microsoft.com/typescript/2018/11/15/announcing-typescript-3-2-rc/.
TypeScript Version: @3.2.0-dev.20181116
Search Terms: jsx invocations function calls resolution
Code
Expected behavior:
Compiles without error.
Actual behavior:
Error: JSX element type 'Component' does not have any construct or call signatures.is reported next toreturn <Component />. While any of them is callable, the union of them is not.Playground Link:
Related Issues:
Changes to JSX resolution were described in https://blogs.msdn.microsoft.com/typescript/2018/11/15/announcing-typescript-3-2-rc/.