Installed type
npm install @types/pdfkit
and import
import {PDFDocument } from 'pdfkit';
Module '"pdfkit"' has no exported member 'PDFDocument'.
import PDFDocument from "pdfkit"; works fine
@marcelh-gh
Thank you but
Module '"pdfkit"' has no default export.
tsc --version
Version 2.8.3
I guess it is fine.
import * as PDFDocument from 'pdfkit';
const doc = new PDFDocument;
I am using typescript and generating pdfs without issues. Is your problem still present @shinriyo ?
I use it like that
import PDFDocument = require('pdfkit');
const document = new PDFDocument({
autoFirstPage: false,
size: [156,106],
});
@jlengrand
I'm sorry for the belated reply.
I quit the project which using the tool, I forgot about it...
No worries!
I had this issue:
Module '"pdfkit"' has no default export.
In one of my TS projects, it works fine, in another it failed. Both created the object and called the import identically.
The import looks like this:
import PDFDocument = require('pdfkit');
My usage:
const doc = new PDFDocument;
In the end, I found by adding "esModuleInterop": true to my tsconfig.json file made it work. Hope this helps others
TS version: 3.9.7
Most helpful comment
I guess it is fine.