Skip to content

Commit

Permalink
fix: empty object type -> Record<string, unknown>
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzarbn committed Mar 24, 2021
1 parent bccccfe commit 1892921
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/drivers/default/builders/queryBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export class QueryBuilder<M extends Model,
const relationQueryBuilder: QueryBuilder<Model> = model[field]();

if (Array.isArray(rawValue)) {
model.$relations[field] = rawValue.map((rawRelation: any) => {
model.$relations[field] = rawValue.map((rawRelation: Record<string, unknown>) => {
return relationQueryBuilder.hydrate(rawRelation, response);
});
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/default/relations/belongsToMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {ExtractModelPersistedAttributesType} from '../../../types/extractModelPe
import {ExtractModelRelationsType} from '../../../types/extractModelRelationsType';

export class BelongsToMany<Relation extends Model,
Pivot = {},
Pivot = Record<string, unknown>,
Attributes = ExtractModelAttributesType<Relation>,
PersistedAttributes = ExtractModelPersistedAttributesType<Attributes>,
Relations = ExtractModelRelationsType<Relation>> extends RelationQueryBuilder<Relation, Attributes, PersistedAttributes, Relations> {
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/default/relations/morphToMany.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {ExtractModelPersistedAttributesType} from '../../../types/extractModelPe
import {ExtractModelRelationsType} from '../../../types/extractModelRelationsType';

export class MorphToMany<Relation extends Model,
Pivot = {},
Pivot = Record<string, unknown>,
Attributes = ExtractModelAttributesType<Relation>,
PersistedAttributes = ExtractModelPersistedAttributesType<Attributes>,
Relations = ExtractModelRelationsType<Relation>,
Expand Down
8 changes: 4 additions & 4 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {ModelConstructor} from './contracts/modelConstructor';
import {AxiosResponse} from 'axios';
import {DefaultPersistedAttributes} from "./types/defaultPersistedAttributes";

export abstract class Model<Attributes = {},
PersistedAttributes = {} | DefaultPersistedAttributes,
Relations = {},
export abstract class Model<Attributes = Record<string, unknown>,
PersistedAttributes = Record<string, unknown> | DefaultPersistedAttributes,
Relations = Record<string, unknown>,
Key extends number | string = number | string,
AllAttributes = Attributes & PersistedAttributes> {
public $attributes!: AllAttributes;
Expand Down Expand Up @@ -41,7 +41,7 @@ export abstract class Model<Attributes = {},
this.$setAttributes(attributes as unknown as AllAttributes);
}

await this.$query().update(this.$getKey(), attributes || this.$attributes);
await this.$query().update(this.$getKey(), (attributes || this.$attributes) as Record<string, unknown>);

return this;
}
Expand Down

0 comments on commit 1892921

Please sign in to comment.