joelcolucci / node-quill-converter

Convert HTML to a Quill Delta or a Quill Delta to HTML
MIT License
95 stars 25 forks source link

TypeScript typings #13

Open dsebastien opened 4 years ago

dsebastien commented 4 years ago

Hello,

Thanks for the project! Could the npm package include TypeScript typings for the public API? This would benefit TypeScript users

joelcolucci commented 4 years ago

Hi @dsebastien! Thanks for reaching out. I'm familiar with Typescript at a high level however I haven't worked with it before.

I'm happy to look into this. Can you provide a link to a doc for what you're looking for?

dsebastien commented 4 years ago

Hello,

Great news! Well you have two choices; either you generate the typings as part of the project (e.g., you could convert it to TypeScript and it would generate those for you, or you could write those and simply include them with the sources and point to the d.ts file within package.json.

Alternatively, you can write the typings and send a PR to the DefinitelyTyped repo on github: https://github.com/DefinitelyTyped/DefinitelyTyped.

Here's an example of what it could look like: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/angular-file-saver/index.d.ts

Thus a namespace definition, in which you'd declare the exported functions:

declare module 'node-quill-converter' {
  function convertTextToDelta(text:string): Delta;
  function convertHtmlToDelta(htmlString: string): Delta;
  function convertDeltaToHtml(delta: Delta): string;

}

Or something like that.. ;-)

Note that the best (but not easiest) option is to convert the project to TypeScript, given how small it is.

HTH!

giovannipds commented 2 years ago

Important to check how this package is done, if you have access to Quill, it's possible that you don't need this package. https://github.com/quilljs/quill/issues/1551