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

no-access-missing-member and async pipe #190

Closed
pierre-hilt opened this issue Dec 13, 2016 · 23 comments
Closed

no-access-missing-member and async pipe #190

pierre-hilt opened this issue Dec 13, 2016 · 23 comments
Assignees
Labels

Comments

@pierre-hilt
Copy link

pierre-hilt commented Dec 13, 2016

Hello,

I have no-access-missing-member error in my project when linting this template:

<div class="main-section" 
  [class.actionBarDisplayed]="(actionBarState$ | async).buttons.length > 0">
  <div class="main-content top-ease-in-out">
    <dashboard *ngIf="(context$ | async) == contextWrapper.dashboard"></dashboard>
    <command
      [init]="(onCommandPageStatus$ | async)" 
      *ngIf="(context$ | async) == contextWrapper.command">
    </command>
    <comp *ngIf="(context$ | async) == contextWrapper.comp"></comp>
  </div>
  <side-bar class="right-transition hidden">
  </side-bar>
</div>

I have error only when accessing async pipe in inputs (ngif is working fine).
packages:
"codelyzer": "^2.0.0-beta.3",
"tslint": "~4.0.0",
"typescript": "2.0.3"

Do you have any idea?

Thanks,

Pierre

@jamesbirtles
Copy link

Having the exact same problem, something that made the error go away was changing things like this

(actionBarState$ | async).buttons.length

to

(actionBarState$ | async)?.buttons?.length

Though I think this might just be hiding the problem, or just preventing the rule from checking properly, so not really a long-term or good solution

@mgechev
Copy link
Owner

mgechev commented Dec 13, 2016

Thanks for pointing this out! I'll fix it during the holidays.

@pierre-hilt
Copy link
Author

Thanks @UnwrittenFun for the workaround 👍

@pierre-hilt
Copy link
Author

And so that points out that ngif is not check for no-access-missing-member as well

@mgechev mgechev self-assigned this Dec 14, 2016
@mgechev mgechev added this to the 2.0.0-Beta 4 KV35 milestone Dec 14, 2016
@mgechev mgechev modified the milestones: 2.0.0-Beta 5 Flightside, 2.0.0-Beta 4 KV35 Dec 21, 2016
@mgechev
Copy link
Owner

mgechev commented Dec 31, 2016

After debugging this further, it turns out that the issue is related with the *ngIf directive, not the async pipe itself.

@victornoel
Copy link

@mgechev Is there another issue open for this bug? I'm experiencing it currently (see angular/angular-cli#4351), and I don't understand from your comment why you closed the present issue…
Thanks :)

@mgechev
Copy link
Owner

mgechev commented Feb 6, 2017

It's caused by lack of metadata for the NgIf directive. This can be workarounded by updating .codelyzer.js/disabling codelyzer for this file.

As part of the new release, we'll work on improvements in this direction.

@victornoel
Copy link

Thank you for the explanation

@victornoel
Copy link

@mgechev sorry to bother you again but could you give an example of what you meant by:

This can be workarounded by updating .codelyzer.js

I really don't get how to make it work…

And by the way, why close this issue if it is not fixed (I just tried latest release)?

@mgechev
Copy link
Owner

mgechev commented Feb 8, 2017

I will take a look at the issue today. Until then, let's reopen it.

@mgechev mgechev reopened this Feb 8, 2017
@victornoel
Copy link

@mgechev anything we can do to help fix this issue? or maybe could you share an easy workaround (via .codelyzer.js I guess) to ignore that issue on html files?

@mgechev mgechev removed this from the 2.0.0-Beta 5 Flightside milestone Feb 19, 2017
@mgechev
Copy link
Owner

mgechev commented Feb 19, 2017

Probably this is caused by the incomplete metadata collection. Introducing ngast should fix the issue. Moving to 2.0.2.

@mgechev mgechev added this to the 2.0.2 - Actualism milestone Feb 19, 2017
@victornoel
Copy link

@mgechev not exactly sure why, but since @angular/cli 1.0.0-rc0, this problem disappeared.
I tested with codelyzer 2.0.1 and both @angular/cli 1.0.0-beta.32.3 and 1.0.0-rc.0: the first shows me the error discussed here and the second does not!

@mgechev
Copy link
Owner

mgechev commented Feb 27, 2017

Thanks! I will close the issue when I have a chance to verify it's gone.

@mgechev
Copy link
Owner

mgechev commented Feb 28, 2017

Yes, it seems async pipe is not causing any issue in the latest release. @victornoel thanks for pointing your observation out!

@mgechev mgechev closed this as completed Feb 28, 2017
@rthewhite
Copy link

I'm using codelyzer 2.0.1 and @angular/cli 1.0.0-rc0 and the problem seems to still exist for me? Anyone else still having issues with this?

@victornoel
Copy link

@rthewhite last time I checked, it worked with exactly both these settings.

Are you sure you configured your angular project exactly as it is in a ng new from latest angular cli? Because lots of things changed so it could be linked…

@connor4312
Copy link
Contributor

connor4312 commented Mar 11, 2017

I ran into the issue today with codelyzer 2.0.1. Here's an example of a failing usage:

<div *ngIf="(groups | async).length > 0"></div>

This issue is also reproducable with 2.0.0. Here's the version of our Angular components:

$ cat package.json | grep angular
    "@angular/common": "2.4.7",
    "@angular/compiler": "2.4.7",
    "@angular/compiler-cli": "2.4.7",
    "@angular/core": "2.4.7",
    "@angular/platform-browser": "2.4.7",
    "@angular/platform-browser-dynamic": "2.4.7",
...

@mgechev
Copy link
Owner

mgechev commented Mar 12, 2017

Codelyzer 3 should has this fixed.

@connor4312
Copy link
Contributor

Awesome 😄 Not sure if we'll upgrade to a beta release but I'll let you know if we run into this again in 3.x

@brian428
Copy link

brian428 commented May 2, 2017

Minko, I'm using 3.0.1. Should this issue be fixed with that version, or was this something you were waiting to tackle in 4.x? I ask because I'm still getting errors related to async pipe, as well as properties in a component superclass not being found:

ERROR: C:/Developer/Projects/app/user.component.html[14, 45]: The method "toggleSettings" that you're trying to access does not exist in the class declaration.
ERROR: C:/Developer/Projects/app/user.component.html[10, 32]: The property "async" that you're trying to access does not exist in the class declaration.
ERROR: C:/Developer/Projects/app/user.component.html[11, 37]: The property "async" that you're trying to access does not exist in the class declaration.

If you think this shouldn't be happening, I can try to come up with a repro case.

@brian428
Copy link

brian428 commented May 2, 2017

Ah I think this is now slated for 4.x, correct? #191 (comment)

@mgechev
Copy link
Owner

mgechev commented May 2, 2017

Yes, I haven't published the changes yet because they require a bit more work. I need to migrate to latest version of ngast and align to the changes in the template compiler of Angular.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants