You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If no "files" property is present in a tsconfig.json, the compiler defaults to including all TypeScript (*.ts or *.tsx) files in the containing directory and subdirectories. When a "files" property is present, only the specified files are included.
I tried just removing those, but the project failed to build after that - for webpacky reasons I'm not familiar with (apparently proceeding to compile everything, as opposed to only files that can be discovered by crawling dependencies starting from app.ts, as tsify is doing)
It's not next to our node_modules, but in a directory that contains our apps ts code. In the angular2-webpack-starter, this would be either src/ or src/app
actually it does make more sense to have tsconfig.json in src/ and another one in test/ then we can omit files without having to worry about different environments
I've never seen anything about "files is an anti-pattern". Nor have I seen the issue in VSCode that is described. What are you trying to fix? The file won't be picked up until it's either imported or included in the files array, but I wouldn't say that makes files an anti-pattern (I'd love some data on that, since it works as expected - their basically entry points to the application for compilation).
"Entry point" for collecting files should be app.ts (or at least it's with tsify). If dependency tree from app.ts is sufficient (don't know enough/anything about webpack to know for sure TBH), the files section seems redundant, no? It's certainly a bit of a pain to maintain (think merge conflicts when everyone is adding new files, etc)
I'm not sure if you missed what entry point means, but files doesn't include every single TypeScript file you manually added to the project. It's the entry files to start compilation. And yes, that's the error message because you haven't imported it, once you import it it'll be included in the project. The reason you get that error is because it's not referenced or included anywhere. Honestly, I wouldn't drop using the files array for any reason, even using exclude can be a pain in the ass.
I didn't understand any of the last paragraph, sorry. What are you trying to say there? Files is used by the TypeScript compiler and tooling. Both the TypeScript compiler, tooling, Webpack, tsify, anything will resolve imports as I described above, but the compiler and tooling doesn't use tsify, it uses tsconfig.json. Sure, you can omit files, but then you have to use exclude instead otherwise you might end up compiling something outside the scope of the project. You end up with a blacklist instead of a whitelist. Whitelists seem easier to maintain here, since compilation will be explicit instead of implicit.
If those are removed from tsconfig.json (meaning that the user will not end up maintaining the file most of the time), that would be fine as well.
Visual Studio Code understands tsconfig.json doesn't have "files" property, as said it understands all .ts (and .d.ts) files contained in the directory tree under the tsconfig file itself. Don't know about Atom.
Yes, seems redundant to me too. But I'm not the person to fix this, just responding because I was pinged unceremoniously. @gdi2290 Fix your shit. The other option is using exclude and basically doing the inverse, but I prefer things to be explicit instead of implicit anyway - includes should land in tsconfig.json soon which will resolve this forever.
Yes, Atom and Sublime and other tooling also understands this also. But you have to exclude everything that's not meant to be included and I can tell you that's a pain sometimes and I wouldn't recommend it as the default. At a minimum, you'll have to start with node_modules. Also, you can't use files with exclude, which means the second some file inside of an excludes needs to be included (E.g. a module provides you an ambient declaration, such as reflect-metadata) you can no longer use exclude properly.
Activity
PatrickJS commentedon Dec 21, 2015
can you make a pull-request and also set
rewriteTsconfigto falsevivainio commentedon Dec 21, 2015
I tried just removing those, but the project failed to build after that - for webpacky reasons I'm not familiar with (apparently proceeding to compile everything, as opposed to only files that can be discovered by crawling dependencies starting from app.ts, as tsify is doing)
PatrickJS commentedon Dec 22, 2015
I removed the files but now I have to exclude everything :/ I also ran into a problem with typings and protractor's ambient type definition file.
cc @blakeembrey
what do you recommend?
vivainio commentedon Dec 22, 2015
For reference, here is all we have in our tsconfig.json (but as said, we are using tsify):
{ "compileOnSave": false, "compilerOptions": { "module": "commonjs", "sourceMap": false, "moduleResolution":"classic", "target":"es5" } }It's not next to our node_modules, but in a directory that contains our apps ts code. In the angular2-webpack-starter, this would be either src/ or src/app
PatrickJS commentedon Dec 22, 2015
actually it does make more sense to have
tsconfig.jsoninsrc/and another one intest/then we can omitfileswithout having to worry about different environmentsblakeembrey commentedon Dec 22, 2015
I've never seen anything about "files is an anti-pattern". Nor have I seen the issue in VSCode that is described. What are you trying to fix? The file won't be picked up until it's either imported or included in the files array, but I wouldn't say that makes files an anti-pattern (I'd love some data on that, since it works as expected - their basically entry points to the application for compilation).
vivainio commentedon Dec 22, 2015
It looks like this before the file is imported somewhere:
Empty files section is used as starting point e.g. here:
"Entry point" for collecting files should be app.ts (or at least it's with tsify). If dependency tree from app.ts is sufficient (don't know enough/anything about webpack to know for sure TBH), the files section seems redundant, no? It's certainly a bit of a pain to maintain (think merge conflicts when everyone is adding new files, etc)
blakeembrey commentedon Dec 22, 2015
I'm not sure if you missed what entry point means, but
filesdoesn't include every single TypeScript file you manually added to the project. It's the entry files to start compilation. And yes, that's the error message because you haven't imported it, once you import it it'll be included in the project. The reason you get that error is because it's not referenced or included anywhere. Honestly, I wouldn't drop using the files array for any reason, even using exclude can be a pain in the ass.blakeembrey commentedon Dec 22, 2015
I didn't understand any of the last paragraph, sorry. What are you trying to say there? Files is used by the TypeScript compiler and tooling. Both the TypeScript compiler, tooling, Webpack, tsify, anything will resolve imports as I described above, but the compiler and tooling doesn't use tsify, it uses
tsconfig.json. Sure, you can omit files, but then you have to use exclude instead otherwise you might end up compiling something outside the scope of the project. You end up with a blacklist instead of a whitelist. Whitelists seem easier to maintain here, since compilation will be explicit instead of implicit.vivainio commentedon Dec 22, 2015
@blakeembrey currently tsconfig.json includes (redundand?) files that are referenced from app.ts:
app.ts:
If those are removed from tsconfig.json (meaning that the user will not end up maintaining the file most of the time), that would be fine as well.
Visual Studio Code understands tsconfig.json doesn't have "files" property, as said it understands all .ts (and .d.ts) files contained in the directory tree under the tsconfig file itself. Don't know about Atom.
blakeembrey commentedon Dec 22, 2015
Yes, seems redundant to me too. But I'm not the person to fix this, just responding because I was pinged unceremoniously. @gdi2290 Fix your shit. The other option is using
excludeand basically doing the inverse, but I prefer things to be explicit instead of implicit anyway - includes should land intsconfig.jsonsoon which will resolve this forever.Yes, Atom and Sublime and other tooling also understands this also. But you have to exclude everything that's not meant to be included and I can tell you that's a pain sometimes and I wouldn't recommend it as the default. At a minimum, you'll have to start with
node_modules. Also, you can't usefileswithexclude, which means the second some file inside of an excludes needs to be included (E.g. a module provides you an ambient declaration, such asreflect-metadata) you can no longer useexcludeproperly.Edit: Grammar.
vivainio commentedon Dec 22, 2015
I made a PR that removes redundant files (making this less confusing), #176. Stuff still seems to work (at least on vscode, didn't try with Atom).
bootstrap.ts is a sufficient starting point for the app itself
PatrickJS commentedon Jan 3, 2016
I would have to exclude
node_modulesandtypingsfor it to work since there is a problem with protractors type definitionPatrickJS commentedon Jan 15, 2016
entry files are now the only files other than spec files which needs to be fixed too. Closing for now