Skip to content

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

Closed
@Andarist

Description

@Andarist

πŸ”Ž 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions