Skip to content

Compilation breaks with TypeScript 3.9 #1750

@oranoran

Description

@oranoran

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>```

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions