heavysixer / node-pptx

Generate PPTX files on the server-side with JavaScript.
MIT License
159 stars 44 forks source link

TypeScript definitions? #117

Closed ezBeanie closed 1 year ago

ezBeanie commented 1 year ago

Is there any way to use this library in typescript?

JClackett commented 1 year ago

Doesn't look like it unfortunately, no @types/node-pptx either, so probably have to manually declare types in own project

ezBeanie commented 1 year ago

Thanks! Sadly i have never written my own types as of yet, but i think i will try to do so. Do you know any ressource or tutorial which i could follow? Thanks for the answer!

JClackett commented 1 year ago

Am working on this:

declare module "nodejs-pptx" {
  declare interface Slide {
    addSlide(options?: any): Slide;
  }
  export class Composer {
    public load(path: string): Promise<Slide>
    public compose: (callback: (pres: Slide) => Promise<void>) => Promise<void>;
    public addSlide(): Slide
    public save(path: string): Promise<void>
  }
}

Im going to just add types for the methods that I need but you can follow a similar format, also literally just started so haven't tested anything yet but you get the idea!

Just create a file called nodejs-pptx.d.ts somewhere in your project, I typically do src/types/nodejs-pptx.d.ts

ezBeanie commented 1 year ago

Wow, thanks! This is more than enough for me to continue!