diff --git a/types/react-hyperscript/index.d.ts b/types/react-hyperscript/index.d.ts new file mode 100644 index 0000000000..4ead727398 --- /dev/null +++ b/types/react-hyperscript/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for react-hyperscript 3.0 +// Project: https://github.com/mlmorg/react-hyperscript +// Definitions by: tock203 +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import { ComponentClass, StatelessComponent, ReactElement } from 'react'; + +declare namespace h {} + +declare function h

( + componentOrTag: ComponentClass

| StatelessComponent

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

; + +export = h; diff --git a/types/react-hyperscript/react-hyperscript-tests.ts b/types/react-hyperscript/react-hyperscript-tests.ts new file mode 100644 index 0000000000..9782a79248 --- /dev/null +++ b/types/react-hyperscript/react-hyperscript-tests.ts @@ -0,0 +1,31 @@ +import * as React from 'react'; +import * as h from 'react-hyperscript'; + +class SomeComponent extends React.Component { + render() { + return React.createElement('div'); + } +} + +const StatelessComponent = () => React.createElement('div'); + +class MainComponent extends React.Component { + render() { + return h('div.example', [ + h('h1#heading', 'This is hyperscript'), + h('h2', 'creating React.js markup'), + h(SomeComponent, {foo: 'bar'}, [ + h('li', [ + h('a', {href: 'http://whatever.com'}, 'One list item') + ]), + h('li', 'Another list item') + ]), + h(StatelessComponent, {foo: 'bar'}, [ + h('li', [ + h('a', {href: 'http://whatever.com'}, 'One list item') + ]), + h('li', 'Another list item') + ]) + ]); + } +} diff --git a/types/react-hyperscript/tsconfig.json b/types/react-hyperscript/tsconfig.json new file mode 100644 index 0000000000..1ad5f62543 --- /dev/null +++ b/types/react-hyperscript/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-hyperscript-tests.ts" + ] +} diff --git a/types/react-hyperscript/tslint.json b/types/react-hyperscript/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-hyperscript/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }