-
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
tsserver (vscode) does not recognize multiple tsconfig.json in the same directory #8435
Comments
This behaves as intended. there is only one special |
Ok, so with tsserver
then how can you organize code by features/components in a simple way? It is a valid use case. TypeScript very first description line:
|
not sure i understand what you mean by this. if you have a tsconfig per feature/component it is going to work. what is not, is having multiple build configurations for the same feature/component in the IDE. |
by features/components/modules:
vs by type of files:
Link from my previous comment: https://www.google.fr/search?q=organize+code+by+feature
Note: most articles don't mention where the tests should go because most people don't write tests and thus don't mention it. |
I still do not understand why you can not do this with one tsconfig.json per folder. |
Nobody wants to ship something bundled with the tests on a website, so you need 2 tsconfig.json :) Also having 1 build for the app and 1 build for the tests helps: you can easily experiment/hack with the app code without having compile errors about the now outdated tests. (typical workflow: hack -> looks good? -> clean things up + write tests). Sure you can have 3 tsconfig.json instead of 2:
=> More things to maintain :/ |
so why not two tsconfig.json files in two folders, i.e. |
Does not solve the problem, see #5828 (my first attempt before TypeScript 1.8 came out with the I think allowing a tsconfig.json to reference other tsconfig.json (TypeScript 2.1) will simplify things:
You have 3 tsconfig.json files but the one for the IDE is just an empty shell that points to the others: easy to maintain. Another better (and complementary?) solution can be multiple "targets"/builds/projects inside 1 tsconfig.json file (see #1928): {
"compilerOptions": {
"noImplicitAny": true,
"removeComments": false,
"sourceMap": true
},
"files": [
"common/util.ts"
]
"projects": {
"app": {
"compilerOptions": {
"outFile": "app.js"
},
"files": [
"feature1/model.ts",
"feature1/controller.ts",
"feature2/model.ts",
"feature2/controller.ts"
]
},
"unittests": {
"compilerOptions": {
"outFile": "unittests.js"
},
"files": [
"feature1/model.spec.ts",
"feature1/controller.spec.ts",
"feature2/model.spec.ts",
"feature2/controller.spec.ts"
]
},
"e2etests": {
"compilerOptions": {
"outFile": "e2etests.js"
},
"files": [
"feature1/e2e.spec.ts",
"feature2/e2e.spec.ts"
]
},
"app-es3-amd": {
"compilerOptions": {
"target": "es3",
"module": "amd",
"outFile": "app-es3-amd.js"
},
"files": [
"feature1/model.ts",
"feature1/controller.ts",
"feature2/model.ts",
"feature2/controller.ts"
]
}
}
}
|
This is not the intended use of tsconfig.json. it is not meant to be a build orchestration tool nor a solution file. a single tsconfig.json represents a single invocation to tsc.exe/tsc.js. and that is that. for more interesting build/configuration consider using other build tools e.g. MSBuild, grunt or gulp. my recommendations for this scenario are:
|
Obviously, how can you do without? sass/less, minification, launch a server, move files around, call tsc -p...
Does not please the IDE, see #5828. You can check for yourself: https://github.com/tkrotoff/vscode-tsconfig.conf-issue Anyway... |
This is the one I'd recommend as well. The test file should be in a folder above the Project pitchI'll work on improving the set project in alm to take more than files by |
I see now, so you want the tests to be next to your app, but not in the production release. so why not have two tsconfig.json, at the root, one |
YES! :-)
Exactly what I do now
Multiple "targets"/builds/projects inside 1 tsconfig.json has already been proposed: #1928. |
I do not think we will be parametrizing tsconfig.json any time soon, for the same reason i listed earlier. tsconfig.json is just an easy way to call tsc.exe with a punch of parameters. if you want to do something fancier, you should use a build system/ solution file (whatever that would be in your editor).
you can see my argument against using tsconfig.json as a build manager in #3469 (comment). |
extends works for maintaining multiple build files, but there's still an editor issue. Jetbrains (IntelliJ / WebStorm) recently implemented IDE support for selecting the appropriate tsconfig file by exclude / include / files: see the blog post and bug A rough description, they have configurable file name patterns for config files, expanding the lookup for Therefore, you could have, for example:
And have the editor know that, e.g. |
This is an incredibly annoying problem. I understand the argument that Real-world example:
We will not put our tests in a separate I have tried putting a spec-specific I can see that this isn't necessarily a typescript issue - for me it's more of a VS Code configuration issue - I should be able to specify which I'm more in favor of a VSCode config file that would register my two I don't have the perfect solution, but I know that putting things like this at the top of all my spec files: // - tests require packages from devDependencies
// - mocha has side-effects
// - chai has odd syntax
/* tslint:disable no-implicit-dependencies no-import-side-effect no-unused-expression function-name max-classes-per-file no-any */ shouldn't be necessary. And looking at this makes the problems panel in VS Code useless. |
It is well-documented (see 1-6 below) that VSCode doesn't support setups like ours, where multiple tsconfig files coexist in a single directory. Strangely, though, it is only recently that this has become a problem, with VSCode at random intervals forgetting that it's ever heard of `expect` or `describe` (because it's not seeing `tsconfig.test.json`, but taking a while to realize it). There is an open issue[7] tracking the addition of support for this, but it's been open for a long time, with little movement. In the meantime, this solves the problem by adding placeholder `test/tsconfig.json` files to each package, each pointing to its corresponding `tsconfig.test.ts` file. I went with this approach over simply moving and renaming the existing test tsconfigs because this allows us to stay consistent in having all flavors of tsconfig for a package live at the package root level, and provides an easy way to reverse this workaround, should VSCode ever fix the underlying problem. [1] angular/angular-cli#5175 [2] microsoft/TypeScript#49210 [3] microsoft/vscode#107750 [4] microsoft/vscode#12463 [5] sillsdev/bible-karaoke#175 [6] microsoft/TypeScript#8435 [7] microsoft/TypeScript#33094
It is well-documented (see 1-6 below) that VSCode doesn't support setups like ours, where multiple tsconfig files coexist in a single directory. Strangely, though, it is only recently that this has become a problem, with VSCode at random intervals forgetting that it's ever heard of `expect` or `describe` (because it's not seeing `tsconfig.test.json`, but taking a while to realize it). There is an open issue[7] tracking the addition of support for this, but it's been open for a long time, with little movement. In the meantime, this solves the problem by adding placeholder `test/tsconfig.json` files to each package, each pointing to its corresponding `tsconfig.test.ts` file. I went with this approach over simply moving and renaming the existing test tsconfigs because this allows us to stay consistent in having all flavors of tsconfig for a package live at the package root level, and provides an easy way to reverse this workaround, should VSCode ever fix the underlying problem. [1] angular/angular-cli#5175 [2] microsoft/TypeScript#49210 [3] microsoft/vscode#107750 [4] microsoft/vscode#12463 [5] sillsdev/bible-karaoke#175 [6] microsoft/TypeScript#8435 [7] microsoft/TypeScript#33094
Is there any option of rethinking this? |
Example of file organization:
tsc works fine. However vscode does not properly highlight files listed in
tsconfig.spec.json
(like #5828).Using TypeScript 1.8.10 and vscode 1.0
The text was updated successfully, but these errors were encountered: