Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

'ngInject' trigger an 'expected an assignment or function call' error #423

Closed
mfilotto opened this issue Jun 6, 2015 · 3 comments
Closed

Comments

@mfilotto
Copy link

mfilotto commented Jun 6, 2015

Hi,
I'm working on an angular app.
When I use ngInject for depency injection, I have the error 'expected an assignment or function call'
Is there any way to tell tslint to ignore 'ngInject'; instructions ?

@adidahiya
Copy link
Contributor

It might help if you posted more code here.
Do you mean you have a statement that looks like this?

'ngInject';

You could disable tslint for that line using comments. What's the exact rule that's failing here? You can find out using the verbose output option. (I would check, but I'm not at a computer right now)

@mfilotto
Copy link
Author

mfilotto commented Jun 6, 2015

That's it, I have this statement in my code.
The error code I have on that line is 'expected an assignment or function call'

class NavbarController {
    currentDate: Date;
    constructor() {
        'ngInject';
        this.currentDate = new Date();
    }
}

@leeavital
Copy link
Contributor

It sounds like you're using no-unused-expression, which is meant to prevent no-ops like the one you have written here.

I think your best bet is to use comments to disable tslint around ngInject.

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

No branches or pull requests

4 participants