-
Notifications
You must be signed in to change notification settings - Fork 6
Conversation
Hey, I'm really sorry for how freaking LONG it's taken me to get around this (I blame ADHD!). So I tried out your It looks like you've tried some fancy stuff above and beyond what the objection docs basically told you to do, and it appears that other than minor nitpicks (e.g. typescript does not pick up At this point, I'm really not sure what to do. As documented in #51 and Vincit/objection.js#1589, TypeScript just seems to shit the bed when it comes to multiple plugins. I'm honestly tempted to just merge this and call it a day, I don't know where to proceed from here. If you have any suggestions for what I should do @olavim, I'd greatly appreciate it. |
Oh, and one more thing I've noticed (the same with #51 if you're still alive @geopic) - even when I fix aforementioned errors, there are two areas where even this solution falls short:
class BaseBaseModel extends plugin(Model) {
static get tableName() {
return `table1-${version}`
}
}
await BaseModel.query() // <----- here this gets typed, it's really unfortunate. A few "fun facts" about the inheritance:
const modelA = await ModelA.query().insertAndFetch({}) errors, but not const modelB = await modelA.$relatedQuery('modelBs').insert({}) 🤔 |
@JaneJeon I don't really remember the minor details anymore, but if Objection's type system and TypeScript's capabilities haven't improved by leaps and bounds, I suggest you give up on this completely. Trying to get proper query builder typings is impossible, and even partial support is a metaphorical hydra: If you solve one issue with the types, you will also create at least one new problem. Even if you assume there are no other plugins, it's impossible to guarantee your types work in all cases given all the trickery you can do with Objection. If there is some other plugin that modifies the query builder, you're straight out of luck. Heed my advice and don't add types to the query builder. You can add types to plugin options though, if you have those 😄 |
RIP the dreams. Thank you very much for giving this a proper crack, at least! |
It was worth a shot. |
Follow-up on #51