Skip to content

Commit

Permalink
feature: add typescript support
Browse files Browse the repository at this point in the history
  • Loading branch information
Skona27 committed Dec 12, 2019
1 parent 9ba11c5 commit 033d966
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "react-animated-slider",
"version": "2.0.0",
"version": "2.1.0",
"description": "Animated slider component for react",
"main": "build/index.js",
"typings": "build/index.d.ts",
"files": [
"build"
],
Expand Down Expand Up @@ -58,6 +59,7 @@
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
"clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^5.1.0",
"css-hot-loader": "^1.4.4",
"css-loader": "^3.2.0",
"eslint": "^6.7.1",
Expand All @@ -77,6 +79,7 @@
"react": "^16.4.0",
"react-dom": "^16.4.0",
"react-test-renderer": "^16.4.0",
"typescript": "3.7.3",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.9.0"
Expand Down
37 changes: 37 additions & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
interface ISliderProps {
children: React.ReactElement[];
slideIndex?: number;
duration?: number;
disabled?: boolean;
infinite?: boolean;
autoplay?: number;
touchDisabled?: boolean;
minSwipeOffset?: number;
previousButton?: React.ReactElement;
nextButton?: React.ReactElement;
classNames?: IClassNames;
}

interface IClassNames {
slider?: string;
previousButton?: string;
nextButton?: string;
buttonDisabled?: string;
track?: string;
slide?: string;
hidden?: string;
previous?: string;
next?: string;
animateIn?: string;
animateOut?: string;
}

declare module "react-animated-slider" {
import React from "react";

class Slider extends React.Component<
ISliderProps & JSX.IntrinsicElements["div"]
> {}

export = Slider;
}
4 changes: 3 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');

const sliderConfig = {
entry: {
Expand Down Expand Up @@ -47,7 +48,8 @@ const sliderConfig = {
new MiniCssExtractPlugin({
filename: '[name].css',
chunkFilename: '[name].css',
}),
}),
new CopyPlugin([{ from: './src/index.d.ts', to: './index.d.ts' }])
],
};

Expand Down

0 comments on commit 033d966

Please sign in to comment.