Closed ctomczyk closed 6 years ago
Hi @ctomczyk! It's hard to know without a self-contained repro case. If you could post one, that would be helpful.
I've noticed that when the npm package typescript
is a version 2.2.0 then ts.isSourceFile(node.parent)
returns false
. When I upgraded typescript
to latest version (2.5.3) (npm install typescript@latest --save-dev
) then ts.isSourceFile(node.parent)
returns true
.
The condition this.hasCycle(resolvedThisFileName)
returns always false.
Also, I've installed an Angular 4 starter and seems tslint-no-circular-imports
works as expected. This indicates that maybe the issue is related to some not up to date npm package(s).
btw I can't share much as the project is non-public :-(
I'm sorry @ctomczyk, but I can't be of much help without more information. If you can distill your project down to the simplest possible repro case (which will likely scrub your private code in the process), I am happy to take a look. Otherwise this isn't enough for me to go on.
Feel free to reopen this issue when you have a repro case.
So far what I've discovered is that tslint-no-circular-imports
checks only for simple one<->one cyclic dependencies while in Angular 4 (see https://github.com/angular/angular-cli/wiki/angular-cli, option showCircularDependencies
) works with deep circular dependencies.
In other words: the results for checking for circular dependencies using tslint-no-circular-imports
are different. Maybe it's worth it to investigate it.
When I run
ng build --scd
then I see all circular dependencies reported. However,tslint-no-circular-imports
doesn't show any errors while using withtslint
in Angular 4 project.It seems that condition
!ts.isSourceFile
is not passing. I do not know why, at the moment. Theconsole.log(node.parent)
returnsSourceFileObject{ here is the content }
;However, even, if I skip condition
if (!node.parent || !ts.isSourceFile(node.parent)
I am getting result:All files pass linting.
.