GeezerVison is showing github.com — Method override completions · Issue #45670 · microsoft/TypeScript
Method override completions #45670DescriptionSuggestion
🔍 Search Terms
- suggest / suggestion
- IntelliSense
- Snippet / snippets
- Tooling
- VS Code / vscode
⭐ Suggestion
For the code:
abstract class Base {
abstract foo(param1: string, param2: boolean): Promise<void>;
}
class Sub extends Base {
}
I should be able to type f inside the body of Sub and get a suggestion for foo that fills in the entire signature of the method when accepted:
class Sub extends Base {
foo(param1: string, param2: boolean): Promise<void> {
| // cursor ends up here
}
}
Right now, accepting the suggestion for foo only inserts the text foo. I have to fill out the entire body of the method myself, typically by copy and pasting from the base class Reacted by Lyu, Wei-Da, Andrew Branch, Daniel Rosenwasser, whzx5byb, Chiri Vulpes, Waseem Dahman and SlurpTheo Activitymjbvz commented on Sep 1, 2021 ContributorAuthor More actions We should be able to use VS Code's snippet syntax for this style of completion. I originally proposed snippet style completions in #25207. It sounds like we have already have adopted a subset of VS Code's snippet string syntax
This would need to be an opt-in feature for editors and we would likely need to add a user facing setting to disable these too andrewbranch commented on Sep 1, 2021 A general question I have about these snippet completions that may insert quite a bit of text is how we want to display them. Xcode has these kinds of method signature completions and it looks like they just truncate, which isn’t too bad:

It’s somewhat less clear how #40700 should display, for example, which is another use case I’m interested in exploring. Reacted by Daniel Rosenwasser andrewbranch commented on Sep 1, 2021 I think we can start by using the full method signature text as the label like Xcode does here and see how we like it. Matt Bierner (@mjbvz) pointed out that the Editor > Suggest: Preview setting is particularly useful for longer snippet completions, and we may want to explore enabling it by default, at least for snippet-text completions. ChiriVulpes commented on Oct 11, 2021 I've wanted this one for so long and assumed it was already suggested, but didn't know what to search for. I'm surprised it only got added to the tracker last month — this would be such a huge usability enhancement for implementing abstract classes! It's honestly one of the only reasons why I sometimes miss working on Java projects 😜
Will this completion automatically propagate visibility modifiers? IE, if the superclass has public/protected, will the completion add the same visibility to the override? Also, will it add the override modifier if the user has the noImplicitOverride flag enabled? Both of those kinds of modifiers being included with these completions would be great. gabritto commented on Oct 12, 2021
Will this completion automatically propagate visibility modifiers? IE, if the superclass has public/protected, will the completion add the same visibility to the override? Also, will it add the override modifier if the user has the noImplicitOverride flag enabled? Both of those kinds of modifiers being included with these completions would be great.
I've been working on implementing this feature, and the override modifier is going to be added if noImplicitOverride is set (modulo possible bugs, of course 😅). About visibility modifiers, I think the suggested method should have them too, but I have yet to test that behavior.
Glad to hear feedback about this feature 😊 Reacted by Andrew Branch, Chiri Vulpes and Erik Reacted by Chiri Vulpes, Erik and tarnishablec
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|