Skip to content

Fix Typescript errors and clean up TS configs#2685

Open
fredrikekelund wants to merge 16 commits intotrunkfrom
f26d/fix-type-errors
Open

Fix Typescript errors and clean up TS configs#2685
fredrikekelund wants to merge 16 commits intotrunkfrom
f26d/fix-type-errors

Conversation

@fredrikekelund
Copy link
Contributor

@fredrikekelund fredrikekelund commented Mar 2, 2026

Related issues

Fixes STU-1373

Proposed Changes

We currently have a few TS errors in our code. This PR addresses that with the following changes:

  • Add a typecheck npm script.
  • Update AGENTS.md to tell agents to do type checking.
  • Run that script as part of the lint CI job.
  • Removed "*": [ "node_modules/*" ] resolvers in tsconfig.json files. This means it's no longer possible to import any code from node_modules files. Instead, we use regular module resolution to import available modules.
    • This may sound like a big change, but it's really not. I only had to apply a minor edit to a single file (use-update-button-tooltip.ts) to make this work.
  • Install @types/glob and wpcom to prevent TS from complaining.
  • Add a patch to fix the lookup path in yargs for the locales directory, fixing the same issue as Fix Studio CLI yargs locale strings displaying in English #2609.
  • Fix all other type errors

Testing Instructions

CI should pass.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@fredrikekelund fredrikekelund requested a review from a team March 2, 2026 10:41
@fredrikekelund fredrikekelund self-assigned this Mar 2, 2026
@fredrikekelund fredrikekelund marked this pull request as ready for review March 3, 2026 10:46
Comment on lines +9 to +10
- directory: resolve(__dirname, '../../../locales'),
+ directory: resolve(dirname(require.resolve('yargs')), 'locales'),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The __dirname relative path lookup fails because we bundle yargs into apps/cli/dist/cli/main.js. Weirdly, translations still worked for me even without this change (after I reverted https://github.com/Automattic/studio/pull/2609)… In any case, this change produces the correct path.

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Mar 3, 2026

📊 Performance Test Results

Comparing 623c5b4 vs trunk

site-editor

Metric trunk 623c5b4 Diff Change
load 1759.00 ms 1730.00 ms -29.00 ms ⚪ 0.0%

site-startup

Metric trunk 623c5b4 Diff Change
siteCreation 6056.00 ms 6087.00 ms +31.00 ms ⚪ 0.0%
siteStartup 3953.00 ms 3942.00 ms -11.00 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants