Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong Error warnings for Unused patched operator in ./rxjs.imports.ts

See original GitHub issue


first I want to say thank you for your really good work here. 👍

So now to my problem:

I am using the rxjs-add rule like this:

"rxjs-add": {
    "options": [
            "allowElsewhere": false,
            "allowUnused": false,
            "file": "./src/app/rxjs-operators.imports.ts"
    "severity": "error"

So I use the approach to have all rxjs operators in on central file and nowhere else it is allowed to have them and don’t have unused imports for the rxjs operators in the central rxjs operator import file.

That worked fine I just got the same error that was mentioned here: I could fix that, but now I am getting linting errors for Unused patched operator although they are for sure used in my project.

I think this problem is related to the stuff that it is an angular project created with angular-cli and calling ng lint and that run’s tslint three times (like you explained it):

  • first, with application files from src/;
  • then with the test files from src/;
  • and, finally, with files from e2e/.

So I think because not all application files are there for the second and third run I get the errors with the Unused patched operators.

For now, my only solution is to use "allowUnused": true.

Do you have an idea or hint how I could fix this problem?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:21 (10 by maintainers)

github_iconTop GitHub Comments

cartantcommented, Sep 16, 2017

I’ve had a quick look at this and I’ve added some notes to the

When using the file option, all files in the program - not just the specs - are walked to determine what is unused. So if unused errors are effected, there must be operators in files that are not imported into tests. The simplest way to solve the problem would be to import them into a test - even if they are not actually tested. Or, they could be added to src/tsconfig.spec.json - but that might be more tedious to maintain.

Closing this, but feel free to re-open if there are further problems. Happy to continue the conversation without re-opening, too.

cartantcommented, Dec 19, 2017

@kamok No worries. I appreciate your reading through the issues to find one related to your problem, but I think I speak for most maintainers in recommending that instead of commenting on a closed issue, a new issue should be opened with references to any relevant/related issues. As you can see from your resolution, it was not the same issue. Anyway, glad to hear that you have it working.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Beware of TSLint's no-unused-variable rule · Issue #4
src/rxjs.imports.ts #5 ... Wrong Error warnings for Unused patched operator in . ... Confused by no-undef errors on type declarations ...
Read more >
Enforces the importation of patched observables and operators used in the module. See below. rxjs-ban-observables, Disallows the use of banned observables. See ...
Read more >
javascript - Importing lettable RxJS operators
What I'm doing wrong? How can we import new RxJS lettable operators in an Angular CLI app so that RxJS would still be...
Read more >
Angular & TypeScript: How to Import RxJS Correctly?
There are different ways to import RxJS operators. ... Both IDEs simply print the following error message from TypeScript:.
Read more >
Pipeable Operators - RxJS
In your application source code, you should import from rxjs/operators , but in your Webpack configuration file you will need to re-map imports...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found