-
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
Adds tsc --init option #4037
Adds tsc --init option #4037
Conversation
I could alternatively put |
@@ -26,6 +26,12 @@ namespace ts { | |||
return undefined; | |||
} | |||
|
|||
export function writeConfigFile(file: string, compilerOptions: CompilerOptions, fileNames: string[]): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be in tsc.ts, i would even inline it there.
@mhegazy could you please reconsider supporting comments. In addition to giving people verbose description, people might want to make annotations themselves in the config file. I can rework my PR if it it doesn't fit TS. |
I am fine doing comments. i just want them in a different change, it will make it easier to focus on one issue at a time, i.e. what are the defaults or the right things to emit, instead of talking about comments and parsing. In general i think writing the output should be simpler. for JSON comments, i would be incline to use the scanner to write a small JSON parser, instead of removing comments. |
But then you would need to create a JSON parser? Right now, I think it is easier to remove the comments and pass them to |
I just updated the PR.
Can we skip splitting the comments in another PR? It is really a small addition(15-20 LOC) to this PR and splitting it out means quite much work for me. I mean saving it another branch and then to remember the branch and merge later and sync changes. |
ping @mhegazy |
let { optionNameMap } = getOptionNameMap(); | ||
writeConfigFile(); | ||
|
||
function writeConfigFile() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i do not think we need a full JSON serializer. That was my inital comment. for me this function, without the support for comments, can be written as:
JSON.stringify(opt, (k, v) => {
switch (k) {
case "target": return scriptTargetToString(k);
case "module": return moduleKindToString(k);
case "init":
case "watch":
case "version":
case "help":
return undefined;
default: return v;
}
}, " ");
sorry for the delay. let me clarify my comments earlier..
|
@mhegazy I just update the PR, please take a look when you have time. |
Sorry for the delay. I have manually merged it as there were merge conflicts, i have also marked the new declarations with the |
@tinganho feel free to send your original changes for supporting comments in a separate PR. |
@mhegazy - I like the feature but I think for editors it would be more useful if this would be exposed via |
created #4466 to track the new feature. |
Fixes #3079.
Defaults to compiler options:
The compiler options are overridable and you are able to define more options via the CLI(with the exception of the CLI options
help
,watch
,version
,init
).Defaults to no
files
property but if one invokes with files:It will add a files property with the specified files.
Adds an exclude of
node_modules
folder only.It outputs comments and trailing commas in
tsconfig.json
. So this PR also adds parsing/stripping of comments and trailing commas intsconfig.json
file.