-
Notifications
You must be signed in to change notification settings - Fork 87
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 support #50
Comments
I don't know if it helps but I made one for my project and it works for me. declare module 'rodal' {
import {MouseEventHandler, ReactNode} from 'react';
type RodalProps = {
children?: ReactNode;
width?: number;
height?: number;
measure?: string;
visible?: boolean;
showMask?: boolean;
closeOnEsc?: boolean;
closeMaskOnClick?: boolean;
showCloseButton?: boolean;
animation?: string;
enterAnimation?: string;
leaveAnimation?: string;
duration?: number;
className?: string;
customStyles?: {[key: string]: any};
customMaskStyles?: {[key: string]: any};
onClose?: MouseEventHandler<HTMLSpanElement>;
onAnimationEnd?: () => never;
};
const Rodal = (_: RodalProps): JSX.Element => {};
export = Rodal;
} |
How do you make use of this? where do you save it? |
In order to use custom types you will need to import it through typescript. To do so, add the path to your custom types into the
In order to add the folder into typescript is adding it to the
|
Make a PR for this :) it helped me out a lot. Although my linter did not like the return type (so I just ignored it for that line) |
thanks a lot |
Now that I'm using nextjs I changed it a little bit: declare module 'rodal' {
import {MouseEventHandler, JSX, PropsWithChildren} from 'react';
type RodalProps = PropsWithChildren & {
width?: number;
height?: number;
measure?: string;
visible?: boolean;
showMask?: boolean;
closeOnEsc?: boolean;
closeMaskOnClick?: boolean;
showCloseButton?: boolean;
animation?: string;
enterAnimation?: string;
leaveAnimation?: string;
duration?: number;
className?: string;
customStyles?: Record<string, any>;
customMaskStyles?: Record<string, any>;
onClose?: MouseEventHandler<HTMLSpanElement>;
onAnimationEnd?: () => never;
};
function Rodal(_: RodalProps): JSX.Element;
export = Rodal;
} and in the {
"compilerOptions": {
"typeRoots": [
"custom-types",
"node_modules/@types"
],
} |
… be uploaded to the root folder of the package. It also solves issue chenjiahan#50.
I sent a PR #72 for this matter. |
Thanks for you contribution! This change has been released in v2.1.0 |
Can we have types for this?
It would be nice to have for folks with typescript boilerplate.
The text was updated successfully, but these errors were encountered: