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

Type Definitions: Awaiting on knex queries violates no-invalid-await rule from SonarTS #3516

Closed
KristjanTammekivi opened this issue Nov 5, 2019 · 2 comments

Comments

@KristjanTammekivi
Copy link
Contributor

Environment

Knex version: 0.20.1
Database + version: Postgres 11.4
OS: Ubuntu 18.04

If issue is about TypeScript definitions, tag @lorefnon

This might be considered a duplicate of #3515, two sides of the same coin sort of deal

Bug

  1. Awaiting on querybuilders/raw queries violates no-invalid-await rule in tslint-sonarts. This worked on 0.19.2 but not on 0.20.1

  2. Refactor this redundant 'await' on a non-promise. (no-invalid-await)

  3. await knex('users').select('*').limit(1);

@lorefnon
Copy link
Collaborator

lorefnon commented Nov 6, 2019

I think this happens because their hasThenMethod checks if .then property has ts.SymbolFlags.Method flag set which won't be in our case because we use a callable interface for the then property of QueryBuilder so then technically doesn't qualify as a method.

Maybe report this in the SonarTS repo with a minimal reproducer like:

interface SomeCallable {
    (cb: Function): Promise; 
} 

interface Builder {
    then: SomeCallable;
}

This would have worked before because QueryBuilder extended Promise interface which had a then method.

@KristjanTammekivi
Copy link
Contributor Author

Reported it in sonarts now, closing this one

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

No branches or pull requests

2 participants