diff --git a/types/react-hyperscript/index.d.ts b/types/react-hyperscript/index.d.ts index 4ead727398..207ffe18ce 100644 --- a/types/react-hyperscript/index.d.ts +++ b/types/react-hyperscript/index.d.ts @@ -8,10 +8,17 @@ import { ComponentClass, StatelessComponent, ReactElement } from 'react'; declare namespace h {} -declare function h

( +type Element = ReactElement | string | number | null; + +declare function h( + componentOrTag: ComponentClass | StatelessComponent | string, + children?: ReadonlyArray | Element +): ReactElement; + +declare function h

( componentOrTag: ComponentClass

| StatelessComponent

| string, - properties?: P, - children?: ReadonlyArray> | string + properties: P, + children?: ReadonlyArray | Element ): ReactElement

; export = h; diff --git a/types/react-hyperscript/react-hyperscript-tests.ts b/types/react-hyperscript/react-hyperscript-tests.ts index 9782a79248..4be72a9b6a 100644 --- a/types/react-hyperscript/react-hyperscript-tests.ts +++ b/types/react-hyperscript/react-hyperscript-tests.ts @@ -1,13 +1,17 @@ import * as React from 'react'; import * as h from 'react-hyperscript'; -class SomeComponent extends React.Component { +interface PropTypes { + foo: string; +} + +class SomeComponent extends React.Component { render() { return React.createElement('div'); } } -const StatelessComponent = () => React.createElement('div'); +const StatelessComponent: React.StatelessComponent = () => React.createElement('div'); class MainComponent extends React.Component { render() { @@ -25,7 +29,19 @@ class MainComponent extends React.Component { h('a', {href: 'http://whatever.com'}, 'One list item') ]), h('li', 'Another list item') - ]) + ]), + h('img', {src: 'https://example.com/some-image'}), + h('span', 1234) + ]); + } +} + +class MixedComponent extends React.Component { + render() { + return h('div', {className: 'some class'}, [ + null, + h('span', 'some tag'), + 'some text node' ]); } }