Dev: Auto-clean TypeScript types when switching branches#76217
Dev: Auto-clean TypeScript types when switching branches#76217
Conversation
Automatically detect branch switches via git HEAD and run `npm run clean:package-types` before the TypeScript build. This prevents stale type artifacts from causing compilation errors when moving between branches. The `headTracker` compares the current git HEAD with a saved `.dev-head` marker file. If they differ, TypeScript declarations are cleaned and rebuilt, ensuring type definitions match the current source code. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If 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. |
|
Size Change: 0 B Total Size: 6.87 MB ℹ️ View Unchanged
|
|
Flaky tests detected in 827c3b6. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/22764995941
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
What?
Automatically clean stale TypeScript type artifacts when switching branches during development to prevent compilation errors.
Why?
When switching Git branches, stale TypeScript declaration files (
.d.ts) and incremental build cache (.tsbuildinfo) from the previous branch cause 40+ type errors on the nextnpm start. Users had to manually runnpm run clean:package-typesto recover.How?
Added a
headTrackerutility tobin/dev.mjsthat:npm start.dev-headmarker file from the last buildnpm run clean:package-typesbefore TypeScript compilationThis means:
Testing Instructions
npm installnpm startgit checkout trunknpm startagain