From 101661ee27b53a228407173b0f8fdfd1a5f901d4 Mon Sep 17 00:00:00 2001 From: Ziad Beyens Date: Fri, 20 Dec 2019 18:17:00 +0100 Subject: [PATCH] fix: Slate editor props (#3359) * fix: Slate editor props TS2322: Type 'Editor' is not assignable to type 'ReactEditor'. * revert * generic type * generic type * generic type * extends Editor * extends Editor * infer * infer --- packages/slate-history/src/with-history.ts | 4 ++-- packages/slate-react/src/plugin/with-react.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/slate-history/src/with-history.ts b/packages/slate-history/src/with-history.ts index 8663b07d1..734547252 100644 --- a/packages/slate-history/src/with-history.ts +++ b/packages/slate-history/src/with-history.ts @@ -7,8 +7,8 @@ import { HistoryEditor } from './history-editor' * editor as operations are applied to it, using undo and redo stacks. */ -export const withHistory = (editor: Editor): HistoryEditor => { - const e = editor as HistoryEditor +export const withHistory = (editor: T) => { + const e = editor as T & HistoryEditor const { apply } = e e.history = { undos: [], redos: [] } diff --git a/packages/slate-react/src/plugin/with-react.ts b/packages/slate-react/src/plugin/with-react.ts index db9218df1..1441aa64b 100644 --- a/packages/slate-react/src/plugin/with-react.ts +++ b/packages/slate-react/src/plugin/with-react.ts @@ -9,8 +9,8 @@ import { EDITOR_TO_ON_CHANGE, NODE_TO_KEY } from '../utils/weak-maps' * `withReact` adds React and DOM specific behaviors to the editor. */ -export const withReact = (editor: Editor): ReactEditor => { - const e = editor as ReactEditor +export const withReact = (editor: T) => { + const e = editor as T & ReactEditor const { apply, onChange } = e e.apply = (op: Operation) => {