mention-hashtag icon indicating copy to clipboard operation
mention-hashtag copied to clipboard

Add TypeScript type definitions

Open francisbrito opened this issue 6 years ago • 4 comments

They would be useful for those of us using TS.

Here's the current definition I'm using:

declare module 'mention-hashtag' {
  export enum ExtractionType {
    MENTION = '@',
    HASH_TAG = '#',
    ALL = 'all',
  }
  export type ExtractionOptions = { type: ExtractionType; unique: boolean; symbol: boolean };
  export type ExtractionResult = { mentions: string[]; hashtags: string[] };

  function extract(text: string, options: ExtractionType.ALL): ExtractionResult;
  function extract(
    text: string,
    options: ExtractionOptions | ExtractionType.MENTION | ExtractionType.HASH_TAG,
  ): string[];

  export default extract;
}

I'm not sure if its the best approach, but it does the work. Are you OK with a PR for this?

francisbrito avatar Jun 23 '18 23:06 francisbrito

Of course! Thanks!

lmfresneda avatar Jun 25 '18 08:06 lmfresneda

They would be useful for those of us using TS.

Here's the current definition I'm using:

declare module 'mention-hashtag' {
  export enum ExtractionType {
    MENTION = '@',
    HASH_TAG = '#',
    ALL = 'all',
  }
  export type ExtractionOptions = { type: ExtractionType; unique: boolean; symbol: boolean };
  export type ExtractionResult = { mentions: string[]; hashtags: string[] };

  function extract(text: string, options: ExtractionType.ALL): ExtractionResult;
  function extract(
    text: string,
    options: ExtractionOptions | ExtractionType.MENTION | ExtractionType.HASH_TAG,
  ): string[];

  export default extract;
}

I'm not sure if its the best approach, but it does the work. Are you OK with a PR for this?

been a couple of years, but do you want to do that PR?

mattbodman avatar Jun 28 '21 05:06 mattbodman

@mattbodman It's been a while since I last used this package, but, sure, I can do it

francisbrito avatar Jun 28 '21 13:06 francisbrito

Cool.. looked like you were 90% there so I thought it would be easy... No pressure though!

On Mon, 28 Jun 2021 at 23:33, Francis Brito @.***> wrote:

@mattbodman https://github.com/mattbodman It's been a while since I last used this package, but, sure, I can do it

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/lmfresneda/mention-hashtag/issues/4#issuecomment-869689313, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAPG6BJ2JLYTJLBPZODC7QTTVB22ZANCNFSM4FGT35NQ .

mattbodman avatar Jun 29 '21 04:06 mattbodman