Skip to content

Class method and property inheritance for components #403

Description

@mspl13

Description

This bug was originally reported over at the angular-cli repository (angular/angular-cli#7587). If you extend a class with an angular component annotation and reference class properties in the child's component html file, the linter will throw an error even though angular handles the inheritance perfectly fine and everything works as expected.

Steps to reproduce

  1. Create a parent angular component and add some properties.
  2. Create a child angular component that extends the one created in step 1.
  3. Try to access the properties defined in the parent class inside the child's component html file.
  4. Run the linter (e.g. using the angular-cli and the ng lint command).

Code example

A minimal example would probably look like this:

@Component({
  selector: 'app-parent-component'
})
export class ParentComponent {
  property: string;
}

@Component({
  selector: 'app-child-component',
  template: `<p [prop]="property"></p>`
})
export class ChildComponent extends ParentComponent { }

Error message

ERROR: /path/to/child.component.html[1, 1]: The property [PROPERTY_NAME] that you're trying to access does not exist in the class declaration.

Packages and versions

The package list contains the following, probably important packages and versions:

"@angular/cli": "^1.3.0",
"@angular/common": "^4.3.4",
"@angular/compiler": "^4.3.4",
"@angular/compiler-cli": "^4.3.4",
"@angular/core": "^4.3.4",
"@angular/forms": "^4.3.4",
"@angular/http": "^4.3.4",
"@angular/platform-browser": "^4.3.4",
"@angular/platform-browser-dynamic": "^4.3.4",
"@angular/router": "^4.3.4",
"@types/node": "^8.0.20",
"codelyzer": "^3.1.2",
"core-js": "^2.5.0",
"rxjs": "^5.4.3",
"ts-node": "^3.3.0",
"tslint": "^5.6.0",
"typescript": "^2.4.2",
"zone.js": "^0.8.16"
...

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