1.0.6 • Published 5 years ago

ts-immutable-json v1.0.6

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

install

yarn add ts-immutable-json

ts-immutable

a simple immutable .d.ts support

usage

import * as Immutable from "immutable";
import { fromJS, IRecord } from "ts-immutable-json";
interface IUser {
    _id: string;
    nickname?: string;
    age: number;
    timestamp: Date;
    children: IUser[];
    parent?: IUser;
    styles: Immutable.Map<string, string>;
}
function func(user: IRecord<IUser>) {
  user.getIn(["children", 0, "age"]); // ok
  user.getIn(["children", 0, "age2"]); // ts error
  user.getIn(Immutable.Seq(["not exists name"])); // ok
}
function usage() {
  const u = fromJS({_id: "ok"});
  u.get("ok"); // error
  u.get("_id"); // ok
}
function fromImmutable() {
  const u: IRecord<IUser> = Immutable.fromJS({});
}

example

pic0 pic0

1.0.6

5 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago