Microsoft/TypeScript
GitHub ã§èŠãAdd missing awaits when destructuring properties from a promisified type
Open
#57,831 opened on 2024幎3æ18æ¥
Experience EnhancementHelp WantedSuggestion
Repository metrics
- Stars
- Â (48,455 stars)
- PR merge metrics
-  (å¹³åããŒãž 6d 17h) (30d ã§ 9 merged PRs)
説æ
ð 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 ð