diff --git a/types/slate/index.d.ts b/types/slate/index.d.ts index ace0d0eae7..7b93e66314 100644 --- a/types/slate/index.d.ts +++ b/types/slate/index.d.ts @@ -12,17 +12,18 @@ // Benjamin Evenson // Han Jeon // Kay Delaney +// Yuichiro Tsuchiya // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 import * as Immutable from "immutable"; import { SyntheticEvent } from "react"; -export class Data extends Immutable.Record({}) { - [key: string]: any; +export interface Data extends Immutable.Map {} - static create(properties: Immutable.Map | { [key: string]: any }): Data; - static fromJSON(object: { [key: string]: any }): Data; - static fromJS(object: { [key: string]: any }): Data; +export namespace Data { + function create(properties: Immutable.Map | { [key: string]: any }): Data; + function fromJSON(object: { [key: string]: any }): Data; + function fromJS(object: { [key: string]: any }): Data; } export interface RulesByNodeType { diff --git a/types/slate/slate-tests.ts b/types/slate/slate-tests.ts index c04deb9603..9f1b483c81 100644 --- a/types/slate/slate-tests.ts +++ b/types/slate/slate-tests.ts @@ -22,6 +22,13 @@ import { import { List } from "immutable"; const data = Data.create({ foo: "bar " }); + +// $ExpectType any +data.get('hoge'); + +// $ExpectError +data['foo']; + const value = Value.create({ data }); const node: BlockJSON = {