-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Discovering .ts files under node_modules resulting in them being compiled (2) #22228
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
add |
@mhegazy it seems not to help in this case -
I still getting js/map files generated in installation folder inside node_modules |
Do you need a simple demo for reproducing? |
do you have an import to a module in the package that is being built? if so then that is expected.. see https://github.com/Microsoft/TypeScript/wiki/FAQ#why-is-a-file-in-the-exclude-list-still-picked-up-by-the-compiler for more details. it seems that this is a bug in the package that you are importing, a .ts file should not be exported from a package. to work around this add a |
yes, the app imports modules from the lib. And only that imported modules are being compiled.
Not sure I understand. Why is it a bug? The app is written in TS and the lib is written in TS, of cause the app imports TS modules from the lib. |
the lib has either First, as a library author you do not want your users to recompile your sources every time they compiler their code. this is a lot of wasted compile time. second, the library author may not be using the same setting as their user do, e.g. The compiler thinks of any |
yes, that's what the issue about and another argument - the ability to debug ts code - with d.ts users will have to debug js in lib.
ok, this is the reason. |
I do not think this is a good idea.. now if they want to use a new compiler version that causes a new error in your code, what do they do? they can not fix these issues anyways.. and why wast compiler cycles compiling the same code over and over.. that is exactly what .d.ts files are for..
that is not true. just include your sources, and soruce maps. just do not make it the resolution location for your package.. e.g. your package can have
that is not always the case. in mono-repo projects, ppl have links between their node_modules, and they expect them to all compile.. we have users who depend on that behavior. |
if *.ts always come with d.ts then a question arises - why do you need *d.ts? if only for avoiding compilation then it could be achieved by other ways - as I said by telling the compiler where to stop or ignore node_modules (ok, with a flag) honestly it's a big surprise for me that libs can't export *.ts and should be recompiled to *.d.ts.
that would be a problem but it also can happen with *d.ts as well.
why this |
A .d.ts does not have expressions.. it represents the shape of the API. it is significantly smaller version of the .ts file. it takes less time to compile, and more importantly it is the API shape, no errors to be reported here.. A .d.ts describes the part of your package your users care about, i.e. the public API you expose; how that is implemented is not so much of interest here. I think we are now debating some basic concept of should you export your code to your users or expose a declaration file. Our position on this is you should expose a declaration file. implementation details that do not impact the API contract, should not be exposed to API authors. |
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed. |
With this config object from aviabird angular 5 seed project I did not get any compilation errors from "node_modules": { |
There's the issue #6964. It's closed and "fixed".
But I still have this problem in TS 2.7.1
There's an app with the following
tsconfig.json
which has a dependency to a lib. The lib is installed via npm into node_modules. When the app is being compiled then lib is compiled as well.It's undesirable.
As you can see the tsconfig includes all app files but no lib's files. So I don't want the lib in node_modules was compiled.
Expected behavior:
No compilation happen for lib files inside node_modules.
Actual behavior:
Compilation does happen.
The text was updated successfully, but these errors were encountered: