chore(ts): finish the TypeScript migration#54
Merged
Merged
Conversation
Final pass: every `.js` / `.jsx` under `resources/scripts/` is now TypeScript (except none — they're all migrated). ## Files | File | Notes | |---|---| | `admin-chat.tsx` (from `.jsx`) | Entry point — DOM-mount the App. No type changes needed beyond the rename. | | `admin-settings.tsx` (from `.jsx`) | Entry point — mounts 4 dataview roots. | | `skill-editor.tsx` (from `.jsx`) | Adds `SkillMeta` + `SkillModelProvider` shapes; casts at the `SelectControl` `options` boundary (`TranslatableText` branding) and at `registerPlugin` (`icon` is typed required since 6.7 but runtime accepts plugins without one). | | `app.tsx` (from `.jsx`) | Typed CustomEvent dispatch handler. | | `editor/block-toolbar-actions.tsx` (from `.jsx`) | Typed `BlockEditProps` shape passed through the HOC; `VoiceLang` for the translate-target enumeration. | | `editor/write-at-cursor.ts` (from `.jsx`) | No JSX in the file — `.ts` works. Typed Event-target narrowing in `isInsideEditorCanvas`; uses a one-off iframe brand for the attach-once flag. | | `editor/diff.ts` (from `.js`) | Exports `DiffSegmentType`, `DiffSegment`, `ModifiedLine`, `DiffRow`. `ToolCallFallback.tsx` can drop its inline shape interface in a follow-up. | | `editor/__tests__/diff.test.ts` (from `.js`) | Same tests; `@types/jest` added so `describe` / `test` / `expect` resolve. Inline segment literals use the `DiffSegment` array type so the discriminated union is satisfied. | ## Sundry - **`types/css.d.ts`** — new ambient declaration so `import "./foo.css"` side-effect imports in the entry files resolve. Lives in its own file (not the existing `globals.d.ts`) so it's loaded as a global script. - **`@types/wordpress__editor` + `@types/wordpress__plugins`** added — used by `skill-editor.tsx`'s `PluginDocumentSettingPanel` + `registerPlugin`. - **`@types/jest`** added — used by the migrated test file. Listed in `tsconfig.json` `compilerOptions.types`. - **`webpack.config.js`** entry paths updated from `.jsx` to `.tsx`. - **Real bug surfaced in the migration**: `UndoContext.UndoableAction.auditId` was typed `string` but the audit-log row id is always `number` (matches `Storage\AuditLog` `id` column). Production code passes a number from `use-runtime-adapter.ts`; `app.tsx` -> `assistant-modal` -> `UndoContext` pipe types now agree. `pending` and `error` also widened to optional / nullable to match the runtime adapter's writes. ## Verification - `npm run typecheck` — clean - `npm run lint:js` — 0 warnings, 0 errors - `npm run build` — succeeds - `npm run test:unit` — 17/17 pass Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…tor install CI's npm ci was failing with 'Missing: date-fns@4.4.0 from lock file' — the lock that landed with the .ts migration commit had a transitive inconsistency where the new @types/wordpress__editor pulled in @wordpress/media-utils which had been resolved against a different date-fns minor version than what was pinned. A clean regen settled everything to consistent versions; `npm ci` now passes locally. No code change, just the lock file. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…rations instead The @types/wordpress__editor + @types/wordpress__plugins packages I added in the previous commit pull in @wordpress/media-utils and @wordpress/components@33 as peer trees that resolve transitive deps (date-fns specifically) to different versions on CI's npm vs local — which breaks 'npm ci' with 'Missing: date-fns@4.4.0 from lock file' even after lock regen. Webpack externalises @wordpress/editor + @wordpress/plugins + @wordpress/block-editor from window.wp.* at runtime anyway, so we only need just-enough types to compile. Added resources/scripts/types/ wp-editor.d.ts with narrow ambient declarations for the three symbols skill-editor / block-toolbar-actions actually use: - PluginDocumentSettingPanel (children + name + title) - registerPlugin (icon optional, runtime-truth) - BlockControls (group + children) skill-editor.tsx is back to plain imports; the SelectControl 'as never' options cast still handles the TranslatableText branding without the @types peer trees being involved. Verified: typecheck clean, lint clean, build succeeds, tests pass, 'npm ci' succeeds locally. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Mirrors the root generogrowth repo's existing supply-chain setting: 'npm install' (and on CI 'npm ci') will refuse package versions published in the last 7 days. Both: - Defends against rapid-publish supply-chain attacks (typosquats, compromised credentials, malicious post-install scripts). - Keeps lock-file resolutions stable between this dev machine (where ~/.npmrc already sets a min-release-age) and CI runners (which were previously resolving '^4.x' on @wordpress/components' date-fns peer to whatever shipped yesterday, then complaining 'Missing: date-fns@4.4.0 from lock file' against a lock that pinned the older release). Requires npm >=11.10; silently ignored by older npm so safe to commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Previous .npmrc / workflow-bump attempts didn't resolve the CI vs local resolution mismatch. `@wordpress/components` declares `date-fns: ^4.x` which local npm 11.14 (with min-release-age) resolves to 4.3.0 while CI npm 10.x resolves to whatever shipped last (4.4.0 currently). The lock mismatch trips 'npm ci'. Adding 'date-fns: 4.3.0' to package.json's 'overrides' forces every transitive consumer to the same version regardless of how the host npm resolves `^4.x`, so the committed lock is portable. Reverts the .npmrc + workflow npm-bump from the prior commits — no longer needed. 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.
Final pass on the TS migration (#41 epilogue). After this, every
.js/.jsxunderresources/scripts/is TypeScript.Files
admin-chat.tsx(from.jsx)admin-settings.tsx(from.jsx)app.tsx(from.jsx)CustomEvent<{ uuid?: string }>for the cross-page resume handler.skill-editor.tsx(from.jsx)SkillMeta+SkillModelProvidershapes; casts at theSelectControloptionsboundary (theTranslatableTextbranding rejects bare strings) and atregisterPlugin(iconis typed required since 6.7 but the runtime still accepts plugins without one).editor/block-toolbar-actions.tsx(from.jsx)BlockEditPropsshape passed through the HOC;VoiceLangfor the translate-target enumeration.editor/write-at-cursor.ts(from.jsx).ts. Typed Event-target narrowing inisInsideEditorCanvas; one-off iframe brand for the attach-once flag.editor/diff.ts(from.js)DiffSegmentType,DiffSegment,ModifiedLine,DiffRow.ToolCallFallback.tsxcan drop its inline shape interface in a follow-up.editor/__tests__/diff.test.ts(from.js)@types/jestadded sodescribe/test/expectresolve. Inline segment literals useDiffSegment[]so the discriminated union is satisfied.Sundry
types/css.d.ts— new ambient declaration soimport "./foo.css"side-effect imports in entry files resolve. Lives in its own file (not the existingglobals.d.ts) so it's loaded as a global script.@types/wordpress__editor+@types/wordpress__pluginsadded — used byskill-editor.tsx'sPluginDocumentSettingPanel+registerPlugin.@types/jestadded — used by the migrated test file. Listed intsconfig.jsoncompilerOptions.types.webpack.config.jsentry paths updated from.jsxto.tsx.Real bug surfaced by the migration
UndoContext.UndoableAction.auditIdwas typedstringbut the audit-log row id is alwaysnumber(matchesStorage\AuditLog.id). Production code already passed a number fromuse-runtime-adapter.ts; the modal'sonUndoprop andUndoContexttype signatures now agree end-to-end.pendinganderroralso widened to optional / nullable to match the runtime adapter's writes.Verification
npm run typecheck— cleannpm run lint:js— 0 warnings, 0 errorsnpm run build— succeedsnpm run test:unit— 17/17 pass🤖 Generated with Claude Code