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

Add TypeScript definitions for React #346

Merged
merged 1 commit into from
Aug 28, 2019
Merged
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
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> {}
}