Is the a TypeScript type definition available?
See original GitHub issueSomething on the order of "@types/pdf-lib".
If not, as embarrassed as I am to ask, how can I get VS Code to recognize the types in this excellent library?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Documentation - Type Declarations - TypeScript
TypeScript automatically finds type definitions under node_modules/@types , so there's no other step needed to get these types available in your program. Your ......
Read more >Surviving the TypeScript Ecosystem — Part 4 - Medium
The solution is to make a type definition file. A type definition file is a file that ends in “.d.ts”. It is a...
Read more >Typescript Typings: The Complete Guide: @types Compiler ...
What are the multiple types of Typescript Type Definitions? How do I use libraries that don't have Type Definitions available?
Read more >TypeScript: Type Definition Files - DEV Community
All definition files are publicly available and placed in the Definitely Typed project in Github. It includes generated types for most of the ......
Read more >Types and Type Declarations | Manual - Deno
When TypeScript is type checking a file, it only cares about the types for the ... available in the global namespace when importing...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

OK having seen the conversation in #484 as well, I tried downgrading to the [deprecated] deno VSCode extension and it still did not work for me. I was still seeing the
PDFDocument.loadfunction have the type signaturePDFDocument.load(pdf: any, options: any): any.At this point, I was frustrated because I could see from the npm download that it should be working, so I spent too much time digging into this this morning.
Finally, I found a little note at the bottom of this page in Skypack’s (formerly Pika) documentation that you have to add
?dtsat the end of a skypack/pika import to get the TS definitions for deno sent alongside the code. Adding that to the import solved the issue even with the latest, official plugin.TDLR;
import { PDFDocument } from 'https://cdn.skypack.dev/pdf-lib@^1.11.1?dts';worksOpened PR #621 to update Pika to Skypack, update the version to latest, and add the ?dts flag for typing in the README to save future devs having to find this thread.
Hello @reselbob!
The TypeScript types are included in the
pdf-libNPM package. You do not need to install anything additional to get them. VSCode should just pick them up. If it’s not, the only cause I can think of is that you have plugins or configurations preventing it from doing so (e.g. the Deno plugin might cause this - haven’t tested it myself though).