-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Set TypeScript compiler's base/working directory #25430
Comments
You might be looking for |
Thank you Ryan for a response. But, according to the docs, the I will try to explain better. I have multiple projects with very similar directory structure and compilation requirements. I would like to define compilation options (including relative paths to source files from the root of the project directory) in a single place. Therefore I have a single Consider, I have the following generic
And I have multiple projects like
Also, I don't want to use I hope it makes sense. |
I see. There's currently no support for this but we could think about ways to accomplish it. The scenario makes a lot of sense IMO |
Thanks. I would love to see this implemented. Right now I have to manually use |
This would be great! |
+1 This feature would be awesome |
I have the same use case. My team is currently building out a component library. The repo is a monorepo and each component is written in typescript. Currently I have to have a {
"extends": "../../tsconfig.json",
"include": ["src/**/*", "../../typings/**/*"]
} This is a lot of duplication. I need to add another tsconfig for build related things. To do this in my current setup I would have to double the amount of tiny tsconfigs in the project. I've been playing around with moving the tsconfig to our |
This is a big issue when using |
Very surprising to not be able to compile just the src directory for exemple. I have some utils directories in my projects which I don't need to be compiled. Additionally I would like to have the |
@L1br3 you should be able to have those at the same level. Here is an example https://github.com/hipstersmoothie/eslint-formatter-github |
The rush-stack-compiler-3.4/includes/tsconfig-base.json {
"$schema": "http://json.schemastore.org/tsconfig",
"compilerOptions": {
"outDir": "../../../../lib",
"rootDirs": ["../../../../src/"], This allows it to be imported like in this example: {
"extends": "./node_modules/@microsoft/rush-stack-compiler-3.4/includes/tsconfig-node.json",
"compilerOptions": {
"types": [
"jest",
"node"
]
}
} However this
Really the TypeScript compiler should define tokens that make it more explicit how relative paths are resolved. For example, jest.config.json supports a Also This seems pretty straightforward to implement for TypeScript's |
relative to this current project. See microsoft/TypeScript#25430
relative to this current project. See microsoft/TypeScript#25430
* feat: typescript * fix: prettier * fix: copy ts migrated .js.flow files to es so that parent projects get tricked * chore(avatar): typescript conversion * feat: typescript support for prettier and eslint BREAKING CHANGE: Peer deps have been updated and added. * chore: upgrading to new @box/frontend * fix: merge conflicts * fix: tsconfig should list its own path relative to this current project. See microsoft/TypeScript#25430
@slavafomin One thing you can do is publish your tsconfig in an NPM package, then in each project just |
@RyanCavanaugh One problem is that If there was a new top-level option (f.e. This would then make it feasible that in each project's tsconfig, we could do something simple like {
"extends": "./node_modules/my-configs/tsconfig.json",
"projectDir": "./"
} and at that point any paths in As @octogonz mentioned, being able to specify module identifiers in |
- base, library, and library-build, same as the package exports - initially started with library, but if I wanted to use this repo for apps as well, I wouldn't want some configurations like declarations or declaration maps as they're unused by apps - so split off library and base - library-build doesn't add much and is for a particular use-case, so I also may end up removing that at some point - NOTE: `extends` resolves relative paths based on the location of the _extended_ config file, not the one doing the extension - https://www.typescriptlang.org/tsconfig#extends - This effectively means that all "path-based compiler options" like `outDir`, `outFile`, `rootDir`, `include`, `exclude`, and `files` have to be repeated in all tsconfigs - c.f. microsoft/TypeScript#29172, microsoft/TypeScript#25430 - so the usage of them here is more of as an "example" of sorts of what should be repeated, as installing from NPM would result in the paths here being _inside_ `node_modules` (or elsewhere pending the NPM client you use)
Any updates on this? |
It looks like TypeScript compiler resolves files relative to the location of the
tsconfig.json
file (however, I couldn't find anything about paths resolution in the official documentation).Is there a way to specify an alternative base/working directory, which will be used for relative paths resolution?
I want to use a generic
tsconfig.json
file to compile multiple projects in various directories (one at a time).P/S: I've created a question on StackOverflow first, but haven't received any attention there, so I've decided to ask here directly.
The text was updated successfully, but these errors were encountered: