SonarSource / SonarTS

Static code analyzer for TypeScript
GNU Lesser General Public License v3.0
761 stars 53 forks source link

Knex version 0.20 and above conflicts with no-invalid-await #889

Open KristjanTammekivi opened 4 years ago

KristjanTammekivi commented 4 years ago

I want to report a bug.

SonarTS version: 1.9.0
Node.js version: 12.13.0
TypeScript version: 3.7.2

TSLint version: 5.18.0

Rule key: no-invalid-await

Reproducer

interface SomeCallable {
    (cb: Function): Promise<any>;
}

interface Builder {
    then: SomeCallable;
}

async function testme(knex: Builder) {
    await knex; // Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member 
}

Expected behavior

Knex typings were changed in 0.20.0 so they don't inherit from Promise anymore, but there are still .then/.catch methods and should not warn (initially reported this in https://github.com/knex/knex/issues/3516)