Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

Rule proposal: require async for Promise returning methods. #1699

Closed
AndyMoreland opened this issue Nov 8, 2016 · 1 comment
Closed

Rule proposal: require async for Promise returning methods. #1699

AndyMoreland opened this issue Nov 8, 2016 · 1 comment

Comments

@AndyMoreland
Copy link
Contributor

I'd like to have a lint rule that requires the async modifier be attached to any method that returns a Promise.

Reasoning:

foo(): Promise<T> can (technically) either return a rejected promise or bubble a standard synchronous Error object. No sane API is designed to use both error paths, because it requires any consumer use two separate error handling constructs at any exception handling point.

In my codebase I'd like to require that any method that returns a Promise also be marked async, because async methods automatically catch synchronous exceptions and convert them into rejected promises. This would prevent accidental synchronous exceptions in async codepaths.

@AndyMoreland AndyMoreland changed the title Require async for Promise returning methods. Rule proposal: require async for Promise returning methods. Nov 8, 2016
buu700 added a commit to buu700/tslint that referenced this issue Nov 23, 2016
@andy-hanson
Copy link
Contributor

Should be fixed by #1779.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants