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

Error: Cannot find ./src/rxjs.imports.ts #5

Closed
herkulano opened this issue Aug 22, 2017 · 12 comments
Closed

Error: Cannot find ./src/rxjs.imports.ts #5

herkulano opened this issue Aug 22, 2017 · 12 comments

Comments

@herkulano
Copy link

Getting this error every time although it works and shows lint errors.

Log:

Error: Cannot find ./src/rxjs.imports.ts
    at Walker.findSourceFile (/Users/Herc/Documents/RADAR/RADAR-Dashboard/node_modules/rxjs-tslint-rules/dist/rules/rxjsAddRule.js:134:15)
    at Walker.walkFile (/Users/Herc/Documents/RADAR/RADAR-Dashboard/node_modules/rxjs-tslint-rules/dist/rules/rxjsAddRule.js:144:35)
    at Walker.onSourceFileEnd (/Users/Herc/Documents/RADAR/RADAR-Dashboard/node_modules/rxjs-tslint-rules/dist/rules/rxjsAddRule.js:48:31)
    at Walker.AddedWalker.visitNode (/Users/Herc/Documents/RADAR/RADAR-Dashboard/node_modules/rxjs-tslint-rules/dist/support/added-walker.js:40:18)
    at Walker.SyntaxWalker.walk (/Users/Herc/Documents/RADAR/RADAR-Dashboard/node_modules/tslint/lib/language/walker/syntaxWalker.js:24:14)
    at Rule.AbstractRule.applyWithWalker (/Users/Herc/Documents/RADAR/RADAR-Dashboard/node_modules/tslint/lib/language/rule/abstractRule.js:31:16)
    at Rule.applyWithProgram (/Users/Herc/Documents/RADAR/RADAR-Dashboard/node_modules/rxjs-tslint-rules/dist/rules/rxjsAddRule.js:15:21)
    at Linter.applyRule (/Users/Herc/Documents/RADAR/RADAR-Dashboard/node_modules/tslint/lib/linter.js:176:29)
    at /Users/Herc/Documents/RADAR/RADAR-Dashboard/node_modules/tslint/lib/linter.js:121:85
    at Object.flatMap (/Users/Herc/Documents/RADAR/RADAR-Dashboard/node_modules/tslint/lib/utils.js:151:29)

ERROR: /Users/Herc/Documents/RADAR/RADAR-Dashboard/src/app/components/charts/chart-base/chart-base.component.ts[78, 8]: RxJS add import is missing from ./src/rxjs.imports.ts: debounceTime

Also had to add "no-unused-variable": false, to tslint for "allowUnused": false to work properly.

@cartant
Copy link
Owner

cartant commented Aug 22, 2017

no-unused-variable has some major problems. It somehow messes with TypeScript. See #4 for more information. When I have the time, I might have a look at it and file another issue with TSLint, but that particular rule has wasted a lot of my time in the past and looking further into it is not something I relish.

Regarding the error relating to ./src/rxjs.imports.ts, the path specified for the central imports file needs to be relative to the tsconfig.json file. Are you sure that you are specifying a tsconfig.json-relative path?

@herkulano
Copy link
Author

herkulano commented Aug 22, 2017

@cartant yes, you can check it here:
https://github.com/RADAR-CNS/RADAR-Dashboard/pull/240/files#diff-ace19bd0c04529e685320269e3c05de9R61

Although it has a main tsconfig.json in the root and then a tsconfig.app.json inside ./src that extends the main tsconfig.json, don't know if this could be the cause of the problem.
https://github.com/RADAR-CNS/RADAR-Dashboard/blob/develop/tsconfig.json
https://github.com/RADAR-CNS/RADAR-Dashboard/blob/develop/src/tsconfig.app.json

@cartant
Copy link
Owner

cartant commented Aug 22, 2017

Thanks. Yeah, it sounds like that could be the problem. I think the path will need to be relative to whichever tsconfig file is supplied to TSLint. And it sounds like that might be src/tsconfig.app.json.

I would try specifying ./rxjs.imports.ts as the path to the central file. If that doesn't solve the problem, I will have look into it tomorrow - my time - as it's getting late, here.

Either way, I'll improve the error message to include the absolute path that it's using to look for the file.

@herkulano
Copy link
Author

Forgot to mention that I also tried ./rxjs.imports.ts but get the same error and then the lint errors do not work.

Thanks a lot for looking into this!

@cartant
Copy link
Owner

cartant commented Aug 22, 2017

No worries. I'll have a look at it tomorrow.

@cartant
Copy link
Owner

cartant commented Aug 22, 2017

The problem is that the Angular CLI runs TSLint three times:

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

If the central imports file is not included in the tests, it's not available in the compiled TypeScript program that TSLint provides to the rules.

You can fix the problem by importing ./src/rxjs.imports.ts in test.ts:

import './rxjs.imports';

and in e2e/app.po.ts:

import '../src/rxjs.imports';

I'll improve the error thrown by the rule to better describe the situation.

@herkulano
Copy link
Author

@cartant thank you so much, it works great now!

@cartant
Copy link
Owner

cartant commented Aug 23, 2017

No worries.

@cartant
Copy link
Owner

cartant commented Sep 16, 2017

@herkulano You might be interested in this issue and this comment. It introduces a somewhat cleaner way of making the rxjs-add rule play nice with @angular/cli.

@kamok
Copy link

kamok commented Nov 10, 2017

@cartant I think you should add to the README: You can fix the problem by importing ./src/rxjs.imports.ts in test.ts:

import './rxjs.imports';

As you've written above. My tests will complain about not finding the rxjs imports otherwise.

@cartant
Copy link
Owner

cartant commented Nov 11, 2017

@kamok The README.md contains a workaround in the @angular/cli gotchas section. I've recommended adding it to the src/tsconfig.spec.json file. I thought that was a cleaner solution, but that's debatable. I will add a note inline with your comment. Thanks.

@kamok
Copy link

kamok commented Nov 11, 2017

@cartant I have no idea why mine didn't work when I added it to the files array of tsconfig.spec.json. Maybe its only my app, but adding it to test.ts did the trick for me.

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

No branches or pull requests

3 participants