mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-01 13:00:16 +02:00
docs: Added migrating gotchas to typescript documentation
This commit is contained in:
@@ -4,6 +4,16 @@ Slate supports typing of one Slate document model \(ie. one set of custom `Edito
|
|||||||
|
|
||||||
**Warning:** You must define `CustomTypes` when using TypeScript or Slate will display typing errors.
|
**Warning:** You must define `CustomTypes` when using TypeScript or Slate will display typing errors.
|
||||||
|
|
||||||
|
> Migrating from 0.47.x?
|
||||||
|
>
|
||||||
|
> Please read the guide below first to understand CustomTypes.
|
||||||
|
>
|
||||||
|
> If you are having issues, here are common migration gotchas:
|
||||||
|
>
|
||||||
|
> - You get typing errors when referring to `node.type` (Property `type` does not exist on type `Node`). To fix this, you need something like `Element.isElement(node) && node.type === 'paragraph'`. This is because a `Node` can be an `Element` or `Text` and `Text` does not have a `type` property.
|
||||||
|
>
|
||||||
|
> - You may have defined CustomType for `Editor` incorrectly. Make sure to define the CustomType for `Editor` as `BaseEditor & ...`. It should not be `Editor & ...`
|
||||||
|
|
||||||
## Defining `Editor`, `Element` and `Text` Types
|
## Defining `Editor`, `Element` and `Text` Types
|
||||||
|
|
||||||
To define a custom `Element` or `Text` type, extend the `CustomTypes` interface in the `slate` module like this.
|
To define a custom `Element` or `Text` type, extend the `CustomTypes` interface in the `slate` module like this.
|
||||||
|
Reference in New Issue
Block a user