Repository navigation
fix(modulespecifiers): do not take lib.d.ts as the main file of "types": "lib/" - #1103
Merged
camc314 merged 2 commits intoNov 26, 2026
Merged
Conversation
β¦s": "lib/"
Declaration emit named a type from `lib.d.ts` with the package name when
`types` ends with `/`:
```
// node_modules/pkg/package.json: { "name": "pkg", "types": "lib/" }
// node_modules/pkg/lib.d.ts: export interface L { x: number }
// node_modules/pkg/lib/index.d.ts: export {};
tsgo: export declare const v: import("pkg/lib").L;
tsrs: export declare const v: import("pkg").L; (this resolves to lib/index.d.ts, which has no L)
```
Go `isPackageMainFile` (`modulespecifiers/specifiers.go:984`) treats a
`main`, `types`, or `typings` value that ends with `/` as a directory, so
only its index file can be the main file. tsrs removed the `/` and compared
the file stems, so `lib` matched `lib.d.ts`. Port the `mainIsDirectory`
check.
Tests: `package_main_directory_stem_match` in `tsrs_cli`.
AI assistance: written with Claude Code.
Contributor
Merging this PR will not alter performanceWarning oxc-project has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 8, 2026 to keep using CodSpeed. 1 warning
Comparing Footnotes
|
camc314
approved these changes
Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Declaration emit named a type from
lib.d.tswith the package name whentypesends with/:Go
isPackageMainFiletreats amain,types, ortypingsvalue that ends with/as a directory, so only its index file can be the main file. tsrs removed the/and compared the file stems, solibmatchedlib.d.ts. This PR ports themainIsDirectorycheck.Tests:
package_main_directory_stem_matchintsrs_cli.AI assistance: written with Claude Code.