Skip to content

Avoid providing promise methods as completions at return positions in non-async functions #59298

Closed

Description

🔎 Search Terms

completions promise return expression type async members

🕗 Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.6.0-dev.20240716#code/C4TwDgpgBAsiAq5oF4oG8CwAoKUBmA9gQFxQDOwATgJYB2A5gNzYC+zW2eArrQMbDUCtKMAgUAFLwBGpcQEooyAHywESKAB8oABUoEAttTIQAPHESQlCtC2zZRE+YpXjMOKAHoAVAEYvH1jk5diA

💻 Code

type MyType = {
  foo: string;
};

function test(cb: () => MyType | Promise<MyType>) {}

test(() => ({
  /*1*/
}));

🙁 Actual behavior

Completions provided at the marker position include catch, foo and then

🙂 Expected behavior

It would be great if in a situation like this promise methods would get at least deprioritized and if they would appear at the bottom of the list.

Additional information about the issue

It's technically okay to return thenables compatible with Promise interface but it should be a very rare situation. I think a DX win here would justify hiding those members completely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Experience EnhancementSuggestion

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions