mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-07-31 04:20:26 +02:00
Improved ExtendedType to limit extending only known custom types
This commit is contained in:
@@ -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<K extends string, B> = unknown extends CustomTypes[K]
|
||||
? B
|
||||
: CustomTypes[K]
|
||||
export type ExtendedType<
|
||||
K extends ExtendableTypes,
|
||||
B
|
||||
> = unknown extends CustomTypes[K] ? B : CustomTypes[K]
|
||||
|
Reference in New Issue
Block a user