Skip to content

Inheritance uses incorrect code. #3

@bluwaterdogz

Description

@bluwaterdogz

since super.getProperties would return a string starting with "id is" already, it should be excluded from the descendent method's return template string.

class Base {
  public id: number;
  getProperties() : string {
    return `id is ${id}`;
  }
}

class Child {
  public name: string;
  getProperties() : string {
    return `id is ${super.getProperties()}, name is ${this.name}`;
  }
}

should be

class Base {
  public id: number;
  getProperties() : string {
    return `id is ${id}`;
  }
}

class Child {
  public name: string;
  getProperties() : string {
    return `${super.getProperties()}, name is ${this.name}`;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions