2015-06-18 23:03:43 +02:00
|
|
|
//@filename: file.tsx
|
|
|
|
//@jsx: preserve
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
function make3<T extends {y: string}> (obj: T) {
|
|
|
|
return <test1 {...obj} />; // Error, missing x
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
<test1 {...{}} />; // Error, missing x
|
2016-08-06 06:45:13 +02:00
|
|
|
<test2 {...{}} />; // Error, missing toString
|