Skip to content

Interfaces don't work #32

@iostreamer-X

Description

@iostreamer-X

If we had an interface for example:

interface Animal{
  walk(): void;
}

And then we have a class like:

class Main {
  private animals = [new Dog(), new Cat()];
  
  randomWalk() {
    const index = Math.round(Math.random());
    const animal = this.animals[index];
    
    // This doesn't work
    animal.walk();
  }
}

Then animal.walk will not work at all. The compiler completely skips it since it sees just an interface and not a concrete class.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions