Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript 4.8.2 and loadFromPivotTable #3417

Closed
roderik opened this issue Aug 26, 2022 · 9 comments · Fixed by #3389
Closed

Typescript 4.8.2 and loadFromPivotTable #3417

roderik opened this issue Aug 26, 2022 · 9 comments · Fixed by #3389

Comments

@roderik
Copy link
Contributor

roderik commented Aug 26, 2022

Describe the bug

Reported a few times before its official release, but now it has been released and dependabot opend a PR on our repo

Stack trace

error TS2344: Type 'MongoDriver' does not satisfy the constraint 'IDatabaseDriver<Connection>'.
             Types of property 'loadFromPivotTable' are incompatible.
               Type '<T, O>(prop: EntityProperty<any>, owners: Primary<O>[][], where?: FilterQuery<T> | undefined, orderBy?: QueryOrderMap<T>[] | undefined, ctx?: any, options?: FindOptions<...> | undefined) => Promise<...>' is not assignable to type '<T extends AnyEntity<T>, O extends AnyEntity<O>>(prop: EntityProperty<any>, owners: Primary<O>[][], where?: FilterQuery<T> | undefined, orderBy?: QueryOrderMap<...>[] | undefined, ctx?: any, options?: FindOptions<...> | undefined) => Promise<...>'.
                 Types of parameters 'options' and 'options' are incompatible.
                   Type 'FindOptions<T, never> | undefined' is not assignable to type 'FindOptions<T | ((Primary<T> extends string ? string | RegExp : Primary<T> extends Date ? string | Date : Primary<T>) & {}), never> | undefined'.
                     Type 'FindOptions<T, never>' is not assignable to type 'FindOptions<T | ((Primary<T> extends string ? string | RegExp : Primary<T> extends Date ? string | Date : Primary<T>) & {}), never>'.
                       Types of property 'fields' are incompatible.
                         Type 'readonly EntityField<T, never>[] | undefined' is not assignable to type 'readonly EntityField<T | ((Primary<T> extends string ? string | RegExp : Primary<T> extends Date ? string | Date : Primary<T>) & {}), never>[] | undefined'.
                           Type 'readonly EntityField<T, never>[]' is not assignable to type 'readonly EntityField<T | ((Primary<T> extends string ? string | RegExp : Primary<T> extends Date ? string | Date : Primary<T>) & {}), never>[]'.
                             Type 'EntityField<T, never>' is not assignable to type 'EntityField<T | ((Primary<T> extends string ? string | RegExp : Primary<T> extends Date ? string | Date : Primary<T>) & {}), never>'.
                               Type 'keyof T' is not assignable to type 'EntityField<T | ((Primary<T> extends string ? string | RegExp : Primary<T> extends Date ? string | Date : Primary<T>) & {}), never>'.
                                 Type 'string | number | symbol' is not assignable to type 'EntityField<T | ((Primary<T> extends string ? string | RegExp : Primary<T> extends Date ? string | Date : Primary<T>) & {}), never>'.
                                   Type 'string' is not assignable to type 'EntityField<T | ((Primary<T> extends string ? string | RegExp : Primary<T> extends Date ? string | Date : Primary<T>) & {}), never>'.

To Reproduce
Steps to reproduce the behavior:

  1. Upgrade typescript
@B4nan
Copy link
Member

B4nan commented Aug 26, 2022

Yes, its out just few hours :] The release is very breaking for our codebase, you can see how many changes were required to support it partially in #3389. This might take some time to finish.

@roderik
Copy link
Contributor Author

roderik commented Aug 26, 2022

auch!

@B4nan
Copy link
Member

B4nan commented Aug 26, 2022

One of the issues TS reports is also coming from knex, cc @kibertoad

$ tsc --noEmit --project tests/tsconfig.json
node_modules/knex/types/index.d.ts:453:33 - error TS2344: Type 'TRecord | TResult' does not satisfy the constraint '{}'.
  Type 'TResult' is not assignable to type '{}'.

453             | Knex.QueryBuilder<TRecord | TResult>
                                    ~~~~~~~~~~~~~~~~~

edit: actually two of them, or maybe this is just a hint for the previous one

  node_modules/knex/types/index.d.ts:447:38
    447       fn: <TRecord extends {} = any, TResult = unknown[]>(
                                             ~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends {}` constraint.

@kibertoad
Copy link
Contributor

It was fixed in knex/knex#5279, I believe, but not yet released. I'll publish a new version soon

@B4nan
Copy link
Member

B4nan commented Aug 26, 2022

So once knex is released, #3389 should be good to go. I am sure this will break some projects on type level, but what can we do :]

@B4nan
Copy link
Member

B4nan commented Aug 31, 2022

@kibertoad could we have the fix published please?

@kibertoad
Copy link
Contributor

yes, will do it tonight

@kibertoad
Copy link
Contributor

@B4nan released in 2.3.0, please let me know if it works as expected

@B4nan
Copy link
Member

B4nan commented Aug 31, 2022

Yes, perfect, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants