Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve TypeScript Compatibility #994

Open
eggsy opened this issue Sep 21, 2023 · 3 comments
Open

Improve TypeScript Compatibility #994

eggsy opened this issue Sep 21, 2023 · 3 comments

Comments

@eggsy
Copy link

eggsy commented Sep 21, 2023

Hey!

Great library, I love how it handles the placement and all, it's shame using the autoTable(doc, { ... }) doesn't return the finalY anyhow. It's easy to use applyPlugin it's not really great to see all those TypeScript errors we get. I searched the docs and issues and seems like nobody yet has found a solution yet, so here I am posting my 100% TypeScript solution:

  1. Create a declaration file somewhere (for my Vue + Vite project, I got a shims.d.ts file already).
  2. Put the following code in it:
import type { Table, UserOptions } from 'jspdf-autotable'

declare module 'jspdf' {
  interface jsPDF {
    lastAutoTable: Table
    autoTable: (options: UserOptions) => void
  }
}
  1. Make sure to include it in your tsconfig.json file's include field.

And voila 🎉, you got your types ready!

image
@eggsy
Copy link
Author

eggsy commented Sep 22, 2023

This could be implemented directly into the library so other users won't experience the same problem 💪. I will see what I can do when I have free time!

@mmghv
Copy link
Collaborator

mmghv commented Sep 30, 2023

In v4 we will remove doc.autoTable({ ... }) in favor of autoTable(doc, { ... }) which will return Table with finalY property and other table info.

@mmghv mmghv added v4 and removed help wanted labels Sep 30, 2023
@eggsy
Copy link
Author

eggsy commented Sep 30, 2023

Good to know! Thanks 🙏

@mmghv mmghv self-assigned this Oct 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants