Skip to content

[BUG] inheritance of static methods doesn't work #40327

@MaxmaxmaximusAWS

Description

@MaxmaxmaximusAWS
class Animal {
  static say() {
    console.log('Animal')
  }

  constructor() {
    this.constructor.say()
  }
}


class Cat extends Animal {
  static say() {
    console.log('Cat')
  }
}

i have error:
image

Expected Behavior:

new Animal() // console log "Animal"
new Cat() // console log "Cat"

If I use the class name to access static methods, then inheritance naturally also does not work, and Cat.say() does not calls with new Cat(), cuz new Cat() calls Animal.say()

class Animal {
  static say() {
    console.log('Animal')
  }

  constructor() {
    Animal.say()
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions