From f6184ce001ea1fbf1144ab9c51c3d8b3a6510c05 Mon Sep 17 00:00:00 2001 From: tock203 Date: Tue, 19 Dec 2017 23:02:26 +0900 Subject: [PATCH 1/6] Add missing test case --- types/react-hyperscript/react-hyperscript-tests.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/types/react-hyperscript/react-hyperscript-tests.ts b/types/react-hyperscript/react-hyperscript-tests.ts index 9782a79248..d8737e6ca9 100644 --- a/types/react-hyperscript/react-hyperscript-tests.ts +++ b/types/react-hyperscript/react-hyperscript-tests.ts @@ -29,3 +29,13 @@ class MainComponent extends React.Component { ]); } } + +class MixedComponent extends React.Component { + render() { + return h('div', {className: 'some class'}, [ + null, + h('span', 'some tag'), + 'some text node' + ]); + } +} From c6f2ca5fd4d6904b7291dfa395e88a644cdb7cd8 Mon Sep 17 00:00:00 2001 From: tock203 Date: Tue, 19 Dec 2017 23:02:35 +0900 Subject: [PATCH 2/6] Make test green again --- types/react-hyperscript/index.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/types/react-hyperscript/index.d.ts b/types/react-hyperscript/index.d.ts index 4ead727398..1c5ccffdc5 100644 --- a/types/react-hyperscript/index.d.ts +++ b/types/react-hyperscript/index.d.ts @@ -8,10 +8,12 @@ import { ComponentClass, StatelessComponent, ReactElement } from 'react'; declare namespace h {} +type Element = ReactElement | string | null; + declare function h

( componentOrTag: ComponentClass

| StatelessComponent

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

; export = h; From 90e1bc1afa41a87dae3fe6b785f8cd0ec1a4617c Mon Sep 17 00:00:00 2001 From: tock203 Date: Tue, 19 Dec 2017 23:51:38 +0900 Subject: [PATCH 3/6] Add testcase --- types/react-hyperscript/react-hyperscript-tests.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/types/react-hyperscript/react-hyperscript-tests.ts b/types/react-hyperscript/react-hyperscript-tests.ts index d8737e6ca9..1d037d6bc2 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,8 @@ 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'}) ]); } } From d47c9aff6ad222e4a2bffda15828c5f5c043b63d Mon Sep 17 00:00:00 2001 From: tock203 Date: Tue, 19 Dec 2017 23:54:20 +0900 Subject: [PATCH 4/6] Stop treating Element as props --- types/react-hyperscript/index.d.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/types/react-hyperscript/index.d.ts b/types/react-hyperscript/index.d.ts index 1c5ccffdc5..2dbddcf776 100644 --- a/types/react-hyperscript/index.d.ts +++ b/types/react-hyperscript/index.d.ts @@ -10,9 +10,14 @@ declare namespace h {} type Element = ReactElement | string | null; -declare function h

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

( componentOrTag: ComponentClass

| StatelessComponent

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

; From 11e7dd40f62478cb822f701bb84cb105732a7665 Mon Sep 17 00:00:00 2001 From: tock203 Date: Wed, 20 Dec 2017 01:16:42 +0900 Subject: [PATCH 5/6] Add a testcase --- types/react-hyperscript/react-hyperscript-tests.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/types/react-hyperscript/react-hyperscript-tests.ts b/types/react-hyperscript/react-hyperscript-tests.ts index 1d037d6bc2..4be72a9b6a 100644 --- a/types/react-hyperscript/react-hyperscript-tests.ts +++ b/types/react-hyperscript/react-hyperscript-tests.ts @@ -30,7 +30,8 @@ class MainComponent extends React.Component { ]), h('li', 'Another list item') ]), - h('img', {src: 'https://example.com/some-image'}) + h('img', {src: 'https://example.com/some-image'}), + h('span', 1234) ]); } } From 185e465458b370a05f3e5e9365035f0aa7ef778f Mon Sep 17 00:00:00 2001 From: tock203 Date: Wed, 20 Dec 2017 01:17:36 +0900 Subject: [PATCH 6/6] Make tests green again --- types/react-hyperscript/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-hyperscript/index.d.ts b/types/react-hyperscript/index.d.ts index 2dbddcf776..207ffe18ce 100644 --- a/types/react-hyperscript/index.d.ts +++ b/types/react-hyperscript/index.d.ts @@ -8,7 +8,7 @@ import { ComponentClass, StatelessComponent, ReactElement } from 'react'; declare namespace h {} -type Element = ReactElement | string | null; +type Element = ReactElement | string | number | null; declare function h( componentOrTag: ComponentClass | StatelessComponent | string,