45 lines
1.6 KiB
Plaintext
45 lines
1.6 KiB
Plaintext
|
tests/cases/conformance/jsx/tsxAttributeResolution5.tsx(21,16): error TS2606: Property 'x' of JSX spread attribute is not assignable to target property.
|
||
|
Type 'number' is not assignable to type 'string'.
|
||
|
tests/cases/conformance/jsx/tsxAttributeResolution5.tsx(25,9): error TS2324: Property 'x' is missing in type 'Attribs1'.
|
||
|
tests/cases/conformance/jsx/tsxAttributeResolution5.tsx(29,1): error TS2324: Property 'x' is missing in type 'Attribs1'.
|
||
|
|
||
|
|
||
|
==== tests/cases/conformance/jsx/tsxAttributeResolution5.tsx (3 errors) ====
|
||
|
declare module JSX {
|
||
|
interface Element { }
|
||
|
interface IntrinsicElements {
|
||
|
test1: Attribs1;
|
||
|
test2: Attribs2;
|
||
|
}
|
||
|
}
|
||
|
interface Attribs1 {
|
||
|
x: string;
|
||
|
}
|
||
|
|
||
|
interface Attribs2 {
|
||
|
toString(): string;
|
||
|
}
|
||
|
|
||
|
function make1<T extends {x: string}> (obj: T) {
|
||
|
return <test1 {...obj} />; // OK
|
||
|
}
|
||
|
|
||
|
function make2<T extends {x: number}> (obj: T) {
|
||
|
return <test1 {...obj} />; // Error (x is number, not string)
|
||
|
~~~~~~~~
|
||
|
!!! error TS2606: Property 'x' of JSX spread attribute is not assignable to target property.
|
||
|
!!! error TS2606: Type 'number' is not assignable to type 'string'.
|
||
|
}
|
||
|
|
||
|
function make3<T extends {y: string}> (obj: T) {
|
||
|
return <test1 {...obj} />; // Error, missing x
|
||
|
~~~~~~~~~~~~~~~~~~
|
||
|
!!! error TS2324: Property 'x' is missing in type 'Attribs1'.
|
||
|
}
|
||
|
|
||
|
|
||
|
<test1 {...{}} />; // Error, missing x
|
||
|
~~~~~~~~~~~~~~~~~
|
||
|
!!! error TS2324: Property 'x' is missing in type 'Attribs1'.
|
||
|
<test2 {...{}} />; // OK
|
||
|
|