Skip to content

Commit

Permalink
type attrs as Object
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanstitt committed Jun 22, 2021
1 parent 8d3ef74 commit d4395ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/serialize-hydrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import { recordParentOf } from './inverse'
function hydrateFromSchema(
instance: any,
prop: string,
attrs?: any,
attrs?: Object,
schema?: ModelSchema,
): void {
if (!attrs) return
if (!schema) {
instance[prop] = attrs[prop]
return
Expand All @@ -33,7 +34,7 @@ function hydrateFromSchema(
}
}

export const hydrateModel = action(<T extends Model>(model: T, attrs?: any, parent?: any): InstanceType<T> => {
export const hydrateModel = action(<T extends Model>(model: T, attrs?: Object, parent?: any): InstanceType<T> => {
if (model == null) { throw new Error(`unable to hydrate null/undefined Model`); }
if (attrs instanceof model) {
return recordParentOf(attrs, parent)
Expand All @@ -45,7 +46,7 @@ export const hydrateModel = action(<T extends Model>(model: T, attrs?: any, pare
return hydrateInstance(instance, attrs, parent)
})

export const hydrateInstance = action(<T extends ModelInstance>(instance: T, attrs?: any, parent?: any): T => {
export const hydrateInstance = action(<T extends ModelInstance>(instance: T, attrs?: Object, parent?: any): T => {
recordParentOf(instance, parent)
const schema = getSchema(instance)
if (typeof instance.hydrate == 'function') {
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface Model extends Function {
}

export interface ModelInstance extends InstanceType<Model> {
hydrate?(attrs: any): void
hydrate?(attrs?: Object): void
}

export interface ModelOption extends Function {
Expand Down

0 comments on commit d4395ac

Please sign in to comment.