Skip to content
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

Specify a tsconfig.json for use with tsc on the command line #5858

Closed
IceDragon200 opened this issue Dec 1, 2015 · 5 comments
Closed

Specify a tsconfig.json for use with tsc on the command line #5858

IceDragon200 opened this issue Dec 1, 2015 · 5 comments
Labels
Question An issue which isn't directly actionable in code

Comments

@IceDragon200
Copy link

Expected:

# works like normal, loads ./tsconfig.json
tsc
# specifying a different tsconfig
tsc --config /path/to/a/tsconfig.json

# example: specifying different config files 
tsc -c /configs/typescript/es3-commonjs.json --outDir ./build/es3
tsc --config /configs/typescript/es5.json --outFile ./build/production.js
tsc --config /configs/typescript/es6-experimental.json --outFile ./build/staging.js

# the order of the parameters should be respected, configs are loaded and their options overloaded 
# by the ones specified on the command line
tsc -c config.json --outDir ./build
# in this case, the config is loaded, and its outDir is overriden if defined
tsc --outDir ./build -c config.json
# outDir is set, but overriden by the config if set

If tsc is able to load a tsconfig.json, why can't I specify what to load?

Certainly I could use the @text.txt format, but that's no fun, I even tried tsc @tsconfig.json only to be met with errors (you couldn't extract the extension from the filename and just load it as a json file, like really?).

@mhegazy
Copy link
Contributor

mhegazy commented Dec 1, 2015

the flag name is --p or ``--projectand notconfig`. it takes the path the the folder containing tsconfig.json, and starting with 1.8, it will allow a full path to the file (see #2869)

you can find more information about this in https://github.com/Microsoft/TypeScript/wiki/tsconfig.json#using-tsconfigjson

@mitermayer
Copy link

I also expect to be able to provide my own configuration that should not reside in the root of the project

@mhegazy
Copy link
Contributor

mhegazy commented Jun 30, 2016

I also expect to be able to provide my own configuration that should not reside in the root of the project

sure. --p argument can be a file path. you can pass any valid json file to it.

@e-cloud
Copy link
Contributor

e-cloud commented Oct 20, 2016

@mhegazy how can i compile only one file with a tsconfig.json using tsc, inside a project with many .ts files

@mhegazy
Copy link
Contributor

mhegazy commented Oct 20, 2016

@mhegazy how can i compile only one file with a tsconfig.json using tsc, inside a project with many .ts files

there is no way to do this currentlly. your best bet is to specify a new tsconfig.json extends the exiting one (see #9876), and add your file to it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Question An issue which isn't directly actionable in code
Projects
None yet
Development

No branches or pull requests

4 participants