Rename *.d.ts to *.d.mts. Close #17241
Add a type test for legacy. - https://www.typescriptlang.org/docs/handbook/modules/reference.html#file-extension-substitution
This commit is contained in:
parent
1b88aad0db
commit
61ed77cfb4
1
external/dist/legacy/web/pdf_viewer.d.mts
vendored
Normal file
1
external/dist/legacy/web/pdf_viewer.d.mts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from "../../types/web/pdf_viewer.component.js";
|
1
external/dist/legacy/web/pdf_viewer.d.ts
vendored
1
external/dist/legacy/web/pdf_viewer.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export * from "../../types/web/pdf_viewer.component";
|
|
1
external/dist/web/pdf_viewer.d.mts
vendored
Normal file
1
external/dist/web/pdf_viewer.d.mts
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
export * from "../types/web/pdf_viewer.component.js";
|
1
external/dist/web/pdf_viewer.d.ts
vendored
1
external/dist/web/pdf_viewer.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
export * from "../types/web/pdf_viewer.component";
|
|
10
gulpfile.mjs
10
gulpfile.mjs
@ -1846,11 +1846,11 @@ gulp.task(
|
|||||||
return merge([
|
return merge([
|
||||||
packageJson().pipe(gulp.dest(TYPESTEST_DIR)),
|
packageJson().pipe(gulp.dest(TYPESTEST_DIR)),
|
||||||
gulp
|
gulp
|
||||||
.src([
|
.src("external/dist/**/*", {
|
||||||
GENERIC_DIR + "build/pdf.mjs",
|
base: "external/dist",
|
||||||
GENERIC_DIR + "build/pdf.worker.mjs",
|
removeBOM: false,
|
||||||
])
|
})
|
||||||
.pipe(gulp.dest(TYPESTEST_DIR + "build/")),
|
.pipe(gulp.dest(TYPESTEST_DIR)),
|
||||||
gulp
|
gulp
|
||||||
.src(TYPES_DIR + "**/*", { base: TYPES_DIR })
|
.src(TYPES_DIR + "**/*", { base: TYPES_DIR })
|
||||||
.pipe(gulp.dest(TYPESTEST_DIR + "types/")),
|
.pipe(gulp.dest(TYPESTEST_DIR + "types/")),
|
||||||
|
23
test/types/legacy.ts
Normal file
23
test/types/legacy.ts
Normal 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("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");
|
||||||
|
});
|
@ -1,5 +1,5 @@
|
|||||||
import { getDocument } from "pdfjs-dist";
|
import { getDocument } from "pdfjs-dist";
|
||||||
import { EventBus } from "pdfjs-dist/web/pdf_viewer.component";
|
import { EventBus } from "pdfjs-dist/web/pdf_viewer.mjs";
|
||||||
|
|
||||||
class MainTest {
|
class MainTest {
|
||||||
eventBus: EventBus;
|
eventBus: EventBus;
|
6
test/types/package.json
Normal file
6
test/types/package.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"type": "module",
|
||||||
|
"dependencies": {
|
||||||
|
"pdfjs-dist": "../../build/typestest/"
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,7 @@
|
|||||||
"outDir": "../../build/tmp",
|
"outDir": "../../build/tmp",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"declaration": false,
|
"declaration": false,
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node10",
|
||||||
"emitDecoratorMetadata": true,
|
"emitDecoratorMetadata": true,
|
||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
@ -17,10 +17,10 @@
|
|||||||
],
|
],
|
||||||
"paths": {
|
"paths": {
|
||||||
"pdfjs-dist": ["../../build/typestest"],
|
"pdfjs-dist": ["../../build/typestest"],
|
||||||
"pdfjs-dist/*": ["../../build/typestest/types/*"]
|
"pdfjs-dist/*": ["../../build/typestest/*"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"files": [
|
"exclude": [
|
||||||
"main.ts"
|
"node_modules"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user