Pustur/whatsapp-chat-parser

Add type definitions for Typescript

Closed this issue · 2 comments

I'd like to add type definitions but I don't have any experience with Typescript yet.
The definition would be for the public API, so just this function:

function parseString(string, options) {

The API is pretty well documented in the readme.

I'd like to have a types folder in the root of the project, with a index.d.ts file inside.
When done, a PR can be opened against the develop branch.

Anyone interested in taking this? Would be very appreciated.

interface Message {
  date: string;
  author: string;
  message: string;
}

interface ParseStringOptions {
  daysFirst?: boolean;
}

export function parseString(string: string, options?: ParseStringOptions): Promise<Message[]>;

Place in root as whatsapp-chat-parser.d.ts.

In package.json:

  • If files is set, add there
  • Add "types": "whatsapp-chat-parser.d.ts" on root

@Cretezy Thank you very much! I made some small adjustments but otherwise your code works very well!