Skip to content

Bump typescript from 5.9.3 to 6.0.2#2434

Open
dependabot[bot] wants to merge 10 commits intotrunkfrom
dependabot/npm_and_yarn/typescript-6.0.2
Open

Bump typescript from 5.9.3 to 6.0.2#2434
dependabot[bot] wants to merge 10 commits intotrunkfrom
dependabot/npm_and_yarn/typescript-6.0.2

Conversation

@dependabot
Copy link
Copy Markdown
Contributor

@dependabot dependabot bot commented on behalf of github Apr 2, 2026

Bumps typescript from 5.9.3 to 6.0.2.

Release notes

Sourced from typescript's releases.

TypeScript 6.0

For release notes, check out the release announcement blog post.

Downloads are available on:

TypeScript 6.0 Beta

For release notes, check out the release announcement.

Downloads are available on:

Commits

TypeScript Fixes

Changes co-authored with Claude and the following was prepared by Claude as well.

Summary

Fix TypeScript 6 type errors across the codebase. TS6 introduces stricter type checking including: requiring explicit type arguments for generic types (Array, Promise), typing catch clause variables as unknown by default, stricter nullable type narrowing, and built-in Navigation API types.

Approach

Wherever possible, fixes use proper null guards and control flow narrowing instead of type casts, so that the code is genuinely safer at runtime — not just silencing the type checker.

Changes by scope

Embed Optimizer

  • Use truthiness guard for dataset.odXpath instead of type cast
  • Add null check for getElementData() return value

Image Prioritizer

  • Use getAttribute() with truthiness guards instead of hasAttribute() + getAttribute() with type casts

Optimization Detective

  • Wrap Promise constructors with Promise<void> type assertions; use arrow function wrappers for event listener resolve callbacks (TS6 no longer allows passing resolve directly as an EventListener)
  • Use || '' fallback for sessionStorage.getItem() passed to parseInt()
  • Add explicit type arguments to bare Array and Promise generics
  • Add Record types to recursiveFreeze parameter and headers object for proper index signatures
  • Add null guard for Object.assign with Map.get() result
  • Add compressedPayload truthiness check in ternary to avoid Blob cast
  • Cast getElementById result to HTMLElement for textContent access
  • Add string type assertions for getAttribute() where null is excluded by control flow

Performance Lab

  • Validate pluginSlug from dataset with early return guard
  • Use shift() with undefined check instead of type cast for queue processing
  • Use optional chaining for actionButtonList?.appendChild()
  • Wrap event handler in arrow function to resolve MouseEvent/Event type mismatch

View Transitions

  • Remove custom Window.navigation declaration that conflicts with TS6 built-in Navigation API types
  • Add explicit type arguments to bare Array[] JSDoc types
  • Use null guards with optional chaining for navigation activation/URL properties

Build Tools

  • Install @types/lodash for proper type declarations
  • Add @ts-ignore for @wordpress/scripts config modules (no types available)
  • Use instanceof Error checks in catch clauses instead of any casts
  • Add Record<string, string> type for webpack manifest and Compiler type for webpack plugin callback
  • Use import('commander').Command type for CLI command parameter
  • Simplify since.js control flow using direct opt.plugin truthiness check
  • Add type predicate for changelog label filtering

@dependabot dependabot bot added [Type] Enhancement A suggestion for improvement of an existing feature javascript Pull requests that update Javascript code no milestone PRs that do not have a defined milestone for release labels Apr 2, 2026
@mukeshpanchal27
Copy link
Copy Markdown
Member

@dependabot rebase

@dependabot dependabot bot force-pushed the dependabot/npm_and_yarn/typescript-6.0.2 branch from 8e0ad84 to 558c0fc Compare April 2, 2026 04:21
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 2, 2026

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: westonruter <westonruter@git.wordpress.org>
Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Copy Markdown
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

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

npm run tsc failed that need to check and fix.

@westonruter
Copy link
Copy Markdown
Member

I'm putting Claude on this...

@westonruter westonruter force-pushed the dependabot/npm_and_yarn/typescript-6.0.2 branch from 5b1e011 to ef7ddd2 Compare April 2, 2026 17:40
@westonruter westonruter marked this pull request as draft April 2, 2026 17:45
@westonruter westonruter self-assigned this Apr 2, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.33%. Comparing base (58c9063) to head (a622034).

Additional details and impacted files
@@           Coverage Diff           @@
##            trunk    #2434   +/-   ##
=======================================
  Coverage   69.33%   69.33%           
=======================================
  Files          90       90           
  Lines        7749     7749           
=======================================
  Hits         5373     5373           
  Misses       2376     2376           
Flag Coverage Δ
multisite 69.33% <ø> (ø)
single 35.73% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@westonruter westonruter force-pushed the dependabot/npm_and_yarn/typescript-6.0.2 branch from ef7ddd2 to 888df45 Compare April 2, 2026 18:02
Bumps [typescript](https://github.com/microsoft/TypeScript) from 5.9.3 to 6.0.2.
- [Release notes](https://github.com/microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v5.9.3...v6.0.2)

---
updated-dependencies:
- dependency-name: typescript
  dependency-version: 6.0.2
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@westonruter westonruter force-pushed the dependabot/npm_and_yarn/typescript-6.0.2 branch from 888df45 to dc16be6 Compare April 2, 2026 18:18
westonruter and others added 2 commits April 2, 2026 11:22
Use truthiness guard for dataset.odXpath since DOMStringMap values are
always strings when present. Add null check for getElementData() return
value since the function legitimately returns ElementData | null.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use getAttribute() with truthiness guards instead of hasAttribute()
followed by getAttribute() with type casts. This lets TS naturally
narrow the return value to string without explicit assertions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@westonruter westonruter force-pushed the dependabot/npm_and_yarn/typescript-6.0.2 branch 2 times, most recently from e2e2d43 to 9df901a Compare April 2, 2026 18:54
westonruter and others added 5 commits April 2, 2026 12:19
- Wrap Promise constructors with Promise<void> type assertions and use
  arrow function wrappers for event listener resolve callbacks, since
  TS6 no longer allows passing resolve directly as an EventListener
- Use || '' fallback for sessionStorage.getItem() calls passed to
  parseInt(), since TS6 requires string arguments
- Add explicit type arguments to bare Array<any> and Promise<void>
  generic types, which TS6 now requires
- Add Record<string, any> type to recursiveFreeze parameter and
  Record<string, string> to headers object for proper index signatures
- Add null guard for Object.assign with Map.get() result
- Add compressedPayload truthiness check in ternary so TS narrows
  away null without a Blob cast
- Cast getElementById result to HTMLElement for textContent access
- Add string type assertions for getAttribute() return values where
  null is excluded by control flow

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add explicit array type for activationQueue with pluginSlug as string
- Guard against missing pluginSlug in dataset with early return
- Use shift() with undefined check instead of type cast for queue item
- Use optional chaining for actionButtonList.appendChild() null check
- Wrap enqueuePluginActivation in arrow function for addEventListener
  to resolve MouseEvent/Event type mismatch

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove custom Window.navigation declaration from types.ts since TS6
  includes built-in Navigation API types that conflict with it
- Add explicit type arguments to bare Array[] JSDoc types, which TS6
  now requires (Array<Array<any>>)
- Add null guards for navigation activation and URL properties instead
  of string type casts, using optional chaining to let TS narrow
  naturally

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add JSDoc type annotations for implicit any parameters in cli.js,
  logger.js, and webpack.config.js
- Add @ts-ignore for modules without declaration files (lodash,
  @wordpress/scripts configs)
- Cast catch clause error variables to any for property access, since
  TS6 types caught errors as unknown by default
- Add string type assertions for possibly-undefined command options
- Add type predicate and Record casts in changelog.js for label
  filtering and PRIMARY_TYPE_LABELS indexing
- Add Record<string, string> type for webpack manifest object
- Add Compiler type annotation for webpack plugin apply callback

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@westonruter westonruter force-pushed the dependabot/npm_and_yarn/typescript-6.0.2 branch from 9df901a to b47f810 Compare April 2, 2026 19:27
@westonruter westonruter marked this pull request as ready for review April 2, 2026 19:29
@westonruter westonruter requested a review from b1ink0 April 2, 2026 22:16
/**
* @param {string|undefined} label - Label.
* @return {label is string} Whether label starts with type prefix.
*/ ( label ) =>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we move it to separate line?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sure. Done in 8d7718e

westonruter and others added 2 commits April 3, 2026 09:11
Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code no milestone PRs that do not have a defined milestone for release [Type] Enhancement A suggestion for improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants