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

Performance of getSemanticDiagnostics in compiler API #5192

Open
use-strict opened this issue Oct 9, 2015 · 2 comments
Open

Performance of getSemanticDiagnostics in compiler API #5192

use-strict opened this issue Oct 9, 2015 · 2 comments
Labels
API Relates to the public API for TypeScript Help Wanted You can do this Suggestion An idea for TypeScript
Milestone

Comments

@use-strict
Copy link

The setup is somewhat similar to the one in the compiler API example (https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#incremental-build-support-using-the-language-services)

The problem, as in the example, is that errors are reported only for files that were directly changed. It doesn't cover the case in which the changed file was a dependency of another file, and even though the file depending on it was not changed, it will still have errors, which won't be reported.

To be more specific, the setup I am talking about is ts-loader + webpack.

What happens is that getSemanticDiagnostics(file) has to be called for every file in the project, which ends up increasing the incremental build times considerably. Even program.getSemanticDiagnostics() iterates through all of the source files as it is seen in the typescript source code.

I can only see this problem fixed from the compiler API. It could expose a method which finds all files dependent on a given file. Because in an incremental build only a single file changed, this should be faster than calling getSemanticDiagnostics() for each and every project file.

The alternative would be some sort of caching on getSemanticDiagnostics() itself, but the compiler would probably have to do internally the same work as above to invalidate the cache on file change. This seems to be equivalent to a getSemanticDiagnosticsForFileAndDependents(file)-like function.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 13, 2015

you analysis is correct. we need an API that given a file it can give you 1. list of dependencies, and 2. list of dependents. this way you know you have covered all your bases.

@mhegazy
Copy link
Contributor

mhegazy commented Oct 13, 2015

also related #3687

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Relates to the public API for TypeScript Help Wanted You can do this Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants