Skip to content

Commit d937469

Browse files
author
shunmugam
committed
type added
1 parent 95a9331 commit d937469

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "use-state-with-callback",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "",
55
"main": "lib/index.js",
66
"scripts": {
@@ -26,6 +26,7 @@
2626
"babel-eslint": "^10.0.2",
2727
"babel-loader": "^8.0.5",
2828
"chai": "^4.2.0",
29+
"copy-webpack-plugin": "^6.1.0",
2930
"coveralls": "^3.0.3",
3031
"enzyme": "^3.9.0",
3132
"enzyme-adapter-react-16": "^1.13.2",

src/index.d.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import React, {SetStateAction, Dispatch} from 'react';
2+
3+
type DispatchWithCallback<A> = (value: A, callback: Callback) => void;
4+
5+
type Callback<S> = (state:s) => (void | (() => void | undefined));
6+
7+
8+
declare function useStateWithCallback<S>(initialState:S,callback:Callback) : [S,Dispatch<SetStateAction<S>>];
9+
10+
export declare function useStateWithCallbackInstant<S>(initialState:S,callback:Callback) : [S,Dispatch<SetStateAction<S>>];
11+
12+
13+
export declare function useStateWithCallbackLazy<S>(initialState:S) : [S,DispatchWithCallback<SetStateAction<S>>];
14+
15+
16+
export default useStateWithCallback;

webpack.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const path = require('path');
2+
const CopyPlugin = require('copy-webpack-plugin');
23

34
module.exports = {
45
entry: './src/index.js',
@@ -21,4 +22,11 @@ module.exports = {
2122
},
2223
],
2324
},
25+
plugins: [
26+
new CopyPlugin({
27+
patterns: [
28+
{ from: './src/index.d.ts', to: './index.d.ts'}
29+
],
30+
}),
31+
],
2432
};

0 commit comments

Comments
 (0)