-
Notifications
You must be signed in to change notification settings - Fork 579
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
typescript definitions file #36
Comments
I'm not familiar with typescript, but would it make sense to ship this file with react-custom-scrollbars? If so, would you mind to make a pull request? |
I am sorry for replying late. People usually organize type-definition files separately. Though you can also provide them with your package which i have no experience with. If you want I can send a pull request with react-custom-scrollbars type-definition and definition test file to the main type-definition repository (definitelyTyped)? |
yes, that would be great! |
Thanks @alihammad-gist ,
Usage
@malte-wessel |
You should host the typings with the library and use the "typings" key in the package.json. See https://github.com/Microsoft/TypeScript-Handbook/blob/master/pages/Typings%20for%20NPM%20Packages.md for details |
Thanks, I'll see what I can do |
Here is an updated TypeScript Definition for declare namespace __RCS {
import React = __React;
interface positionValues {
top: number;
left: number;
clientWidth: number;
clientHeight: number;
scrollWidth: number;
scrollHeight: number;
scrollLeft: number;
scrollTop: number;
}
interface props extends React.HTMLProps<ScrollBar> {
onScroll?: React.UIEventHandler;
onScrollFrame?: (values: positionValues) => void;
onScrollStart?: () => void;
onScrollStop?: () => void;
onUpdate?: (values: positionValues) => void;
renderView?: React.StatelessComponent<any>;
renderTrackHorizontal?: React.StatelessComponent<any>;
renderTrackVertical?: React.StatelessComponent<any>;
renderThumbHorizontal?: React.StatelessComponent<any>;
renderThumbVertical?: React.StatelessComponent<any>;
autoHide?: boolean;
autoHideTimeout?: number;
autoHideDuration?: number;
thumbSize?: number;
thumbMinSize?: number;
universal?: boolean;
}
class ScrollBar extends React.Component<props, {}> {
scrollTop(top: number): void;
scrollLeft(left: number): void;
scrollToTop(): void;
scrollToBottom(): void;
scrollToLeft(): void;
scrollToRight(): void;
getScrollLeft(): number;
getScrollTop(): number;
getScrollWidth(): number;
getScrollHeight(): number;
getWidth(): number;
getHeight(): number;
getValues(): positionValues;
}
}
declare module 'react-custom-scrollbars' {
var Scrollbars: typeof __RCS.ScrollBar;
export {
Scrollbars,
}
} Is the coupled distribution of the definition still planned? Edit: If you still want a pull request for the initial integration of the definition, i could prepare it next weekend. |
I followed the instructions that @jombie gave, but I can't get it to compile. I am using TypeScript 2.1 and up until now, typings was not setup in my project since I use npm @types instead. So, I made a minor change and created a @types/react-custom-scrollbars/index.d.ts file:
To reference it from a project file:
I am very new to hacking up ts definition files (this was my first without directly using types or npm). So bare with me if I am doing something fundamentally wrong. Is this something that could be pushed to npm? Edit: I updated the code above to allow an import statement rather than a require. |
You deleted typings from a repository? |
It has never been published to the npm registry (yet). For now, you can grab one of the above snippets. I think this is why this issue hasn't been closed yet. |
I have created a pull request to add the definition file to the repo and subsequently to the npm package. |
Ooops, me too :-) |
here is type definition file for this package for anyone looking for it.
The text was updated successfully, but these errors were encountered: