mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
Fix test, add test to demonstrate how custom elements will work
This commit is contained in:
@@ -43,14 +43,14 @@ function testInstance(inst: ReactTestInstance) {
|
||||
inst.props = {
|
||||
prop1: "p",
|
||||
};
|
||||
inst.type = "t";
|
||||
testInstance(inst.find(n => n.type === "t"));
|
||||
inst.type = "a";
|
||||
testInstance(inst.find(n => n.type === "a"));
|
||||
testInstance(inst.findByProps({ prop1: "p" }));
|
||||
testInstance(inst.findByType("t"));
|
||||
testInstance(inst.findByType("a"));
|
||||
testInstance(inst.findByType(TestComponent));
|
||||
inst.findAll(n => n.type === "t", { deep: true }).map(testInstance);
|
||||
inst.findAllByProps({ prop1: "p" }, { deep: true }).map(testInstance);
|
||||
inst.findAllByType("t", { deep: true }).map(testInstance);
|
||||
inst.findAllByType("a", { deep: true }).map(testInstance);
|
||||
inst.findAllByType(TestComponent, { deep: true }).map(testInstance);
|
||||
}
|
||||
|
||||
|
||||
@@ -332,3 +332,16 @@ const HasFoo2: React.ReactType<{ foo: boolean }> = (props: { foo: boolean }) =>
|
||||
const HasFoo3: React.ReactType<{ foo: boolean }> = (props: { foo: string }) => null; // $ExpectError
|
||||
const HasHref: React.ReactType<{ href?: string }> = 'a';
|
||||
const HasHref2: React.ReactType<{ href?: string }> = 'div'; // $ExpectError
|
||||
|
||||
const CustomElement: React.ReactType = 'my-undeclared-element'; // $ExpectError
|
||||
|
||||
// custom elements now need to be declared as intrinsic elements
|
||||
declare global {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
'my-declared-element': {};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const CustomElement2: React.ReactType = 'my-declared-element';
|
||||
|
||||
Reference in New Issue
Block a user