objection.js: Compilation breaks with TypeScript 3.9
Upgraded a project from Typescript 3.8.2 to TypeScript 3.9.2. The project is using the latest Objection (2.1.3).
After the TS upgrade, the project fails to compile with compilation errors related to Objection types.
I suspect this is related to “Stricter Checks on Intersections and Optional Properties” as described here.
node_modules/objection/typings/objection/index.d.ts:268:43 - error TS2344: Type 'Model & T' does not satisfy the constraint 'Model'.
The types of 'QueryBuilderType.findById(...).update(...).page(...).insertGraph' are incompatible between these types.
Type 'InsertGraphMethod<Model & T>' is not assignable to type 'InsertGraphMethod<Model>'.
Types of parameters 'graph' and 'graph' are incompatible.
Type 'PartialModelGraph<Model, Model & GraphParameters>' is not assignable to type 'PartialModelGraph<Model & T, Model & T & GraphParameters>'.
268 ? SingleQueryBuilder<QueryBuilderType<T>>
~
node_modules/objection/typings/objection/index.d.ts:271:26 - error TS2344: Type 'Model & I' does not satisfy the constraint 'Model'.
The types of 'QueryBuilderType.findById(...).update(...).page(...).insertGraph' are incompatible between these types.
Type 'InsertGraphMethod<Model & I>' is not assignable to type 'InsertGraphMethod<Model>'.
Types of parameters 'graph' and 'graph' are incompatible.
Type 'PartialModelGraph<Model, Model & GraphParameters>' is not assignable to type 'PartialModelGraph<Model & I, Model & I & GraphParameters>'.
271 ? QueryBuilderType<I>
~
node_modules/objection/typings/objection/index.d.ts:281:24 - error TS2344: Type 'Model & T' does not satisfy the constraint 'Model'.
The types of 'QueryBuilderType.findById(...).update(...).page(...).insertGraph' are incompatible between these types.
Type 'InsertGraphMethod<Model & T>' is not assignable to type 'InsertGraphMethod<Model>'.
Types of parameters 'graph' and 'graph' are incompatible.
Type 'PartialModelGraph<Model, Model & GraphParameters>' is not assignable to type 'PartialModelGraph<Model & T, Model & T & GraphParameters>'.
281 ? QueryBuilderType<T>
~
node_modules/objection/typings/objection/index.d.ts:284:26 - error TS2344: Type 'Model & I' does not satisfy the constraint 'Model'.
The types of 'QueryBuilderType.findById(...).update(...).page(...).insertGraph' are incompatible between these types.
Type 'InsertGraphMethod<Model & I>' is not assignable to type 'InsertGraphMethod<Model>'.
Types of parameters 'graph' and 'graph' are incompatible.
Type 'PartialModelGraph<Model, Model & GraphParameters>' is not assignable to type 'PartialModelGraph<Model & I, Model & I & GraphParameters>'.
284 ? QueryBuilderType<I>```
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 15
- Comments: 15 (1 by maintainers)
Commits related to this issue
- support typescript 3.9. closes #1750 — committed to Vincit/objection.js by koskimas 4 years ago
The fix is now released. No need for any workarounds.
Disabling
"strict"
turns TS into a glorified linter.A better workaround is to import the git branch with the fix. Or fork the repo at the last released version and cherry-pick the fix.