-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(57348): Auto-complete on satisfies auto-imports satisfies #57364
Conversation
src/services/completions.ts
Outdated
@@ -4004,7 +4005,9 @@ function getCompletionData( | |||
if (!isIdentifierText(symbolName, getEmitScriptTarget(host.getCompilationSettings()))) return false; | |||
if (!detailsEntryId && isStringANonContextualKeyword(symbolName)) return false; | |||
if (!isTypeOnlyLocation && !importStatementCompletion && !(targetFlags & SymbolFlags.Value)) return false; | |||
if (!isTypeOnlyLocation && contextToken && isExpression(contextToken) && contains([SyntaxKind.AsKeyword, SyntaxKind.SatisfiesKeyword], stringToToken(symbolName))) return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Special-casing just these two feels off - why can't we just return both the auto-import and the keyword? For example, if you have a module like this:
namespace foo {
export function await() {
}
}
export = foo;
Both the keyword and auto-import are available in other files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I understand it, this "special-casing" should apply in cases where the user is in a "casting/satisfies" position.
1 a/**/
1 sati/**/
// should we suggest auto-import here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that's fine - in which case, at the very least that you need to check for no line terminator before the position, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn’t the keyword supposed to be present and sorted above the auto-import? Here’s async
, for example:
In a position like 1 satisf/**/
, it’s true that an identifier would be invalid, so we could consider blocking all auto-imports there. However, I sometimes find myself wanting completions in the middle of a messy edit:
const x = someFn bla/**/, foo); // going to backtrack and add the missing `(`
so I’m hesitant to block completions based on relying too much on the current state of the parse tree. It feels to me like the bug is just that the keywords don’t show up here, even though they’re valid:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was marked as duplicate.
This comment was marked as duplicate.
Sorry, something went wrong.
Thanks @a-tarasyuk! |
Fixes #57348