The super call must supply all parameters for base class. The constructor is not inherited. Commented out artist because I guess it is not needed when doing like this.

class StreetArtist extends Artist {
  constructor(
    name: string,
    age: number,
    style: string,
    location: string,
    public medium: string,
    public famous: boolean,
    public arrested: boolean,
    /*public art: Artist*/
  ){
    super(name, age, style, location);
    console.log(`instantiated ${this.name}. Are they famous? ${famous}. Are they locked up? ${arrested}`);
  }
}

Or if you intended the art parameter to populate base properties, but in that case I guess there isn't really a need for using public on art parameter as the properties would be inherited and it would only store duplicate data.

class StreetArtist extends Artist {
  constructor(
    public medium: string,
    public famous: boolean,
    public arrested: boolean,
    /*public */art: Artist
  ){
    super(art.name, art.age, art.style, art.location);
    console.log(`instantiated ${this.name}. Are they famous? ${famous}. Are they locked up? ${arrested}`);
  }
}
Answer from mollwe on Stack Overflow
🌐
DEV Community
dev.to › tak089 › understanding-this-and-super-in-typescript-3hmg
Understanding This and Super in Typescript - DEV Community
March 13, 2025 - In Typescript, this and super are keywords used in object-oriented programming to refer to the current instance of a class and the base class, respectively.
🌐
C# Corner
c-sharpcorner.com › UploadFile › 5089e0 › how-to-use-super-keyword-in-typescript
How to Use Super Keyword In TypeScript
October 4, 2019 - The super keyword can be used in expressions to reference base class properties and the base class constructor. Super calls consist of the keyword super followed by an argument list enclosed in parentheses.
🌐
O'Reilly
oreilly.com › library › view › mastering-typescript-3 › 9781789536706 › 38bfedc0-a0ec-429f-9f1c-319202d62a22.xhtml
The super keyword - Mastering TypeScript 3 - Third Edition [Book]
In other words, the constructor of a derived class overrides, or supersedes, the constructor of the base class. TypeScript includes the super keyword to enable calling a base class's function with the same name.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Operators › super
super - JavaScript | MDN
The super keyword is used to access properties on an object literal or class's [[Prototype]], or invoke a superclass's constructor.
🌐
SPGuides
spguides.com › super-keyword-in-typescript
super Keyword in Typescript
October 14, 2024 - In TypeScript, the super keyword is used within a subclass to access the parent class’s methods and constructors. It enables subclasses to inherit and extend the functionalities of their parent classes.
🌐
TypeScript
typescriptlang.org › docs › handbook › 2 › classes.html
TypeScript: Documentation - Classes
Base method definitions can still be called via super. In classes, a special type called this refers dynamically to the type of the current class. Let’s see how this is useful: ... Here, TypeScript inferred the return type of set to be this, rather than Box.
🌐
TypeScript
typescriptlang.org › docs › handbook › classes.html
TypeScript: Handbook - Classes
Again, we see the extends keywords used to create two new subclasses of Animal: Horse and Snake. One difference from the prior example is that each derived class that contains a constructor function must call super() which will execute the constructor of the base class. What’s more, before we ever access a property on this in a constructor body, we have to call super(). This is an important rule that TypeScript will enforce.
Find elsewhere
🌐
DEV Community
dev.to › ahmad_tibibi › ts1034-super-must-be-followed-by-an-argument-list-or-member-access-495o
TS1034: 'super' must be followed by an argument list or member access - DEV Community
January 7, 2025 - In TypeScript (and JavaScript), the super keyword is used in derived classes to access and call functions on an object's parent class.
🌐
YouTube
youtube.com › watch
How to use Super in Typescript? - YouTube
In this video we will learn how to use "Super" in typescript and usage of it.
Published   May 27, 2020
🌐
YouTube
youtube.com › watch
Super keyword typescript | Super keyword in classes of typescript | Super function typescript - YouTube
In TypeScript, the super keyword is used to call methods and constructors from a parent class (superclass) within a derived class (subclass). It allows you t...
Published   August 11, 2023
🌐
W3Schools
w3schools.com › jsref › jsref_class_super.asp
JavaScript Class super keyword
Create a class named "Model" which will inherit the methods from the "Car" class, by using the extends keyword. By calling the super() method in the constructor method, we call the parent's constructor method and gets access to the parent's properties and methods:
🌐
Tutorial Teacher
tutorialsteacher.com › typescript › typescript-class
TypeScript Classes
The constructor of the Employee class initializes its own members as well as the parent class's properties using a special keyword 'super'. The super keyword is used to call the parent constructor and passes the property values.
🌐
GitHub
github.com › microsoft › TypeScript › issues › 54900
`super` keyword allows calling arrow functions defined on the super class, but shouldn't · Issue #54900 · microsoft/TypeScript
May 2, 2023 - How I got here: I am trying to get contravariant type checking on subclass overrides of abstract super class functions, and as discussed in several places (below are some examples), you can only achieve this with superclass abstract instance properties that are functions (and not with abstract class methods): ... But I would also like to let these subclasses sometimes call a superclass's default implementation (i.e.
Published   Jul 06, 2023
🌐
Krython
krython.com › tutorial › typescript › super-keyword-calling-parent-class-members
📞 Super Keyword: Calling Parent Class Members - Tutorial | Krython
By the end of this tutorial, you’ll be a super expert at using super! Let’s dive in! 🏊‍♂️ · The super keyword is like a telephone 📞 that lets you call your parent class directly.
Top answer
1 of 3
10

Another solution I eventually came up with, in addition to the ones provided by @iberbeu and @Nypan, is to add and intermediary initProps() method right before the call to scream():

class Person 
{
    public firstName: string;

    constructor(firstName: string, props?: any)
    {
        this.firstName = firstName;
        this.initProps(props);
        this.scream();
    }

    protected initProps(props: any): void
    {
    }

    protected scream(): void
    {
        console.log(this.firstName);
    }
}

class Employee extends Person
{
    public lastName: string;

    constructor(firstName: string, lastName: string)
    {
        super(firstName, {lastName});
    }

    protected initProps(props: any): void
    {
        this.lastName = props.lastName;
    }

    protected scream(): void
    {
        console.log(this.firstName + ' ' + this.lastName);
    }
}

Although I think both made a strong point and I should actually be using a factory pattern instead..

2 of 3
6

Am I doing a dumb thing here?

Yes you are. As iberbeu said in his comment a constructor should never do anything that does not have to do with constructing the object. It is a case of bad practice that can lead to all sorts of unexpected behaviour.

Are there better ways to arrange my code so I don't need to do this?

Using the solution you provided in your C option is the way to go here.

Is there some way to work around this error?

It depends on what you actually want to do. The normal way of doing things is illustrated by yourself in your C option. If the problem you are having is related to actually instantiating complex objects you might want to look in to builder/factory patterns. But if you actually want the constructors to do something you are simply doing it wrong; constructors are not ment to perform actions, they are there to construct objects and nothing else.

🌐
SonarSource
rules.sonarsource.com › typescript › rspec-3854
TypeScript static code analysis
Unique rules to find Bugs, Vulnerabilities, Security Hotspots, and Code Smells in your TYPESCRIPT code
🌐
Xjavascript
xjavascript.com › blog › typescript-super
Mastering `super` in TypeScript | XJavaScript.com
June 16, 2025 - The super keyword in TypeScript is a powerful tool when working with class - based inheritance. It allows you to call the parent constructor and methods, which is essential for proper initialization and extending functionality.
Top answer
1 of 2
237

Working example. Notes below.

class Animal {
    constructor(public name) {
    }

    move(meters) {
        alert(this.name + " moved " + meters + "m.");
    }
}

class Snake extends Animal {
    move() {
        alert(this.name + " is Slithering...");
        super.move(5);
    }
}

class Horse extends Animal {
    move() {
        alert(this.name + " is Galloping...");
        super.move(45);
    }
}

var sam = new Snake("Sammy the Python");
var tom: Animal = new Horse("Tommy the Palomino");

sam.move();
tom.move(34);
  1. You don't need to manually assign the name to a public variable. Using public name in the constructor definition does this for you.

  2. You don't need to call super(name) from the specialised classes.

  3. Using this.name works.

Notes on use of super.

This is covered in more detail in section 4.9.2 of the language specification.

The behaviour of the classes inheriting from Animal is not dissimilar to the behaviour in other languages. You need to specify the super keyword in order to avoid confusion between a specialised function and the base class function. For example, if you called move() or this.move() you would be dealing with the specialised Snake or Horse function, so using super.move() explicitly calls the base class function.

There is no confusion of properties, as they are the properties of the instance. There is no difference between super.name and this.name - there is simply this.name. Otherwise you could create a Horse that had different names depending on whether you were in the specialized class or the base class.

2 of 2
11

You're using the keywords super and this incorrectly. Below is an example that demonstrates them being correctly.

    class Animal {
        public name: string;

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

        move(meters: number) {
            console.log(this.name + " moved " + meters + "m.");
        }
    }
    
    class Horse extends Animal {
        move() {
            console.log(super.name + " is Galloping...");
            console.log(this.name + " is Galloping...");
         
            super.move(45);
        }
    }
    
    var tom: Animal = new Horse("Tommy the Palomino");
    
    Animal.prototype.name = 'horseee'; 
    
    tom.move(34);
    // Outputs:
    
    // horseee is Galloping...
    // Tommy the Palomino is Galloping...
    // Tommy the Palomino moved 45m.

Explanation:

  1. The first logs the dynamic value for super.name which is proceeded by the static string value "is Galloping...". The keyword this references the "prototype chain" of the object tom, and not the object tom self. Because we have added a name property on the Animal.prototype, horse will be outputted.

  2. The second log outputs this.name, the this keyword refers to the the tom object itself.

  3. The third log is logged using the move method of the Animal base class. This method is called from Horse class move method with the syntax super.move(45);. Using the super keyword in this context will look for a move method on the prototype chain which is found on the Animal prototype.

Remember TS still uses prototypes under the hood and the class and extends keywords are just syntactic sugar over prototypical inheritance.

🌐
Reddit
reddit.com › r/javascript › what does `super()` actually do?
r/javascript on Reddit: What does `super()` actually do?
March 18, 2018 -

I've used it plenty of times, and I've read that it calls the constructor function of its parent class, but I'm not really grasping the concept of it to be honest. I know it's not a concept unique to JS, so if anyone has any good links/examples to explain it in other languages, that would also be great. I thought I understood it, but as I'm trying to learn more about OOP i seem to get more confused by the day lol.

Thanks