Repository navigation
Plugins: Convert the tests to TypeScript - #85088
R1shabh-Gupta wants to merge 2 commits into
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
| { "path": "../compose/tsconfig.build.json" }, | ||
| { "path": "../deprecated/tsconfig.build.json" }, | ||
| { "path": "../element/tsconfig.build.json" }, | ||
| { "path": "../hooks" }, |
There was a problem hiding this comment.
hooks was split in #85141, so after rebasing this must be ../hooks/tsconfig.build.json; ../hooks is now its noEmit dev project, which a project reference cannot point at. The rebase conflict lands in tsconfig.json, so this line is easy to miss.
| const ComponentSpy = vi.fn( ( { content } ) => { | ||
| return `plugin: ${ content }.`; | ||
| } ); | ||
| const ComponentSpy: ComponentType< { content: string } > = vi.fn( |
There was a problem hiding this comment.
Typing the parameter, as TestComponent does above, is shorter and keeps the mock type. The ComponentType import can then go:
const ComponentSpy = vi.fn( ( { content }: { content: string } ) => {
return `plugin: ${ content }.`;
} );
What?
Part of #67691.
Converts the two JavaScript tests in
@wordpress/plugins,src/api/test/index.jsandsrc/components/test/plugin-area.jsdom.test.jsx, to TypeScript.Why?
The package source is already TypeScript, but its tests were still JavaScript and not type checked. This is the
pluginsitem under Tests in the tracking issue.How?
Splits the package's single
tsconfig.jsoninto a build project (tsconfig.build.json) and a dev project (tsconfig.json). Consumers and the roottsconfig.build.jsonnow reference the build project, and the stale ESLint suppressions for the old paths are removed.Test changes, all type-only:
render, an object scope), so each of those arguments gets a narrow@ts-expect-error.TestComponentgets a{ content: string }props type.ComponentSpyis annotated asComponentType< { content: string } >.Testing Instructions
npm run test:unit:vitest -- packages/plugins: all 16 tests pass.npm run typecheck,npm run lint:tsconfig,npm run lint:jsandnpm run buildpass.Use of AI Tools
This PR was developed with the assistance of Claude Code.
@coderabbitai review