Last active
December 20, 2017 19:25
-
-
Save B-Reif/772bdb132dc9597f1a014d15707167ba to your computer and use it in GitHub Desktop.
my stab at redux-orm flow-typing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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