Skip to content

Commit

Permalink
Better types
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed May 29, 2023
1 parent 60db28b commit cf1b115
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 3 additions & 3 deletions packages/core-data/src/private-selectors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Internal dependencies
*/
import type { State } from './selectors';
import type { State, UndoEdit } from './selectors';

type Optional< T > = T | undefined;

Expand All @@ -13,7 +13,7 @@ type Optional< T > = T | undefined;
*
* @return The edit.
*/
export function getUndoEdits( state: State ): Optional< any > {
export function getUndoEdits( state: State ): Optional< UndoEdit[] > {
return state.undo.list[ state.undo.list.length - 1 + state.undo.offset ];
}

Expand All @@ -25,6 +25,6 @@ export function getUndoEdits( state: State ): Optional< any > {
*
* @return The edit.
*/
export function getRedoEdits( state: State ): Optional< any > {
export function getRedoEdits( state: State ): Optional< UndoEdit[] > {
return state.undo.list[ state.undo.list.length + state.undo.offset ];
}
11 changes: 10 additions & 1 deletion packages/core-data/src/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,18 @@ interface EntityConfig {
kind: string;
}

export interface UndoEdit {
name: string;
kind: string;
recordId: string;
from: any;
to: any;
}

interface UndoState {
list: Array< Object >;
list: Array< UndoEdit[] >;
offset: number;
cache: UndoEdit[];
}

interface UserState {
Expand Down

0 comments on commit cf1b115

Please sign in to comment.