Skip to content

Commit

Permalink
fix(sloth-entity): returns type constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
vinz243 committed Apr 24, 2018
1 parent 4d29c90 commit f41833d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/decorators/SlothEntity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ function mapPropsOrDocToDocument({ fields }: ProtoData, data: any) {
export default function SlothEntity<S extends { _id: string }>(name: string) {
return <T extends BaseEntity<S>>(constructor: {
new (factory: PouchFactory<S>, idOrProps: Partial<S> | string): T
}) => {
}): EntityConstructor<S, T> => {
const data = getProtoData(constructor.prototype, true)

data.name = name

const BaseEntity = constructor as EntityConstructor<any, any>

return class WrappedEntity extends BaseEntity {
constructor(factory: PouchFactory<S>, idOrProps: Partial<S> | string) {
super(factory, idOrProps)
Expand All @@ -48,6 +50,6 @@ export default function SlothEntity<S extends { _id: string }>(name: string) {
idOrProps
)
}
}
} as any
}
}

0 comments on commit f41833d

Please sign in to comment.