-
Notifications
You must be signed in to change notification settings - Fork 235
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
no-access-missing-member and extended classes #191
Comments
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 angular/angular@f5c8e09 since |
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 fileclass 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:
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.
|
@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 #64. |
What is the tslint property to disable this check for time being? |
|
@guojenman your workaround worked for me. Was not just a property but a method.
|
There's no migration involve - just install the language service and everything works. Regarding failures of the build when there's a missing property - just run the Angular's AoT and it will throw an error. |
Ah yeah right! We have already AoT in our build process. Thanks! |
Same issue with |
Actually I'm on codelyzer 3.1.2 and still getting that error. |
Use Angular's AoT or revert back to 2. There will be no fix: #191 (comment) |
@mgechev sorry If I misunderstood, but I'm still having issues with extended classes. It seems working fine for Classes, but not for templates inline and external
I can use the property in the extended class, however, if I try to access in the template, the command:
Returns the error:
Eq: export abstract class MyParentClass {
public config: string = 'name';
} @Component({
selector: 'my-child-component',
template: `<h1>{{config}}</h1>` // The property "config" that you're trying to access does not exist in the class declaration.
})
export class MyChildComponent extends MyParentClass {
method() {
this.config = 'new name'; // no complains
}
} I wonder how would I run ng-lint with AOT? Thanks |
@leocaseiro You don't run lint with AoT, you run a seperate AoT build which comes up with such errors. |
Thanks @CSchulz My question is: How can I pass my lint, though? |
You can disable the rule and rely on the AoT build. |
I see, I have to disable on tslint: {
"rules": {
"no-access-missing-member": false
}
} @CSchulz thanks for that!!!! |
Fixed tslint errors.
The AOT-Build does not catch usage of inexisting properties in |
I had checked it with
|
@leocaseiro The problem with disabling the rule is that you lose this exact validation. So is there a codelyzer version (and tslint combination) which solves this issue ? (FYI: I'm using this in a WebpackStarter project, not in a Angular CLI project) |
@StefH, you can keep it in your |
The error message is pointing to a html file. Example:
So where to put the lines ? |
Now both issues are closed? Please re-open one ! |
Try on |
@mgechev just to double check, you'll be removing |
I have this issue in my project too: EDIT: so the solution is to disable no-access-missing-member in tslint config as it shouldn't be used anymore - nvm then |
disabling is not a solution for us who are not using angular cli. |
@Dzivo , Angular CLI isn't necessary. You just should use the Language Service form Angular and disable this rule. |
… lint check, the aot compiler now checks it.
I have the same issue for: "@angular/core": "8.0.0", |
Have you tried the dirty workaround of prepending a disable directive as the component's first line?
|
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:
I get the following warnings:
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
The text was updated successfully, but these errors were encountered: