Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add typescript support #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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