GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Auto-insert `await` for property accesses on Promise · Issue #31450 · microsoft/TypeScript

Auto-insert await for property accesses on Promise #31450

New issue
Copy link
New issue
Copy link
Closed
#32101
Closed
Auto-insert await for property accesses on Promise#31450
#32101
Copy link
Assignees
andrewbranch
Labels
Domain: LS: Completion ListsThe issue relates to showing completion lists in an editorThe issue relates to showing completion lists in an editorEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Fix AvailableA PR has been opened for this issueA PR has been opened for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
TypeScript 3.7.0

Description

@DanielRosenwasser
Daniel Rosenwasser (DanielRosenwasser)
opened on May 17, 2019
Issue body actions
async function foo(x: Promise<string>) {
  x./**/
}

Go to the /**/ marker and request completions.

The proposal here is that all the completions for string should show up. When the user selects a string member, we should automatically await the value, so selecting toLowerCase changes the code to (await x).toLowerCase.

Reacted by Wenlu Wang, Titian Cernicova-Dragomir, Bruce Pascoe, Daniel Ehrenberg, Markus Johnsson, Sindre Sorhus, ulrichb, Jake Tunaley, Leon, Fredrik A. Madsen-Malmo and 15 more
Reacted by uhyo
Reacted by uhyo, Jake Richards and Bazyli Brzóska

Activity

Next
  1. fatcerberus commented on May 18, 2019

    @fatcerberus
    Bruce Pascoe (fatcerberus)
    on May 18, 2019
    More actions

    This seems like a good idea but should only be done inside async functions if possible. In the example above, the function is not async so adding an await there would make the code invalid.

    Reacted by Daniel Rosenwasser, Titian Cernicova-Dragomir and Pierre PACI
    Reacted by Daniel Rosenwasser
  2. DanielRosenwasser commented on May 18, 2019

    @DanielRosenwasser
    Daniel Rosenwasser (DanielRosenwasser)
    on May 18, 2019
    MemberAuthor
    More actions

    Yes, thank you, that was one of the subtler points I forgot to add to this issue. It would be incredibly annoying/unsafe otherwise.

  3. Daniel Rosenwasser (DanielRosenwasser)
    added
    Domain: LS: Completion ListsThe issue relates to showing completion lists in an editorThe issue relates to showing completion lists in an editor
    SuggestionAn idea for TypeScriptAn idea for TypeScript
    on May 18, 2019
  4. fatcerberus commented on May 18, 2019

    @fatcerberus
    Bruce Pascoe (fatcerberus)
    on May 18, 2019
    More actions

    Something else I just thought of: since this would be done via autocompletion, the feature probably shouldn't get any ideas about automatically converting the function to async - doing so is a breaking change in most cases since it forces the function into returning a promise.

    Reacted by Daniel Rosenwasser
  5. DanielRosenwasser commented on May 22, 2019

    @DanielRosenwasser
    Daniel Rosenwasser (DanielRosenwasser)
    on May 22, 2019
    MemberAuthor
    More actions

    Spoke with Daniel Ehrenberg (@littledan) today, and once top-level await lands, we should consider doing this at the top level based on target and module options.

    Reacted by Daniel Ehrenberg, Bo Lingen and SlurpTheo
  6. Daniel Rosenwasser (DanielRosenwasser)
    added
    Effort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".
    help wanted
    on May 25, 2019
  7. Daniel Rosenwasser (DanielRosenwasser)
    self-assigned this
    on May 25, 2019
  8. Daniel Rosenwasser (DanielRosenwasser)
    added this to the TypeScript 3.6.0 milestone on May 25, 2019
  9. Daniel Rosenwasser (DanielRosenwasser)
    assigned
    Andrew Branch (andrewbranch)
    and unassigned
    Daniel Rosenwasser (DanielRosenwasser)
    on Jun 26, 2019
  10. andrewbranch commented on Jun 26, 2019

    @andrewbranch
    Andrew Branch (andrewbranch)
    on Jun 26, 2019
    Member
    More actions

    Related: #30646

  11. andrewbranch commented on Jun 26, 2019

    @andrewbranch
    Andrew Branch (andrewbranch)
    on Jun 26, 2019
    Member
    More actions

    /cc Brian Terlson (@bterlson): Thoughts on this (and the work done already at #32101) as a partial solution for #30646? Personally, I’d still like to surface a quick fix and make sure we have a really good diagnostic message in addition to this, but I think completions are a good first line of defense for the last bullet point you mentioned:

    • The target of a member expression and T has the member (or maybe the property name is not in Promise).
  12. bterlson commented on Jun 26, 2019

    @bterlson
    Brian Terlson (bterlson)
    on Jun 26, 2019
    Member
    More actions

    I like it a lot, personally. Incrementally addressing the various bullets is fine by me, and I think this is probably one of the biggest rocks.

  13. 1 remaining item

  14. Kingwl commented on Jun 27, 2019

    @Kingwl
    Wenlu Wang (Kingwl)
    on Jun 27, 2019
    Contributor
    More actions

    Another quick fix is better, the current completion behavior seems cannot add async modifier simply as far as I know

  15. Daniel Rosenwasser (DanielRosenwasser)
    modified the milestones: TypeScript 3.6.0, TypeScript 3.6.1 on Jul 19, 2019
  16. Andrew Branch (andrewbranch)
    modified the milestones: TypeScript 3.6.1, TypeScript 3.7.0 on Jul 22, 2019
  17. Andrew Branch (andrewbranch)
    added
    Fix AvailableA PR has been opened for this issueA PR has been opened for this issue
    and removed
    help wanted
    on Jul 23, 2019
  18. xujif commented on Aug 13, 2019

    @xujif
    浊酒 (xujif)
    on Aug 13, 2019
    More actions

    a suggestion: add a new keyword to a function and translate to js with await all variables.

  19. Andrew Branch (andrewbranch)
    closed this as completedin #32101on Aug 26, 2019
  20. Daniel Rosenwasser (DanielRosenwasser)
    modified the milestones: TypeScript 3.7.0, TypeScript 3.6.3 on Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @andrewbranch
    Andrew Branch (andrewbranch)

Labels

Domain: LS: Completion ListsThe issue relates to showing completion lists in an editorThe issue relates to showing completion lists in an editorEffort: ModerateRequires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Requires experience with the TypeScript codebase, but feasible. Harder than "Effort: Casual".Fix AvailableA PR has been opened for this issueA PR has been opened for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript

Type

No type

Projects

No projects

    Milestone

    • TypeScript 3.7.0

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.