Skip to content
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

[Intellisense TS] Poor Intellisense support when overriding methods/properties/getters/setters #11822

Closed
waderyan opened this issue Oct 24, 2016 · 4 comments
Labels
VS Code Tracked There is a VS Code equivalent to this issue

Comments

@waderyan
Copy link

From @Elarcis on October 14, 2016 18:13

  • VSCode Version: Code 1.6.1 (9e4e44c19e393803e2b05fe2323cf4ed7e36880e, 2016-10-13T16:21:53.542Z)
  • OS Version: Windows_NT ia32 10.0.14393
  • Typescript version: 2.0.3
  • Extensions: abierbaum.vscode-file-peek-1.0.1, alefragnani.Bookmarks-0.9.2, be5invis.vscode-icontheme-nomo-dark-1.1.4, codezombiech.gitignore-0.2.0, dbaeumer.vscode-eslint-1.0.8, eg2.tslint-0.5.39, gerane.Theme-TomorrowNight-0.0.2, jakethashi.vscode-angular2-emmet-1.0.9, joelday.docthis-0.3.5, johnpapa.Angular2-1.0.2, ms-vscode.csharp-1.4.1, ms-vscode.typescript-javascript-grammar-0.0.4, msjsdiag.debugger-for-chrome-1.2.0, ryu1kn.partial-diff-0.1.0

Intellisense falls a bit short when overriding a class's properties and methods using inheritance.

Steps to Reproduce:

  1. In a Typescript file, start with this base code:
abstract class Parent {
    /**
     * Function that can be overriden.
     */
    public abstract toOverride(param1, param2): number;

    public canBeOverridden(param1) { }
}

class Child extends Parent {

}
  1. In the Child class, try to implement the function toOverride : no autocompletion is proposed, yet TS shows the error Non-abstract class 'Child' does not implement inherited abstract member 'toOverride' from class 'Parent'. when hovering the class name until we actually write a function with the same signature, which means it knows the missing function's signature.
  2. When the function has been implemented in Child, the parent function's doc isn't reflected in the overriding function, even if it has no doc. I can imagine why it is so, but that means we have to copy paste the doc for it to actually show up when we use Child.toOverride().
  3. It doesn't work either with non-abstract functions, nor getter/setters, etc.

Full code:

abstract class Parent {
    /**
     * This doc will only show up for `Parent` instances,
     * or objets treated as `Parent`.
     */
    public abstract toOverride(param1, param2): number;

    public canBeOverridden(param1) { }
}

class Child extends Parent {
    // No completion has been provided while implementing this function
    public toOverride(p, p2): number {
        return 2;
    }
}

new Child().toOverride(1, 2); // The doc doesn't show up when hovering toOverride.
(new Child() as Parent).toOverride(1, 2); // The doc shows up when hovering toOverride.

Copied from original issue: microsoft/vscode#13779

@waderyan waderyan self-assigned this Oct 24, 2016
@waderyan waderyan added the js label Oct 24, 2016
@waderyan
Copy link
Author

@Elarcis thank you for opening this issue. This is an excellent find. This issue is with the JavaScript language service. Migrating to that repo.

@waderyan
Copy link
Author

Note that I have confirmed this with the latest bits VS Code Insiders and TS 2.0.6

@masaeedu
Copy link
Contributor

@waderyan I think this is also tracked in #7158

@waderyan
Copy link
Author

Closed as duplicated of #7158

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
VS Code Tracked There is a VS Code equivalent to this issue
Projects
None yet
Development

No branches or pull requests

2 participants