-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Migrate undo-manager package to TS #70757
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
Migrate undo-manager package to TS #70757
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. |
packages/undo-manager/src/index.ts
Outdated
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 > { |
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.
We already have all of these interfaces in the types.ts
file, can we please update those and use them in this file?
packages/undo-manager/src/types.ts
Outdated
export interface HistoryChange< T = unknown > { | ||
/** The previous value */ | ||
from: T; | ||
/** The new value */ | ||
to: T; | ||
} |
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.
Isn't it possible that from
and to
can be of different type?
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.
Yes it is possible, have changed the interface to allow from
and to
to be different types.
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.
This looks good now
Co-authored-by: dhruvikpatel18 <dhruvik18@git.wordpress.org> Co-authored-by: manzoorwanijk <manzoorwanijk@git.wordpress.org>
What?
Part of: #67691
Migrating the undo-manager package to Typescript.
Why?
Type safety.
Testing Instructions
Type check