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.
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.
Isn't it possible that from and to can be of different type?
There was a problem hiding this comment.
Yes it is possible, have changed the interface to allow from and to to be different types.
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