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

TypeScript declaration file mismatch #964

Open
scottpageindysoft opened this issue May 5, 2023 · 2 comments
Open

TypeScript declaration file mismatch #964

scottpageindysoft opened this issue May 5, 2023 · 2 comments

Comments

@scottpageindysoft
Copy link

I'm not sure how to describe this better than TypeScript 5.0.4 can.

Here's the warning I get when I import 'jspdf-autotable' in a React tsx component.

Could not find a declaration file for module 'jspdf-autotable'. 'C:/Users/scott/Documents/projects/indysoftweb/IndySoftWebAPI/ClientApp/node_modules/.pnpm/registry.npmjs.org+jspdf-autotable@3.5.28_jspdf@2.5.1/node_modules/jspdf-autotable/dist/jspdf.plugin.autotable.js' implicitly has an 'any' type. There are types at 'c:/Users/scott/Documents/projects/indysoftweb/IndySoftWebAPI/ClientApp/packages/indysoft-react-main-app/node_modules/jspdf-autotable/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'jspdf-autotable' library may need to update its package.json or typings.ts(7016)

This is definitely a typing issue from this package, since we don't have any local declarations for it.

@simonbengtsson
Copy link
Owner

Could it be fixed in the latest version?

@thierschi
Copy link

I also experienced this issue using NodeJS with TypeScript. Somehow the types are inaccessible to TS and VS Code.

The error I'm getting here is autotable [...] is not callable or doc.autoTable is not a function.

The current workaround is this:

import {jsPDF} from 'jspdf';
import 'jspdf-autotable';
import {UserOptions} from 'jspdf-autotable';

interface jsPDFCustom extends jsPDF {
    autoTable: (options: UserOptions) => void;
}

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

4 participants