fix: support namespace imports in @renders validation#25
Merged
HorusGoul merged 2 commits intoMay 2, 2026
Merged
Conversation
Previously, components accessed through namespace imports (e.g., `import * as Nav from './barrel'; <Nav.Sidebar>...`) were not validated by @renders annotations. This happened because: 1. `getExternalPropAnnotations` used `typeChecker.resolveName` with dotted names like "Nav.Sidebar", but `resolveName` only handles simple identifiers. 2. `collectImports` didn't enumerate namespace import members, so the render chain map missed entries like "Nav.NavItems". 3. `valid-renders-jsdoc` short-circuited on dotted names by only checking if the base namespace was imported, missing typos in member names. Changes: - `getExternalPropAnnotations`: split dotted names on ".", resolve base with `resolveName`, then traverse member properties (same pattern already used by `getComponentTypeId`). - `collectImports`: enumerate exported members of namespace imports as "NS.Member" entries, enabling render chain resolution. - `buildResolvedRenderMap`: handle dotted local names when resolving imported symbols for target type IDs. - `valid-renders-jsdoc`: for dotted names, use `getComponentTypeId` (which does full member resolution) instead of just checking the base name exists. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
This was AI assisted, tbh I'm not 100% sure of the quality. |
Merged
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
Components accessed through namespace imports (
import * as Nav from './barrel') were not validated by@rendersannotations. For example:Similarly,
valid-renders-jsdocdidn't catch typos in namespace member references:Root Cause
Three separate issues:
getExternalPropAnnotationsusedtypeChecker.resolveName()with dotted names like"Nav.Sidebar", butresolveNameonly handles simple identifiers → returnednull→ no validation.collectImportsdidn't enumerate namespace import members, so the render chain map missed entries like"Nav.NavItems"→ chain resolution failed.valid-renders-jsdoc(isComponentAvailable) short-circuited on dotted names by only checking if the base namespace was imported → typos in member names went undetected.Fix
getExternalPropAnnotations: Split dotted names on".", resolve base withresolveName, then traverse member properties (same pattern already used bygetComponentTypeId).collectImports: Enumerate exported members of namespace imports as"NS.Member"entries.buildResolvedRenderMap: Handle dotted local names when resolving imported symbols for target type IDs.valid-renders-jsdoc: For dotted names, usegetComponentTypeId(full member resolution) instead of just checking the base name.Tests
Added 6 new test cases:
namespace-barrel.ts(re-exports viaexport * from)All 428 tests pass (422 existing + 6 new).