-
Notifications
You must be signed in to change notification settings - Fork 642
Closed
Description
After version 3.0.3, more specifically after this PR: #2399 I've been encountering a breaking change to types.
I define my own query builder like this:
export class BaseModelWithOnlyTimestamp
extends Model
{
// Both of these are needed.
public QueryBuilderType!: MyQueryBuilder<this>
public static QueryBuilder = MyQueryBuilder
@Hook('beforeInsert', () => new Date().toISOString())
public createdAt?: string
@Hook('beforeUpdate', () => new Date().toISOString())
public updatedAt?: string
constructor(props?: { updatedAt?: string; createdAt?: string }) {
super()
this.updatedAt = props?.updatedAt
this.createdAt = props?.createdAt
}
}
Then I call the following function:
let qb = MyModel.relatedQuery(related).withGraphJoined(...)
Before the PR mentioned, the type of qb would be MyQueryBuilder<MyModel> which would be correct.
After the update the type becomes QueryBuilder<Objection.Model>
If I change the code to have a constructor that doens't take any arguments then the code works again as expected. Reverting the changes from the PR also results in correct types
FrancisRocfalkenhawk