Skip to content

Instantly share code, notes, and snippets.

@B-Reif
Last active December 20, 2017 19:25
Show Gist options
  • Save B-Reif/772bdb132dc9597f1a014d15707167ba to your computer and use it in GitHub Desktop.
Save B-Reif/772bdb132dc9597f1a014d15707167ba to your computer and use it in GitHub Desktop.
my stab at redux-orm flow-typing
declare module "redux-orm" {
declare export class Model<I> {
// Static properties
static all: () => QuerySet<this>;
static filter: (filterArg: {} | (this => boolean)) => QuerySet<this>;
static first: () => this | typeof undefined;
static create: (props?: {}) => this;
static get: (lookupObj: {}) => this;
static hasId: (id: I) => boolean;
static withId: (id: I) => this;
static modelName: string;
static fields: {};
static count: () => number;
// Instance properties
set(propertyName: string, value: mixed): void;
delete(): void;
}
declare export class ORM {
mutableSession: (state: any) => any;
getEmptyState: () => any;
register: (...models: Array<mixed>) => void;
}
declare export class QuerySet<SubModel> {
modelClass: Class<SubModel>;
count: () => number;
first: () => SubModel | typeof undefined;
toRefArray: () => Array<{}>;
toModelArray: () => Array<SubModel>;
delete: () => void;
orderBy: (string) => QuerySet<SubModel>
}
declare export class Session {}
declare export function createSelector(
orm: ORM,
...args: Array<Function>
): (session: Session, ...args: Array<any>) => any;
declare export function createReducer(orm: ORM): Function;
declare export function attr(opts?: { getDefault: () => mixed }): void;
declare export function fk(modelName: string, relatedName?: string): void;
declare export function many(modelName: string, relatedName?: string): void;
declare export function oneToOne(
modelName: string,
relatedName?: string
): void;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment