Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Typescript Types missing in the npm package #27

Open
bpasham opened this issue Oct 13, 2019 · 3 comments
Open

Typescript Types missing in the npm package #27

bpasham opened this issue Oct 13, 2019 · 3 comments

Comments

@bpasham
Copy link

bpasham commented Oct 13, 2019

Seems like types are well created but doesn't seem to be included in the npm package. Including them will help a lot of folks who are struggling to use this package in Typescript projects.

Also Thank you for all the hard work you put into this project.

@HackbrettXXX
Copy link
Member

You are right. We also should update the types first, since they were merged/copied from upstream and are missing some methods from this fork.

@Danebrouwer97
Copy link

Danebrouwer97 commented Dec 20, 2019

How do I get and use the typings file? I see they exist, but if I try copy+paste the code over into an index.d.ts file, TS just complains that it is not a module.

File '.../jspdf-yworks/index.d.ts' is not a module.

Edit: Found the solution.
Change:

declare module 'jspdf' {
    // ... Interfaces ...
    class jsPDF { ... }
    namespace jsPDF { }

    export = jsPDF;
}

To:

declare namespace jsPDF {
    // ... Interfaces ...
    class jsPDF { ... }
}
export = jsPDF;

Update:
This solves any issues thrown by typescript, but fails in actual use. Likely because it's no longer a module that exports an actual class. I know nothing of creating Typings files, and only have a basic knowledge of producing typesafed code, so this is honestly all trial and error.

TypeError: jspdf_yworks__WEBPACK_IMPORTED_MODULE_5__.jsPDF is not a constructor

@HackbrettXXX
Copy link
Member

Great you found the solution. A release where the types are included in the npm package is already in the pipeline.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants