react-native-twitter-textview icon indicating copy to clipboard operation
react-native-twitter-textview copied to clipboard

Typescript Support

Open emech-en opened this issue 4 years ago • 3 comments

Great Component! Do you plan to support typescript?

emech-en avatar Apr 16 '20 22:04 emech-en

Thanks a lot, @emech-en!

There's no reason not to! The only issue is, I have very limited experience using TypeScript, so I wouldn't be best suited to perform the migration. I'd be more than happy to accept a Pull Request for TypeScript support, though.

It would be especially useful for me to see how a component I'm familiar with gets transformed into the TS equivalent.

Do you think you'd be up to it?

cawfree avatar Apr 17 '20 08:04 cawfree

Hello,

Here is it:

react-native-twitter-textview.d.ts

declare module 'react-native-twitter-textview' {
  import {FC} from 'react';
  import {GestureResponderEvent, TextStyle, ViewProps} from 'react-native';

  export interface ReactNativeTwitterTextviewProps extends Omit<ViewProps, 'children'>{
    children?: string | never[];
    extractHashtags?: boolean;
    extractMentions?: boolean;
    extractLinks?: boolean;
    extractEmails?: boolean;
    onPressHashtag?: (e: GestureResponderEvent, hashtag: string) => void;
    onPressMention?: (e: GestureResponderEvent, mention: string) => void;
    onPressLink?: (e: GestureResponderEvent, link: string) => string | void;
    onPressEmail?: (e: GestureResponderEvent, email: string) => string | void;
    hashtagStyle?: TextStyle;
    mentionStyle?: TextStyle;
    linkStyle?: TextStyle;
    emailStyle?: TextStyle;
  }

  const ReactNativeTwitterTextView: FC<ReactNativeTwitterTextviewProps>;
  export default ReactNativeTwitterTextView;
}

Have a great day.

centrual avatar Dec 03 '20 16:12 centrual

Instead Omit<ViewProps, 'children'> I think should be Omit<TextProps, 'children'>

ggunti avatar Jun 15 '21 08:06 ggunti