no-access-missing-member and extended classes
Hi Minko,
I don't know if the following problem is related to #190, but if I set the property on the subject to true (as recommended) when I have an extended class I get warnings. For example:
@Component({
templateUrl: 'signin.component.html'
})
export class SigninComponent extends Signin {
constructor(public router: Router, public authenticationService: AuthenticationService) {
super(router, authenticationService);
...
}
}
export class Signin {
model: any = {};
errorMessage: string = "";
constructor(public router: Router, public authenticationService: AuthenticationService) { }
...
}
I get the following warnings:
app/account/signin.component.html[11, 59]: The property "model" that you're trying to access does not exist in the class declaration.
app/account/signin.component.html[10, 71]: The property "errorMessage" that you're trying to access does not exist in the class declaration.
Packages: "codelyzer": "2.0.0-beta.3", "tslint": "4.0.2", "typescript": "2.0.10"
Note that up to codelyzer 2.0.0-beta.1 I didn't get any error.
Thanks,
Roberto
Since recently Angular didn't support metadata for inheritance so this issue was low priority. Probably I will work on it as part of the next release.
@mgechev I think you missed https://github.com/angular/angular/commit/f5c8e09 since 2.3
Yes, I said "didn't", this is the reason the issue is still open :-)
Is there any workaround to ignore these?
I'll work on this during the weekend. Hopefully, by Monday we'll have these working:
Imported base class
// base.ts
class Base {
bar;
}
// child.ts
import { Base } from './base';
@Component({
selector: 'child',
template: '{{ bar }}'
})
class Child extends Base {}
Base class declared in the same file
class Base {
bar;
}
@Component({
selector: 'child',
template: '{{ bar }}'
})
class Child extends Base {}
@mgechev Thanks!
@mgechev not sure if this has to be part of this issue. I have disabled tslinting in html for the whole file:

But still getting this error:
The property "message" that you're trying to access does not exist in the class declaration.
Note: message is a base class property of this component.
So, shouldn't disabling override any other check?
@asadsahi You have to disable the rule/tslint in the component (typescript file), not the template.
@saithis Thanks. sorted. :)
Excuse me for the delay. There were a lot of things on my plate. I'll try to come up with a fix in the next a couple of days/week.
@mgechev I'm having this issue now. Any progress on this?
@mgechev @wlngwang as a workaround while this issue is resolved, you can use this['your_prop_name'] in your template. Not ideal, but it gets the warning out of the way for now.
class Base {
bar;
}
@Component({
selector: 'child',
template: '{{ this["bar"] }}'
})
class Child extends Base {}
@guojenman Thanks. Another workaround could be setting up a proxy property in the child class to return the desired property.
I'm doing this (redeclaring the var) but it's quite annoying :(
I've been working on ngast for better metadata extraction.
Tomorrow I'll reuse the TypeChecker with program aware walkers, to find the base classes and all symbols. Setting it as a todo item in Things! 👨💻
Related to https://github.com/mgechev/codelyzer/issues/64.
What is the tslint property to disable this check for time being?
What is the tslint property to disable this check for time being?
no-access-missing-member?
@guojenman your workaround worked for me. Was not just a property but a method.
class Base {
bar(arg){return 'x'};
}
@Component({
selector: 'child',
template: '{{ this["bar"](arg) }}'
})
class Child extends Base {}
Good news! Just pushed code which introduces support for extended classes. You can find it here.
I will release 2.0.1 once I make sure everything works properly.
Btw, if you see any test cases which may fail, please comment in the issue.