GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — add completion for promise context by Kingwl · Pull Request #32101 · microsoft/TypeScript Conversation
|
|
Ok, so in our user tests (123,359 TS/JS/TSX/JSX files), I looked for the forms:
The results were:
This isn't a huge sample size (of files that actually contain |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
That should be a quick fix and trigger by type mismatch. I‘m not sure but I think you cannot find too many property access is caused people always write the following code rather than parens and parens: async function fetchThings(fetchOptions: RequestInfo): Thing[] { const resp = await fetch(fetchOptions) const rawJson = await resp.json(); return deserializeThingsResponse(rawJson); } |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Sure, maybe my example wasn’t very good. But I think there will generally be cases like declare function someAsyncThing(): Promise<{ foo: string }>; async function whatever() { const x = someAsyncThing(); // meant to await x./*|*/ } and if we complete |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It's also a bit weird that we request autocomplete here and the leading code has been modified.
And I'm not sure that is acceptable what request find all reference in autocomplete? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I’m working on something similar for the codefix scenario: Over the next couple days I’ll be testing this out and seeing how the performance is. We don’t need to do quite a full find-all-references, and the scope should be limited to the source file at largest. I think we should get this merged, and if it seems reasonable to add the initializer await, I can make it pull in the same code I’m working on now. Have you addressed Sheetal’s feedback? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Yeah, it doesn’t work for me either—I stepped through on the VS Code side and confirmed the response from TSServer looks good, and I couldn’t find where it was getting filtered out. It seems like it makes it all the way out of the typescript-language-features extension. Will likely need some help from the VS Code folks to figure this one out, but I don’t think it’s a problem for this PR. 👇 stupid MacBook trackpad clicked the button while I was typing 😑 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| function addSymbol (symbol: Symbol) { | ||
| if (insertAwait && !symbolToOriginInfoMap[getSymbolId(symbol)]) { | ||
| symbolToOriginInfoMap[getSymbolId(symbol)] = { kind: SymbolOriginInfoKind.Promise }; | ||
| if (preferences.includeCompletionsWithInsertText) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be something like if (!insertAwait || preferences.includeCompletionsWithInsertText)? Seems like addSymbol would now reject all completions if the preference is disabled 🙃
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I still felt it's hard to get an await-missing expression when you are coding. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Looks like just a lint error now. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Hope I have not delay your release. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| origin: SymbolOriginInfo | undefined, | ||
| kind: CompletionKind, | ||
| ): CompletionEntryDisplayNameForSymbol | undefined { | ||
| const needsConvertAwait = !!(origin && originIsPromise(origin)); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be passed around since this check can easily be performed as usage sites of needsConvertAwait
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
* add completion for promise context * check insert text inside add symbol helper * fix incorrect branch * avoid completions with includeCompletionsWithInsertText perferences * avoid useless parameter
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Auto-insertawait for property accesses on Promise
There was an error while loading. Please reload this page.