Fix @types/slate Data type definition to extend Immutable.Map, not Immutable.Record (#38772)

This commit is contained in:
Yuichiro Tsuchiya 2019-10-11 09:12:00 +09:00 committed by Armando Aguirre
parent 24472452e4
commit dc72e8ed3b
2 changed files with 13 additions and 5 deletions

View File

@ -12,17 +12,18 @@
// Benjamin Evenson <https://github.com/benjiro>
// Han Jeon <https://github.com/hanstar17>
// Kay Delaney <https://github.com/kaydelaney>
// Yuichiro Tsuchiya <https://github.com/tuttieee>
// 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<any, any> {}
static create(properties: Immutable.Map<string, any> | { [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<string, any> | { [key: string]: any }): Data;
function fromJSON(object: { [key: string]: any }): Data;
function fromJS(object: { [key: string]: any }): Data;
}
export interface RulesByNodeType {

View File

@ -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 = {