Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Use a branded Promise type for always-resolved Promises #4101

Closed
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

Coming over fromtypescript-eslint/typescript-eslint#7008 (comment): there is a known annoyance with the@typescript-eslint/no-floating-promises lint rule that it flags the Promises created bycreateAsyncThunk as"floating" if not handled, despite those Promises being known "safe" ones that never resolve. There's no way for the lint rule to know that these Promises are safe.

That issue tracks adding anallow option to the lint rule that would let users allowlist these Promises. But in order to help with RTK, the known safe Promises would need some kind of specific type that can be added to the rule's allowlist. +1 to@phryneas's suggestion:

So, it would be nice if we could mark those promises with some kind of branded type to them to signal to eslint that these promises can be handled, but don't need to.

We're up for adding inallow on our end if you're up for adding that branded type here! Is that something you're up for? Even if this issue is marked as blocked on us implementing theallow option, as long as that's the only blocker we're good to go.

I'd be happy to contribute the actual code change to RTK myself if you think it's doable for a first-timer. 😄

Edit: to be clear, this is roughly what users would be able to specify in their ESLint config oncetypescript-eslint/typescript-eslint#7008 is resolved(pending naming bikeshedding):

"@typescript-eslint/no-floating-promises":["error",{"allowForKnownSafePromises":[{"from":"package","name":"SafePromise","package":"@reduxjs/toolkit"]}]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp