Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inheritance uses incorrect code. #3

Open
bluwaterdogz opened this issue Sep 13, 2018 · 0 comments
Open

Inheritance uses incorrect code. #3

bluwaterdogz opened this issue Sep 13, 2018 · 0 comments

Comments

@bluwaterdogz
Copy link

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}`;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant