Analyze published type dependencies (resolve #1909) - #1912
Open
webpro wants to merge 4 commits into
Open
Conversation
commit: |
This was referenced Jul 27, 2026
Deploying knip with
|
| Latest commit: |
1504998
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://7fdb5b3e.knip.pages.dev |
| Branch Preview URL: | https://issue-1909-exact-type-depend.knip.pages.dev |
webpro
force-pushed
the
issue-1909-exact-type-dependencies
branch
from
July 27, 2026 20:25
c5e52e9 to
08aa075
Compare
# Conflicts: # packages/knip/src/DependencyDeputy.ts
webpro
marked this pull request as ready for review
July 29, 2026 07:00
Contributor
|
Hey, I was planning on giving this a shot, someday! What's up with everybody taking my issues? (jk) Whoooooowhooooo! Thanks Lars! This is🔥 🔥 You've made my day and I just woke up! (Ok I should go so I can get a chance to use it but I just had to show some appreciation here.) |
Member
Author
|
Thanks Eli. That is all much appreciated, and it means a lot coming from a true power user! |
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.
Resolves #1909. Implements the emitted-declaration analysis originally requested in #248.
Type-only imports that end up in a package's emitted declaration files are part of its public API. Consumers resolve them from their own dependency tree, so the referenced packages must be in
dependencies, while strict mode used to expect all type-only imports indevDependencies.Knip now analyzes the published type surface of non-private workspaces. Entry declarations are taken from
types/typings, the declaration next tomain, theindex.d.tsfallback,exports(withtypescondition precedence, wildcard patterns andnullsubpath exclusions) andtypesVersions. The declaration graph is walked from there, including triple-slash references and relative and self-name imports.External packages referenced by this graph count as production usage:
devDependenciesor missing.@types/*counterpart, so the report names the package consumers actually need..tsand.jsspecifiers in emitted declarations resolve to the matching.d.tsvia extension aliases, and the author's tsconfigpathsdo not apply (the source graph still uses them).If declaration output has not been built, Knip does not guess from source imports. The walk is bounded to declarations reachable from the published entry points; on this repository it adds about 35ms.