mention-hashtag
mention-hashtag copied to clipboard
Add TypeScript type definitions
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?
Of course! Thanks!
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 It's been a while since I last used this package, but, sure, I can do it
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 .