-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Convert date package to TypeScript #67665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
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: 1.91 MB ℹ️ View Unchanged
|
Flaky tests detected in 5094cb2. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/16372557269
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR converts the date package from JavaScript to TypeScript, introducing explicit type definitions and updating function signatures and documentation accordingly.
- Adds a
types.ts
file with TS type definitions for date settings and localization. - Converts
index.ts
to TypeScript by adding type annotations, removing legacy JSDoc typedefs, and updating function signatures. - Updates
README.md
andCHANGELOG.md
to reflect the new TypeScript types and APIs.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
File | Description |
---|---|
packages/date/src/types.ts | New TypeScript type definitions for all date configs and settings. |
packages/date/src/index.ts | Migrated core logic to TS, added type annotations on imports, functions, and variables. |
packages/date/README.md | Updated parameter and return type docs for TS signatures. |
packages/date/CHANGELOG.md | Added changelog entry for improved TypeScript definitions. |
Comments suppressed due to low confidence (4)
packages/date/src/index.ts:612
- Using a truthiness check means a zero offset (0) will be treated as falsy and skip this branch. Consider checking for undefined or null explicitly (e.g.,
if ( timezone != null && isUTCOffset( timezone ) )
) to handle 0 correctly.
if ( timezone && isUTCOffset( timezone ) ) {
packages/date/src/types.ts:64
- [nitpick] The property name
string
is confusing and collides with a primitive type name. Consider renaming it to something more descriptive likezoneName
orname
.
string: string;
packages/date/README.md:125
- The
_to_
parameter is optional in the implementation (to?: ...
), but the docs don't indicate it's optional. Mark it as_to_?
or note that it can be omitted to match the function signature.
_to_ `Moment | Date | string | number`: To date, formatted in the WP timezone.
packages/date/src/index.ts:399
- [nitpick] The JSDoc
@param
tags omit a hyphen between the parameter name and description. For consistency and readability, consider using@param dateFormat - PHP-style formatting string.
or removing redundant JSDoc since TypeScript already enforces the type.
* @param dateFormat PHP-style formatting string.
Supercedes #67573, which got closed after I deleted my fork 🤦
What?
Why?
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast