Skip to content

Commit 033d966

Browse files
committed
feature: add typescript support
1 parent 9ba11c5 commit 033d966

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"name": "react-animated-slider",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "Animated slider component for react",
55
"main": "build/index.js",
6+
"typings": "build/index.d.ts",
67
"files": [
78
"build"
89
],
@@ -58,6 +59,7 @@
5859
"babel-jest": "^24.9.0",
5960
"babel-loader": "^8.0.6",
6061
"clean-webpack-plugin": "^3.0.0",
62+
"copy-webpack-plugin": "^5.1.0",
6163
"css-hot-loader": "^1.4.4",
6264
"css-loader": "^3.2.0",
6365
"eslint": "^6.7.1",
@@ -77,6 +79,7 @@
7779
"react": "^16.4.0",
7880
"react-dom": "^16.4.0",
7981
"react-test-renderer": "^16.4.0",
82+
"typescript": "3.7.3",
8083
"webpack": "^4.41.2",
8184
"webpack-cli": "^3.3.10",
8285
"webpack-dev-server": "^3.9.0"

src/index.d.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
interface ISliderProps {
2+
children: React.ReactElement[];
3+
slideIndex?: number;
4+
duration?: number;
5+
disabled?: boolean;
6+
infinite?: boolean;
7+
autoplay?: number;
8+
touchDisabled?: boolean;
9+
minSwipeOffset?: number;
10+
previousButton?: React.ReactElement;
11+
nextButton?: React.ReactElement;
12+
classNames?: IClassNames;
13+
}
14+
15+
interface IClassNames {
16+
slider?: string;
17+
previousButton?: string;
18+
nextButton?: string;
19+
buttonDisabled?: string;
20+
track?: string;
21+
slide?: string;
22+
hidden?: string;
23+
previous?: string;
24+
next?: string;
25+
animateIn?: string;
26+
animateOut?: string;
27+
}
28+
29+
declare module "react-animated-slider" {
30+
import React from "react";
31+
32+
class Slider extends React.Component<
33+
ISliderProps & JSX.IntrinsicElements["div"]
34+
> {}
35+
36+
export = Slider;
37+
}

webpack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const path = require('path');
22
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
33
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
44
const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin');
5+
const CopyPlugin = require('copy-webpack-plugin');
56

67
const sliderConfig = {
78
entry: {
@@ -47,7 +48,8 @@ const sliderConfig = {
4748
new MiniCssExtractPlugin({
4849
filename: '[name].css',
4950
chunkFilename: '[name].css',
50-
}),
51+
}),
52+
new CopyPlugin([{ from: './src/index.d.ts', to: './index.d.ts' }])
5153
],
5254
};
5355

0 commit comments

Comments
 (0)