Show completions based on type of inherited / overridden field or method #53785
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Domain: Completion Lists
The issue relates to showing completion lists in an editor
Suggestion
An idea for TypeScript
Suggestion
TypeScript Version: v5.0.4, tested in TypeScript playground
π Search Terms
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Below, I will use
β
to indicate the location where intellisense fails to show the expected result.Scenario 1: Class Overrides Method from Interface
In the code below, there are no intellisense hints available to help fill in the required values for the return type
{ x: number, y : number}
ofgetLocation
.I would expect the suggestions to include
(x:number), (y:number)
.Scenario 2: Class Overrides Field from Interface
I would expect the suggestions to include
(x:number), (y:number)
.Scenario 3: Class Overrides Method from Abstract Class
I would expect the suggestions to include
(x:number), (y:number)
.Scenario 4: Class Overrides Field from Abstract Class
I would expect the suggestions to include
(x:number), (y:number)
.Working Scenario: Interface Instance
By comparison, if we declare a variable to have type
HasLocation
, intellisense works as expected:π Motivating Example
See the scenarios above. This feature would make it easier for users of a library to correctly implement interfaces and extend abstract classes exposed by the library, without the need to directly check the documentation.
π» Use Cases
I ran into this issue while building a "community plugin" system for a TypeScript library. The idea is:
Extension
interface (or abstract class)class CustomExtension implements Extension
(orclass CustomExtension extends Extension
), with rich intellisense hints available for filling in the required valuesIf needed I can provide further details about the motivation, but I think the scenarios above are already clear enough. As a workaround, for now, I can structure my code similar to the "Working Scenario" listed above and require the user to pass in an
ExtensionConfig
instance to theExtension
constructor. This isn't terrible, but adds some complexity.The text was updated successfully, but these errors were encountered: