Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ceeeb9c

Browse filesBrowse files
Always preserve new lines for array and object literals and additional constructs like blocks.
1 parent 631a9d8 commit ceeeb9c
Copy full SHA for ceeeb9c

1,982 files changed

+11,645-29,470Lines changed: 11645 additions & 29470 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Jakefile‎

Copy file name to clipboardExpand all lines: Jakefile
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ function compileFile(outFile, sources, prereqs, prefixes, useBuiltCompiler, noOu
254254
options += " --stripInternal"
255255
}
256256

257-
options += " --cacheDownlevelForOfLength --preserveNewLines";
257+
options += " --cacheDownlevelForOfLength";
258258

259259
var cmd = host + " " + dir + compilerFilename + " " + options + " ";
260260
cmd = cmd + sources.join(" ");
Collapse file

‎src/compiler/commandLineParser.ts‎

Copy file name to clipboardExpand all lines: src/compiler/commandLineParser.ts
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,6 @@ module ts {
140140
description: Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation,
141141
experimental: true
142142
},
143-
{
144-
name: "preserveNewLines",
145-
type: "boolean",
146-
description: Diagnostics.Preserve_new_lines_when_emitting_code,
147-
experimental: true
148-
},
149143
{
150144
name: "cacheDownlevelForOfLength",
151145
type: "boolean",
Collapse file

‎src/compiler/emitter.ts‎

Copy file name to clipboardExpand all lines: src/compiler/emitter.ts
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ module ts {
8888
let writeLine = writer.writeLine;
8989
let increaseIndent = writer.increaseIndent;
9090
let decreaseIndent = writer.decreaseIndent;
91-
let preserveNewLines = compilerOptions.preserveNewLines || false;
9291

9392
let currentSourceFile: SourceFile;
9493

@@ -799,7 +798,7 @@ module ts {
799798

800799
increaseIndent();
801800

802-
if (preserveNewLines && nodeStartPositionsAreOnSameLine(parent, nodes[0])) {
801+
if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) {
803802
if (spacesBetweenBraces) {
804803
write(" ");
805804
}
@@ -810,7 +809,7 @@ module ts {
810809

811810
for (let i = 0, n = nodes.length; i < n; i++) {
812811
if (i) {
813-
if (preserveNewLines && nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) {
812+
if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) {
814813
write(", ");
815814
}
816815
else {
@@ -828,7 +827,7 @@ module ts {
828827

829828
decreaseIndent();
830829

831-
if (preserveNewLines && nodeEndPositionsAreOnSameLine(parent, lastOrUndefined(nodes))) {
830+
if (nodeEndPositionsAreOnSameLine(parent, lastOrUndefined(nodes))) {
832831
if (spacesBetweenBraces) {
833832
write(" ");
834833
}
@@ -1727,7 +1726,7 @@ module ts {
17271726
// If the code is not indented, an optional valueToWriteWhenNotIndenting will be
17281727
// emitted instead.
17291728
function indentIfOnDifferentLines(parent: Node, node1: Node, node2: Node, valueToWriteWhenNotIndenting?: string): boolean {
1730-
let realNodesAreOnDifferentLines = preserveNewLines && !nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2);
1729+
let realNodesAreOnDifferentLines = !nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2);
17311730

17321731
// Always use a newline for synthesized code if the synthesizer desires it.
17331732
let synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2);
@@ -2035,7 +2034,7 @@ module ts {
20352034
}
20362035

20372036
function emitBlock(node: Block) {
2038-
if (preserveNewLines && isSingleLineEmptyBlock(node)) {
2037+
if (isSingleLineEmptyBlock(node)) {
20392038
emitToken(SyntaxKind.OpenBraceToken, node.pos);
20402039
write(" ");
20412040
emitToken(SyntaxKind.CloseBraceToken, node.statements.end);
@@ -2419,7 +2418,7 @@ module ts {
24192418
write("default:");
24202419
}
24212420

2422-
if (preserveNewLines && node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) {
2421+
if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) {
24232422
write(" ");
24242423
emit(node.statements[0]);
24252424
}
@@ -3169,7 +3168,7 @@ module ts {
31693168

31703169
// If we didn't have to emit any preamble code, then attempt to keep the arrow
31713170
// function on one line.
3172-
if (preserveNewLines && !preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) {
3171+
if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) {
31733172
write(" ");
31743173
emitStart(body);
31753174
write("return ");
@@ -3217,7 +3216,7 @@ module ts {
32173216

32183217
let preambleEmitted = writer.getTextPos() !== initialTextPos;
32193218

3220-
if (preserveNewLines && !preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) {
3219+
if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) {
32213220
for (let statement of body.statements) {
32223221
write(" ");
32233222
emit(statement);
Collapse file

‎src/compiler/types.ts‎

Copy file name to clipboardExpand all lines: src/compiler/types.ts
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1588,7 +1588,6 @@ module ts {
15881588
version?: boolean;
15891589
watch?: boolean;
15901590
/* @internal */ stripInternal?: boolean;
1591-
/* @internal */ preserveNewLines?: boolean;
15921591
/* @internal */ cacheDownlevelForOfLength?: boolean;
15931592
[option: string]: string | number | boolean;
15941593
}
Collapse file

‎src/harness/harness.ts‎

Copy file name to clipboardExpand all lines: src/harness/harness.ts
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,10 +1008,6 @@ module Harness {
10081008
options.outDir = setting.value;
10091009
break;
10101010

1011-
case 'preservenewlines':
1012-
options.preserveNewLines = !!setting.value;
1013-
break;
1014-
10151011
case 'sourceroot':
10161012
options.sourceRoot = setting.value;
10171013
break;
@@ -1465,7 +1461,7 @@ module Harness {
14651461
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
14661462

14671463
// List of allowed metadata names
1468-
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "preservenewlines", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal"];
1464+
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal"];
14691465

14701466
function extractCompilerSettings(content: string): CompilerSetting[] {
14711467

Collapse file

‎tests/baselines/reference/2dArrays.js‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/2dArrays.js
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ var Board = (function () {
3030
function Board() {
3131
}
3232
Board.prototype.allShipsSunk = function () {
33-
return this.ships.every(function (val) {
34-
return val.isSunk;
35-
});
33+
return this.ships.every(function (val) { return val.isSunk; });
3634
};
3735
return Board;
3836
})();
Collapse file

‎tests/baselines/reference/APISample_compile.js‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/APISample_compile.js
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,8 +2021,6 @@ function compile(fileNames, options) {
20212021
}
20222022
exports.compile = compile;
20232023
compile(process.argv.slice(2), {
2024-
noEmitOnError: true,
2025-
noImplicitAny: true,
2026-
target: 1 /* ES5 */,
2027-
module: 1 /* CommonJS */
2024+
noEmitOnError: true, noImplicitAny: true,
2025+
target: 1 /* ES5 */, module: 1 /* CommonJS */
20282026
});
Collapse file

‎tests/baselines/reference/APISample_linter.js‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/APISample_linter.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2055,7 +2055,8 @@ function delint(sourceFile) {
20552055
if (ifStatement.thenStatement.kind !== 176 /* Block */) {
20562056
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
20572057
}
2058-
if (ifStatement.elseStatement && ifStatement.elseStatement.kind !== 176 /* Block */ && ifStatement.elseStatement.kind !== 180 /* IfStatement */) {
2058+
if (ifStatement.elseStatement &&
2059+
ifStatement.elseStatement.kind !== 176 /* Block */ && ifStatement.elseStatement.kind !== 180 /* IfStatement */) {
20592060
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
20602061
}
20612062
break;
Collapse file

‎tests/baselines/reference/APISample_transform.js‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/APISample_transform.js
+11-25Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,43 +2051,29 @@ function transform(contents, compilerOptions) {
20512051
// Create a compilerHost object to allow the compiler to read and write files
20522052
var compilerHost = {
20532053
getSourceFile: function (fileName, target) {
2054-
return files[fileName] !== undefined ? ts.createSourceFile(fileName, files[fileName], target) : undefined;
2054+
return files[fileName] !== undefined ?
2055+
ts.createSourceFile(fileName, files[fileName], target) : undefined;
20552056
},
20562057
writeFile: function (name, text, writeByteOrderMark) {
2057-
outputs.push({
2058-
name: name,
2059-
text: text,
2060-
writeByteOrderMark: writeByteOrderMark
2061-
});
2058+
outputs.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark });
20622059
},
2063-
getDefaultLibFileName: function () {
2064-
return "lib.d.ts";
2065-
},
2066-
useCaseSensitiveFileNames: function () {
2067-
return false;
2068-
},
2069-
getCanonicalFileName: function (fileName) {
2070-
return fileName;
2071-
},
2072-
getCurrentDirectory: function () {
2073-
return "";
2074-
},
2075-
getNewLine: function () {
2076-
return "\n";
2077-
}
2060+
getDefaultLibFileName: function () { return "lib.d.ts"; },
2061+
useCaseSensitiveFileNames: function () { return false; },
2062+
getCanonicalFileName: function (fileName) { return fileName; },
2063+
getCurrentDirectory: function () { return ""; },
2064+
getNewLine: function () { return "\n"; }
20782065
};
20792066
// Create a program from inputs
2080-
var program = ts.createProgram([
2081-
"file.ts"
2082-
], compilerOptions, compilerHost);
2067+
var program = ts.createProgram(["file.ts"], compilerOptions, compilerHost);
20832068
// Query for early errors
20842069
var errors = ts.getPreEmitDiagnostics(program);
20852070
var emitResult = program.emit();
20862071
errors = errors.concat(emitResult.diagnostics);
20872072
return {
20882073
outputs: outputs,
20892074
errors: errors.map(function (e) {
2090-
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
2075+
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): "
2076+
+ ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
20912077
})
20922078
};
20932079
}
Collapse file

‎tests/baselines/reference/APISample_watcher.js‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/APISample_watcher.js
+13-29Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2080,33 +2080,21 @@ function watch(rootFileNames, options) {
20802080
var files = {};
20812081
// initialize the list of files
20822082
rootFileNames.forEach(function (fileName) {
2083-
files[fileName] = {
2084-
version: 0
2085-
};
2083+
files[fileName] = { version: 0 };
20862084
});
20872085
// Create the language service host to allow the LS to communicate with the host
20882086
var servicesHost = {
2089-
getScriptFileNames: function () {
2090-
return rootFileNames;
2091-
},
2092-
getScriptVersion: function (fileName) {
2093-
return files[fileName] && files[fileName].version.toString();
2094-
},
2087+
getScriptFileNames: function () { return rootFileNames; },
2088+
getScriptVersion: function (fileName) { return files[fileName] && files[fileName].version.toString(); },
20952089
getScriptSnapshot: function (fileName) {
20962090
if (!fs.existsSync(fileName)) {
20972091
return undefined;
20982092
}
20992093
return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString());
21002094
},
2101-
getCurrentDirectory: function () {
2102-
return process.cwd();
2103-
},
2104-
getCompilationSettings: function () {
2105-
return options;
2106-
},
2107-
getDefaultLibFileName: function (options) {
2108-
return ts.getDefaultLibFilePath(options);
2109-
}
2095+
getCurrentDirectory: function () { return process.cwd(); },
2096+
getCompilationSettings: function () { return options; },
2097+
getDefaultLibFileName: function (options) { return ts.getDefaultLibFilePath(options); }
21102098
};
21112099
// Create the language service files
21122100
var services = ts.createLanguageService(servicesHost, ts.createDocumentRegistry());
@@ -2115,10 +2103,7 @@ function watch(rootFileNames, options) {
21152103
// First time around, emit all files
21162104
emitFile(fileName);
21172105
// Add a watch on the file to handle next change
2118-
fs.watchFile(fileName, {
2119-
persistent: true,
2120-
interval: 250
2121-
}, function (curr, prev) {
2106+
fs.watchFile(fileName, { persistent: true, interval: 250 }, function (curr, prev) {
21222107
// Check timestamp
21232108
if (+curr.mtime <= +prev.mtime) {
21242109
return;
@@ -2143,7 +2128,9 @@ function watch(rootFileNames, options) {
21432128
});
21442129
}
21452130
function logErrors(fileName) {
2146-
var allDiagnostics = services.getCompilerOptionsDiagnostics().concat(services.getSyntacticDiagnostics(fileName)).concat(services.getSemanticDiagnostics(fileName));
2131+
var allDiagnostics = services.getCompilerOptionsDiagnostics()
2132+
.concat(services.getSyntacticDiagnostics(fileName))
2133+
.concat(services.getSemanticDiagnostics(fileName));
21472134
allDiagnostics.forEach(function (diagnostic) {
21482135
if (diagnostic.file) {
21492136
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
@@ -2156,10 +2143,7 @@ function watch(rootFileNames, options) {
21562143
}
21572144
}
21582145
// Initialize files constituting the program as all .ts files in the current directory
2159-
var currentDirectoryFiles = fs.readdirSync(process.cwd()).filter(function (fileName) {
2160-
return fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts";
2161-
});
2146+
var currentDirectoryFiles = fs.readdirSync(process.cwd()).
2147+
filter(function (fileName) { return fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts"; });
21622148
// Start the watcher
2163-
watch(currentDirectoryFiles, {
2164-
module: 1 /* CommonJS */
2165-
});
2149+
watch(currentDirectoryFiles, { module: 1 /* CommonJS */ });

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.