Skip to content

Commit 3ee9b23

Browse files
kingdarojamiebuilds
authored andcommitted
added typescript types
1 parent 3ac1c85 commit 3ee9b23

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "0.1.3",
44
"description": "Polyfill for the proposed React context API",
55
"main": "lib/index.js",
6+
"typings": "src/index.d.ts",
67
"repository": "https://github.com/thejameskyle/create-react-context",
78
"author": "James Kyle <me@thejameskyle.com>",
89
"license": "MIT",

src/index.d.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
// PRs welcome
1+
import * as React from 'react';
2+
3+
export default function createReactContext<T>(defaultValue: T): Context<T>;
4+
5+
export type Context<T> = {
6+
Provider: React.ComponentClass<ProviderProps<T>>;
7+
Consumer: React.ComponentClass<ConsumerProps<T>>;
8+
};
9+
10+
export type ProviderProps<T> = {
11+
value: T;
12+
children?: React.ReactNode;
13+
};
14+
15+
export type ConsumerProps<T> = {
16+
children: (value: T) => React.ReactNode;
17+
};

0 commit comments

Comments
 (0)