TypeScript/tests/baselines/reference/tsxSfcReturnUndefinedStrictNullChecks.errors.txt
uhyo 1f56ab02f0
Improve error message for invalid return type of JSX component (#32702)
* New diagnostic message for wrong JSX function component

* Component and Mixed type

* fix existing tests

* add new test for JSX component return type error

* fix tslint error

* update diagnostic message to include component name

* accept baseline

* update tests

* missing semicolon

* accept baseline

Co-authored-by: Wesley Wigham <wwigham@gmail.com>
2020-03-30 13:04:33 -07:00

23 lines
935 B
Plaintext

tests/cases/conformance/jsx/file.tsx(9,14): error TS2786: 'Foo' cannot be used as a JSX component.
Its return type 'undefined' is not a valid JSX element.
tests/cases/conformance/jsx/file.tsx(10,12): error TS2786: 'Greet' cannot be used as a JSX component.
Its return type 'undefined' is not a valid JSX element.
==== tests/cases/conformance/jsx/file.tsx (2 errors) ====
import React = require('react');
const Foo = (props: any) => undefined;
function Greet(x: {name?: string}) {
return undefined;
}
// Error
const foo = <Foo />;
~~~
!!! error TS2786: 'Foo' cannot be used as a JSX component.
!!! error TS2786: Its return type 'undefined' is not a valid JSX element.
const G = <Greet />;
~~~~~
!!! error TS2786: 'Greet' cannot be used as a JSX component.
!!! error TS2786: Its return type 'undefined' is not a valid JSX element.