jsPDF-AutoTable icon indicating copy to clipboard operation
jsPDF-AutoTable copied to clipboard

TypeScript declaration file mismatch

Open scottpageindysoft opened this issue 2 years ago • 2 comments

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/[email protected][email protected]/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.

scottpageindysoft avatar May 05 '23 01:05 scottpageindysoft

Could it be fixed in the latest version?

simonbengtsson avatar May 20 '23 22:05 simonbengtsson

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;
}

thierschi avatar Jun 14 '23 22:06 thierschi