This commit is contained in:
2026-06-08 13:26:57 +02:00
parent be60be5b03
commit 141762041b
2444 changed files with 1179392 additions and 15 deletions

23
test/types/legacy.ts Normal file
View File

@@ -0,0 +1,23 @@
import { getDocument } from "pdfjs-dist/legacy/build/pdf.mjs";
import { EventBus } from "pdfjs-dist/legacy/web/pdf_viewer.mjs";
class MainTest {
eventBus: EventBus;
task: ReturnType<typeof getDocument> | undefined;
constructor(public file: string) {
this.eventBus = new EventBus();
}
loadPdf() {
this.task = getDocument({ url: "file://" + this.file });
return this.task.promise;
}
}
// This is actually never called, as the test only consists in compiling the file.
// The compilation will crawl through all files and make sure that the types are consistent.
const mt = new MainTest("../pdfs/basicapi.pdf");
mt.loadPdf().then(() => {
console.log("loaded");
});

23
test/types/modern.ts Normal file
View File

@@ -0,0 +1,23 @@
import { getDocument } from "pdfjs-dist";
import { EventBus } from "pdfjs-dist/web/pdf_viewer.mjs";
class MainTest {
eventBus: EventBus;
task: ReturnType<typeof getDocument> | undefined;
constructor(public file: string) {
this.eventBus = new EventBus();
}
loadPdf() {
this.task = getDocument({ url: "file://" + this.file });
return this.task.promise;
}
}
// This is actually never called, as the test only consists in compiling the file.
// The compilation will crawl through all files and make sure that the types are consistent.
const mt = new MainTest("../pdfs/basicapi.pdf");
mt.loadPdf().then(() => {
console.log("loaded");
});

6
test/types/package.json Normal file
View File

@@ -0,0 +1,6 @@
{
"type": "module",
"dependencies": {
"pdfjs-dist": "../../build/typestest/"
}
}

20
test/types/tsconfig.json Normal file
View File

@@ -0,0 +1,20 @@
{
"compilerOptions": {
"outDir": "../../build/tmp",
"sourceMap": true,
"declaration": false,
"moduleResolution": "bundler",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "ESNext",
"module": "ESNext",
"strict": true,
"types": [],
"lib": ["ESNext", "DOM"],
"paths": {
"pdfjs-dist": ["../../build/typestest"],
"pdfjs-dist/*": ["../../build/typestest/*"]
}
},
"exclude": ["node_modules"]
}