Skip to content

Fix typo #247

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

Merged
merged 1 commit into from
May 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/problems/FallbackCondition.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ This issue commonly occurs in combination with [“Masquerading as CJS”](./Fal
where an `index.d.ts` exists but `index.d.mts` does not. TypeScript first does a resolution pass only looking for types and ignoring JavaScript files, so when resolving with the `import` condition, that first pass goes something like:

1. `"import"` matches, so try substituting the `.mjs` extension for the type-equivalent `.d.mts`. `index.d.mts` does not exist, so **continue** (this is the bug).
2. `"default"` conditions always match, so try substituting the `.js` extension for the type-equivalent `.d.ts`. `index.d.ts` exists, so us that as a resolution result.
2. `"default"` conditions always match, so try substituting the `.js` extension for the type-equivalent `.d.ts`. `index.d.ts` exists, so use that as a resolution result.

But in this example, `index.d.ts` is a CommonJS module since the package.json lacks a `"type": "module"` field, whereas the runtime resolution would have been `index.mjs`, which is an ES module. So, an instance of [“Masquerading as CJS”](./FalseCJS.md) also occurred. If the library adds an `index.d.mts` file to represent the `index.mjs` file, both problems will be solved simultaneously.