-
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
[CLI DX] Improve the output for tsc --init
#45714
Comments
Hey @orta, i would like to try implementing it. |
Sure, give it a shot - until there's a solid WIP PR it's open for anyone to give it a go. |
Hi @orta! I’ve made some progress on this, but I’d appreciate some guidance as to whether I’m on the right track and how to deal with a couple problems I’m running into: Getting serialized option valueI believe we’d want the new logic for outputting the set values to live in My current approach is to export that function so that I can use it in Determining if defaultThe other thing I’m struggling with is how to determine whether a config value is different from the default. I saw there's a Do you have suggestions for figuring out if a value isn’t a default? Should I be hardcoding something for the specific options listed in this issue? I appreciate any help you can offer! And also, @AlexMunoz, if you've attempted this too and have any advice, let me know! Thanks! |
Ace! Re: Getting serialized option valueExporting that function and marking it internal is 👍🏻 ( that might even mean I can opt in to sneakily re-use it in the playground too) - it's the same pattern use for Determining if defaultInteresting, I wonder if we can generate a 'blank' tsconfig object and compare the one generated by that with the one we're about to make and see what the differences are there instead. Will look in the code now. Maybe |
From a quick test it seemed like From what I can tell, it seems like an approach like generating a blank tsconfig wouldn't work because the default settings aren't applied at the tsconfig level, but at a later point. For example, the default setting for I think based on that it would be hard to know what the default for any given setting is without having to hardcode something like "for I think this gets particularly complex for settings like I'd appreciate any thoughts you have - I'm not sure if I'm overcomplicating something here or if this is actually complicated! |
Hi @orta, following up to see if you have any further suggestions! I'm still interested in taking this on, but was feeling blocked on how to figure if a setting is different from the default. |
Ah sorry - this issue isn't assigned to me, so it falls through some of my email filters. Some great questions, after digging through the code I think maybe it's worth thinking about it from scratch again. From a design perspective:
Should show the diff from the blank tsconfig.
Should show es2015 for target, instead of the current es5.
We probably want to also include This means we have two sets of inputs we want to show, and instead of trying to take two tsconfigs and resolve the difference, we can instead use the known sets of changes and work to present them. So we have this code in the compiler: export const defaultInitCompilerOptions: CompilerOptions = {
module: ModuleKind.CommonJS,
target: ScriptTarget.ES5,
strict: true,
esModuleInterop: true,
forceConsistentCasingInFileNames: true,
skipLibCheck: true
}; Which is the If you struggle to find a way to go from ScriptTarget.ES2015 (1) to "es2015" leave that to me, and I'll figure that out and make something general, it can just print the number Maybe then we drop the requirement that |
Hi @orta, @wizered67 I have tried to fix this, not sure if this is the right way. If you have any advice, let me know. |
Suggestion
As of 4.4, a run of
tsc
looks like:I propose instead we change this message to provide more context about a few key values which have been set:
Example
The qualifiers for whether something should be included in the list is that
showInSimplifiedHelpView: true
and the value is not the default. In the case abouttarget
ises5
but the default ises3
for example.The cute little right aligned logo is used in
tsc --help
so you can re-use that code.It's worth noting that a user can pass in defaults via
tsc --init --target es2017
, but I think that occurs before the code where you would write this, so it's just context which might be useful for testing.Exceptions
None that I can think of.
The text was updated successfully, but these errors were encountered: