-
Notifications
You must be signed in to change notification settings - Fork 78
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
Type definitions for this package #46
Comments
I would appreciate it as well |
I had the same problem when using typescript, need it as well |
It would be very useful to have the typings :+1 |
I'm not familiar with typed React. PR would be very welcomed. |
i started with this (not complete): declare module "react-lines-ellipsis" {
type ExpandCollapseProps = {
text: string;
maxLine: Number;
component?: string;
onClick?: Function;
basedOn?: string;
ellipsis?: string;
};
declare class ExpandCollapse extends React.Component<ExpandCollapseProps> {}
export default ExpandCollapse;
} anybody feel free to continue and add all props |
@digitalkaoz
and import in my file: but then I got ts2604 error, not sure why this happened |
After two options enabled in tsconfig.json, the error had gone, everything is ok now
|
I built on the above and came up with this as I also needed to use the responsive HOC. Make sure you add the folder for the declaration file to your tsconfig. Hope this helps somebody in the future. // tsconfig.json
{
"compilierOptions": {
...
"typeRoots": ["./node_modules/@types", "./src/@types"]
}
} // /src/@types/react-lines-ellipsis/index.d.ts
declare module "react-lines-ellipsis" {
import * as React from "react";
interface ReactLinesEllipsisProps {
basedOn?: "letters" | "words";
className?: string;
component?: string;
ellipsis?: string;
isClamped?: () => boolean;
maxLine?: number | string;
onReflow?: ({ clamped, text }: { clamped: boolean; text: string }) => any;
style?: React.CSSProperties;
text?: string;
trimRight?: boolean;
winWidth?: number;
}
class LinesEllipsis extends React.Component<ReactLinesEllipsisProps> {
static defaultProps?: ReactLinesEllipsisProps;
}
export default LinesEllipsis;
}
declare module "react-lines-ellipsis/lib/responsiveHOC" {
import * as React from "react";
export default function responsiveHOC(): <P>(
WrappedComponent: React.ComponentType<P>,
) => React.ComponentClass<P>;
} |
@keithort,this works for me! @xiaody / @keithort , can we arrange this to be merged as a PR? If not, maybe a DefinitelyTyped entry? https://github.com/DefinitelyTyped/DefinitelyTyped (I'm happy to help out in either situation) |
Feel free to. |
I made a DefinitelyTyped PR: DefinitelyTyped/DefinitelyTyped#56523 Edit: PR is merged |
@angeloaltamiranom, it seems you forgot to add the text property for LinesEllipsisLoose |
For anyone who wants to import the types:
|
Hey guys, when using the typed package, I'm not able to pass an HTML element to the ellipsis props as the example in the following link did: https://www.cluemediator.com/truncate-text-in-react-using-react-lines-ellipsis |
Any chance you could add type definitions to this package?
https://github.com/DefinitelyTyped/DefinitelyTyped
The text was updated successfully, but these errors were encountered: