MCPcopy Index your code
hub / github.com/nodejs/node / generateTSConfig

Function generateTSConfig

test/fixtures/snapshot/typescript.js:41312–41386  ·  view source on GitHub ↗
(options, fileNames, newLine)

Source from the content-addressed store, hash-verified

41310 */
41311 /* @internal */
41312 function generateTSConfig(options, fileNames, newLine) {
41313 var compilerOptionsMap = getSerializedCompilerOption(options);
41314 return writeConfigurations();
41315 function makePadding(paddingLength) {
41316 return Array(paddingLength + 1).join(" ");
41317 }
41318 function isAllowedOptionForOutput(_a) {
41319 var category = _a.category, name = _a.name, isCommandLineOnly = _a.isCommandLineOnly;
41320 // Skip options which do not have a category or have categories which are more niche
41321 var categoriesToSkip = [ts.Diagnostics.Command_line_Options, ts.Diagnostics.Editor_Support, ts.Diagnostics.Compiler_Diagnostics, ts.Diagnostics.Backwards_Compatibility, ts.Diagnostics.Watch_and_Build_Modes, ts.Diagnostics.Output_Formatting];
41322 return !isCommandLineOnly && category !== undefined && (!categoriesToSkip.includes(category) || compilerOptionsMap.has(name));
41323 }
41324 function writeConfigurations() {
41325 // Filter applicable options to place in the file
41326 var categorizedOptions = ts.createMultiMap();
41327 for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
41328 var option = optionDeclarations_1[_i];
41329 var category = option.category;
41330 if (isAllowedOptionForOutput(option)) {
41331 categorizedOptions.add(ts.getLocaleSpecificMessage(category), option);
41332 }
41333 }
41334 // Serialize all options and their descriptions
41335 var marginLength = 0;
41336 var seenKnownKeys = 0;
41337 var entries = [];
41338 categorizedOptions.forEach(function (options, category) {
41339 if (entries.length !== 0) {
41340 entries.push({ value: "" });
41341 }
41342 entries.push({ value: "/* ".concat(category, " */") });
41343 for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
41344 var option = options_1[_i];
41345 var optionName = void 0;
41346 if (compilerOptionsMap.has(option.name)) {
41347 optionName = "\"".concat(option.name, "\": ").concat(JSON.stringify(compilerOptionsMap.get(option.name))).concat((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ",");
41348 }
41349 else {
41350 optionName = "// \"".concat(option.name, "\": ").concat(JSON.stringify(getDefaultValueForOption(option)), ",");
41351 }
41352 entries.push({
41353 value: optionName,
41354 description: "/* ".concat(option.description && ts.getLocaleSpecificMessage(option.description) || option.name, " */")
41355 });
41356 marginLength = Math.max(optionName.length, marginLength);
41357 }
41358 });
41359 // Write the output
41360 var tab = makePadding(2);
41361 var result = [];
41362 result.push("{");
41363 result.push("".concat(tab, "\"compilerOptions\": {"));
41364 result.push("".concat(tab).concat(tab, "/* ").concat(ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_to_read_more_about_this_file), " */"));
41365 result.push("");
41366 // Print out each row, aligning all the descriptions on the same column.
41367 for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) {
41368 var entry = entries_2[_a];
41369 var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b;

Callers

nothing calls this directly

Calls 2

writeConfigurationsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…