Skip to content

Conversation

dhruvikpatel18
Copy link
Contributor

What?

Part of: #67691
Migrating the undo-manager package to Typescript.

Why?

Type safety.

Testing Instructions

Type check

@t-hamano t-hamano added the [Type] Code Quality Issues or PRs that relate to code quality label Jul 17, 2025
@t-hamano t-hamano mentioned this pull request Jul 18, 2025
39 tasks
@dhruvikpatel18 dhruvikpatel18 marked this pull request as ready for review July 18, 2025 09:28
Copy link

github-actions bot commented Jul 18, 2025

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: dhruvikpatel18 <dhruvik18@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>

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

Comment on lines 9 to 34
export interface HistoryChange< T = unknown > {
/** The previous value */
from: T;
/** The new value */
to: T;
}

/**
* Represents changes for a single item.
*/
export interface HistoryChanges< T = unknown > {
/** The identifier for the item being changed */
id: string | Record< string, unknown >;
/** The changes made to the item */
changes: Record< string, HistoryChange< T > >;
}

/**
* Represents a record of history changes.
*/
export type HistoryRecord< T = unknown > = HistoryChanges< T >[];

/**
* The undo manager interface.
*/
export interface UndoManager< T = unknown > {
Copy link
Member

Choose a reason for hiding this comment

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

We already have all of these interfaces in the types.ts file, can we please update those and use them in this file?

Comment on lines 4 to 9
export interface HistoryChange< T = unknown > {
/** The previous value */
from: T;
/** The new value */
to: T;
}
Copy link
Member

Choose a reason for hiding this comment

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

Isn't it possible that from and to can be of different type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it is possible, have changed the interface to allow from and to to be different types.

Copy link
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

This looks good now

@manzoorwanijk manzoorwanijk enabled auto-merge (squash) July 31, 2025 06:23
@manzoorwanijk manzoorwanijk merged commit 452c28f into WordPress:trunk Jul 31, 2025
71 of 72 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.4 milestone Jul 31, 2025
adamsilverstein pushed a commit to adamsilverstein/gutenberg that referenced this pull request Jul 31, 2025
Co-authored-by: dhruvikpatel18 <dhruvik18@git.wordpress.org>
Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Code Quality Issues or PRs that relate to code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants