fix: don't shift output when a dependency resolves to a .ts file - #502
Merged
Conversation
A dependency that resolution lands on a `.ts` file for (ex. `type-detect`, which ships an `index.ts` and declares no `types`) enters the program as a source file. That moved TypeScript's inferred common source directory from `<outDir>/src` up to `<outDir>`, so every emitted file gained an extra `src` segment while the package.json paths did not, leaving them dangling. Pin `rootDir` to the sources, and ignore diagnostics from node_modules since `skipLibCheck` only covers a dependency's `.d.ts` files. Closes denoland#460
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.
When a dependency's resolution lands on a
.tsfile, TypeScript pulls it into the program as a source file rather than a declaration file. That moved the inferred common source directory from<outDir>/srcup to<outDir>, so every emitted file gained an extrasrcsegment while the package.json paths — built from the transform's entry point paths — did not:{ "module": "./esm/mod.js" } // points at nothingPinning
rootDirto the sources keeps the output where the package.json says it is, and stops the dependency being emitted into the package.Type checking hit the same file for the second half of the problem —
skipLibCheckonly covers a dependency's.d.tsfiles, so a dependency shipping.tsreported its own errors against the package author (14 of them fortype-detect, ex.Cannot find name 'window'). Its code is no more the author's problem than a.d.tswould be, so diagnostics from node_modules are ignored the same way.The regression test uses
type-detect@^4.1.0, which has notypes/typingsentry and shipsindex.js,index.d.tsandindex.ts. Nothing is specific to that package — any dependency shipping a.tsfile that resolution lands on does it. The test fails on both counts without the fix.Closes #460