40 lines
1.4 KiB
Text
40 lines
1.4 KiB
Text
|
tests/cases/conformance/jsx/tsxAttributeErrors.tsx(15,6): error TS2322: Type 'number' is not assignable to type 'string'.
|
||
|
tests/cases/conformance/jsx/tsxAttributeErrors.tsx(18,6): error TS2322: Type 'string' is not assignable to type 'number'.
|
||
|
tests/cases/conformance/jsx/tsxAttributeErrors.tsx(22,6): error TS2606: Property 'text' of JSX spread attribute is not assignable to target property.
|
||
|
Type 'number' is not assignable to type 'string'.
|
||
|
|
||
|
|
||
|
==== tests/cases/conformance/jsx/tsxAttributeErrors.tsx (3 errors) ====
|
||
|
|
||
|
declare namespace JSX {
|
||
|
interface Element { }
|
||
|
interface IntrinsicElements {
|
||
|
div: {
|
||
|
text?: string;
|
||
|
width?: number;
|
||
|
}
|
||
|
|
||
|
span: any;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Error, number is not assignable to string
|
||
|
<div text={42} />;
|
||
|
~~~~~~~~~
|
||
|
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||
|
|
||
|
// Error, string is not assignable to number
|
||
|
<div width={'foo'} />;
|
||
|
~~~~~~~~~~~~~
|
||
|
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||
|
|
||
|
// Error, number is not assignable to string
|
||
|
var attribs = { text: 100 };
|
||
|
<div {...attribs} />;
|
||
|
~~~~~~~~~~~~
|
||
|
!!! error TS2606: Property 'text' of JSX spread attribute is not assignable to target property.
|
||
|
!!! error TS2606: Type 'number' is not assignable to type 'string'.
|
||
|
|
||
|
// No errors here
|
||
|
<span foo='bar' bar={'foo'} />;
|
||
|
|