mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-10 17:24:02 +02:00
Improved ExtendedType to limit extending only known custom types
This commit is contained in:
@@ -2,10 +2,28 @@
|
|||||||
* Extendable Custom Types Interface
|
* Extendable Custom Types Interface
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
type ExtendableTypes =
|
||||||
|
| 'Editor'
|
||||||
|
| 'Element'
|
||||||
|
| 'Text'
|
||||||
|
| 'Selection'
|
||||||
|
| 'Range'
|
||||||
|
| 'Point'
|
||||||
|
| 'InsertNodeOperation'
|
||||||
|
| 'InsertTextOperation'
|
||||||
|
| 'MergeNodeOperation'
|
||||||
|
| 'MoveNodeOperation'
|
||||||
|
| 'RemoveNodeOperation'
|
||||||
|
| 'RemoveTextOperation'
|
||||||
|
| 'SetNodeOperation'
|
||||||
|
| 'SetSelectionOperation'
|
||||||
|
| 'SplitNodeOperation'
|
||||||
|
|
||||||
export interface CustomTypes {
|
export interface CustomTypes {
|
||||||
[key: string]: unknown
|
[key: string]: unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ExtendedType<K extends string, B> = unknown extends CustomTypes[K]
|
export type ExtendedType<
|
||||||
? B
|
K extends ExtendableTypes,
|
||||||
: CustomTypes[K]
|
B
|
||||||
|
> = unknown extends CustomTypes[K] ? B : CustomTypes[K]
|
||||||
|
Reference in New Issue
Block a user