Skip to content

Commit 40afa30

Browse files
committed
fix: add typescript and flowtype definition
1 parent ab1c880 commit 40afa30

File tree

4 files changed

+48
-5
lines changed

4 files changed

+48
-5
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ build/Release
3636
node_modules/
3737
jspm_packages/
3838

39-
# TypeScript v1 declaration files
40-
typings/
41-
4239
# Optional npm cache directory
4340
.npm
4441

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Flowtype definitions for index
3+
* Generated by Flowgen from a Typescript Definition
4+
* Flowgen v1.2.0
5+
* Author: [Joar Wilk](http://twitter.com/joarwilk)
6+
* Repo: http://github.com/joarwilk/flowgen
7+
*/
8+
9+
declare export type Renderable<T>= React.ComponentType<T | void>| React.ReactNode;
10+
declare export type RenderResult<T>= React.ReactElement<T>| null;
11+
declare export interface RenderOptions {
12+
cloneElement?: boolean
13+
}
14+
declare export function createRender<P, T>(
15+
renderable?: Renderable<P>,
16+
options?: RenderOptions): ((...args: [any]) => RenderResult)
17+
declare export default function render<P, T>(
18+
renderable?: Renderable<P>,
19+
props?: P,
20+
options?: RenderOptions): RenderResult<T >

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"main": "dist/react-render-callback.cjs.js",
77
"module": "dist/react-render-callback.esm.js",
88
"unpkg": "dist/react-render-callback.umd.min.js",
9+
"typings": "typings/index.d.ts",
910
"author": "Sascha Tandel <s.tandel@me.com>",
1011
"license": "MIT",
1112
"repository": {
@@ -17,12 +18,13 @@
1718
},
1819
"scripts": {
1920
"add-contributor": "kcd-scripts contributors add",
20-
"build": "kcd-scripts build --bundle --no-clean --size-snapshot",
21+
"build": "kcd-scripts build --bundle --no-clean --size-snapshot && npm run flowgen",
2122
"lint": "kcd-scripts lint",
2223
"test": "kcd-scripts test",
2324
"test:cover": "kcd-scripts test --coverage",
2425
"test:update": "npm test -- --updateSnapshot --coverage",
2526
"test:build": "jest --projects other/misc-tests",
27+
"flowgen": "flowgen typings/index.d.ts -o flow-typed/npm/react-render-callback_v1.x.x.js.flow",
2628
"build-and-test": "npm run build -s && npm run test:build -s",
2729
"validate": "kcd-scripts validate lint,test:cover,build-and-test",
2830
"setup": "npm install && npm run validate -s",
@@ -41,8 +43,10 @@
4143
},
4244
"devDependencies": {
4345
"@babel/plugin-transform-runtime": "^7.0.0",
46+
"@types/react": "^16.4.2",
4447
"ajv": "^6.5.3",
4548
"babel-plugin-dynamic-import-node": "^2.1.0",
49+
"flowgen": "^1.2.2",
4650
"react": "^16.4.2",
4751
"kcd-scripts": "^0.44.0",
4852
"rollup-plugin-commonjs": "^9.1.0",
@@ -57,7 +61,9 @@
5761
"dist"
5862
],
5963
"files": [
60-
"dist"
64+
"dist",
65+
"flow-typed",
66+
"typings"
6167
],
6268
"keywords": [
6369
"react",

typings/index.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import * as React from 'react'
2+
3+
export type Renderable<T> = React.ComponentType<T | void> | React.ReactNode
4+
5+
export type RenderResult<T = any> = React.ReactElement<T> | null
6+
7+
export interface RenderOptions {
8+
cloneElement?: boolean
9+
}
10+
11+
export function createRender<P, T = any>(
12+
renderable?: Renderable<P>,
13+
options?: RenderOptions,
14+
): ((...args: [any]) => RenderResult)
15+
16+
export default function render<P, T = any>(
17+
renderable?: Renderable<P>,
18+
props?: P,
19+
options?: RenderOptions,
20+
): RenderResult<T>

0 commit comments

Comments
 (0)