Merge branch 'master' into arrowLookAhead

This commit is contained in:
Daniel Rosenwasser 2014-07-24 18:17:30 -07:00
commit b0c59e7c37
93 changed files with 867 additions and 985 deletions

View File

@ -306,6 +306,11 @@ function exec(cmd, completeHandler) {
}
complete();
});
ex.addListener("error", function(e, status) {
process.stderr.write(status);
process.stderr.write(e);
complete();
})
try{
ex.run();
} catch(e) {

View File

@ -4038,7 +4038,7 @@ module ts {
function checkAndAggregateReturnExpressionTypes(body: Block, contextualType?: Type, contextualMapper?: TypeMapper): Type[] {
var aggregatedTypes: Type[] = [];
forEachReturnStatement(body, (returnStatement) => {
forEachReturnStatement(body, returnStatement => {
var expr = returnStatement.expression;
if (expr) {
var type = checkAndMarkExpression(expr, contextualType, contextualMapper);
@ -4052,7 +4052,7 @@ module ts {
}
function bodyContainsAReturnStatement(funcBody: Block) {
return forEachReturnStatement(funcBody, (returnStatement) => {
return forEachReturnStatement(funcBody, returnStatement => {
return true;
});
}
@ -5284,7 +5284,7 @@ module ts {
function checkWithStatement(node: WithStatement) {
checkExpression(node.expression);
checkSourceElement(node.statement);
error(node.expression, Diagnostics.All_symbols_within_a_with_block_will_be_resolved_to_any);
}
function checkSwitchStatement(node: SwitchStatement) {
@ -5343,7 +5343,7 @@ module ts {
// for interfaces property and indexer might be inherited from different bases
// check if any base class already has both property and indexer.
// check should be performed only if 'type' is the first type that brings property\indexer together
var someBaseClassHasBothPropertyAndIndexer = forEach((<InterfaceType>type).baseTypes, (base) => getPropertyOfType(base, prop.name) && getIndexTypeOfType(base, indexKind));
var someBaseClassHasBothPropertyAndIndexer = forEach((<InterfaceType>type).baseTypes, base => getPropertyOfType(base, prop.name) && getIndexTypeOfType(base, indexKind));
errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : type.symbol.declarations[0];
}

View File

@ -123,6 +123,7 @@ module ts {
Setters_cannot_return_a_value: { code: 2122, category: DiagnosticCategory.Error, key: "Setters cannot return a value." },
Invalid_left_hand_side_of_assignment_expression: { code: 2130, category: DiagnosticCategory.Error, key: "Invalid left-hand side of assignment expression." },
Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: { code: 2134, category: DiagnosticCategory.Error, key: "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'." },
All_symbols_within_a_with_block_will_be_resolved_to_any: { code: 2135, category: DiagnosticCategory.Error, key: "All symbols within a 'with' block will be resolved to 'any'." },
The_operand_of_an_increment_or_decrement_operator_must_be_a_variable_property_or_indexer: { code: 2139, category: DiagnosticCategory.Error, key: "The operand of an increment or decrement operator must be a variable, property or indexer." },
Overload_signatures_must_all_be_public_or_private: { code: 2150, category: DiagnosticCategory.Error, key: "Overload signatures must all be public or private." },
Overload_signatures_must_all_be_exported_or_not_exported: { code: 2151, category: DiagnosticCategory.Error, key: "Overload signatures must all be exported or not exported." },

View File

@ -485,6 +485,10 @@
"category": "Error",
"code": 2134
},
"All symbols within a 'with' block will be resolved to 'any'.": {
"category": "Error",
"code": 2135
},
"The operand of an increment or decrement operator must be a variable, property or indexer.": {
"category": "Error",
"code": 2139

View File

@ -865,12 +865,13 @@ module ts {
return createMissingList<T>();
}
function parseEntityName(): EntityName {
// The allowReservedWords parameter controls whether reserved words are permitted after the first dot
function parseEntityName(allowReservedWords: boolean): EntityName {
var entity: EntityName = parseIdentifier();
while (parseOptional(SyntaxKind.DotToken)) {
var node = <QualifiedName>createNode(SyntaxKind.QualifiedName, entity.pos);
node.left = entity;
node.right = parseIdentifier();
node.right = allowReservedWords ? parseIdentifierName() : parseIdentifier();
entity = finishNode(node);
}
return entity;
@ -899,7 +900,7 @@ module ts {
function parseTypeReference(): TypeReferenceNode {
var node = <TypeReferenceNode>createNode(SyntaxKind.TypeReference);
node.typeName = parseEntityName();
node.typeName = parseEntityName(/*allowReservedWords*/ false);
if (!scanner.hasPrecedingLineBreak() && token === SyntaxKind.LessThanToken) {
node.typeArguments = parseTypeArguments();
}
@ -909,7 +910,7 @@ module ts {
function parseTypeQuery(): TypeQueryNode {
var node = <TypeQueryNode>createNode(SyntaxKind.TypeQuery);
parseExpected(SyntaxKind.TypeOfKeyword);
node.exprName = parseEntityName();
node.exprName = parseEntityName(/*allowReservedWords*/ true);
return finishNode(node);
}
@ -1873,7 +1874,12 @@ module ts {
if (token === SyntaxKind.OpenParenToken || token === SyntaxKind.LessThanToken) {
var sig = parseSignature(SyntaxKind.CallSignature, SyntaxKind.ColonToken);
var body = parseBody(/* ignoreMissingOpenBrace */ false);
node.initializer = makeFunctionExpression(SyntaxKind.FunctionExpression, node.pos, node.name, sig, body);
// do not propagate property name as name for function expression
// for scenarios like
// var x = 1;
// var y = { x() { } }
// otherwise this will bring y.x into the scope of x which is incorrect
node.initializer = makeFunctionExpression(SyntaxKind.FunctionExpression, node.pos, undefined, sig, body);
}
else {
parseExpected(SyntaxKind.ColonToken);
@ -2852,7 +2858,7 @@ module ts {
parseExpected(SyntaxKind.ImportKeyword);
node.name = parseIdentifier();
parseExpected(SyntaxKind.EqualsToken);
var entityName = parseEntityName();
var entityName = parseEntityName(/*allowReservedWords*/ false);
if (entityName.kind === SyntaxKind.Identifier && (<Identifier>entityName).text === "require" && parseOptional(SyntaxKind.OpenParenToken)) {
node.externalModuleName = parseStringLiteral();
parseExpected(SyntaxKind.CloseParenToken);

View File

@ -18,7 +18,7 @@
/// <reference path='..\compiler\sys.ts' />
/// <reference path='external\mocha.d.ts'/>
/// <reference path='external\chai.d.ts'/>
///<reference path='sourceMapRecorder.ts'/>
/// <reference path='sourceMapRecorder.ts'/>
// this will work in the browser via browserify
var _chai: typeof chai = require('chai');
@ -598,7 +598,7 @@ module Harness {
this.inputFiles.push(file);
}
public compile(options?: ts.CompilerOptions) {
public setCompilerOptions(options?: ts.CompilerOptions) {
this.compileOptions = options || { noResolve: false };
}
@ -624,7 +624,7 @@ module Harness {
settingsCallback(null);
}
this.settings.forEach(setting => {
this.settings.forEach(setting => {
switch (setting.flag.toLowerCase()) {
// "filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outDir", "noimplicitany", "noresolve"
case "module":
@ -692,6 +692,10 @@ module Harness {
case 'declaration':
options.declaration = !!setting.value;
break;
case 'newline':
case 'newlines':
sys.newLine = setting.value;
break;
case 'mapsourcefiles':
case 'maproot':
@ -753,6 +757,9 @@ module Harness {
// Covert the source Map data into the baseline
result.updateSourceMapRecord(program, sourceMapData);
onComplete(result);
// reset what newline means in case the last test changed it
sys.newLine = '\r\n';
return options;
}
}
@ -891,7 +898,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", "noimplicitany", "noresolve"];
var fileMetadataNames = ["filename", "comments", "declaration", "module", "nolib", "sourcemap", "target", "out", "outDir", "noimplicitany", "noresolve", "newline", "newlines"];
function extractCompilerSettings(content: string): CompilerSetting[] {
@ -1119,7 +1126,7 @@ module Harness {
return filePath.indexOf('lib.d.ts') >= 0 || filePath.indexOf('lib.core.d.ts') >= 0;
}
if (Error) (<any>Error).stackTraceLimit = 100;
if (Error) (<any>Error).stackTraceLimit = 1;
}
// TODO: not sure why Utils.evalFile isn't working with this, eventually will concat it like old compiler instead of eval

View File

@ -104,4 +104,6 @@ if (runners.length === 0) {
// runners.push(new GeneratedFourslashRunner());
}
sys.newLine = '\r\n';
runTests(runners);

View File

@ -143,7 +143,7 @@ module RWC {
harnessCompiler.addInputFile({ unitName: resolvedPath, content: content });
});
harnessCompiler.compile();
harnessCompiler.setCompilerOptions();
// Emit the results
harnessCompiler.emitAll(emitterIOHost);

View File

@ -37,7 +37,7 @@ class UnitTestRunner extends RunnerBase {
return { unitName: test, content: Harness.IO.readFile(test) }
});
harnessCompiler.addInputFiles(toBeAdded);
harnessCompiler.compile({ noResolve: true });
harnessCompiler.setCompilerOptions({ noResolve: true });
var stdout = new Harness.Compiler.EmitterIOHost();
var emitDiagnostics = harnessCompiler.emitAll(stdout);

View File

@ -1,4 +1,4 @@
==== tests/cases/compiler/ambientWithStatements.ts (14 errors) ====
==== tests/cases/compiler/ambientWithStatements.ts (15 errors) ====
declare module M {
break;
~~~~~
@ -52,5 +52,7 @@
with (x) {
~~~~
!!! Statements are not allowed in ambient contexts.
~
!!! All symbols within a 'with' block will be resolved to 'any'.
}
}

View File

@ -1,8 +1,10 @@
==== tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts (9 errors) ====
==== tests/cases/conformance/expressions/functions/arrowFunctionContexts.ts (10 errors) ====
// Arrow function used in with statement
with (window) {
~~~~~~
!!! All symbols within a 'with' block will be resolved to 'any'.
~~~~~~
!!! Cannot find name 'window'.
var p = () => this;
}
@ -52,10 +54,10 @@
// Arrow function used in with statement
with (window) {
~~~~~~
!!! All symbols within a 'with' block will be resolved to 'any'.
~~~~~~
!!! Cannot find name 'window'.
var p = () => this;
~~~~
!!! 'this' cannot be referenced in a module body.
}
// Arrow function as argument to super call

View File

@ -103,9 +103,8 @@ var __extends = this.__extends || function (d, b) {
__.prototype = b.prototype;
d.prototype = new __();
};
var _this = this;
with (window) {
var p = function () { return _this; };
var p = function () { return this; };
}
var Base = (function () {
function Base(n) {
@ -137,9 +136,8 @@ var M;
})(M || (M = {}));
var M2;
(function (M2) {
var _this = this;
with (window) {
var p = function () { return _this; };
var p = function () { return this; };
}
var Base = (function () {
function Base(n) {

View File

@ -90,10 +90,10 @@ var h;
x = h;
var i;
x = i;
x = { f: function f() {
x = { f: function () {
return 1;
} };
x = { f: function f(x) {
x = { f: function (x) {
return x;
} };
function j(a) {

View File

@ -66,7 +66,7 @@ t = { f: function (x) { return 1; } };
t = { f: function f() {
return 1;
} };
t = { f: function f(x) {
t = { f: function (x) {
return '';
} };
a = { f: function () { return 1; } };

View File

@ -32,7 +32,7 @@ var badFundule: Function = bad; // error
//// [assignmentToObjectAndFunction.js]
var errObj = { toString: 0 };
var goodObj = {
toString: function toString(x) {
toString: function (x) {
return "";
}
};

View File

@ -72,7 +72,7 @@ var C = (function () {
})();
var a;
var b = {
foo: function foo(x, y) {
foo: function (x, y) {
},
a: function foo(x, y) {
},

View File

@ -72,7 +72,7 @@ var C = (function () {
})();
var a;
var b = {
foo: function foo(x, x) {
foo: function (x, x) {
},
a: function foo(x, x) {
},

View File

@ -89,7 +89,7 @@ a(1);
a.foo();
a.foo(1);
var b = {
foo: function foo(x) {
foo: function (x) {
},
a: function foo(x, y) {
},

View File

@ -95,7 +95,7 @@ a(1);
a.foo();
a.foo(1);
var b = {
foo: function foo(x) {
foo: function (x) {
if (x === void 0) { x = 1; }
},
a: function foo(x, y) {

View File

@ -234,5 +234,5 @@
interface B extends A { }
var x: B = { };
~
!!! Type '{}' is not assignable to type 'B':
!!! Property 'x' is missing in type '{}'.
!!! Type '{}' is not assignable to type 'B':\n Property 'x' is missing in type '{}'.

View File

@ -228,198 +228,8 @@ Point.prototype = {
interface A { x: string; }
interface B extends A { }
var x: B = { };
var x: B = { };
//// [contextualTyping.js]
var C1T5 = (function () {
function C1T5() {
this.foo = function (i) {
return i;
};
}
return C1T5;
})();
var C2T5;
(function (C2T5) {
C2T5.foo = function (i) {
return i;
};
})(C2T5 || (C2T5 = {}));
var c3t1 = (function (s) {
return s;
});
var c3t2 = ({
n: 1
});
var c3t3 = [];
var c3t4 = function () {
return ({});
};
var c3t5 = function (n) {
return ({});
};
var c3t6 = function (n, s) {
return ({});
};
var c3t7 = function (n) {
return n;
};
var c3t8 = function (n) {
return n;
};
var c3t9 = [[], []];
var c3t10 = [({}), ({})];
var c3t11 = [function (n, s) {
return s;
}];
var c3t12 = {
foo: ({})
};
var c3t13 = ({
f: function (i, s) {
return s;
}
});
var c3t14 = ({
a: []
});
var C4T5 = (function () {
function C4T5() {
this.foo = function (i, s) {
return s;
};
}
return C4T5;
})();
var C5T5;
(function (C5T5) {
C5T5.foo;
C5T5.foo = function (i, s) {
return s;
};
})(C5T5 || (C5T5 = {}));
var c6t5;
c6t5 = function (n) {
return ({});
};
var c7t2;
c7t2[0] = ({ n: 1 });
var objc8 = ({});
objc8.t1 = (function (s) {
return s;
});
objc8.t2 = ({
n: 1
});
objc8.t3 = [];
objc8.t4 = function () {
return ({});
};
objc8.t5 = function (n) {
return ({});
};
objc8.t6 = function (n, s) {
return ({});
};
objc8.t7 = function (n) {
return n;
};
objc8.t8 = function (n) {
return n;
};
objc8.t9 = [[], []];
objc8.t10 = [({}), ({})];
objc8.t11 = [function (n, s) {
return s;
}];
objc8.t12 = {
foo: ({})
};
objc8.t13 = ({
f: function (i, s) {
return s;
}
});
objc8.t14 = ({
a: []
});
function c9t5(f) {
}
;
c9t5(function (n) {
return ({});
});
var c10t5 = function () {
return function (n) {
return ({});
};
};
var C11t5 = (function () {
function C11t5(f) {
}
return C11t5;
})();
;
var i = new C11t5(function (n) {
return ({});
});
var c12t1 = (function (s) {
return s;
});
var c12t2 = ({
n: 1
});
var c12t3 = [];
var c12t4 = function () {
return ({});
};
var c12t5 = function (n) {
return ({});
};
var c12t6 = function (n, s) {
return ({});
};
var c12t7 = function (n) {
return n;
};
var c12t8 = function (n) {
return n;
};
var c12t9 = [[], []];
var c12t10 = [({}), ({})];
var c12t11 = [function (n, s) {
return s;
}];
var c12t12 = {
foo: ({})
};
var c12t13 = ({
f: function (i, s) {
return s;
}
});
var c12t14 = ({
a: []
});
function EF1(a, b) {
return a + b;
}
var efv = EF1(1, 2);
function Point(x, y) {
this.x = x;
this.y = y;
return this;
}
Point.origin = new Point(0, 0);
Point.prototype.add = function (dx, dy) {
return new Point(this.x + dx, this.y + dy);
};
Point.prototype = {
x: 0,
y: 0,
add: function (dx, dy) {
return new Point(this.x + dx, this.y + dy);
}
};
var x = {};
//# sourceMappingURL=contextualTyping.js.map
var C1T5 = (function () {\n function C1T5() {\n this.foo = function (i) {\n return i;\n };\n }\n return C1T5;\n})();\nvar C2T5;\n(function (C2T5) {\n C2T5.foo = function (i) {\n return i;\n };\n})(C2T5 || (C2T5 = {}));\nvar c3t1 = (function (s) {\n return s;\n});\nvar c3t2 = ({\n n: 1\n});\nvar c3t3 = [];\nvar c3t4 = function () {\n return ({});\n};\nvar c3t5 = function (n) {\n return ({});\n};\nvar c3t6 = function (n, s) {\n return ({});\n};\nvar c3t7 = function (n) {\n return n;\n};\nvar c3t8 = function (n) {\n return n;\n};\nvar c3t9 = [[], []];\nvar c3t10 = [({}), ({})];\nvar c3t11 = [function (n, s) {\n return s;\n}];\nvar c3t12 = {\n foo: ({})\n};\nvar c3t13 = ({\n f: function (i, s) {\n return s;\n }\n});\nvar c3t14 = ({\n a: []\n});\nvar C4T5 = (function () {\n function C4T5() {\n this.foo = function (i, s) {\n return s;\n };\n }\n return C4T5;\n})();\nvar C5T5;\n(function (C5T5) {\n C5T5.foo;\n C5T5.foo = function (i, s) {\n return s;\n };\n})(C5T5 || (C5T5 = {}));\nvar c6t5;\nc6t5 = function (n) {\n return ({});\n};\nvar c7t2;\nc7t2[0] = ({ n: 1 });\nvar objc8 = ({});\nobjc8.t1 = (function (s) {\n return s;\n});\nobjc8.t2 = ({\n n: 1\n});\nobjc8.t3 = [];\nobjc8.t4 = function () {\n return ({});\n};\nobjc8.t5 = function (n) {\n return ({});\n};\nobjc8.t6 = function (n, s) {\n return ({});\n};\nobjc8.t7 = function (n) {\n return n;\n};\nobjc8.t8 = function (n) {\n return n;\n};\nobjc8.t9 = [[], []];\nobjc8.t10 = [({}), ({})];\nobjc8.t11 = [function (n, s) {\n return s;\n}];\nobjc8.t12 = {\n foo: ({})\n};\nobjc8.t13 = ({\n f: function (i, s) {\n return s;\n }\n});\nobjc8.t14 = ({\n a: []\n});\nfunction c9t5(f) {\n}\n;\nc9t5(function (n) {\n return ({});\n});\nvar c10t5 = function () {\n return function (n) {\n return ({});\n };\n};\nvar C11t5 = (function () {\n function C11t5(f) {\n }\n return C11t5;\n})();\n;\nvar i = new C11t5(function (n) {\n return ({});\n});\nvar c12t1 = (function (s) {\n return s;\n});\nvar c12t2 = ({\n n: 1\n});\nvar c12t3 = [];\nvar c12t4 = function () {\n return ({});\n};\nvar c12t5 = function (n) {\n return ({});\n};\nvar c12t6 = function (n, s) {\n return ({});\n};\nvar c12t7 = function (n) {\n return n;\n};\nvar c12t8 = function (n) {\n return n;\n};\nvar c12t9 = [[], []];\nvar c12t10 = [({}), ({})];\nvar c12t11 = [function (n, s) {\n return s;\n}];\nvar c12t12 = {\n foo: ({})\n};\nvar c12t13 = ({\n f: function (i, s) {\n return s;\n }\n});\nvar c12t14 = ({\n a: []\n});\nfunction EF1(a, b) {\n return a + b;\n}\nvar efv = EF1(1, 2);\nfunction Point(x, y) {\n this.x = x;\n this.y = y;\n return this;\n}\nPoint.origin = new Point(0, 0);\nPoint.prototype.add = function (dx, dy) {\n return new Point(this.x + dx, this.y + dy);\n};\nPoint.prototype = {\n x: 0,\n y: 0,\n add: function (dx, dy) {\n return new Point(this.x + dx, this.y + dy);\n }\n};\nvar x = {};\n//# sourceMappingURL=contextualTyping.js.map

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,10 @@
==== tests/cases/compiler/functionExpressionInWithBlock.ts (1 errors) ====
function x() {
with({}) {
~~
!!! All symbols within a 'with' block will be resolved to 'any'.
function f() {
() => this;
}
}
}

View File

@ -11,8 +11,7 @@ function x() {
function x() {
with ({}) {
function f() {
var _this = this;
(function () { return _this; });
(function () { return this; });
}
}
}

View File

@ -51,7 +51,7 @@ function foo(x, y) {
function foo2(x, y) {
}
var x = { a: new C() };
var x2 = { a: { bar: function bar() {
var x2 = { a: { bar: function () {
return 1;
} } };
var D = (function () {

View File

@ -54,7 +54,7 @@ var M;
M.x = 1;
})(M || (M = {}));
x = M;
x = { f: function f() {
x = { f: function () {
} };
function f(a) {
x = a;

View File

@ -59,5 +59,5 @@ var E;
})(E || (E = {}));
x = E;
x = 0 /* A */;
x = { f: function f() {
x = { f: function () {
} };

View File

@ -46,7 +46,7 @@ var a;
x = a;
var b;
x = b;
x = { f: function f() {
x = { f: function () {
} };
var M;
(function (M) {

View File

@ -1,5 +0,0 @@
==== tests/cases/compiler/nameCollisionsInPropertyAssignments.ts (1 errors) ====
var x = 1
var y = { x() { x++; } };
~
!!! An arithmetic operand must be of type 'any', 'number' or an enum type.

View File

@ -4,6 +4,6 @@ var y = { x() { x++; } };
//// [nameCollisionsInPropertyAssignments.js]
var x = 1;
var y = { x: function x() {
var y = { x: function () {
x++;
} };

View File

@ -126,7 +126,7 @@ var C = (function () {
return C;
})();
var a;
var b = { foo: function foo(x) {
var b = { foo: function (x) {
return '';
} };
function foo1(x) {

View File

@ -126,7 +126,7 @@ var C = (function () {
return C;
})();
var a;
var b = { foo: function foo(x) {
var b = { foo: function (x) {
return '';
} };
function foo1(x) {

View File

@ -126,7 +126,7 @@ var C = (function () {
return C;
})();
var a;
var b = { foo: function foo(x) {
var b = { foo: function (x) {
return '';
} };
function foo1(x) {

View File

@ -143,7 +143,7 @@ var C = (function () {
})();
var a;
var b = {
foo: function foo(x) {
foo: function (x) {
return '';
}
};

View File

@ -90,7 +90,7 @@ var C = (function () {
return C;
})();
var a;
var b = { new: function new(x) {
var b = { new: function (x) {
return '';
} };
function foo1b(x) {

View File

@ -90,7 +90,7 @@ var C = (function () {
return C;
})();
var a;
var b = { new: function new(x) {
var b = { new: function (x) {
return '';
} };
function foo1b(x) {

View File

@ -126,7 +126,7 @@ var C = (function () {
return C;
})();
var a;
var b = { foo: function foo(x) {
var b = { foo: function (x) {
return x;
} };
function foo1(x) {

View File

@ -126,7 +126,7 @@ var C = (function () {
return C;
})();
var a;
var b = { foo: function foo(x, y) {
var b = { foo: function (x, y) {
return x;
} };
function foo1(x) {

View File

@ -128,7 +128,7 @@ var C = (function () {
return C;
})();
var a;
var b = { foo: function foo(x) {
var b = { foo: function (x) {
return '';
} };
function foo1(x) {

View File

@ -148,7 +148,7 @@ var D = (function () {
return D;
})();
var a;
var b = { foo: function foo(x, y) {
var b = { foo: function (x, y) {
return '';
} };
function foo1(x) {

View File

@ -167,7 +167,7 @@ var D = (function () {
return D;
})();
var a;
var b = { foo: function foo(x, y) {
var b = { foo: function (x, y) {
return '';
} };
function foo1(x) {

View File

@ -128,7 +128,7 @@ var C = (function () {
return C;
})();
var a;
var b = { foo: function foo(x) {
var b = { foo: function (x) {
return null;
} };
function foo1(x) {

View File

@ -128,7 +128,7 @@ var C = (function () {
return C;
})();
var a;
var b = { foo: function foo(x) {
var b = { foo: function (x) {
return null;
} };
function foo1(x) {

View File

@ -126,7 +126,7 @@ var C = (function () {
return C;
})();
var a;
var b = { foo: function foo(x) {
var b = { foo: function (x) {
return x;
} };
function foo1(x) {

View File

@ -126,7 +126,7 @@ var C = (function () {
return C;
})();
var a;
var b = { foo: function foo(x) {
var b = { foo: function (x) {
return x;
} };
function foo1(x) {

View File

@ -128,7 +128,7 @@ var C = (function () {
return C;
})();
var a;
var b = { foo: function foo(x, y) {
var b = { foo: function (x, y) {
return x;
} };
function foo1(x) {

View File

@ -128,7 +128,7 @@ var C = (function () {
return C;
})();
var a;
var b = { foo: function foo(x, y) {
var b = { foo: function (x, y) {
return x;
} };
function foo1(x) {

View File

@ -128,7 +128,7 @@ var C = (function () {
return C;
})();
var a;
var b = { foo: function foo(x, y) {
var b = { foo: function (x, y) {
return x;
} };
function foo1(x) {

View File

@ -89,7 +89,7 @@ var C = (function () {
return C;
})();
var a;
var b = { new: function new(x) {
var b = { new: function (x) {
return '';
} };
function foo1b(x) {

View File

@ -106,7 +106,7 @@ var D = (function () {
return D;
})();
var a;
var b = { new: function new(x, y) {
var b = { new: function (x, y) {
return '';
} };
function foo1b(x) {

View File

@ -125,7 +125,7 @@ var D = (function () {
return D;
})();
var a;
var b = { new: function new(x, y) {
var b = { new: function (x, y) {
return '';
} };
function foo1b(x) {

View File

@ -96,7 +96,7 @@ var C = (function () {
return C;
})();
var a;
var b = { new: function new(x) {
var b = { new: function (x) {
return null;
} };
function foo1b(x) {

View File

@ -92,7 +92,7 @@ var C = (function () {
return C;
})();
var a;
var b = { new: function new(x) {
var b = { new: function (x) {
return null;
} };
function foo1b(x) {

View File

@ -86,7 +86,7 @@ var C = (function () {
return C;
})();
var a;
var b = { new: function new(x) {
var b = { new: function (x) {
return x;
} };
function foo1b(x) {

View File

@ -86,7 +86,7 @@ var C = (function () {
return C;
})();
var a;
var b = { new: function new(x) {
var b = { new: function (x) {
return new C(x);
} };
function foo1b(x) {

View File

@ -88,7 +88,7 @@ var C = (function () {
return C;
})();
var a;
var b = { new: function new(x, y) {
var b = { new: function (x, y) {
return new C(x, y);
} };
function foo1b(x) {

View File

@ -88,7 +88,7 @@ var C = (function () {
return C;
})();
var a;
var b = { new: function new(x, y) {
var b = { new: function (x, y) {
return new C(x, y);
} };
function foo1b(x) {

View File

@ -88,7 +88,7 @@ var C = (function () {
return C;
})();
var a;
var b = { new: function new(x, y) {
var b = { new: function (x, y) {
return new C(x, y);
} };
function foo1b(x) {

View File

@ -48,7 +48,7 @@ var C = (function () {
})();
var a;
var b = {
foo: function foo(x) {
foo: function (x) {
return x;
},
a: function foo(x) {

View File

@ -2,5 +2,5 @@
var v = { foo() { } };
//// [parserFunctionPropertyAssignment1.js]
var v = { foo: function foo() {
var v = { foo: function () {
} };

View File

@ -2,5 +2,5 @@
var v = { 0() { } };
//// [parserFunctionPropertyAssignment2.js]
var v = { 0: function 0() {
var v = { 0: function () {
} };

View File

@ -2,5 +2,5 @@
var v = { "foo"() { } };
//// [parserFunctionPropertyAssignment3.js]
var v = { "foo": function "foo"() {
var v = { "foo": function () {
} };

View File

@ -2,5 +2,5 @@
var v = { 0<T>() { } };
//// [parserFunctionPropertyAssignment4.js]
var v = { 0: function 0() {
var v = { 0: function () {
} };

View File

@ -1,6 +1,8 @@
==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode14.ts (1 errors) ====
==== tests/cases/conformance/parser/ecmascript5/StrictMode/parserStrictMode14.ts (2 errors) ====
"use strict";
with (a) {
~
!!! All symbols within a 'with' block will be resolved to 'any'.
~
!!! Cannot find name 'a'.
}

View File

@ -1,7 +1,9 @@
==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement1.d.ts (2 errors) ====
==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement1.d.ts (3 errors) ====
with (foo) {
~~~~
!!! Statements are not allowed in ambient contexts.
~~~
!!! All symbols within a 'with' block will be resolved to 'any'.
~~~
!!! Cannot find name 'foo'.
}

View File

@ -0,0 +1,5 @@
==== tests/cases/conformance/parser/ecmascript5/Statements/parserWithStatement2.ts (1 errors) ====
with (1)
~
!!! All symbols within a 'with' block will be resolved to 'any'.
return;

View File

@ -2,6 +2,6 @@
var x = { n() { } };
//// [sourceMapValidationFunctionPropertyAssignment.js]
var x = { n: function n() {
var x = { n: function () {
} };
//# sourceMappingURL=sourceMapValidationFunctionPropertyAssignment.js.map

View File

@ -1,2 +1,2 @@
//// [sourceMapValidationFunctionPropertyAssignment.js.map]
{"version":3,"file":"sourceMapValidationFunctionPropertyAssignment.js","sourceRoot":"","sources":["sourceMapValidationFunctionPropertyAssignment.ts"],"names":["n"],"mappings":"AAAA,IAAI,CAAC,GAAG,EAAE,CAAC,EAAD,SAAA,CAAC;AAAKA,CAACA,EAAE,CAAC"}
{"version":3,"file":"sourceMapValidationFunctionPropertyAssignment.js","sourceRoot":"","sources":["sourceMapValidationFunctionPropertyAssignment.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG,EAAE,CAAC,EAAD;AAAM,CAAC,EAAE,CAAC"}

View File

@ -8,7 +8,7 @@ sources: sourceMapValidationFunctionPropertyAssignment.ts
emittedFile:tests/cases/compiler/sourceMapValidationFunctionPropertyAssignment.js
sourceFile:sourceMapValidationFunctionPropertyAssignment.ts
-------------------------------------------------------------------
>>>var x = { n: function n() {
>>>var x = { n: function () {
1 >
2 >^^^^
3 > ^
@ -16,8 +16,6 @@ sourceFile:sourceMapValidationFunctionPropertyAssignment.ts
5 > ^^
6 > ^
7 > ^^
8 > ^^^^^^^^^
9 > ^
1 >
2 >var
3 > x
@ -25,8 +23,6 @@ sourceFile:sourceMapValidationFunctionPropertyAssignment.ts
5 > {
6 > n
7 >
8 >
9 > n
1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0)
2 >Emitted(1, 5) Source(1, 5) + SourceIndex(0)
3 >Emitted(1, 6) Source(1, 6) + SourceIndex(0)
@ -34,8 +30,6 @@ sourceFile:sourceMapValidationFunctionPropertyAssignment.ts
5 >Emitted(1, 11) Source(1, 11) + SourceIndex(0)
6 >Emitted(1, 12) Source(1, 12) + SourceIndex(0)
7 >Emitted(1, 14) Source(1, 11) + SourceIndex(0)
8 >Emitted(1, 23) Source(1, 11) + SourceIndex(0)
9 >Emitted(1, 24) Source(1, 12) + SourceIndex(0)
---
>>>} };
1 >
@ -43,12 +37,12 @@ sourceFile:sourceMapValidationFunctionPropertyAssignment.ts
3 > ^^
4 > ^
5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1 >() {
1 >n() {
2 >}
3 > }
4 > ;
1 >Emitted(2, 1) Source(1, 17) + SourceIndex(0) name (n)
2 >Emitted(2, 2) Source(1, 18) + SourceIndex(0) name (n)
1 >Emitted(2, 1) Source(1, 17) + SourceIndex(0)
2 >Emitted(2, 2) Source(1, 18) + SourceIndex(0)
3 >Emitted(2, 4) Source(1, 20) + SourceIndex(0)
4 >Emitted(2, 5) Source(1, 21) + SourceIndex(0)
---

View File

@ -0,0 +1,86 @@
==== tests/cases/compiler/sourceMapValidationStatements.ts (1 errors) ====
function f() {
var y;
var x = 0;
for (var i = 0; i < 10; i++) {
x += i;
x *= 0;
}
if (x > 17) {
x /= 9;
} else {
x += 10;
x++;
}
var a = [
1,
2,
3
];
var obj = {
z: 1,
q: "hello"
};
for (var j in a) {
obj.z = a[j];
var v = 10;
}
try {
obj.q = "ohhh";
} catch (e) {
if (obj.z < 10) {
obj.z = 12;
} else {
obj.q = "hmm";
}
}
try {
throw new Error();
} catch (e1) {
var b = e1;
} finally {
y = 70;
}
with (obj) {
~~~
!!! All symbols within a 'with' block will be resolved to 'any'.
i = 2;
z = 10;
}
switch (obj.z) {
case 0: {
x++;
break;
}
case 1: {
x--;
break;
}
default: {
x *= 2;
x = 50;
break;
}
}
while (x < 10) {
x++;
}
do {
x--;
} while (x > 4)
x = y;
var z = (x == 1) ? x + 1 : x - 1;
(x == 1) ? x + 1 : x - 1;
x === 1;
x = z = 40;
eval("y");
return;
}
var b = function () {
var x = 10;
x = x + 1;
};
f();

View File

@ -42,7 +42,7 @@ var C = (function () {
})();
var a;
var b = {
foo: function foo(x) {
foo: function (x) {
},
a: function foo(x, y) {
},

View File

@ -41,8 +41,8 @@ var C = (function () {
})();
var a;
var b = {
foo: function foo(x) {
foo: function (x) {
},
foo: function foo(x) {
foo: function (x) {
},
};

View File

@ -1,4 +1,4 @@
==== tests/cases/compiler/superCallsInConstructor.ts (2 errors) ====
==== tests/cases/compiler/superCallsInConstructor.ts (1 errors) ====
class C {
foo() {}
bar() {}
@ -11,13 +11,11 @@
class Derived extends Base {
constructor() {
with(new C()) {
~~~~~~~
!!! All symbols within a 'with' block will be resolved to 'any'.
foo();
~~~
!!! Cannot find name 'foo'.
super();
bar();
~~~
!!! Cannot find name 'bar'.
}
try {} catch(e) { super(); }

View File

@ -29,7 +29,7 @@ var MyClass = (function () {
return MyClass;
})();
var obj = {
f: function f() {
f: function () {
return this.spaaace;
}
};

View File

@ -88,7 +88,7 @@ var C = (function () {
})();
var aa = {
id: 12,
biz: function biz() {
biz: function () {
throw this;
}
};

View File

@ -0,0 +1,29 @@
//// [typeQueryWithReservedWords.ts]
class Controller {
create() {
}
delete() {
}
var() {
}
}
interface IScope {
create: typeof Controller.prototype.create;
delete: typeof Controller.prototype.delete; // Should not error
var: typeof Controller.prototype.var; // Should not error
}
//// [typeQueryWithReservedWords.js]
var Controller = (function () {
function Controller() {
}
Controller.prototype.create = function () {
};
Controller.prototype.delete = function () {
};
Controller.prototype.var = function () {
};
return Controller;
})();

View File

@ -1,13 +1,11 @@
==== tests/cases/compiler/withStatement.ts (2 errors) ====
==== tests/cases/compiler/withStatement.ts (1 errors) ====
declare var ooo:any;
with (ooo.eee.oo.ah_ah.ting.tang.walla.walla) { // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! All symbols within a 'with' block will be resolved to 'any'.
bing = true; // no error
~~~~
!!! Cannot find name 'bing'.
bang = true; // no error
~~~~
!!! Cannot find name 'bang'.
function bar() {}

View File

@ -1,13 +1,11 @@
==== tests/cases/compiler/withStatementErrors.ts (4 errors) ====
==== tests/cases/compiler/withStatementErrors.ts (3 errors) ====
declare var ooo:any;
with (ooo.eee.oo.ah_ah.ting.tang.walla.walla) { // error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! All symbols within a 'with' block will be resolved to 'any'.
bing = true; // no error
~~~~
!!! Cannot find name 'bing'.
bang = true; // no error
~~~~
!!! Cannot find name 'bang'.
function bar() {} // no error

View File

@ -0,0 +1,11 @@
==== tests/cases/compiler/withStatementNestedScope.ts (1 errors) ====
var x = 1;
with (x) {
~
!!! All symbols within a 'with' block will be resolved to 'any'.
function f(a: number) {
return 1;
}
// should be any
var r = f(1);
}

View File

@ -1,10 +1,8 @@
==== tests/cases/conformance/statements/withStatements/withStatements.ts (2 errors) ====
==== tests/cases/conformance/statements/withStatements/withStatements.ts (1 errors) ====
var x = 12;
with (x) {
~
!!! All symbols within a 'with' block will be resolved to 'any'.
name = 'twelve'
~~~~
!!! Cannot find name 'name'.
id = 12
~~
!!! Cannot find name 'id'.
}

View File

@ -1,3 +1,4 @@
// @newline: \n
// @sourcemap: true
// DEFAULT INTERFACES
interface IFoo {
@ -228,4 +229,4 @@ Point.prototype = {
interface A { x: string; }
interface B extends A { }
var x: B = { };
var x: B = { };

View File

@ -0,0 +1,14 @@
class Controller {
create() {
}
delete() {
}
var() {
}
}
interface IScope {
create: typeof Controller.prototype.create;
delete: typeof Controller.prototype.delete; // Should not error
var: typeof Controller.prototype.var; // Should not error
}