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

Access to inline template objects results in "no-access-missing-member" rule being triggerred #231

Closed
DethAriel opened this issue Feb 16, 2017 · 4 comments
Assignees
Labels

Comments

@DethAriel
Copy link

Consider this code:

@Component({
  template: `
    <div #myModal="my-modal" myModal></div>
    <button (click)="myModal.show()">Show</button>
  `,
}) export class MyComponent { }

@Directive({
  selector: '[myModal]',
  exportAs: 'my-modal',
}) export class MyModalDirective { 
  public show() { /* ... */ }
}

If you run tslint with codelyzer's "no-access-missing-member" rule enabled, you get an error:

The method "myModal" that you're trying to access does not exist in the class declaration.

This is not right. Of course, "myModal" is indeed not a method, and it does not exist in the class declaration. Yet, this is perfectly valid code

@mgechev
Copy link
Owner

mgechev commented Feb 19, 2017

This issue will be fixed when we start gathering metadata with ngast. The timeline is not very clear but probably will happen somewhen next month. Until then, you can update your .codelyzer.js and add the directive declaration manually.

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

Matmo10 commented Feb 27, 2017

Is there a way to disable this rule in an external template only, but not for the whole project? I don't have a .codelyzer.js config, I just reference the codelyzer rules from tslint.json.

EDIT:

Nevermind, all you need to do is add /* tslint:disable no-access-missing-member */ in the corresponding typescript file. :)

@mgechev
Copy link
Owner

mgechev commented Feb 27, 2017

You can create a .codelyzer.js in the root of your project.

Nevermind, all you need to do is add /* tslint:disable no-access-missing-member */ in the corresponding typescript file. :)

That's correct.

@mgechev
Copy link
Owner

mgechev commented Mar 5, 2017

Implemented by d10e980.

Will be released as part of 3.0.0-beta.1.

@mgechev mgechev closed this as completed Mar 5, 2017
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

3 participants