-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Exclude some files from typechecking #8082
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
Comments
FYI, at Google we wrapped the compiler and pass an additional argument which is the list of "immediate" ts inputs to the compilation. Then we typecheck exactly these files. |
This is something we have talked about before. i do not see an issue in doing this under a flag in tsc. |
Using the compiler API, you have full control on what files you typecheck (i.e. call getSemanticDiagnostics for). you can choose to do this for all files (default), exclude lib.d.ts (with |
@mhegazy I'll add a configuration option into awesome-typescript-loader, but I'd like to see this option in Maybe it's enough to have a global flag like |
Compiler comments like I'll need something like this for alm as I start to use it to demonstrate migrating JavaScript code bases 🌹 |
closing in favor of #8124 |
To loop back on this, we have discussed this at length in today's design meeting. there are two aspects here, 1. correctness and 2. speed. The language semantics allows for semantic errors to be produced in definition file from other files in the compilation. for instance, consider two definition files defining the same variable, or the same member of a type, if the errors were ignored, the user will get an undefined behavior with no warning. this will also mean a dependency on error recovery logic in the compiler to build a project, which is not defined, and not intended to have a defined and supported behavior. Correctness and predictable behavior of the compiler would trump speed. at least for the general public. and that is why we will not be supporting a flag to enable this. For the API users, however, if you are aware of the ramifications of not checking definition files, and you are sure of their correctness (possibly through an out-of-band type check), then you can leverage that knowledge and skip checking them. I have a write-up on why this would be bad for general user experience in #8124 (comment). |
cross posting here as well.
|
Hello. It's mostly a question and not a suggestion, but I want to hear your opinion. In my company we have a graph database, which allows to acquire it's model structure via API, and we use this information for code generation.
So we generate a lot of
.d.ts
files which describe our database structure, and then distribute these typings as a separate library which everybody can use in projects. Out database has special query syntax to receive nested model relations, so definition files can't be isolated and used by one.The issue here is that this library already weights about
2MB
and it still grows. So we have about300Kb
-400Kb
applications and the huge generated support library. Compilation time without the library is about1-2sec
, but with library it grows up to5-6sec
.My question: is it possible, using current TypeScript compiler architecture, to disable some sort of typechecking for the files that are considered good (because they are auto-generated) and never have errors?
I understand that compiler still needs to analyze types to know the shape of objects, because it must type-check usages of types, but my question is about disabling some sort of checks that compiler possibly makes for declarations.
The text was updated successfully, but these errors were encountered: