Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Enhancement: [no-floating-promises] Check PromiseLike in addition to Promise by default #9869

Copy link
Copy link
Closed as not planned
@JoshuaKGoldberg

Description

@JoshuaKGoldberg
Issue body actions

Before You File a Proposal Please Confirm You Have Done The Following...

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Link to the rule's documentation

https://typescript-eslint.io/rules/no-floating-promises

Description

As of #8433 -> #9263, no-floating-promises has a checkThenables option (enabled by default as of v8) that stops it from flagging anything that's not explicitly a Promise type. That means the rule won't flag something that's explicitly marked as type PromiseLike (rather than Promise) without explicitly enabling checkThenables.

Coming out of conversation with @jakebailey: PromiseLike does semantically indicate a value is intended to be used like a Promise. That's different from something that coincidentally has a .then() which can be used with await (🤯).

Proposal: should we have the rule also check for PromiseLike, in addition to Promise?

Fail

declare function createThenable(): PromiseLike<void>;

createThenable();

Pass

declare function createThenable(): { then(a: () => void, b: () => void): void }

createThenable();

Additional Info

I'm in favor of this personally, for the stated reasoning.

In terms of whether this would be a breaking change: it almost feels like a bugfix rather than a feature? PromiseLike is quite rare in real-world usage. If this is accepted, I'd also be in favor of landing it in a minor version rather than a major.

💖

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement: plugin rule optionNew rule option for an existing eslint-plugin ruleNew rule option for an existing eslint-plugin ruleevaluating community engagementwe're looking for community engagement on this issue to show that this problem is widely importantwe're looking for community engagement on this issue to show that this problem is widely importantlocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.