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

Saving non emitting files causes failure in resolving paths from tsconfig.json for es6 imports #75

Closed
vleandersson opened this issue Nov 22, 2017 · 7 comments

Comments

@vleandersson
Copy link

First of all, thank you very much for this awesome plugin! Keep up the good work!

Description
We are building an Angular (v4) application, using webpack, angular2-template-loader and awesome-typescript-loader, and want now to lint our project with an async linter, i.e. fork-ts-checker-webpack-plugin. The setup works fine for files emitting js, but non emitting files (interfaces, html etc) causes a failure in resolving our defined paths in tsconfig.json. For the questionmarks around the html files, angular2-template-loader triggers a build on them from a save in an html file, as expected.

We have identified an "ugly" fix in IncrementalChecker.ts, where our problem disappears by loading programConfig every iteration (i.e. remove if (!this.programConfig) ). This seems to solve the problem.

We have identified that the host.getSourceFile function runs twice for files emitting js, but only once for non emitting files.

Technical spec
@angular/* version 4.3.5
typescript: 2.3.2
"webpack": "^2.4.1"
"tslint": "^5.4.3",

Reproduce
This error could not be reproduced in a new clean repo. Help needed!!!

@piotr-oles
Copy link
Collaborator

It will be hard to help you without reproduction repo :/ My first guess is some bug in Typescript if you use newer version of ts in the new clean repo :)

@vleandersson
Copy link
Author

vleandersson commented Dec 11, 2017

@piotr-oles here is our fix. Upp till 1.0 fixes this problem for us. Do not propose you to use the same method, since its an ugly hack. Thou 1.1 (latest commit) might be of intrest for you. It fixes a bug that we have not reported here. It fixes our problem of linting for templates (Angular v. 4) gets stuck, i.e. you use a private variable in the view, which with angular-template-loader triggers a save and linting error. This is then caought in your plugin, but when you fix the linting error its stuck till you restart the watch.

Here is the commit that fixes the above problem: vleandersson/ugly-ts-checker-webpack-plugin@6514797

Fixes bug in prev. commit : https://github.com/vleandersson/ugly-ts-checker-webpack-plugin/pull/2/commits

Please use as you like :)

/V

@johnnyreilly
Copy link
Member

johnnyreilly commented Dec 11, 2017

This doesn't look like the worst fix in the world 😄. Maybe we should use it?

@vleandersson
Copy link
Author

vleandersson commented Dec 11, 2017

@johnnyreilly updated the code for a bug when file list is empty. Se old comment for details.

Go nuts! :)

@johnnyreilly
Copy link
Member

@piotr-oles what do you think?

@piotr-oles
Copy link
Collaborator

piotr-oles commented Jan 9, 2018

@vleandersson Your fix looks good, could you create a PR? :) Sorry for delay :/

@pelotom
Copy link
Contributor

pelotom commented Jan 9, 2018

I'm curious if this is related to #74 at all, since that also has symptoms of not resolving paths after saving a file. However there the condition of being a non-emitting file seems to be sufficient but not necessary. I have a reproducing project here:

https://github.com/pelotom/fork-ts-checker-bug

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

4 participants