microsoft / microsoft/TypeScript
Add missing awaits when destructuring properties from a promisified type
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 117
Description
🔎 Search Terms
missing await destructuring codefix promise promisified members properties
🕗 Version & Regression Information
- This is the behavior in every version I tried
⏯ Playground Link
💻 Code
interface User {
id: string;
name: string;
}
declare function getUser(): Promise<User>;
async function test() {
const name = getUser()./*1*/;
const { /*2*/ } = getUser();
}
🙁 Actual behavior
with preferences.includeCompletionsWithInsertText at marker 1 we get completions for id and name and the line gets auto-fixed for us:
const name = (await getUser()).name
Nothing like that happens at marker 2 - no completions, no auto-fixes
🙂 Expected behavior
It would be cool if the second would work like the first one in this regard. It could go from:
const { /*2*/ } = getUser();
to
const { name } = await getUser();
Additional information about the issue
it's a feature request but the bug report template just worked the best here 😉
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked TypeScript Playground and compare completions at marker 1 with the destructuring case at marker 2. Trace the existing property-access await insertion behavior and identify the corresponding destructuring completion or codefix path. Done means destructuring offers the relevant member completions and produces the expected awaited form, with regression coverage for the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers, developer-experience
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100