fix: don't lint private-type-ref for pure type alias re-exports#816
Open
crowlbot wants to merge 1 commit into
Open
fix: don't lint private-type-ref for pure type alias re-exports#816crowlbot wants to merge 1 commit into
crowlbot wants to merge 1 commit into
Conversation
A type alias whose body is just another type reference (e.g. `export type A = B`) is effectively another name for the referenced type, re-exposing it through the alias. Treat such a reference as a re-export rather than a reference to a private type, so it no longer triggers a spurious `private-type-ref` lint diagnostic. The referenced type is still included in the generated documentation.
|
|
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.
Problem
deno doc --lintreports a spuriousprivate-type-refdiagnostic for a typealias that simply re-names another type:
A type alias whose body is just another type reference (
export type A = B) iseffectively another name for the referenced type —
Bis re-exposed through thealias and should be considered part of the public API, not a private type leaked
into it.
Fix
When collecting the dependencies of an exported symbol, detect declarations that
are pure type aliases — a
type X = Ywhose body is a bareTsTypeRefwith notype arguments — and flag their references as alias re-exports
(
SymbolDeclDeps::is_alias_reexport). The diagnostics collector then skipsemitting
private-type-reffor those references.The referenced type is still included in the generated documentation (it remains
a non-exported public type), so only the spurious lint diagnostic is suppressed.
Tests
tests/specs/private_type_via_type_alias.txtpins the reproductionfrom the issue: no diagnostic, with the referenced interface still documented.
tests/specs/reexport_deep.txt, which exercises the sameexport type A = Bpattern across re-exported modules — itsprivate-type-refdiagnostics are now correctly suppressed (the deep re-export resolution it
primarily tests is unchanged).
Fixes #429