Make typescript an optional peer dependency - #224
Open
veksa wants to merge 1 commit into
Open
Conversation
veksa
force-pushed
the
typescript-optional-peer
branch
from
August 14, 2026 08:59
c672b23 to
63cb128
Compare
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.
dependency-tree pins typescript in dependencies, which breaks dedup: anyone whose TypeScript falls outside ^6.0.3 gets an extra copy of the compiler nested inside node_modules/dependency-tree. On a project with typescript@5.9.3 that's 114 MB → 91 MB.
typescript is only needed here to pre-parse a tsConfig given as a path, and it is already required lazily, so the peer is marked optional. The require goes through a loadTypeScript() helper that reports a missing peer dependency, or one that no longer carries the config-parsing API, instead of failing on an undefined property. That matters for typescript@7, which is already the latest tag and is a rewrite without readJsonConfigFile or parseJsonSourceFileConfigFileContent. No version is inspected anywhere; the range in package.json matches what detective-typescript and detective-vue2 already declare.
One related fix in index.js: getDependencies() swallows everything precinct throws and returns an empty list, which is right for a file that fails to parse but wrong for a missing peer dependency — that silently produced an empty tree instead of an error. Errors tagged ERR_TYPESCRIPT_UNAVAILABLE are now rethrown. Unrelated parse failures behave exactly as before, and there's a test pinning that down.