Merge pull request #2265 from Microsoft/preserveFormatting

Move line preservation in emit behind an experimental compiler flag.
This commit is contained in:
CyrusNajmabadi
2015-03-08 20:25:36 -07:00
1893 changed files with 28575 additions and 11145 deletions
+6
View File
@@ -140,6 +140,12 @@ module ts {
description: Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation,
experimental: true
},
{
name: "preserveNewLines",
type: "boolean",
description: Diagnostics.Preserve_new_lines_when_emitting_code,
experimental: true
},
{
name: "target",
shortName: "t",
@@ -463,6 +463,7 @@ module ts {
File_0_must_have_extension_ts_or_d_ts: { code: 6054, category: DiagnosticCategory.Error, key: "File '{0}' must have extension '.ts' or '.d.ts'." },
Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures: { code: 6055, category: DiagnosticCategory.Message, key: "Suppress noImplicitAny errors for indexing objects lacking index signatures." },
Do_not_emit_declarations_for_code_that_has_an_internal_annotation: { code: 6056, category: DiagnosticCategory.Message, key: "Do not emit declarations for code that has an '@internal' annotation." },
Preserve_new_lines_when_emitting_code: { code: 6057, category: DiagnosticCategory.Message, key: "Preserve new-lines when emitting code." },
Variable_0_implicitly_has_an_1_type: { code: 7005, category: DiagnosticCategory.Error, key: "Variable '{0}' implicitly has an '{1}' type." },
Parameter_0_implicitly_has_an_1_type: { code: 7006, category: DiagnosticCategory.Error, key: "Parameter '{0}' implicitly has an '{1}' type." },
Member_0_implicitly_has_an_1_type: { code: 7008, category: DiagnosticCategory.Error, key: "Member '{0}' implicitly has an '{1}' type." },
+4
View File
@@ -1844,6 +1844,10 @@
"category": "Message",
"code": 6056
},
"Preserve new-lines when emitting code.": {
"category": "Message",
"code": 6057
},
"Variable '{0}' implicitly has an '{1}' type.": {
"category": "Error",
+13 -11
View File
@@ -1531,6 +1531,7 @@ module ts {
var sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap ? [] : undefined;
var diagnostics: Diagnostic[] = [];
var newLine = host.getNewLine();
var preserveNewLines = compilerOptions.preserveNewLines || false;
if (targetSourceFile === undefined) {
forEach(host.getSourceFiles(), sourceFile => {
@@ -2172,7 +2173,7 @@ module ts {
increaseIndent();
if (nodeStartPositionsAreOnSameLine(parent, nodes[0])) {
if (preserveNewLines && nodeStartPositionsAreOnSameLine(parent, nodes[0])) {
if (spacesBetweenBraces) {
write(" ");
}
@@ -2183,7 +2184,7 @@ module ts {
for (var i = 0, n = nodes.length; i < n; i++) {
if (i) {
if (nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) {
if (preserveNewLines && nodeEndIsOnSameLineAsNodeStart(nodes[i - 1], nodes[i])) {
write(", ");
}
else {
@@ -2195,15 +2196,13 @@ module ts {
emit(nodes[i]);
}
var closeTokenIsOnSameLineAsLastElement = nodeEndPositionsAreOnSameLine(parent, lastOrUndefined(nodes));
if (nodes.hasTrailingComma && allowTrailingComma) {
write(",");
}
decreaseIndent();
if (closeTokenIsOnSameLineAsLastElement) {
if (preserveNewLines && nodeEndPositionsAreOnSameLine(parent, lastOrUndefined(nodes))) {
if (spacesBetweenBraces) {
write(" ");
}
@@ -3035,10 +3034,12 @@ module ts {
}
function indentIfOnDifferentLines(parent: Node, node1: Node, node2: Node) {
var isSynthesized = nodeIsSynthesized(parent);
// Use a newline for existin code if the original had one, and we're preserving formatting.
var realNodesAreOnDifferentLines = preserveNewLines && !nodeIsSynthesized(parent) && !nodeEndIsOnSameLineAsNodeStart(node1, node2);
var realNodesAreOnDifferentLines = !isSynthesized && !nodeEndIsOnSameLineAsNodeStart(node1, node2);
// Always use a newline for synthesized code if hte generator asked for it.
var synthesizedNodeIsOnDifferentLine = synthesizedNodeStartsOnNewLine(node2);
if (realNodesAreOnDifferentLines || synthesizedNodeIsOnDifferentLine) {
increaseIndent();
writeLine();
@@ -3383,7 +3384,7 @@ module ts {
}
function emitBlock(node: Block) {
if (isSingleLineEmptyBlock(node)) {
if (preserveNewLines && isSingleLineEmptyBlock(node)) {
emitToken(SyntaxKind.OpenBraceToken, node.pos);
write(" ");
emitToken(SyntaxKind.CloseBraceToken, node.statements.end);
@@ -3600,7 +3601,8 @@ module ts {
else {
write("default:");
}
if (node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) {
if (preserveNewLines && node.statements.length === 1 && nodeStartPositionsAreOnSameLine(node, node.statements[0])) {
write(" ");
emit(node.statements[0]);
}
@@ -4303,7 +4305,7 @@ module ts {
// If we didn't have to emit any preamble code, then attempt to keep the arrow
// function on one line.
if (!preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) {
if (preserveNewLines && !preambleEmitted && nodeStartPositionsAreOnSameLine(node, body)) {
write(" ");
emitStart(body);
write("return ");
@@ -4354,7 +4356,7 @@ module ts {
var preambleEmitted = writer.getTextPos() !== initialTextPos;
if (!preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) {
if (preserveNewLines && !preambleEmitted && nodeEndIsOnSameLineAsNodeStart(body, body)) {
for (var i = 0, n = body.statements.length; i < n; i++) {
write(" ");
emit(body.statements[i]);
+1
View File
@@ -1554,6 +1554,7 @@ module ts {
version?: boolean;
watch?: boolean;
stripInternal?: boolean;
preserveNewLines?: boolean;
[option: string]: string | number | boolean;
}
+1 -1
View File
@@ -1174,7 +1174,7 @@ module ts {
}
export function nodeIsSynthesized(node: Node): boolean {
return node.pos === -1 && node.end === -1;
return node.pos === -1;
}
export function createSynthesizedNode(kind: SyntaxKind, startsOnNewLine?: boolean): Node {
+5 -1
View File
@@ -1007,6 +1007,10 @@ module Harness {
options.outDir = setting.value;
break;
case 'preservenewlines':
options.preserveNewLines = !!setting.value;
break;
case 'sourceroot':
options.sourceRoot = setting.value;
break;
@@ -1470,7 +1474,7 @@ module Harness {
var optionRegex = /^[\/]{2}\s*@(\w+)\s*:\s*(\S*)/gm; // multiple matches on multiple lines
// List of allowed metadata names
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal"];
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outdir", "noemitonerror", "noimplicitany", "noresolve", "newline", "newlines", "emitbom", "errortruncation", "usecasesensitivefilenames", "preserveconstenums", "preservenewlines", "includebuiltfile", "suppressimplicitanyindexerrors", "stripinternal"];
function extractCompilerSettings(content: string): CompilerSetting[] {
+3 -1
View File
@@ -30,7 +30,9 @@ var Board = (function () {
function Board() {
}
Board.prototype.allShipsSunk = function () {
return this.ships.every(function (val) { return val.isSunk; });
return this.ships.every(function (val) {
return val.isSunk;
});
};
return Board;
})();
@@ -1234,6 +1234,7 @@ declare module "typescript" {
version?: boolean;
watch?: boolean;
stripInternal?: boolean;
preserveNewLines?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -2006,6 +2007,8 @@ function compile(fileNames, options) {
}
exports.compile = compile;
compile(process.argv.slice(2), {
noEmitOnError: true, noImplicitAny: true,
target: 1 /* ES5 */, module: 1 /* CommonJS */
noEmitOnError: true,
noImplicitAny: true,
target: 1 /* ES5 */,
module: 1 /* CommonJS */
});
@@ -3939,6 +3939,9 @@ declare module "typescript" {
stripInternal?: boolean;
>stripInternal : boolean
preserveNewLines?: boolean;
>preserveNewLines : boolean
[option: string]: string | number | boolean;
>option : string
}
@@ -1265,6 +1265,7 @@ declare module "typescript" {
version?: boolean;
watch?: boolean;
stripInternal?: boolean;
preserveNewLines?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -2040,8 +2041,7 @@ function delint(sourceFile) {
if (ifStatement.thenStatement.kind !== 174 /* Block */) {
report(ifStatement.thenStatement, "An if statement's contents should be wrapped in a block body.");
}
if (ifStatement.elseStatement &&
ifStatement.elseStatement.kind !== 174 /* Block */ && ifStatement.elseStatement.kind !== 178 /* IfStatement */) {
if (ifStatement.elseStatement && ifStatement.elseStatement.kind !== 174 /* Block */ && ifStatement.elseStatement.kind !== 178 /* IfStatement */) {
report(ifStatement.elseStatement, "An else statement's contents should be wrapped in a block body.");
}
break;
@@ -4085,6 +4085,9 @@ declare module "typescript" {
stripInternal?: boolean;
>stripInternal : boolean
preserveNewLines?: boolean;
>preserveNewLines : boolean
[option: string]: string | number | boolean;
>option : string
}
@@ -1266,6 +1266,7 @@ declare module "typescript" {
version?: boolean;
watch?: boolean;
stripInternal?: boolean;
preserveNewLines?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -2036,20 +2037,35 @@ function transform(contents, compilerOptions) {
// Create a compilerHost object to allow the compiler to read and write files
var compilerHost = {
getSourceFile: function (fileName, target) {
return files[fileName] !== undefined ?
ts.createSourceFile(fileName, files[fileName], target) : undefined;
return files[fileName] !== undefined ? ts.createSourceFile(fileName, files[fileName], target) : undefined;
},
writeFile: function (name, text, writeByteOrderMark) {
outputs.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark });
outputs.push({
name: name,
text: text,
writeByteOrderMark: writeByteOrderMark
});
},
getDefaultLibFileName: function () { return "lib.d.ts"; },
useCaseSensitiveFileNames: function () { return false; },
getCanonicalFileName: function (fileName) { return fileName; },
getCurrentDirectory: function () { return ""; },
getNewLine: function () { return "\n"; }
getDefaultLibFileName: function () {
return "lib.d.ts";
},
useCaseSensitiveFileNames: function () {
return false;
},
getCanonicalFileName: function (fileName) {
return fileName;
},
getCurrentDirectory: function () {
return "";
},
getNewLine: function () {
return "\n";
}
};
// Create a program from inputs
var program = ts.createProgram(["file.ts"], compilerOptions, compilerHost);
var program = ts.createProgram([
"file.ts"
], compilerOptions, compilerHost);
// Query for early errors
var errors = ts.getPreEmitDiagnostics(program);
var emitResult = program.emit();
@@ -2057,8 +2073,7 @@ function transform(contents, compilerOptions) {
return {
outputs: outputs,
errors: errors.map(function (e) {
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): "
+ ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
})
};
}
@@ -4035,6 +4035,9 @@ declare module "typescript" {
stripInternal?: boolean;
>stripInternal : boolean
preserveNewLines?: boolean;
>preserveNewLines : boolean
[option: string]: string | number | boolean;
>option : string
}
+30 -13
View File
@@ -1303,6 +1303,7 @@ declare module "typescript" {
version?: boolean;
watch?: boolean;
stripInternal?: boolean;
preserveNewLines?: boolean;
[option: string]: string | number | boolean;
}
const enum ModuleKind {
@@ -2065,21 +2066,33 @@ function watch(rootFileNames, options) {
var files = {};
// initialize the list of files
rootFileNames.forEach(function (fileName) {
files[fileName] = { version: 0 };
files[fileName] = {
version: 0
};
});
// Create the language service host to allow the LS to communicate with the host
var servicesHost = {
getScriptFileNames: function () { return rootFileNames; },
getScriptVersion: function (fileName) { return files[fileName] && files[fileName].version.toString(); },
getScriptFileNames: function () {
return rootFileNames;
},
getScriptVersion: function (fileName) {
return files[fileName] && files[fileName].version.toString();
},
getScriptSnapshot: function (fileName) {
if (!fs.existsSync(fileName)) {
return undefined;
}
return ts.ScriptSnapshot.fromString(fs.readFileSync(fileName).toString());
},
getCurrentDirectory: function () { return process.cwd(); },
getCompilationSettings: function () { return options; },
getDefaultLibFileName: function (options) { return ts.getDefaultLibFilePath(options); }
getCurrentDirectory: function () {
return process.cwd();
},
getCompilationSettings: function () {
return options;
},
getDefaultLibFileName: function (options) {
return ts.getDefaultLibFilePath(options);
}
};
// Create the language service files
var services = ts.createLanguageService(servicesHost, ts.createDocumentRegistry());
@@ -2088,7 +2101,10 @@ function watch(rootFileNames, options) {
// First time around, emit all files
emitFile(fileName);
// Add a watch on the file to handle next change
fs.watchFile(fileName, { persistent: true, interval: 250 }, function (curr, prev) {
fs.watchFile(fileName, {
persistent: true,
interval: 250
}, function (curr, prev) {
// Check timestamp
if (+curr.mtime <= +prev.mtime) {
return;
@@ -2113,9 +2129,7 @@ function watch(rootFileNames, options) {
});
}
function logErrors(fileName) {
var allDiagnostics = services.getCompilerOptionsDiagnostics()
.concat(services.getSyntacticDiagnostics(fileName))
.concat(services.getSemanticDiagnostics(fileName));
var allDiagnostics = services.getCompilerOptionsDiagnostics().concat(services.getSyntacticDiagnostics(fileName)).concat(services.getSemanticDiagnostics(fileName));
allDiagnostics.forEach(function (diagnostic) {
if (diagnostic.file) {
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
@@ -2128,7 +2142,10 @@ function watch(rootFileNames, options) {
}
}
// Initialize files constituting the program as all .ts files in the current directory
var currentDirectoryFiles = fs.readdirSync(process.cwd()).
filter(function (fileName) { return fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts"; });
var currentDirectoryFiles = fs.readdirSync(process.cwd()).filter(function (fileName) {
return fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts";
});
// Start the watcher
watch(currentDirectoryFiles, { module: 1 /* CommonJS */ });
watch(currentDirectoryFiles, {
module: 1 /* CommonJS */
});
@@ -4208,6 +4208,9 @@ declare module "typescript" {
stripInternal?: boolean;
>stripInternal : boolean
preserveNewLines?: boolean;
>preserveNewLines : boolean
[option: string]: string | number | boolean;
>option : string
}
@@ -17,7 +17,10 @@ var cl = Point.Origin;
//// [function.js]
function Point() {
return { x: 0, y: 0 };
return {
x: 0,
y: 0
};
}
//// [test.js]
var cl;
@@ -2,4 +2,5 @@
var v = (public x: string) => { };
//// [ArrowFunctionExpression1.js]
var v = function (x) { };
var v = function (x) {
};
@@ -58,7 +58,8 @@ var clodule1 = (function () {
})();
var clodule1;
(function (clodule1) {
function f(x) { }
function f(x) {
}
})(clodule1 || (clodule1 = {}));
var clodule2 = (function () {
function clodule2() {
@@ -81,7 +82,9 @@ var clodule3 = (function () {
})();
var clodule3;
(function (clodule3) {
clodule3.y = { id: T };
clodule3.y = {
id: T
};
})(clodule3 || (clodule3 = {}));
var clodule4 = (function () {
function clodule4() {
@@ -19,7 +19,8 @@ module clodule {
var clodule = (function () {
function clodule() {
}
clodule.fn = function (id) { };
clodule.fn = function (id) {
};
return clodule;
})();
var clodule;
@@ -19,7 +19,8 @@ module clodule {
var clodule = (function () {
function clodule() {
}
clodule.fn = function (id) { };
clodule.fn = function (id) {
};
return clodule;
})();
var clodule;
@@ -19,7 +19,9 @@ module clodule {
var clodule = (function () {
function clodule() {
}
clodule.sfn = function (id) { return 42; };
clodule.sfn = function (id) {
return 42;
};
return clodule;
})();
var clodule;
@@ -28,12 +28,19 @@ var Point = (function () {
this.x = x;
this.y = y;
}
Point.Origin = function () { return { x: 0, y: 0 }; }; // unexpected error here bug 840246
Point.Origin = function () {
return {
x: 0,
y: 0
};
}; // unexpected error here bug 840246
return Point;
})();
var Point;
(function (Point) {
function Origin() { return null; }
function Origin() {
return null;
}
Point.Origin = Origin; //expected duplicate identifier error
})(Point || (Point = {}));
var A;
@@ -43,13 +50,20 @@ var A;
this.x = x;
this.y = y;
}
Point.Origin = function () { return { x: 0, y: 0 }; }; // unexpected error here bug 840246
Point.Origin = function () {
return {
x: 0,
y: 0
};
}; // unexpected error here bug 840246
return Point;
})();
A.Point = Point;
var Point;
(function (Point) {
function Origin() { return ""; }
function Origin() {
return "";
}
Point.Origin = Origin; //expected duplicate identifier error
})(Point = A.Point || (A.Point = {}));
})(A || (A = {}));
@@ -28,12 +28,19 @@ var Point = (function () {
this.x = x;
this.y = y;
}
Point.Origin = function () { return { x: 0, y: 0 }; };
Point.Origin = function () {
return {
x: 0,
y: 0
};
};
return Point;
})();
var Point;
(function (Point) {
function Origin() { return ""; } // not an error, since not exported
function Origin() {
return "";
} // not an error, since not exported
})(Point || (Point = {}));
var A;
(function (A) {
@@ -42,12 +49,19 @@ var A;
this.x = x;
this.y = y;
}
Point.Origin = function () { return { x: 0, y: 0 }; };
Point.Origin = function () {
return {
x: 0,
y: 0
};
};
return Point;
})();
A.Point = Point;
var Point;
(function (Point) {
function Origin() { return ""; } // not an error since not exported
function Origin() {
return "";
} // not an error since not exported
})(Point = A.Point || (A.Point = {}));
})(A || (A = {}));
@@ -28,7 +28,10 @@ var Point = (function () {
this.x = x;
this.y = y;
}
Point.Origin = { x: 0, y: 0 };
Point.Origin = {
x: 0,
y: 0
};
return Point;
})();
var Point;
@@ -42,7 +45,10 @@ var A;
this.x = x;
this.y = y;
}
Point.Origin = { x: 0, y: 0 };
Point.Origin = {
x: 0,
y: 0
};
return Point;
})();
A.Point = Point;
@@ -28,7 +28,10 @@ var Point = (function () {
this.x = x;
this.y = y;
}
Point.Origin = { x: 0, y: 0 };
Point.Origin = {
x: 0,
y: 0
};
return Point;
})();
var Point;
@@ -42,7 +45,10 @@ var A;
this.x = x;
this.y = y;
}
Point.Origin = { x: 0, y: 0 };
Point.Origin = {
x: 0,
y: 0
};
return Point;
})();
A.Point = Point;
@@ -8,6 +8,7 @@ class C {
var C = (function () {
function C() {
}
C.prototype.foo = function () { };
C.prototype.foo = function () {
};
return C;
})();
@@ -8,6 +8,7 @@ class C {
var C = (function () {
function C() {
}
C.prototype.bar = function () { };
C.prototype.bar = function () {
};
return C;
})();
@@ -8,6 +8,7 @@ class C {
var C = (function () {
function C() {
}
C.prototype[1] = function () { };
C.prototype[1] = function () {
};
return C;
})();
@@ -8,6 +8,7 @@ class C {
var C = (function () {
function C() {
}
C.prototype["bar"] = function () { };
C.prototype["bar"] = function () {
};
return C;
})();
@@ -17,7 +17,8 @@ var M;
var C = (function () {
function C() {
}
C.prototype[Symbol.iterator] = function () { };
C.prototype[Symbol.iterator] = function () {
};
return C;
})();
M.C = C;
@@ -12,7 +12,8 @@ var Symbol;
var C = (function () {
function C() {
}
C.prototype[Symbol.iterator] = function () { };
C.prototype[Symbol.iterator] = function () {
};
return C;
})();
(new C)[Symbol.iterator];
@@ -12,7 +12,8 @@ var Symbol;
var C = (function () {
function C() {
}
C.prototype[Symbol.iterator] = function () { };
C.prototype[Symbol.iterator] = function () {
};
return C;
})();
(new C)[Symbol.iterator];
@@ -12,7 +12,8 @@ var Symbol;
var C = (function () {
function C() {
}
C.prototype[Symbol.iterator] = function () { };
C.prototype[Symbol.iterator] = function () {
};
return C;
})();
(new C)[Symbol.iterator](0); // Should error
@@ -9,7 +9,8 @@ class C {
var C = (function () {
function C() {
}
C.prototype[Symbol.iterator] = function () { };
C.prototype[Symbol.iterator] = function () {
};
return C;
})();
(new C)[Symbol.iterator];
@@ -12,7 +12,8 @@ var Symbol;
var C = (function () {
function C() {
}
C.prototype[Symbol.iterator] = function () { };
C.prototype[Symbol.iterator] = function () {
};
return C;
})();
(new C)[Symbol.iterator];
@@ -35,7 +35,10 @@ var A;
return Point;
})();
A.Point = Point;
A.Origin = { x: 0, y: 0 };
A.Origin = {
x: 0,
y: 0
};
var Point3d = (function (_super) {
__extends(Point3d, _super);
function Point3d() {
@@ -44,7 +47,11 @@ var A;
return Point3d;
})(Point);
A.Point3d = Point3d;
A.Origin3d = { x: 0, y: 0, z: 0 };
A.Origin3d = {
x: 0,
y: 0,
z: 0
};
var Line = (function () {
function Line(start, end) {
this.start = start;
@@ -38,7 +38,10 @@ var A;
}
return Point;
})();
A.Origin = { x: 0, y: 0 };
A.Origin = {
x: 0,
y: 0
};
var Point3d = (function (_super) {
__extends(Point3d, _super);
function Point3d() {
@@ -47,7 +50,11 @@ var A;
return Point3d;
})(Point);
A.Point3d = Point3d;
A.Origin3d = { x: 0, y: 0, z: 0 };
A.Origin3d = {
x: 0,
y: 0,
z: 0
};
var Line = (function () {
function Line(start, end) {
this.start = start;
@@ -33,7 +33,10 @@ var A;
})();
A.Line = Line;
function fromOrigin(p) {
return new Line({ x: 0, y: 0 }, p);
return new Line({
x: 0,
y: 0
}, p);
}
A.fromOrigin = fromOrigin;
})(A || (A = {}));
@@ -32,7 +32,10 @@ var A;
})();
A.Line = Line;
function fromOrigin(p) {
return new Line({ x: 0, y: 0 }, p);
return new Line({
x: 0,
y: 0
}, p);
}
A.fromOrigin = fromOrigin;
})(A || (A = {}));
@@ -32,7 +32,10 @@ var A;
return Line;
})();
function fromOrigin(p) {
return new Line({ x: 0, y: 0 }, p);
return new Line({
x: 0,
y: 0
}, p);
}
A.fromOrigin = fromOrigin;
})(A || (A = {}));
@@ -25,6 +25,13 @@ module A {
//// [ExportInterfaceWithAccessibleTypesInTypeParameterConstraintsClassHeritageListMemberTypeAnnotations.js]
var A;
(function (A) {
A.Origin = { x: 0, y: 0 };
A.Origin3d = { x: 0, y: 0, z: 0 };
A.Origin = {
x: 0,
y: 0
};
A.Origin3d = {
x: 0,
y: 0,
z: 0
};
})(A || (A = {}));
@@ -26,6 +26,13 @@ module A {
//// [ExportInterfaceWithInaccessibleTypeInTypeParameterConstraint.js]
var A;
(function (A) {
A.Origin = { x: 0, y: 0 };
A.Origin3d = { x: 0, y: 0, z: 0 };
A.Origin = {
x: 0,
y: 0
};
A.Origin3d = {
x: 0,
y: 0,
z: 0
};
})(A || (A = {}));
@@ -38,7 +38,10 @@ var A;
function Line(start, end) {
}
Line.fromOrigin = function (p) {
return new Line({ x: 0, y: 0 }, p);
return new Line({
x: 0,
y: 0
}, p);
};
return Line;
})();
@@ -21,6 +21,12 @@ var A;
}
return Point;
})();
A.Origin = { x: 0, y: 0 };
A.Unity = { start: new Point(0, 0), end: new Point(1, 0) };
A.Origin = {
x: 0,
y: 0
};
A.Unity = {
start: new Point(0, 0),
end: new Point(1, 0)
};
})(A || (A = {}));
@@ -15,5 +15,8 @@ module A {
var A;
(function (A) {
// valid since Point is exported
A.Origin = { x: 0, y: 0 };
A.Origin = {
x: 0,
y: 0
};
})(A || (A = {}));
@@ -22,7 +22,14 @@ module A {
var A;
(function (A) {
// valid since Point is exported
A.Origin = { x: 0, y: 0 };
A.Origin = {
x: 0,
y: 0
};
// invalid Point3d is not exported
A.Origin3d = { x: 0, y: 0, z: 0 };
A.Origin3d = {
x: 0,
y: 0,
z: 0
};
})(A || (A = {}));
@@ -47,7 +47,10 @@ var cl = B.Point.Origin;
var A;
(function (A) {
function Point() {
return { x: 0, y: 0 };
return {
x: 0,
y: 0
};
}
A.Point = Point;
})(A || (A = {}));
@@ -56,7 +59,10 @@ var A;
(function (A) {
var Point;
(function (Point) {
Point.Origin = { x: 0, y: 0 };
Point.Origin = {
x: 0,
y: 0
};
})(Point = A.Point || (A.Point = {}));
})(A || (A = {}));
//// [test.js]
@@ -69,12 +75,18 @@ var cl = A.Point.Origin; // not expected to be an error.
var B;
(function (B) {
function Point() {
return { x: 0, y: 0 };
return {
x: 0,
y: 0
};
}
B.Point = Point;
var Point;
(function (Point) {
Point.Origin = { x: 0, y: 0 };
Point.Origin = {
x: 0,
y: 0
};
})(Point = B.Point || (B.Point = {}));
})(B || (B = {}));
var fn;
@@ -26,7 +26,10 @@ var cl = B.Point.Origin;
var A;
(function (A) {
function Point() {
return { x: 0, y: 0 };
return {
x: 0,
y: 0
};
}
A.Point = Point;
})(A || (A = {}));
@@ -35,7 +38,10 @@ var B;
(function (B) {
var Point;
(function (Point) {
Point.Origin = { x: 0, y: 0 };
Point.Origin = {
x: 0,
y: 0
};
})(Point = B.Point || (B.Point = {}));
})(B || (B = {}));
//// [test.js]
@@ -4,5 +4,7 @@ function * foo(a = yield => yield) {
//// [FunctionDeclaration10_es6.js]
function foo(a) {
if (a === void 0) { a = function (yield) { return yield; }; }
if (a === void 0) { a = function (yield) {
return yield;
}; }
}
@@ -2,4 +2,5 @@
var v = function * yield() { }
//// [FunctionDeclaration12_es6.js]
var v = , yield = function () { };
var v = , yield = function () {
};
@@ -3,4 +3,5 @@ function foo();
function bar() { }
//// [FunctionDeclaration4.js]
function bar() { }
function bar() {
}
@@ -6,5 +6,6 @@
//// [FunctionDeclaration6.js]
{
function bar() { }
function bar() {
}
}
@@ -2,4 +2,5 @@
var v = function * () { }
//// [FunctionExpression1_es6.js]
var v = function () { };
var v = function () {
};
@@ -2,4 +2,5 @@
var v = function * foo() { }
//// [FunctionExpression2_es6.js]
var v = function foo() { };
var v = function foo() {
};
@@ -2,4 +2,7 @@
var v = { *foo() { } }
//// [FunctionPropertyAssignments1_es6.js]
var v = { foo: function () { } };
var v = {
foo: function () {
}
};
@@ -2,4 +2,7 @@
var v = { *() { } }
//// [FunctionPropertyAssignments2_es6.js]
var v = { : function () { } };
var v = {
: function () {
}
};
@@ -2,4 +2,7 @@
var v = { *{ } }
//// [FunctionPropertyAssignments3_es6.js]
var v = { : function () { } };
var v = {
: function () {
}
};
@@ -2,4 +2,6 @@
var v = { * }
//// [FunctionPropertyAssignments4_es6.js]
var v = { : function () { } };
var v = {
: function () { }
};
@@ -3,6 +3,7 @@ var v = { *[foo()]() { } }
//// [FunctionPropertyAssignments5_es6.js]
var v = (_a = {},
_a[foo()] = function () { },
_a[foo()] = function () {
},
_a);
var _a;
@@ -2,4 +2,7 @@
var v = { *<T>() { } }
//// [FunctionPropertyAssignments6_es6.js]
var v = { : function () { } };
var v = {
: function () {
}
};
@@ -8,7 +8,8 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "Foo", {
set: function (a) { },
set: function (a) {
},
enumerable: true,
configurable: true
});
@@ -7,6 +7,7 @@ class C {
var C = (function () {
function C() {
}
C.prototype.foo = function () { };
C.prototype.foo = function () {
};
return C;
})();
@@ -7,6 +7,7 @@ class C {
var C = (function () {
function C() {
}
C.prototype.foo = function () { };
C.prototype.foo = function () {
};
return C;
})();
@@ -7,6 +7,7 @@ class C {
var C = (function () {
function C() {
}
C.prototype[foo] = function () { };
C.prototype[foo] = function () {
};
return C;
})();
@@ -7,6 +7,7 @@ class C {
var C = (function () {
function C() {
}
C.prototype. = function () { };
C.prototype. = function () {
};
return C;
})();
@@ -7,6 +7,7 @@ class C {
var C = (function () {
function C() {
}
C.prototype.foo = function () { };
C.prototype.foo = function () {
};
return C;
})();
@@ -34,7 +34,10 @@ var A;
(function (A) {
var Point;
(function (Point) {
Point.Origin = { x: 0, y: 0 };
Point.Origin = {
x: 0,
y: 0
};
})(Point = A.Point || (A.Point = {}));
})(A || (A = {}));
//// [function.js]
@@ -42,7 +45,10 @@ var A;
(function (A) {
// duplicate identifier error
function Point() {
return { x: 0, y: 0 };
return {
x: 0,
y: 0
};
}
A.Point = Point;
})(A || (A = {}));
@@ -51,11 +57,17 @@ var B;
(function (B) {
var Point;
(function (Point) {
Point.Origin = { x: 0, y: 0 };
Point.Origin = {
x: 0,
y: 0
};
})(Point = B.Point || (B.Point = {}));
// duplicate identifier error
function Point() {
return { x: 0, y: 0 };
return {
x: 0,
y: 0
};
}
B.Point = Point;
})(B || (B = {}));
@@ -54,9 +54,15 @@ var B;
var Geometry;
(function (Geometry) {
var Lines = B;
Geometry.Origin = { x: 0, y: 0 };
Geometry.Origin = {
x: 0,
y: 0
};
// this is valid since B.Line _is_ visible outside Geometry
Geometry.Unit = new Lines.Line(Geometry.Origin, { x: 1, y: 0 });
Geometry.Unit = new Lines.Line(Geometry.Origin, {
x: 1,
y: 0
});
})(Geometry || (Geometry = {}));
// expected to work since all are exported
var p;
+2 -1
View File
@@ -7,6 +7,7 @@ class C {
var C = (function () {
function C() {
}
C.prototype.m = function () { };
C.prototype.m = function () {
};
return C;
})();
+2 -1
View File
@@ -7,6 +7,7 @@ class C {
var C = (function () {
function C() {
}
C.m = function () { };
C.m = function () {
};
return C;
})();
+2 -1
View File
@@ -7,6 +7,7 @@ class C {
var C = (function () {
function C() {
}
C.m = function () { };
C.m = function () {
};
return C;
})();
+2 -1
View File
@@ -7,6 +7,7 @@ class C {
var C = (function () {
function C() {
}
C.prototype.m = function () { };
C.prototype.m = function () {
};
return C;
})();
@@ -56,7 +56,10 @@ var A;
function Point() {
}
Point.prototype.fromCarthesian = function (p) {
return { x: p.x, y: p.y };
return {
x: p.x,
y: p.y
};
};
return Point;
})();
@@ -47,11 +47,17 @@ var A;
var Utils;
(function (Utils) {
function mirror(p) {
return { x: p.y, y: p.x };
return {
x: p.y,
y: p.x
};
}
Utils.mirror = mirror;
})(Utils = A.Utils || (A.Utils = {}));
A.Origin = { x: 0, y: 0 };
A.Origin = {
x: 0,
y: 0
};
})(A || (A = {}));
//// [part2.js]
var A;
@@ -78,4 +84,7 @@ var o = A.Origin;
var o = A.Utils.mirror(o);
var p;
var p;
var p = new A.Utils.Plane(o, { x: 1, y: 1 });
var p = new A.Utils.Plane(o, {
x: 1,
y: 1
});
@@ -35,17 +35,26 @@ var A;
var Utils;
(function (Utils) {
function mirror(p) {
return { x: p.y, y: p.x };
return {
x: p.y,
y: p.x
};
}
Utils.mirror = mirror;
})(Utils = A.Utils || (A.Utils = {}));
A.Origin = { x: 0, y: 0 };
A.Origin = {
x: 0,
y: 0
};
})(A = exports.A || (exports.A = {}));
//// [part2.js]
var A;
(function (A) {
// collision with 'Origin' var in other part of merged module
A.Origin = { x: 0, y: 0 };
A.Origin = {
x: 0,
y: 0
};
var Utils;
(function (Utils) {
var Plane = (function () {
@@ -38,7 +38,10 @@ var Root;
var Utils;
(function (Utils) {
function mirror(p) {
return { x: p.y, y: p.x };
return {
x: p.y,
y: p.x
};
}
Utils.mirror = mirror;
})(Utils = A.Utils || (A.Utils = {}));
@@ -50,7 +53,10 @@ var otherRoot;
var A;
(function (A) {
// have to be fully qualified since in different root
A.Origin = { x: 0, y: 0 };
A.Origin = {
x: 0,
y: 0
};
var Utils;
(function (Utils) {
var Plane = (function () {
@@ -45,7 +45,10 @@ var A;
var Utils;
(function (Utils) {
function mirror(p) {
return { x: p.y, y: p.x };
return {
x: p.y,
y: p.x
};
}
Utils.mirror = mirror;
})(Utils = A.Utils || (A.Utils = {}));
@@ -53,7 +56,10 @@ var A;
//// [part2.js]
var A;
(function (A) {
A.Origin = { x: 0, y: 0 };
A.Origin = {
x: 0,
y: 0
};
var Utils;
(function (Utils) {
var Plane = (function () {
@@ -74,4 +80,7 @@ var o = A.Origin;
var o = A.Utils.mirror(o);
var p;
var p;
var p = new A.Utils.Plane(o, { x: 1, y: 1 });
var p = new A.Utils.Plane(o, {
x: 1,
y: 1
});
@@ -6,7 +6,8 @@ var v = { * foo() {
//// [YieldExpression10_es6.js]
var v = { foo: function () {
var v = {
foo: function () {
;
}
};
@@ -2,4 +2,6 @@
function* foo() { yield }
//// [YieldExpression13_es6.js]
function foo() { ; }
function foo() {
;
}
@@ -2,4 +2,8 @@
var v = { get foo() { yield foo; } }
//// [YieldExpression17_es6.js]
var v = { get foo() { ; } };
var v = {
get foo() {
;
}
};
@@ -50,36 +50,48 @@ class E {
var C = (function () {
function C() {
}
C.privateMethod = function () { };
C.privateMethod = function () {
};
Object.defineProperty(C, "privateGetter", {
get: function () { return 0; },
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, "privateSetter", {
set: function (a) { },
set: function (a) {
},
enumerable: true,
configurable: true
});
C.protectedMethod = function () { };
C.protectedMethod = function () {
};
Object.defineProperty(C, "protectedGetter", {
get: function () { return 0; },
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, "protectedSetter", {
set: function (a) { },
set: function (a) {
},
enumerable: true,
configurable: true
});
C.publicMethod = function () { };
C.publicMethod = function () {
};
Object.defineProperty(C, "publicGetter", {
get: function () { return 0; },
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, "publicSetter", {
set: function (a) { },
set: function (a) {
},
enumerable: true,
configurable: true
});
@@ -89,36 +101,48 @@ var C = (function () {
var D = (function () {
function D() {
}
D.privateMethod = function () { };
D.privateMethod = function () {
};
Object.defineProperty(D, "privateGetter", {
get: function () { return 0; },
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(D, "privateSetter", {
set: function (a) { },
set: function (a) {
},
enumerable: true,
configurable: true
});
D.protectedMethod = function () { };
D.protectedMethod = function () {
};
Object.defineProperty(D, "protectedGetter", {
get: function () { return 0; },
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(D, "protectedSetter", {
set: function (a) { },
set: function (a) {
},
enumerable: true,
configurable: true
});
D.publicMethod = function () { };
D.publicMethod = function () {
};
Object.defineProperty(D, "publicGetter", {
get: function () { return 0; },
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(D, "publicSetter", {
set: function (a) { },
set: function (a) {
},
enumerable: true,
configurable: true
});
@@ -128,14 +152,18 @@ var D = (function () {
var E = (function () {
function E() {
}
E.prototype.method = function () { };
E.prototype.method = function () {
};
Object.defineProperty(E.prototype, "getter", {
get: function () { return 0; },
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(E.prototype, "setter", {
set: function (a) { },
set: function (a) {
},
enumerable: true,
configurable: true
});
@@ -10,12 +10,14 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "X", {
set: function (v) { },
set: function (v) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(C, "X", {
set: function (v2) { },
set: function (v2) {
},
enumerable: true,
configurable: true
});
+5 -2
View File
@@ -47,8 +47,11 @@ var D = (function () {
return D;
})();
var x = {
get a() { return 1; }
get a() {
return 1;
}
};
var y = {
set b(v) { }
set b(v) {
}
};
+5 -2
View File
@@ -44,8 +44,11 @@ var D = (function () {
return D;
})();
var x = {
get a() { return 1; }
get a() {
return 1;
}
};
var y = {
set b(v) { }
set b(v) {
}
};
@@ -2,4 +2,6 @@
var v = { get foo() }
//// [accessorWithoutBody1.js]
var v = { get foo() { } };
var v = {
get foo() { }
};
@@ -2,4 +2,6 @@
var v = { set foo(a) }
//// [accessorWithoutBody2.js]
var v = { set foo(a) { } };
var v = {
set foo(a) { }
};
@@ -20,7 +20,9 @@ var C = (function () {
}
Object.defineProperty(C.prototype, "x", {
get: function () {
return function (x) { return ""; };
return function (x) {
return "";
};
},
set: function (v) {
},
@@ -11,10 +11,16 @@ var C = (function () {
function C() {
}
Object.defineProperty(C.prototype, "x", {
get: function () { return 1; },
get: function () {
return 1;
},
enumerable: true,
configurable: true
});
return C;
})();
var y = { get foo() { return 3; } };
var y = {
get foo() {
return 3;
}
};
@@ -18,26 +18,40 @@ var LanguageSpec_section_4_5_error_cases = (function () {
function LanguageSpec_section_4_5_error_cases() {
}
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedSetter_SetterFirst", {
get: function () { return ""; },
set: function (a) { },
get: function () {
return "";
},
set: function (a) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedSetter_SetterLast", {
get: function () { return ""; },
set: function (a) { },
get: function () {
return "";
},
set: function (a) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedGetter_GetterFirst", {
get: function () { return ""; },
set: function (aStr) { aStr = 0; },
get: function () {
return "";
},
set: function (aStr) {
aStr = 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_error_cases.prototype, "AnnotatedGetter_GetterLast", {
get: function () { return ""; },
set: function (aStr) { aStr = 0; },
get: function () {
return "";
},
set: function (aStr) {
aStr = 0;
},
enumerable: true,
configurable: true
});
@@ -47,38 +47,56 @@ var LanguageSpec_section_4_5_inference = (function () {
function LanguageSpec_section_4_5_inference() {
}
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredGetterFromSetterAnnotation", {
get: function () { return new B(); },
set: function (a) { },
get: function () {
return new B();
},
set: function (a) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredGetterFromSetterAnnotation_GetterFirst", {
get: function () { return new B(); },
set: function (a) { },
get: function () {
return new B();
},
set: function (a) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredFromGetter", {
get: function () { return new B(); },
set: function (a) { },
get: function () {
return new B();
},
set: function (a) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredFromGetter_SetterFirst", {
get: function () { return new B(); },
set: function (a) { },
get: function () {
return new B();
},
set: function (a) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredSetterFromGetterAnnotation", {
get: function () { return new B(); },
set: function (a) { },
get: function () {
return new B();
},
set: function (a) {
},
enumerable: true,
configurable: true
});
Object.defineProperty(LanguageSpec_section_4_5_inference.prototype, "InferredSetterFromGetterAnnotation_GetterFirst", {
get: function () { return new B(); },
set: function (a) { },
get: function () {
return new B();
},
set: function (a) {
},
enumerable: true,
configurable: true
});
@@ -40,11 +40,13 @@ var r19 = a + { a: '' };
var r20 = a + ((a: string) => { return a });
//// [additionOperatorWithAnyAndEveryType.js]
function foo() { }
function foo() {
}
var C = (function () {
function C() {
}
C.foo = function () { };
C.foo = function () {
};
return C;
})();
var E;
@@ -83,5 +85,9 @@ var r15 = a + 0 /* a */;
var r16 = a + M;
var r17 = a + '';
var r18 = a + 123;
var r19 = a + { a: '' };
var r20 = a + (function (a) { return a; });
var r19 = a + {
a: ''
};
var r20 = a + (function (a) {
return a;
});
@@ -41,11 +41,13 @@ var r19 = E.a + C.foo();
var r20 = E.a + M;
//// [additionOperatorWithInvalidOperands.js]
function foo() { }
function foo() {
}
var C = (function () {
function C() {
}
C.foo = function () { };
C.foo = function () {
};
return C;
})();
var E;
@@ -25,7 +25,9 @@ var r11 = null + (() => { });
//// [additionOperatorWithNullValueAndInvalidOperator.js]
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
function foo() { return undefined; }
function foo() {
return undefined;
}
var a;
var b;
var c;
@@ -40,6 +42,9 @@ var r6 = null + c;
// other cases
var r7 = null + d;
var r8 = null + true;
var r9 = null + { a: '' };
var r9 = null + {
a: ''
};
var r10 = null + foo();
var r11 = null + (function () { });
var r11 = null + (function () {
});
@@ -75,5 +75,7 @@ var r15 = x + E;
var r16 = x + 0 /* a */;
var r17 = x + '';
var r18 = x + 0;
var r19 = x + { a: '' };
var r19 = x + {
a: ''
};
var r20 = x + [];
@@ -74,6 +74,7 @@ function foo(t, u) {
var r16 = t + undefined;
var r17 = t + t;
var r18 = t + u;
var r19 = t + (function () { });
var r19 = t + (function () {
});
var r20 = t + [];
}
@@ -25,7 +25,9 @@ var r11 = undefined + (() => { });
//// [additionOperatorWithUndefinedValueAndInvalidOperands.js]
// If one operand is the null or undefined value, it is treated as having the type of the other operand.
function foo() { return undefined; }
function foo() {
return undefined;
}
var a;
var b;
var c;
@@ -40,6 +42,9 @@ var r6 = undefined + c;
// other cases
var r7 = undefined + d;
var r8 = undefined + true;
var r9 = undefined + { a: '' };
var r9 = undefined + {
a: ''
};
var r10 = undefined + foo();
var r11 = undefined + (function () { });
var r11 = undefined + (function () {
});
@@ -46,5 +46,9 @@ var VisualizationModel = (function (_super) {
exports.VisualizationModel = VisualizationModel;
//// [aliasUsageInArray_main.js]
var moduleA = require("aliasUsageInArray_moduleA");
var xs = [moduleA];
var xs2 = [moduleA];
var xs = [
moduleA
];
var xs2 = [
moduleA
];
@@ -45,5 +45,9 @@ var VisualizationModel = (function (_super) {
exports.VisualizationModel = VisualizationModel;
//// [aliasUsageInFunctionExpression_main.js]
var moduleA = require("aliasUsageInFunctionExpression_moduleA");
var f = function (x) { return x; };
f = function (x) { return moduleA; };
var f = function (x) {
return x;
};
f = function (x) {
return moduleA;
};
@@ -52,5 +52,9 @@ var moduleA = require("aliasUsageInGenericFunction_moduleA");
function foo(x) {
return x;
}
var r = foo({ a: moduleA });
var r2 = foo({ a: null });
var r = foo({
a: moduleA
});
var r2 = foo({
a: null
});

Some files were not shown because too many files have changed in this diff Show More