FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Generate diagnostics without a leading comma, retain old spaces by weswigham · Pull Request #17534 · microsoft/TypeScript · GitHub

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .ts  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
16 changes: 6 additions & 10 deletions scripts/processDiagnosticMessages.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,16 @@ function buildInfoFileOutput(messageTable: InputDiagnosticMessageTable): string

function buildDiagnosticMessageOutput(messageTable: InputDiagnosticMessageTable): string {
let result = '{';
let first = true;
messageTable.forEach(({ code }, name) => {
if (!first) {
first = false;
}
else {
result += ',';
}

const propName = convertPropertyName(name);
result += `\r\n "${createKey(propName, code)}": "${name.replace(/[\"]/g, '\\"')}"`;
result += `\r\n "${createKey(propName, code)}" : "${name.replace(/[\"]/g, '\\"')}",`;
});

result += '\r\n}';
// Shave trailing comma, then add newline and ending brace
result = result.slice(0, result.length - 1) + '\r\n}';

// Assert that we generated valid JSON
JSON.parse(result);

return result;
}
Expand Down

Back | FazBrowse Home | New Git URL