If you're looking for tsc
to flag this as an error, it seems like there would need to be a specific compiler flag related to async-await
, but I couldn't find one in the official documentation.
However, there is a linting rule (assuming you are using
eslint</code) that should catch this issue and notify you about it. Check out the <a href="https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/await-thenable.md" rel="nofollow noreferrer">eslint docs</a> to understand how it operates.</p>
<p>On another note, if you really want to enforce this behavior specifically, you could attempt to modify the classification of <a href="https://github.com/microsoft/TypeScript/blob/master/src/compiler/diagnosticMessages.json#L4943-L4946" rel="nofollow noreferrer">this diagnostic message</a> to "Error" within your <code>node_modules
directory for
typescript
. However, this method may be fragile, so relying on the linter might be a safer option!
For seamlessly integrating eslint
with VSCode, there is a handy plugin available that can directly incorporate linting warnings into the editor interface. You should be able to add this plugin to your VSCode installation from the marketplace within the editor itself.