Class method and property inheritance for components
Description
This bug was originally reported over at the angular-cli repository (https://github.com/angular/angular-cli/issues/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
- Create a parent angular component and add some properties.
- Create a child angular component that extends the one created in step 1.
- Try to access the properties defined in the parent class inside the child's component html file.
- Run the linter (e.g. using the angular-cli and the
ng lintcommand).
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"
...
+1
@shahraship Please use the GitHub's reaction functionality to "vote" on issues instead of writing the "+1" responses.
Hi @mspl13, Take a look at the existing issues. For example #285 .
@wKoza Thanks for the quick response and sorry for the duplicate. Just to be clear: the fix for the issue is that the rule will be removed because the functionality is out of scope for this tool? If so, we should report back to the angular-cli team, which seems to include this rule by default (see for example https://github.com/angular/angular-cli/issues/7587).