Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TResult = unknown[] needs extends {} constraint? #5280

@lizthegrey

Description

@lizthegrey

Environment

Knex version: 2.2.0
Database + version: n/a (type check issue)
OS: Ubuntu 22.04
Typescript version: 4.8.0-beta (works fine with 4.7.4, so regression is from stricter type checking in 4.8)

tagging @lorefnon for typescript issue

Bug

.yarn/__virtual__/knex-virtual-a119e71548/0/cache/knex-npm-2.2.0-54a090c353-eff5161ece.zip/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>
                                    ~~~~~~~~~~~~~~~~~

  .yarn/__virtual__/knex-virtual-a119e71548/0/cache/knex-npm-2.2.0-54a090c353-eff5161ece.zip/node_modules/knex/types/index.d.ts:447:38
    447       fn: <TRecord extends {} = any, TResult = unknown[]>(
                                             ~~~~~~~~~~~~~~~~~~~
    This type parameter might need an `extends {}` constraint.


Found 1 error in .yarn/__virtual__/knex-virtual-a119e71548/0/cache/knex-npm-2.2.0-54a090c353-eff5161ece.zip/node_modules/knex/types/index.d.ts:453

This is probably https://devblogs.microsoft.com/typescript/announcing-typescript-4-8-beta/#unconstrained-generics-no-longer-assignable-to

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions