diff --git a/packages/slate/src/interfaces/custom-types.ts b/packages/slate/src/interfaces/custom-types.ts index c8999cd38..397112a05 100644 --- a/packages/slate/src/interfaces/custom-types.ts +++ b/packages/slate/src/interfaces/custom-types.ts @@ -2,10 +2,28 @@ * Extendable Custom Types Interface */ +type ExtendableTypes = + | 'Editor' + | 'Element' + | 'Text' + | 'Selection' + | 'Range' + | 'Point' + | 'InsertNodeOperation' + | 'InsertTextOperation' + | 'MergeNodeOperation' + | 'MoveNodeOperation' + | 'RemoveNodeOperation' + | 'RemoveTextOperation' + | 'SetNodeOperation' + | 'SetSelectionOperation' + | 'SplitNodeOperation' + export interface CustomTypes { [key: string]: unknown } -export type ExtendedType = unknown extends CustomTypes[K] - ? B - : CustomTypes[K] +export type ExtendedType< + K extends ExtendableTypes, + B +> = unknown extends CustomTypes[K] ? B : CustomTypes[K]