question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Compilation breaks with TypeScript 3.9

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:15
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
koskimascommented, May 26, 2020

The fix is now released. No need for any workarounds.

1reaction
Kinranycommented, May 25, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - TypeScript 3.9
TypeScript 3.9 addresses this issue by changing the internals of how the compiler and language service caches file lookups.
Read more >
Programming language TypeScript 3.9 cuts compile times by ...
A Microsoft engineer who works on the Outlook Web App says upgrading to TypeScript 3.9 has cut his compile times from 26 seconds...
Read more >
Announcing TypeScript 3.9 - Microsoft Developer Blogs
TypeScript 3.9 addresses this issue by changing the internals of how the compiler and language service caches file lookups.
Read more >
TypeScript 3.9 slashes compile times for packages - InfoWorld
Latest TypeScript production release addresses extremely poor editing and compilation speeds associated with packages.
Read more >
compile errors with v4.4.x under typescript 3.9.x and node 14
Since typescript does not restrict breaking changes to major versions we consider this support best effort. If you run into any unexpected ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found