chore(ts): migrate all components/ to TypeScript#52
Merged
Conversation
…y, skills-cache, ReadAloudController, memory-dataview, conversations-dataview, Composer) Checkpoint within the components/ migration. Adds: - types/globals.d.ts — shared GdsAssistantGlobal interface (extracted from use-runtime-adapter.ts so every module sees the same merged shape and skills-cache + dataviews don't race to redeclare `window.gdsAssistant`) - panel-geometry.ts — pure utilities, typed PanelSize / PanelPosition - skills-cache.ts — typed Skill interface + REST row narrowing - ReadAloudController.tsx — typed ProgressState map - memory-dataview.tsx — wired through Field<MemoryRecord> + View + Operator from @wordpress/dataviews - conversations-dataview.tsx — same dataviews pattern with ConversationRow - Composer.tsx — typed sub-components (SlashAutocomplete, SelectionChip, ComposerAttachment) + handlers `npm run typecheck` clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Continues the components/ pass. Both files use typed local interfaces for the message-part shapes assistant-ui passes through (AnyMessagePart, ToolDiff, BlockChipProps etc.) and cast at the library boundary where the library's type carries internal bookkeeping (status, addResult, resume on the Fallback prop; readonly tuple union on s.content). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Voice dictation + voice-mode (auto-send) component. Adds local VoiceLang shape, narrows the useTtsEnabled / useVoiceMode tuples from the JS hook modules until those migrate too. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add typed AssistantModalProps and PendingApproval interfaces. Type all useState/useRef/useCallback hooks and DOM event handlers. Pure type addition — no behaviour changes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Typed FIELDS as Field<SkillRow>[] and DEFAULT_VIEW as View. Introduced SkillRow / ExportedSkill / EditingSkill interfaces and typed the modal sub-component. Cast schedule value at SelectControl since its literal union doesn't match our string-typed state. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Added ThreadProps interface and TranscriptMessage/Part shapes for the Markdown serializer. Imports PendingApproval from assistant-modal and ConversationSummary from the runtime adapter. Runtime messages narrowed via unknown cast since the thread runtime types its messages as a readonly internal union. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Export typed props for every panel (PanelHeader, SystemContextInput, SkillsList, ConversationList). Type useState/useCallback handlers and the SessionUsageSnapshot subscription. Window globals (models config, defaultMaxTokens) read via local cast rather than augmenting the global type — they're consumed in only two spots. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Added ServerRow / AuthDetail / NoticeState / AuthPayload interfaces and typed both the list view and the add/edit modal. AuthType narrowed to a union; SelectControl onChange casts back to the union since the library types its callback as a generic string. Notice style prop is spread via a cast because @types/wordpress__components omits it (the runtime forwards it to the wrapper div). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Prettier reformatting (import collapsing, paren wrapping) plus jsdoc/require-param additions across the just-migrated .tsx files and a handful of previously-migrated files that share the components folder. Manually stripped the noisy `@param root0.X` blocks the autofix inserted on assistant-modal and SidePanels — the destructured props are already documented through the typed interface. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Follow-up to #41: migrate every remaining
components/*.jsx+ the two.jshelpers to TypeScript. No behaviour change — pure type addition over the existing logic.Files
15 components total. All previously
.jsx/.js; now.tsx/.ts. TheUndoContextsmoke migration from PR #47 was already TS — this PR finishes the rest.panel-geometry.tsPanelSize/PanelPositionexportsskills-cache.tsSkillinterface, narrowed REST row mappingReadAloudController.tsxProgressStatemapmemory-dataview.tsxField<MemoryRecord>[],View,Operatorfrom @wordpress/dataviewsconversations-dataview.tsxConversationRowshapeComposer.tsxToolCallFallback.tsxToolDiff,DiffViewerProps, exportedToolCallFallbackPropsMessages.tsxAnyMessagePart,BlockChipProps, narrowed wp.data block-editor accessMicButton.tsxVoiceLang, narroweduseTtsEnabled/useVoiceModeJS-hook tuplesassistant-modal.tsxPendingApproval(reused by Thread)skills-dataview.tsxThread.tsxPendingApprovalfrom assistant-modalSidePanels.tsxModelsConfig/ModelProvider/ModelOptionforwindow.gdsAssistant.modelsmcp-servers-dataview.tsxAuthTypeliteral union, narrowed Modal/Notice prop boundariestypes/globals.d.tsGdsAssistantGlobalinterface — was previously redeclared piecemeal inuse-runtime-adapter.ts; extracted so every module sees the same merged shapeType-shape decisions
window.gdsAssistantextracted totypes/globals.d.tssoskills-cache, dataviews, anduse-runtime-adapterdon't race to redeclare the same global with incompatible shapes (the original conflict surfaced anunknownintersection that brokeX-WP-Nonceheaders).PendingApprovaldefined once inassistant-modal.tsxwith thetrustableHostfield used by the approval bar —Thread.tsximports it rather than redeclaring.apiFetchcalls returningResponse(whenparse: false) cast at the call site ((await apiFetch({...})) as Response) sinceapiFetchreturnsPromise<unknown>by default.Fallbackslot inMessages.tsxcasts tounknown as never(the library prop type carries internal runtime bookkeeping —status,addResult,resume— we don't read).s.contenttuple union cast toreadonly AnyMessagePart[]inside selectors.useTtsEnabled/useVoiceModetuples narrowed at destructure untiluse-tts.jsitself migrates.What stayed
.jsThe 3 hooks in
resources/scripts/hooks/(use-tts.js,use-voice-input.js,use-editor-selection.js) — out of scope here. Each can migrate independently in a follow-up; the components that consume them already narrow the tuple shape locally.Verification
npm run typecheck— cleannpm run lint:js— 0 errors, 0 warnings (continues PR chore(lint): clear all ESLint warnings across components + TS files #51's clean state)npm run build— succeeds (only pre-existing asset-size warnings)npm run test:unit— 17/17 passCommits
9 commits, individually reviewable:
ead80cd— panel-geometry, skills-cache, ReadAloudController, memory-dataview, conversations-dataview, Composer + globals.d.tsc5d81c4— ToolCallFallback, Messages8163ae5— MicButton56b4e59— assistant-modalce8a400— skills-dataview8f7ec78— Threadb3a6203— SidePanelsabfd99c— mcp-servers-dataview484f5e8—lint:fix:jsautofix sweep across the freshly-migrated files🤖 Generated with Claude Code