-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rename *.d.ts to *.d.mts #17252
Rename *.d.ts to *.d.mts #17252
Conversation
The change itself looks good, but why didn't the typing tests catch this before when we did the change to JavaScript modules? I would assume that |
I have added a test. Is it acceptable that the test depends on |
Now the test depends on |
This comment was marked as resolved.
This comment was marked as resolved.
Yes, that should be correct because of the comment below it: type checking happens at compile time, not at run time, so the file itself is not actually run and therefore the exception is not actually thrown. I have verified that the test do fail correctly if the type annotations are wrong, with the following diff: diff --git a/test/types/legacy.ts b/test/types/legacy.ts
index 5a09b683d..7ed6b5805 100644
--- a/test/types/legacy.ts
+++ b/test/types/legacy.ts
@@ -2,7 +2,7 @@ import { getDocument } from "pdfjs-dist/legacy/build/pdf.mjs";
import { EventBus } from "pdfjs-dist/legacy/web/pdf_viewer.mjs";
class MainTest {
- eventBus: EventBus;
+ eventBus: boolean;
task: ReturnType<typeof getDocument> | undefined;
constructor(public file: string) {
diff --git a/test/types/modern.ts b/test/types/modern.ts
index 06b892c91..c0720902f 100644
--- a/test/types/modern.ts
+++ b/test/types/modern.ts
@@ -2,7 +2,7 @@ import { getDocument } from "pdfjs-dist";
import { EventBus } from "pdfjs-dist/web/pdf_viewer.mjs";
class MainTest {
- eventBus: EventBus;
+ eventBus: number;
task: ReturnType<typeof getDocument> | undefined;
constructor(public file: string) { This results in the follow output with a non-zero exit code:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, but please squash the commits before we can merge it. Thank you for fixing this and improving the tests!
Thanks! |
Rename
*.d.ts
to*.d.mts
. Close #17241TypeScript doesn't look up
*.d.ts
files from*.mjs
. It only looks up*.d.mts
files.See
Notice that TypeScript can find
types/src/pdf.d.ts
even though it has the.d.ts
extension because"types": "types/src/pdf.d.ts"
is set inpackage.json
.