mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-06 06:19:58 +08:00
Add new definition: react-hyperscript (#20693)
* Add new package: react-hyperscript * Type of function should be declared by function keyword... * Add a workaround tsc does not allow `export =`ing function because ES spec does not allow that. But react-hyperscript does that. So this workaround is required.
This commit is contained in:
17
types/react-hyperscript/index.d.ts
vendored
Normal file
17
types/react-hyperscript/index.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
// Type definitions for react-hyperscript 3.0
|
||||
// Project: https://github.com/mlmorg/react-hyperscript
|
||||
// Definitions by: tock203 <https://github.com/tock203>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { ComponentClass, StatelessComponent, ReactElement } from 'react';
|
||||
|
||||
declare namespace h {}
|
||||
|
||||
declare function h<P>(
|
||||
componentOrTag: ComponentClass<P> | StatelessComponent<P> | string,
|
||||
properties?: P,
|
||||
children?: ReadonlyArray<ReactElement<any>> | string
|
||||
): ReactElement<P>;
|
||||
|
||||
export = h;
|
||||
31
types/react-hyperscript/react-hyperscript-tests.ts
Normal file
31
types/react-hyperscript/react-hyperscript-tests.ts
Normal file
@@ -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')
|
||||
])
|
||||
]);
|
||||
}
|
||||
}
|
||||
23
types/react-hyperscript/tsconfig.json
Normal file
23
types/react-hyperscript/tsconfig.json
Normal file
@@ -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"
|
||||
]
|
||||
}
|
||||
1
types/react-hyperscript/tslint.json
Normal file
1
types/react-hyperscript/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user