Skip to content

Fix Typescript errors and clean up TS configs#2685

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

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

Conversation

@fredrikekelund
Copy link
Contributor

@fredrikekelund fredrikekelund commented Mar 2, 2026

Related issues

N/A

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.
  • 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 6892b6b vs trunk

site-editor

Metric trunk 6892b6b Diff Change
load 1773.00 ms 1506.00 ms -267.00 ms 🟢 -15.1%

site-startup

Metric trunk 6892b6b Diff Change
siteCreation 7108.00 ms 7130.00 ms +22.00 ms ⚪ 0.0%
siteStartup 3940.00 ms 3965.00 ms +25.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