heavysixer / node-pptx

Generate PPTX files on the server-side with JavaScript.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeScript definitions?

ezBeanie opened this issue · comments

commented

Is there any way to use this library in typescript?

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

commented

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!

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

commented

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