Skip to content

Commit

Permalink
Merge pull request #346 from sparkled/add-react-typings
Browse files Browse the repository at this point in the history
Add TypeScript definitions for React
  • Loading branch information
Grsmto authored Aug 28, 2019
2 parents 8686641 + 82c5849 commit bf3ae5b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 3 additions & 1 deletion packages/simplebar-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"main": "dist/simplebar-react.js",
"module": "dist/simplebar-react.esm.js",
"types": "dist/simplebar-react.d.ts",
"bugs": "https://github.com/grsmto/simplebar/issues",
"homepage": "https://grsmto.github.io/simplebar/",
"license": "MIT",
Expand All @@ -31,7 +32,8 @@
"react-dom": "^0.14.9 || ^15.3.0 || ^16.0.0-rc || ^16.0"
},
"devDependencies": {
"react-test-renderer": "^16.3.2"
"react-test-renderer": "^16.3.2",
"rollup-plugin-copy": "^3.0.0"
},
"jest": {
"transform": {
Expand Down
6 changes: 5 additions & 1 deletion packages/simplebar-react/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import babel from 'rollup-plugin-babel';
import copy from 'rollup-plugin-copy';
import license from 'rollup-plugin-license';
import { terser } from 'rollup-plugin-terser';
import pkg from './package.json';
Expand All @@ -17,7 +18,7 @@ const banner = {
};
const globals = {
'prop-types': 'PropTypes',
'react': 'React'
react: 'React'
};
const external = [...Object.keys(pkg.dependencies), 'react'];

Expand All @@ -37,6 +38,9 @@ export default [
}),
resolve(), // so Rollup can find dependencies
commonjs(), // so Rollup can convert dependencies to an ES module
copy({
targets: [{ src: 'simplebar-react.d.ts', dest: 'dist' }]
}),
terser(),
license(banner)
]
Expand Down
10 changes: 10 additions & 0 deletions packages/simplebar-react/simplebar-react.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

declare module 'simplebar-react' {
interface Props extends React.HTMLAttributes<HTMLElement> {
scrollableNodeProps?: object;
options?: object;
}

export default class SimpleBar extends React.Component<Props> {}
}

0 comments on commit bf3ae5b

Please sign in to comment.