You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(require-await) Async method 'bar' has no 'await' expression.
async bar() {
^^^
at /tmp/foo.ts:6:9
hint: Remove 'async' keyword from the function or use 'await' expression inside.
help: for further information visit https://lint.deno.land/#require-await
However if you follow that hint and remove the async keyword you actually introduce the following TypeScript error (as reported by deno check):
error: TS2416 [ERROR]: Property 'bar' in type 'Bar' is not assignable to the same property in base type 'Foo'.
Type '() => number' is not assignable to type '() => Promise<number>'.
Type 'number' is not assignable to type 'Promise<number>'.
bar() {
~~~
Since implementing some interface that requires an async function is incredibly common in TypeScript and deno lint currently has absolutely no clue about types (see #1138) and therefore currently cannot detect that the async keyword is actually needed, I think it would be best to disable the require-await rule by default (i.e. removing it from the recommended rules set).
There is also https://typescript-eslint.io/rules/promise-function-async/ which makes so much sense to me.
What is it about type checking, is it not possible for deno to do that?
Or asked differently, is there any chance that deno will ever have a rule like promise-function-async?
(And with the background of JSR "performant types" in which, if I understood it correctly, all exported functions have to declare their return type, maybe it would even be possible to that without type checks, by enforcing declaring the return type on all functions?)
Consider the following code:
deno lint
currently by default complains:However if you follow that hint and remove the
async
keyword you actually introduce the following TypeScript error (as reported bydeno check
):Since implementing some interface that requires an async function is incredibly common in TypeScript and
deno lint
currently has absolutely no clue about types (see #1138) and therefore currently cannot detect that theasync
keyword is actually needed, I think it would be best to disable therequire-await
rule by default (i.e. removing it from the recommended rules set).(sidenote: ESLint also doesn't recommend
require-await
)The text was updated successfully, but these errors were encountered: