-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Is it really truly wrong to have an empty array for files
in the config?
#12762
Comments
I understand that this change in behavior was intentional and for good reason, like, if you aren't intentionally asking not to compile anything, then it's probably bad if the compiler doesn't compile anything and also doesn't let you know. So, by way of suggestion, maybe there can be an explicit config file flag that indicates "really, zero files are being listed intentionally." |
We have added the error to avoid users calling the compiler with no input and wondering why they got no outputs. tsloader calls the compiler API, it can change the config before passing it to the compiler. |
But what can it change the config to in order to successfully tell TypeScript that it's okay that the config explicitly specifies zero files? Near as I can tell, there's nothing straightforward it can do to say that. (One workaround is to add a dummy entry to Adding a flag to that effect is the suggestion I made in the second comment on this bug, above. |
add a single file that it is using? or ignore the errors? i have a made a similar change for ts-node: https://github.com/TypeStrong/ts-node/pull/226/files |
In this case, there isn't actually any file at all (see original description). The config file is loaded (and specifies zero files), and then the resulting compiler is used to compile arbitrary individual files. Maybe |
So you're simply using TypeScript to verify your |
Like I said before, I'm just a consumer of `ts-loader` who suddenly started
seeing errors reported unexpectedly (with the version bump), and with only
a basic understanding of how it's all hooked up. Please forgive my
ignorance.
Ultimately, that no-files config gets used / reused when actually compiling
a file, but at the moment the compiler is instantiated, it doesn't have a
list of files to compile, yet something *does* make a call to check the
config file. You can see the code in question on the `ts-loader` bug I
linked to.
Thanks for looking into this.
|
All my files are in |
@hilts-vaughan why not use the |
Legacy reasons, mostly up until this point. Is |
It seems like it still does this even if |
|
What I mean is that instead of using |
Also if you need to support |
Yet more who are requesting an option to disable this error when there are 0 files! Why the stubbornness? Just support what your users want! You are now forcing to use stupid workarounds, like having empty .ts files! http://stackoverflow.com/q/41211566/550975 |
I don't understand the use case? If you have zero files and you know you have zero files (in order to be in a position to specify the flag), why not just not invoke tsc ? |
@RyanCavanaugh more recent context from @serjster here: #13656 |
It is easier for us to just have all of our 30+ projects to have the same configs, we can automate such things, but having to deal with whether or not there are any ts files to only then have our automated azure builds run tsc is not practical, however because tsc failed our automated builds now fail as well. This change basically causes a bunch of our automated builds to fail! We have standardized templates that we use in all of our projects and this prevents us from using them... |
I agree with much of the sentiment here. Consider another case: creating a new project and configuring typescript is often the first step for many teams. The notion that their initial project will throw an exception when no ts has been written yet is jarring. The absence of anything to compile shouldn't throw an exception, it should succeed with ease. |
Maybe this could be downgraded to a warning? |
Same issue as @serjster here: I'd prefer to keep an homogeneous config and not see some of my ICs fail due to this error. Keeping this behavior but providing a flag to demote this to a warning would definitely do the trick for me. |
I have a repository specifying data structure types. I have a The only work around I've found so far is to add a "blank.ts" file in |
Hi, I'm trying out the Salsa language service in an ASP.NET MVC 5 project where everything is still JavaScript, but I enabled Salsa just to have IntelliSense for e.g. jQuery and Kendo via @types packages. So, in this IntelliSense-only scenario, the officially recommended way of making the compiler happy is to add an empty dummy file to the project because the "include" array must not be empty, right? |
No. make sure the tsconfig.json content kind is In the next release of VS we will also add support for jsconfig.json to avoid this whole issue. |
@mhegazy : I followed your instructions and set the build action for tsconfig.json to "None" and added true to my project file. Anyway, I stopped my Salsa experiment and disabled it now. That's because I learned that it doesn't seem to understand my ES3 style JS "classes" in IIFE "namespaces" . So it gives me nice IntelliSense support for external libraries (via "d.ts" files), but removes support for my own JS code. I need IntelliSense for my own code more than for those external libraries, so the decision was easy. |
@Casimodo72 these seems to be a few issues going on here. the error again means that the files were not picked. so I will need some additional info to debug the issue. can you share a project?
We are making some changes, to address some of these issues in #21974, if you can share a sample of the issues you are running into we can make sure we have them fixed. |
@mhegazy My experiment is located inside my current web project, so I can't share it. But you're welcome to look at it via team viewer or similar :-) The last time I tried it even didn't pick up the "index.d.ts" in @types folders for me. Maybe I was doing something fundamentally wrong. My issue regarding "classes" and IIFE "namespaces": The only difference to my scenario is that I'm writing: "var fn = Animal.prototype; instead of the playground's generated code: "Animal.prototype.move = function" But I could adapt to "Animal.prototype.move = function" if that would be supported by Salsa. |
@mhegazy Ok, I fixed my scenario and added the folder with my JS code to the list of "include". |
Please share a project we can use to diagnose the issue. |
We'll be allowing zero-input compilations if a |
See above comment - this behavior is now available in the nightly build / |
@RyanCavanaugh When it will be in NPM? |
@Delagen shipped with 3.0 on Monday |
@RyanCavanaugh seems still emit TS18003 |
Did you add the empty |
I supply empty include array. |
Did you add the empty |
What is the references? I didn't find any tsconfig property with this name. |
{
"compilerOptions": { /* ... */ },
"references": []
} |
References is for separating projects from main entry. I want to disable load any files at start. And load its manually. When I use tsconfig.json with webpack all files from current directory included by default. |
AFAICT this works with empty
|
TypeScript Version: 2.1.4
Code
Expected behavior:
tsc
doesn't complain about not actually getting asked to compile anything.Actual behavior:
The error as noted.
Context:
It is of course pretty silly to actually use the TS compiler on the commandline and with an actual
tsconfig.json
in the way demo'ed here. However, in the case of using thets-loader
module to hook up the TS compiler to Webpack, this is how it sets itself up. (I'm just a user ofts-loader
, not a developer of it, so please take this with a grain of salt.) AIUIts-loader
sets up the basic config with an emptyfiles
, and then makes separate calls to compile each file it's asked to, one at a time. This arrangement worked as oftypescript
version 2.0.10, but it broke as of 2.1.4.I also filed TypeStrong/ts-loader#405 on
ts-loader
. It's not clear to me what the best way to address the issue is.The text was updated successfully, but these errors were encountered: