diff --git a/types/slate/index.d.ts b/types/slate/index.d.ts index 95e7a95d0f..4446b26883 100644 --- a/types/slate/index.d.ts +++ b/types/slate/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Slate +// Type definitions for slate 0.33 // Project: https://github.com/ianstormtaylor/slate // Definitions by: Andy Kent // Jamie Talbot @@ -44,12 +44,12 @@ declare module 'slate' { first?: KindsAndTypes; isVoid?: boolean; last?: KindsAndTypes; - nodes?: { + nodes?: Array<{ kinds?: string[]; types?: string[]; min?: number; max?: number; - }[]; + }>; normalize?: ( change: Change, reason: InvalidReason, @@ -200,7 +200,7 @@ declare module 'slate' { static create(properties: BlockProperties | Block | string): Block; static createList( - array: (BlockProperties | Block | string)[] + array: (BlockProperties[] | Block[] | string[]) ): Immutable.List; static fromJSON(properties: BlockProperties | Block): Block; static isBlock(maybeBlock: any): maybeBlock is Block; @@ -232,7 +232,7 @@ declare module 'slate' { static create(properties: InlineProperties | Inline | string): Inline; static createList( - array: (InlineProperties | Inline | string)[] + array: (InlineProperties[] | Inline[] | string[]) ): Immutable.List; static fromJSON(properties: InlineProperties | Inline): Inline; static isInline(maybeInline: any): maybeInline is Inline; @@ -307,13 +307,13 @@ declare module 'slate' { getNextBlock(key: string | Node): Block | null; getNextSibling(key: string | Node): Node | null; getNextText(key: string | Node): Text | null; - getParent(key: string | Node): Node | void; - getPreviousBlock(key: string | Node): Block | void; - getPreviousSibling(key: string | Node): Node | void; - getPreviousText(key: string | Node): Text | void; + getParent(key: string | Node): Node | null; + getPreviousBlock(key: string | Node): Block | null; + getPreviousSibling(key: string | Node): Node | null; + getPreviousText(key: string | Node): Text | null; getTexts(): Immutable.List; getTextsAsArray(): Text[]; - getTextAtOffset(offset: Number): Text | void; + getTextAtOffset(offset: number): Text | null; getTextsAtRange(range: Range): Immutable.List; getTextsAtRangeAsArray(range: Range): Text[]; hasChild(key: string | Node): boolean; @@ -333,7 +333,7 @@ declare module 'slate' { properties: CharacterProperties | Character | string ): Character; static createList( - array: (CharacterProperties | Character | string)[] + array: (CharacterProperties[] | Character[] | string[]) ): Immutable.List; static fromJSON(properties: CharacterProperties | Character): Character; static isCharacter(maybeCharacter: any): maybeCharacter is Character; @@ -358,7 +358,7 @@ declare module 'slate' { static create(properties: MarkProperties | Mark | string): Mark; static createSet( - array: (MarkProperties | Mark | string)[] + array: (MarkProperties[] | Mark[] | string[]) ): Immutable.Set; static fromJSON(properties: MarkJSON | Mark): Mark; static isMark(maybeMark: any): maybeMark is Mark; @@ -617,94 +617,94 @@ declare module 'slate' { | SetSelectionOperation | SetValueOperation; - type InsertTextOperation = { + interface InsertTextOperation { type: 'insert_text'; path: number[]; offset: number; text: string; marks: Mark[]; - }; + } - type RemoveTextOperation = { + interface RemoveTextOperation { type: 'remove_text'; path: number[]; offset: number; text: string; - }; + } - type AddMarkOperation = { + interface AddMarkOperation { type: 'add_mark'; path: number[]; offset: number; length: number; mark: Mark; - }; + } - type RemoveMarkOperation = { + interface RemoveMarkOperation { type: 'remove_mark'; path: number[]; offset: number; length: number; mark: Mark; - }; + } - type SetMarkOperation = { + interface SetMarkOperation { type: 'set_mark'; path: number[]; offset: number; length: number; mark: Mark; properties: MarkProperties; - }; + } - type InsertNodeOperation = { + interface InsertNodeOperation { type: 'insert_node'; path: number[]; node: Node; - }; + } - type MergeNodeOperation = { + interface MergeNodeOperation { type: 'merge_node'; path: number[]; position: number; - }; + } - type MoveNodeOperation = { + interface MoveNodeOperation { type: 'move_node'; path: number[]; newPath: number[]; - }; + } - type RemoveNodeOperation = { + interface RemoveNodeOperation { type: 'remove_node'; path: number[]; node: Node; - }; + } - type SetNodeOperation = { + interface SetNodeOperation { type: 'set_node'; path: number[]; properties: BlockProperties | InlineProperties | TextProperties; - }; + } - type SplitNodeOperation = { + interface SplitNodeOperation { type: 'split_node'; path: number[]; position: number; target: number; - }; + } - type SetSelectionOperation = { + interface SetSelectionOperation { type: 'set_selection'; properties: RangeProperties; selection: Range; - }; + } - type SetValueOperation = { + interface SetValueOperation { type: 'set_value'; properties: ValueProperties; value: Value; - }; + } export const Operations: { apply: (value: Value, operation: Operation) => Value; @@ -715,6 +715,6 @@ declare module 'slate' { plugins: any[]; } - export function setKeyGenerator(func: () => string): void; - export function resetKeyGenerator(): void; + export function setKeyGenerator(func: () => string): null; + export function resetKeyGenerator(): null; } diff --git a/types/slate/package.json b/types/slate/package.json index 18a02b734c..e9aa4c4b7b 100644 --- a/types/slate/package.json +++ b/types/slate/package.json @@ -1,29 +1,4 @@ { - "description": "TypeScript definitions for slate", "license": "MIT", - "contributors": [ - { - "name": "Andy Kent", - "url": "https://github.com/andykent" - }, - { - "name": "Jamie Talbot", - "url": "https://github.com/majelbstoat" - }, - { - "name": "Jan Löbel", - "url": "https://github.com/JanLoebel" - } - ], - "main": "", - "name": "@types/slate", - "repository": { - "type": "git", - "url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git" - }, - "devDependencies": { - "immutable": "^3.8.2" - }, - "typeScriptVersion": "2.3", - "version": "0.33.4" + "private": true } diff --git a/types/slate/slate-tests.ts b/types/slate/slate-tests.ts index 5efc4cf7a3..4668b1b7b6 100644 --- a/types/slate/slate-tests.ts +++ b/types/slate/slate-tests.ts @@ -1,7 +1,6 @@ -/// import * as Slate from "slate"; -let value = Slate.Value.create(); +const value = Slate.Value.create(); value.change() .focus() .selectAll() diff --git a/types/slate/tsconfig.json b/types/slate/tsconfig.json index 2498dea7ba..1649280316 100644 --- a/types/slate/tsconfig.json +++ b/types/slate/tsconfig.json @@ -9,13 +9,14 @@ "noImplicitThis": true, "strictNullChecks": true, "strictFunctionTypes": true, - "baseUrl": "types", - "typeRoots": ["types"], + "baseUrl": "../", + "typeRoots": ["../"], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts" + "index.d.ts", + "slate-tests.ts" ] }