question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Proposal] Display all properties (inherited or not) of a given class (in TypeScript)

See original GitHub issue

From @yahiko00 on September 4, 2016 21:56

Visual Studio Code is a fantastic tool and I am really impressed by all its features despite being quite young.

There is a feature that does not still exists in VS Code which could be really convenient when we are forced to deal with big inheritance hierarchies.

This proposal is based on the TypeScript language, but I am quite sure this could apply to other OOP languages VS Code supports.

Overview of the Workflow

Let us assume we have a source file animal.ts like this:

// animal.ts

abstract class Animal {
    private dna: number;
    name: string;

    constructor(name: string) {
        this.dna = Math.random();
        this.name = name;
    }

    abstract shout(): string;
}

This file could be open or not in VS Code, but it is part of the current project.

Let us assume we have another source file bird.ts like this:

// bird.ts

class Bird extends Animal {
    constructor() {
        super();
        this.name = "Hector";
    }
    shout(): string {
        return "Cuicui!"; // sorry it is in French... I do not know how a bird shouts in English ^_^
    }
}

This file is open in VS Code.

What I would like to be able to do in VS Code is displaying all properties, inherited or not, available for the class Bird.

To do so, we could move the cursor on the Bird identifier, press F1 key, and run a new Display all inherited properties command.

This new command would open a new file in a new tab called Bird (all inherited properties).

In this example, the content of this file would be the following:

class Bird {
    private dna: number;
    name: string;

    super.constructor(name: string) {
        this.dna = Math.random();
        this.name = name;
    }

    constructor() {
        super();
        this.name = "Hector";
    }

    shout(): string {
        return "Cuicui!";
    }
}

The content of Bird (all inherited properties) has nothing to do with valid syntax. Its purpose is only informational.

Some informal rules

  • Attributes should be displayed first.
  • Type anotations should be rendered unchanged.
  • Access modifiers public, protected, private should be rendered unchanged.
  • Abstract methods which are not overriden should be rendered.
  • All versions of an overriden method should be rendered, with a concatenation of super prefixes to distinguish each version in the inheritance hierarchy. For instance super.method() would refer to immediate method()'s parent, whereas super.super.method() would refer to method()'s grand-parent, and so on.
  • Method()'s parent should be displayed before the method() itself.
  • The same rules for method() apply to constructor().

Copied from original issue: Microsoft/vscode#11526

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:15
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
Papoochcommented, Jun 28, 2021

I’ve searched far and wide for this functionality, and it seems all the related issues have been closed with a link to this one. Has anyone found a way to easily visualize all inherited properties of a class or interface? @BrainMaxx Your extension seems to be the only attempt to solve this on the whole internet, but is now unpublished, any idea why?

3reactions
cachiuscommented, Sep 6, 2022

Related issue in the VS Code repo: #157461. Please vote there until October 15, 2022 to turn the issue into a feature request!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to list all possible properties of a class in typescript
I see several approaches of listing properties of an object, like myObj.hasOwnProperty(key) , but they don't seem to work with possible ...
Read more >
Documentation - Classes - TypeScript
Property 'greet' in type 'Derived' is not assignable to the same property in base type 'Base'. Type '(name: string) => void' is not...
Read more >
Advanced TypeScript 4.8 Concepts: Classes and Types
Most notably, it allows for non-method properties, similar to this Stage 3 proposal. In fact, declaration of each instance method or property ......
Read more >
typescript-cheatsheet - GitHub Pages
In TypeScript any argument of a function may be assigned a type no matter how ... properties or classes for being inherited, there...
Read more >
Learn TypeScript: Advanced Object Types Cheatsheet
Like JavaScript classes, an interface can inherit properties and methods from another interface using the extends keyword. Members from the inherited interface ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found