Bump typescript from 5.9.3 to 6.0.2#2434
Conversation
|
@dependabot rebase |
8e0ad84 to
558c0fc
Compare
|
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. |
mukeshpanchal27
left a comment
There was a problem hiding this comment.
npm run tsc failed that need to check and fix.
|
I'm putting Claude on this... |
5b1e011 to
ef7ddd2
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ef7ddd2 to
888df45
Compare
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>
888df45 to
dc16be6
Compare
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>
e2e2d43 to
9df901a
Compare
- 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>
9df901a to
b47f810
Compare
Co-authored-by: mukeshpanchal27 <mukesh27@git.wordpress.org>
There was a problem hiding this comment.
Pull request overview
This PR upgrades TypeScript to 6.0.2 and applies repo-wide TS6 compatibility fixes (primarily JSDoc typing, stricter unknown catch handling, and DOM API typing adjustments) across build tooling and multiple plugin scripts.
Changes:
- Bump TypeScript from 5.9.3 to 6.0.2 and add missing type deps (
@types/lodash). - Update JS/TS code to satisfy TS6’s stricter type checking (Promise generics, event listeners, safer DOM access,
unknowncatch, index signatures). - Remove conflicting custom Navigation API typings and adjust view-transitions code to match built-in types.
Reviewed changes
Copilot reviewed 12 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
package.json |
Bumps typescript to ^6.0.2 and adds @types/lodash. |
package-lock.json |
Locks updated TypeScript and new @types/lodash dependency. |
tsconfig.json |
(Context) Repo type-checks JS via checkJs + allowJs (relevant to TS6 fixes). |
webpack.config.js |
Adds TS ignore for untyped WP scripts config and types webpack compiler param in plugin. |
tools/webpack/utils.js |
Adds explicit Record<string,string> typing for the build manifest object. |
tools/e2e/playwright.config.ts |
Adds TS ignore for untyped WP scripts Playwright config import. |
plugins/view-transitions/js/view-transitions.js |
Updates JSDoc array types and adds optional chaining for Navigation API usage. |
plugins/view-transitions/js/types.ts |
Removes custom Window.navigation declaration (now relying on built-in Navigation types). |
plugins/performance-lab/includes/admin/plugin-activate-ajax.js |
Adds runtime guards, safer queue handling, optional chaining, and event typing tweaks. |
plugins/optimization-detective/detect.js |
TS6-driven typing fixes (Promises, Records, guards) and minor runtime safety improvements. |
plugins/optimization-detective/detect-loader.js |
Adds stronger DOM element checks and runtime validation for injected detect args. |
plugins/image-prioritizer/lazy-load-video.js |
Reworks attribute reads using getAttribute() + truthiness guards. |
plugins/embed-optimizer/detect.js |
Adds dataset truthiness guard and null guard around getElementData() usage. |
bin/plugin/lib/logger.js |
Adds JSDoc typing for formatter functions. |
bin/plugin/cli.js |
Tightens option defaults handling and improves unknown error handling in CLI wrapper. |
bin/plugin/commands/changelog.js |
Adds type predicate for labels and improves error stack fallback. |
bin/plugin/commands/readme.js |
Uses instanceof Error handling for safer error messages. |
bin/plugin/commands/versions.js |
Uses instanceof Error handling for safer error messages. |
bin/plugin/commands/since.js |
Simplifies plugin selection control flow. |
.github/dependabot.yml |
Normalizes quoting style for the @types/node ignore rule. |
Comments suppressed due to low confidence (1)
plugins/view-transitions/js/view-transitions.js:210
- This branch guards with optional chaining, but then accesses
window.navigation.activation.from.urlwithout optional chaining / narrowing. UndercheckJs, TypeScript generally won’t narrowwindow.navigation.activationbased onwindow.navigation?.activation?.from?.url, so this pattern can still trigger "possibly null/undefined" errors. Store the URL in a local variable from the optional chain and use that, or use optional chaining consistently in the access.
viewTransitionEntries = getViewTransitionEntries(
transitionType,
document.body,
window.navigation?.activation?.from?.url
? getArticleForUrl(
window.navigation.activation.from.url
)
: null
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const data = JSON.parse( argsScript.textContent ); | ||
| if ( | ||
| ! Array.isArray( data ) || | ||
| data.length !== 2 || | ||
| 'string' !== typeof data[ 0 ] || | ||
| 'object' !== typeof data[ 1 ] | ||
| ) { | ||
| throw new Error( | ||
| 'SCRIPT#optimization-detective-detect-args is not [ string, object ]' | ||
| ); |
There was a problem hiding this comment.
The validation for data[1] is too weak: typeof data[1] === 'object' also allows null and arrays, so malformed args like ["/detect.js", null] or ["/detect.js", []] will pass this guard but likely break later. Tighten the check to require a non-null, non-array plain object (or at least data[1] !== null && !Array.isArray(data[1])).
There was a problem hiding this comment.
This is overkill. This is a simple sanity check for whether the JSON was corrupted unexpectedly.
… dependabot/npm_and_yarn/typescript-6.0.2
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Bumps typescript from 5.9.3 to 6.0.2.
Release notes
Sourced from typescript's releases.
Commits
607a22aBump version to 6.0.2 and LKG9e72ab7🤖 Pick PR #63239 (Fix missing lib files in reused pro...) into release-6.0 (#...35ff23d🤖 Pick PR #63163 (Port anyFunctionType subtype fix an...) into release-6.0 (#...e175b69Bump version to 6.0.1-rc and LKGaf4caacUpdate LKG8efd7e8Merge remote-tracking branch 'origin/main' into release-6.0206ed1aDeprecate assert in import() (#63172)e688ac8Update dependencies (#63156)29b300dBump the github-actions group across 1 directory with 2 updates (#63205)0c2c7a3DOM update (#63183)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 asunknownby 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
dataset.odXpathinstead of type castgetElementData()return valueImage Prioritizer
getAttribute()with truthiness guards instead ofhasAttribute()+getAttribute()with type castsOptimization Detective
Promiseconstructors withPromise<void>type assertions; use arrow function wrappers for event listener resolve callbacks (TS6 no longer allows passingresolvedirectly as anEventListener)|| ''fallback forsessionStorage.getItem()passed toparseInt()ArrayandPromisegenericsRecordtypes torecursiveFreezeparameter andheadersobject for proper index signaturesObject.assignwithMap.get()resultcompressedPayloadtruthiness check in ternary to avoidBlobcastgetElementByIdresult toHTMLElementfortextContentaccessgetAttribute()where null is excluded by control flowPerformance Lab
pluginSlugfrom dataset with early return guardshift()with undefined check instead of type cast for queue processingactionButtonList?.appendChild()MouseEvent/Eventtype mismatchView Transitions
Window.navigationdeclaration that conflicts with TS6 built-in Navigation API typesArray[]JSDoc typesBuild Tools
@types/lodashfor proper type declarations@ts-ignorefor@wordpress/scriptsconfig modules (no types available)instanceof Errorchecks in catch clauses instead ofanycastsRecord<string, string>type for webpack manifest andCompilertype for webpack plugin callbackimport('commander').Commandtype for CLI command parametersince.jscontrol flow using directopt.plugintruthiness check