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

Add showConfig tsc flag for debugging configs #27353

Merged
merged 8 commits into from
Oct 31, 2018

Conversation

weswigham
Copy link
Member

Fixes #15213

I happened to be in the area today, saw the issue while looking through something else, and though it'd actually be a somewhat useful utility to have.

@weswigham weswigham added this to the TypeScript 3.2 milestone Oct 5, 2018
@weswigham
Copy link
Member Author

Ping @sheetalkamat - would be nice to get this reviewed, too;

@@ -132,6 +132,11 @@ namespace ts {
const commandLineOptions = commandLine.options;
if (configFileName) {
const configParseResult = parseConfigFileWithSystem(configFileName, commandLineOptions, sys, reportDiagnostic)!; // TODO: GH#18217
if (commandLineOptions.showConfig) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Should we intentionally be ignoring this in --b mode? Should it error when invoked without tsconfig file?

Copy link
Member Author

@weswigham weswigham Oct 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it could be fine without a config file - serves as a fine way to convert a response file or other command line args to a tsconfig.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Afaik it is ignored in -b mode; iirc that bails out way early on in the command line parser, since it has its own subset of args.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could have this even in --b just like how we have eg (list files, list emitted files) could be good information I think. Especially in verbose mode?

@weswigham
Copy link
Member Author

weswigham commented Oct 31, 2018

@sheetalkamat I've updated this to support showing a config when there's no config file, but didn't enable it in --b; it just doesn't make much sense there. The only options --b respects are a handful that it takes on the command line only; and if the intent was to question the contents of the configs --b reads to actually perform builds, since it reads more than 1 config, it still doesn't make too much sense (since the point of the flag is to print the config instead of actually running the build the config configures). The functions for pretty printing the options, however, are here if you determine that such output would be useful in the builder's verbose logs.

@weswigham weswigham merged commit a4a1bed into microsoft:master Oct 31, 2018
@weswigham weswigham deleted the show-config-compiler-flag branch October 31, 2018 22:57
@shabbyrobe
Copy link

I tried to use this today but ran into a couple of issues. The first one's simple --showConfig doesn't appear in tsc --help as it should.

The second is that the PR doesn't appear to implement the feature as requested in #15213. I could be using it incorrectly, but my output only shows compilerOptions I've explicitly set myself in my tsconfig.json. I interpret "effective config" to mean "show me everything that's about to be used to compile, regardless of whether or not I set it", but that's not what I see.

@weswigham
Copy link
Member Author

Hmm, as is it contains everything less some things that are implied defaults/equivalent to their defaults. I suppose in that respect it makes more of a minimal config. But not doing that would be... Unfortunate. Because then we'd have to list every option. And there's a lot of options.

@shabbyrobe
Copy link

shabbyrobe commented Jan 14, 2019

And there's a lot of options.

It's true, but that's exactly what I want to see. I'm not sure how else to easily discover what those defaults actually are. I could be off base here, but it looks to me like the documentation for tsconfig.json shows the implied default, but not the resolved one. I might want to extend something that has implied default values when unset, like typeRoots, but retain the existing values. Or I might want to diff my effective config to the effective config of a previous version to track down which new compiler options have influenced my program (I've had to do this the hard way before; it involved a lot of rather nasty console.log() calls in the TypeScript source). A diff can show me that in five seconds flat.

@weswigham
Copy link
Member Author

tsc --init prints with a ton of commented out defaults and help text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants