Repository navigation
fix: annotate props with named react type imports - #131
Merged
Merged
Conversation
`import type React from 'react'` fixed the declarations of each component's
own file, but a component aggregated with `Object.assign` re-emits its
members' annotations textually, so `Tabs.d.ts` names `React` without
importing it. Six aggregates still leaked a bare `React.` into `dist`.
Importing each type by name makes the emitter write `import("react").X`
everywhere, which no local binding has to exist for. Only the value uses of
the namespace (`React.useState` and friends) keep `import * as React`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
🎉 This PR is included in version 6.19.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
#130 was incomplete. It gave every component file that names
Reactin a prop annotation its ownimport type React from 'react', which fixed that file's own declaration — but a component assembled withObject.assignre-emits its members' annotations textually into its own.d.ts, without carrying their imports. Sodist/components/Tabs/Tabs.d.tsstill read:with no
Reactin scope. Six aggregates were left that way after 6.19.1:Tabs,Select,Sheet,Table,HoverCardandDropdownMenu.The fix
Import each type by name instead of reaching through the namespace. The declaration emitter then writes
import("react").ComponentProps<...>, which is self-contained and needs no local binding to survive being re-emitted anywhere:94 files. The namespace import stays only where
Reactis used as a value —React.useState,React.useRef,React.useEffectinComboBoxandFieldGroupDescription— since those never reach a declaration.This also makes the class of bug structurally impossible rather than fixed case by case: the next
Object.assignaggregate cannot reintroduce it.Why it matters downstream
A consumer without
@types/reacthas noReactUMD global, so the unresolved name silently degrades every prop on these six components toany(skipLibCheckhides the error in the declaration itself). In Open Data Capture that surfaced as 18TS7006errors across 7 files on 6.19.1.Verification
distdeclarations naming a bareReact.: 6 → 0pnpm lintclean,pnpm buildclean, 226/226 tests passtsc --noEmitinapps/webgoes from 18TS7006errors to 0🤖 Generated with Claude Code