mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Baseline updates now that we emit in the presence of parse errors.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
//// [ArrowFunction1.ts]
|
||||
var v = (a: ) => {
|
||||
|
||||
};
|
||||
|
||||
//// [ArrowFunction1.js]
|
||||
var v = function (a) {
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
//// [ArrowFunction3.ts]
|
||||
var v = (a): => {
|
||||
|
||||
};
|
||||
|
||||
//// [ArrowFunction3.js]
|
||||
var v = function (a) {
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [ExportAssignment7.ts]
|
||||
export class C {
|
||||
}
|
||||
|
||||
export = B;
|
||||
|
||||
//// [ExportAssignment7.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
exports.C = C;
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [ExportAssignment8.ts]
|
||||
export = B;
|
||||
|
||||
export class C {
|
||||
}
|
||||
|
||||
//// [ExportAssignment8.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
exports.C = C;
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
//// [ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.ts]
|
||||
module A {
|
||||
|
||||
class Point {
|
||||
constructor(public x: number, public y: number) { }
|
||||
}
|
||||
|
||||
export var UnitSquare : {
|
||||
top: { left: Point, right: Point },
|
||||
bottom: { left: Point, right: Point }
|
||||
} = null;
|
||||
}
|
||||
|
||||
//// [ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.js]
|
||||
var A;
|
||||
(function (A) {
|
||||
var Point = (function () {
|
||||
function Point(x, y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
return Point;
|
||||
})();
|
||||
A.UnitSquare = null;
|
||||
})(A || (A = {}));
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [FunctionDeclaration12_es6.ts]
|
||||
var v = function * yield() { }
|
||||
|
||||
//// [FunctionDeclaration12_es6.js]
|
||||
var v = , yield = function () {
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
//// [FunctionDeclaration5_es6.ts]
|
||||
function*foo(yield) {
|
||||
}
|
||||
|
||||
//// [FunctionDeclaration5_es6.js]
|
||||
yield;
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [FunctionPropertyAssignments2_es6.ts]
|
||||
var v = { *() { } }
|
||||
|
||||
//// [FunctionPropertyAssignments2_es6.js]
|
||||
var v = { : function () {
|
||||
} };
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [FunctionPropertyAssignments3_es6.ts]
|
||||
var v = { *{ } }
|
||||
|
||||
//// [FunctionPropertyAssignments3_es6.js]
|
||||
var v = { : function () {
|
||||
} };
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [FunctionPropertyAssignments4_es6.ts]
|
||||
var v = { * }
|
||||
|
||||
//// [FunctionPropertyAssignments4_es6.js]
|
||||
var v = { : function () {
|
||||
} };
|
||||
@@ -0,0 +1,6 @@
|
||||
//// [FunctionPropertyAssignments6_es6.ts]
|
||||
var v = { *<T>() { } }
|
||||
|
||||
//// [FunctionPropertyAssignments6_es6.js]
|
||||
var v = { : function () {
|
||||
} };
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [MemberFunctionDeclaration4_es6.ts]
|
||||
class C {
|
||||
*() { }
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration4_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype. = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [MemberFunctionDeclaration5_es6.ts]
|
||||
class C {
|
||||
*
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration5_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [MemberFunctionDeclaration6_es6.ts]
|
||||
class C {
|
||||
*foo
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration6_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,22 @@
|
||||
//// [MemberFunctionDeclaration8_es6.ts]
|
||||
class C {
|
||||
foo() {
|
||||
// Make sure we don't think of *bar as the start of a generator method.
|
||||
if (a) # * bar;
|
||||
return bar;
|
||||
}
|
||||
}
|
||||
|
||||
//// [MemberFunctionDeclaration8_es6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
// Make sure we don't think of *bar as the start of a generator method.
|
||||
if (a)
|
||||
;
|
||||
* bar;
|
||||
return bar;
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [TemplateExpression1.ts]
|
||||
var v = `foo ${ a
|
||||
|
||||
//// [TemplateExpression1.js]
|
||||
var v = "foo " + a;
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [TupleType4.ts]
|
||||
var v: [
|
||||
|
||||
//// [TupleType4.js]
|
||||
var v;
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
//// [tests/cases/conformance/internalModules/DeclarationMerging/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.ts] ////
|
||||
|
||||
//// [part1.ts]
|
||||
export module A {
|
||||
export interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
export module Utils {
|
||||
export function mirror<T extends Point>(p: T) {
|
||||
return { x: p.y, y: p.x };
|
||||
}
|
||||
}
|
||||
|
||||
export var Origin: Point = { x: 0, y: 0 };
|
||||
}
|
||||
|
||||
//// [part2.ts]
|
||||
export module A {
|
||||
// collision with 'Origin' var in other part of merged module
|
||||
export var Origin: Point = { x: 0, y: 0 };
|
||||
|
||||
export module Utils {
|
||||
export class Plane {
|
||||
constructor(public tl: Point, public br: Point) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [part1.js]
|
||||
var A;
|
||||
(function (A) {
|
||||
var Utils;
|
||||
(function (Utils) {
|
||||
function mirror(p) {
|
||||
return { x: p.y, y: p.x };
|
||||
}
|
||||
Utils.mirror = mirror;
|
||||
})(Utils = A.Utils || (A.Utils = {}));
|
||||
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 };
|
||||
var Utils;
|
||||
(function (Utils) {
|
||||
var Plane = (function () {
|
||||
function Plane(tl, br) {
|
||||
this.tl = tl;
|
||||
this.br = br;
|
||||
}
|
||||
return Plane;
|
||||
})();
|
||||
Utils.Plane = Plane;
|
||||
})(Utils = A.Utils || (A.Utils = {}));
|
||||
})(A = exports.A || (exports.A = {}));
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [TypeArgumentList1.ts]
|
||||
Foo<A,B,\ C>(4, 5, 6);
|
||||
|
||||
//// [TypeArgumentList1.js]
|
||||
Foo(4, 5, 6);
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [YieldExpression5_es6.ts]
|
||||
function* foo() {
|
||||
yield*
|
||||
}
|
||||
|
||||
//// [YieldExpression5_es6.js]
|
||||
function foo() {
|
||||
;
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
//// [aliasErrors.ts]
|
||||
module foo {
|
||||
export class Provide {
|
||||
}
|
||||
export module bar { export module baz {export class boo {}}}
|
||||
}
|
||||
|
||||
import provide = foo;
|
||||
import booz = foo.bar.baz;
|
||||
import beez = foo.bar;
|
||||
|
||||
import m = no;
|
||||
import m2 = no.mod;
|
||||
import n = 5;
|
||||
import o = "s";
|
||||
import q = null;
|
||||
import r = undefined;
|
||||
|
||||
|
||||
var p = new provide.Provide();
|
||||
|
||||
function use() {
|
||||
|
||||
beez.baz.boo;
|
||||
var p1: provide.Provide;
|
||||
var p2: foo.Provide;
|
||||
var p3:booz.bar;
|
||||
var p22 = new provide.Provide();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//// [aliasErrors.js]
|
||||
var foo;
|
||||
(function (foo) {
|
||||
var Provide = (function () {
|
||||
function Provide() {
|
||||
}
|
||||
return Provide;
|
||||
})();
|
||||
foo.Provide = Provide;
|
||||
var bar;
|
||||
(function (bar) {
|
||||
var baz;
|
||||
(function (baz) {
|
||||
var boo = (function () {
|
||||
function boo() {
|
||||
}
|
||||
return boo;
|
||||
})();
|
||||
baz.boo = boo;
|
||||
})(baz = bar.baz || (bar.baz = {}));
|
||||
})(bar = foo.bar || (foo.bar = {}));
|
||||
})(foo || (foo = {}));
|
||||
var provide = foo;
|
||||
var booz = foo.bar.baz;
|
||||
var beez = foo.bar;
|
||||
5;
|
||||
"s";
|
||||
null;
|
||||
var p = new provide.Provide();
|
||||
function use() {
|
||||
beez.baz.boo;
|
||||
var p1;
|
||||
var p2;
|
||||
var p3;
|
||||
var p22 = new provide.Provide();
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//// [tests/cases/conformance/ambient/ambientDeclarationsExternal.ts] ////
|
||||
|
||||
//// [decls.ts]
|
||||
|
||||
// Ambient external module with export assignment
|
||||
declare module 'equ' {
|
||||
var x;
|
||||
export = x;
|
||||
}
|
||||
|
||||
declare module 'equ2' {
|
||||
var x: number;
|
||||
}
|
||||
|
||||
// Ambient external import declaration referencing ambient external module using top level module name
|
||||
//// [consumer.ts]
|
||||
/// <reference path="decls.ts" />
|
||||
import imp1 = require('equ');
|
||||
|
||||
|
||||
// Ambient external module members are always exported with or without export keyword when module lacks export assignment
|
||||
import imp3 = require('equ2');
|
||||
var n = imp3.x;
|
||||
var n: number;
|
||||
|
||||
|
||||
//// [decls.js]
|
||||
// Ambient external import declaration referencing ambient external module using top level module name
|
||||
//// [consumer.js]
|
||||
// Ambient external module members are always exported with or without export keyword when module lacks export assignment
|
||||
var imp3 = require('equ2');
|
||||
var n = imp3.x;
|
||||
var n;
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [ambiguousGenericAssertion1.ts]
|
||||
function f<T>(x: T): T { return null; }
|
||||
var r = <T>(x: T) => x;
|
||||
var r2 = < <T>(x: T) => T>f; // valid
|
||||
var r3 = <<T>(x: T) => T>f; // ambiguous, appears to the parser as a << operation
|
||||
|
||||
|
||||
//// [ambiguousGenericAssertion1.js]
|
||||
function f(x) {
|
||||
return null;
|
||||
}
|
||||
var r = function (x) { return x; };
|
||||
var r2 = f; // valid
|
||||
var r3 = << T > (x), T;
|
||||
T > f; // ambiguous, appears to the parser as a << operation
|
||||
@@ -0,0 +1,24 @@
|
||||
//// [amdModuleName2.ts]
|
||||
///<amd-module name='FirstModuleName'/>
|
||||
///<amd-module name='SecondModuleName'/>
|
||||
class Foo {
|
||||
x: number;
|
||||
constructor() {
|
||||
this.x = 5;
|
||||
}
|
||||
}
|
||||
export = Foo;
|
||||
|
||||
|
||||
//// [amdModuleName2.js]
|
||||
define("SecondModuleName", ["require", "exports"], function (require, exports) {
|
||||
///<amd-module name='FirstModuleName'/>
|
||||
///<amd-module name='SecondModuleName'/>
|
||||
var Foo = (function () {
|
||||
function Foo() {
|
||||
this.x = 5;
|
||||
}
|
||||
return Foo;
|
||||
})();
|
||||
return Foo;
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
//// [anonymousModules.ts]
|
||||
module {
|
||||
export var foo = 1;
|
||||
|
||||
module {
|
||||
export var bar = 1;
|
||||
}
|
||||
|
||||
var bar = 2;
|
||||
|
||||
module {
|
||||
var x = bar;
|
||||
}
|
||||
}
|
||||
|
||||
//// [anonymousModules.js]
|
||||
module;
|
||||
{
|
||||
exports.foo = 1;
|
||||
module;
|
||||
{
|
||||
exports.bar = 1;
|
||||
}
|
||||
var bar = 2;
|
||||
module;
|
||||
{
|
||||
var x = bar;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [arrayTypeOfTypeOf.ts]
|
||||
// array type cannot use typeof.
|
||||
|
||||
var x = 1;
|
||||
var xs: typeof x[]; // Not an error. This is equivalent to Array<typeof x>
|
||||
var xs2: typeof Array;
|
||||
var xs3: typeof Array<number>;
|
||||
var xs4: typeof Array<typeof x>;
|
||||
|
||||
//// [arrayTypeOfTypeOf.js]
|
||||
// array type cannot use typeof.
|
||||
var x = 1;
|
||||
var xs; // Not an error. This is equivalent to Array<typeof x>
|
||||
var xs2;
|
||||
var xs3 = ;
|
||||
var xs4 = ;
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [arrowFunctionMissingCurlyWithSemicolon.ts]
|
||||
// Should error at semicolon.
|
||||
var f = () => ;
|
||||
var b = 1 * 2 * 3 * 4;
|
||||
var square = (x: number) => x * x;
|
||||
|
||||
//// [arrowFunctionMissingCurlyWithSemicolon.js]
|
||||
// Should error at semicolon.
|
||||
var f = ;
|
||||
var b = 1 * 2 * 3 * 4;
|
||||
var square = function (x) { return x * x; };
|
||||
@@ -0,0 +1,140 @@
|
||||
//// [arrowFunctionsMissingTokens.ts]
|
||||
|
||||
module missingArrowsWithCurly {
|
||||
var a = () { };
|
||||
|
||||
var b = (): void { }
|
||||
|
||||
var c = (x) { };
|
||||
|
||||
var d = (x: number, y: string) { };
|
||||
|
||||
var e = (x: number, y: string): void { };
|
||||
}
|
||||
|
||||
module missingCurliesWithArrow {
|
||||
module withStatement {
|
||||
var a = () => var k = 10;};
|
||||
|
||||
var b = (): void => var k = 10;}
|
||||
|
||||
var c = (x) => var k = 10;};
|
||||
|
||||
var d = (x: number, y: string) => var k = 10;};
|
||||
|
||||
var e = (x: number, y: string): void => var k = 10;};
|
||||
|
||||
var f = () => var k = 10;}
|
||||
}
|
||||
|
||||
module withoutStatement {
|
||||
var a = () => };
|
||||
|
||||
var b = (): void => }
|
||||
|
||||
var c = (x) => };
|
||||
|
||||
var d = (x: number, y: string) => };
|
||||
|
||||
var e = (x: number, y: string): void => };
|
||||
|
||||
var f = () => }
|
||||
}
|
||||
}
|
||||
|
||||
module ce_nEst_pas_une_arrow_function {
|
||||
var a = ();
|
||||
|
||||
var b = (): void;
|
||||
|
||||
var c = (x);
|
||||
|
||||
var d = (x: number, y: string);
|
||||
|
||||
var e = (x: number, y: string): void;
|
||||
}
|
||||
|
||||
module okay {
|
||||
var a = () => { };
|
||||
|
||||
var b = (): void => { }
|
||||
|
||||
var c = (x) => { };
|
||||
|
||||
var d = (x: number, y: string) => { };
|
||||
|
||||
var e = (x: number, y: string): void => { };
|
||||
}
|
||||
|
||||
//// [arrowFunctionsMissingTokens.js]
|
||||
var missingArrowsWithCurly;
|
||||
(function (missingArrowsWithCurly) {
|
||||
var a = function () {
|
||||
};
|
||||
var b = function () {
|
||||
};
|
||||
var c = function (x) {
|
||||
};
|
||||
var d = function (x, y) {
|
||||
};
|
||||
var e = function (x, y) {
|
||||
};
|
||||
})(missingArrowsWithCurly || (missingArrowsWithCurly = {}));
|
||||
var missingCurliesWithArrow;
|
||||
(function (missingCurliesWithArrow) {
|
||||
var withStatement;
|
||||
(function (withStatement) {
|
||||
var a = function () {
|
||||
var k = 10;
|
||||
};
|
||||
var b = function () {
|
||||
var k = 10;
|
||||
};
|
||||
var c = function (x) {
|
||||
var k = 10;
|
||||
};
|
||||
var d = function (x, y) {
|
||||
var k = 10;
|
||||
};
|
||||
var e = function (x, y) {
|
||||
var k = 10;
|
||||
};
|
||||
var f = function () {
|
||||
var k = 10;
|
||||
};
|
||||
})(withStatement || (withStatement = {}));
|
||||
var withoutStatement;
|
||||
(function (withoutStatement) {
|
||||
var a = ;
|
||||
})(withoutStatement || (withoutStatement = {}));
|
||||
;
|
||||
var b = ;
|
||||
})(missingCurliesWithArrow || (missingCurliesWithArrow = {}));
|
||||
var c = ;
|
||||
;
|
||||
var d = ;
|
||||
;
|
||||
var e = ;
|
||||
;
|
||||
var f = ;
|
||||
var ce_nEst_pas_une_arrow_function;
|
||||
(function (ce_nEst_pas_une_arrow_function) {
|
||||
var a = ();
|
||||
var b = ;
|
||||
var c = (x);
|
||||
var d = ;
|
||||
var e = ;
|
||||
})(ce_nEst_pas_une_arrow_function || (ce_nEst_pas_une_arrow_function = {}));
|
||||
var okay;
|
||||
(function (okay) {
|
||||
var a = function () {
|
||||
};
|
||||
var b = function () {
|
||||
};
|
||||
var c = function (x) {
|
||||
};
|
||||
var d = function (x, y) {
|
||||
};
|
||||
var e = function (x, y) {
|
||||
};
|
||||
})(okay || (okay = {}));
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [assertInWrapSomeTypeParameter.ts]
|
||||
class C<T extends C<T>> {
|
||||
foo<U extends C<C<T>>(x: U) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//// [assertInWrapSomeTypeParameter.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function (x) {
|
||||
return null;
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,164 @@
|
||||
//// [assignmentLHSIsValue.ts]
|
||||
// expected error for all the LHS of assignments
|
||||
var value;
|
||||
|
||||
// this
|
||||
class C {
|
||||
constructor() { this = value; }
|
||||
foo() { this = value; }
|
||||
static sfoo() { this = value; }
|
||||
}
|
||||
|
||||
function foo() { this = value; }
|
||||
|
||||
this = value;
|
||||
|
||||
// identifiers: module, class, enum, function
|
||||
module M { export var a; }
|
||||
M = value;
|
||||
|
||||
C = value;
|
||||
|
||||
enum E { }
|
||||
E = value;
|
||||
|
||||
foo = value;
|
||||
|
||||
// literals
|
||||
null = value;
|
||||
true = value;
|
||||
false = value;
|
||||
0 = value;
|
||||
'' = value;
|
||||
/d+/ = value;
|
||||
|
||||
// object literals
|
||||
{ a: 0} = value;
|
||||
|
||||
// array literals
|
||||
['', ''] = value;
|
||||
|
||||
// super
|
||||
class Derived extends C {
|
||||
constructor() { super(); super = value; }
|
||||
|
||||
foo() { super = value }
|
||||
|
||||
static sfoo() { super = value; }
|
||||
}
|
||||
|
||||
// function expression
|
||||
function bar() { } = value;
|
||||
() => { } = value;
|
||||
|
||||
// function calls
|
||||
foo() = value;
|
||||
|
||||
// parentheses, the containted expression is value
|
||||
(this) = value;
|
||||
(M) = value;
|
||||
(C) = value;
|
||||
(E) = value;
|
||||
(foo) = value;
|
||||
(null) = value;
|
||||
(true) = value;
|
||||
(0) = value;
|
||||
('') = value;
|
||||
(/d+/) = value;
|
||||
({}) = value;
|
||||
([]) = value;
|
||||
(function baz() { }) = value;
|
||||
(foo()) = value;
|
||||
|
||||
//// [assignmentLHSIsValue.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
// expected error for all the LHS of assignments
|
||||
var value;
|
||||
// this
|
||||
var C = (function () {
|
||||
function C() {
|
||||
this = value;
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
this = value;
|
||||
};
|
||||
C.sfoo = function () {
|
||||
this = value;
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
function foo() {
|
||||
this = value;
|
||||
}
|
||||
this = value;
|
||||
// identifiers: module, class, enum, function
|
||||
var M;
|
||||
(function (M) {
|
||||
M.a;
|
||||
})(M || (M = {}));
|
||||
M = value;
|
||||
C = value;
|
||||
var E;
|
||||
(function (E) {
|
||||
})(E || (E = {}));
|
||||
E = value;
|
||||
foo = value;
|
||||
// literals
|
||||
null = value;
|
||||
true = value;
|
||||
false = value;
|
||||
0 = value;
|
||||
'' = value;
|
||||
/d+/ = value;
|
||||
// object literals
|
||||
{
|
||||
a: 0;
|
||||
}
|
||||
value;
|
||||
// array literals
|
||||
'' = value[0], '' = value[1];
|
||||
// super
|
||||
var Derived = (function (_super) {
|
||||
__extends(Derived, _super);
|
||||
function Derived() {
|
||||
_super.call(this);
|
||||
_super.prototype. = value;
|
||||
}
|
||||
Derived.prototype.foo = function () {
|
||||
_super.prototype. = value;
|
||||
};
|
||||
Derived.sfoo = function () {
|
||||
_super. = value;
|
||||
};
|
||||
return Derived;
|
||||
})(C);
|
||||
// function expression
|
||||
function bar() {
|
||||
}
|
||||
value;
|
||||
(function () {
|
||||
});
|
||||
value;
|
||||
// function calls
|
||||
foo() = value;
|
||||
// parentheses, the containted expression is value
|
||||
(this) = value;
|
||||
(M) = value;
|
||||
(C) = value;
|
||||
(E) = value;
|
||||
(foo) = value;
|
||||
(null) = value;
|
||||
(true) = value;
|
||||
(0) = value;
|
||||
('') = value;
|
||||
(/d+/) = value;
|
||||
({}) = value;
|
||||
([]) = value;
|
||||
(function baz() {
|
||||
}) = value;
|
||||
(foo()) = value;
|
||||
@@ -0,0 +1,52 @@
|
||||
//// [autoLift2.ts]
|
||||
class A
|
||||
|
||||
{
|
||||
constructor() {
|
||||
this.foo: any;
|
||||
this.bar: any;
|
||||
}
|
||||
|
||||
|
||||
baz() {
|
||||
|
||||
this.foo = "foo";
|
||||
|
||||
this.bar = "bar";
|
||||
|
||||
[1, 2].forEach((p) => this.foo);
|
||||
|
||||
[1, 2].forEach((p) => this.bar);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var a = new A();
|
||||
|
||||
a.baz();
|
||||
|
||||
|
||||
|
||||
|
||||
//// [autoLift2.js]
|
||||
var A = (function () {
|
||||
function A() {
|
||||
this.foo;
|
||||
any;
|
||||
this.bar;
|
||||
any;
|
||||
}
|
||||
A.prototype.baz = function () {
|
||||
var _this = this;
|
||||
this.foo = "foo";
|
||||
this.bar = "bar";
|
||||
[1, 2].forEach(function (p) { return _this.foo; });
|
||||
[1, 2].forEach(function (p) { return _this.bar; });
|
||||
};
|
||||
return A;
|
||||
})();
|
||||
var a = new A();
|
||||
a.baz();
|
||||
@@ -0,0 +1,46 @@
|
||||
//// [bases.ts]
|
||||
interface I {
|
||||
x;
|
||||
}
|
||||
|
||||
class B {
|
||||
constructor() {
|
||||
this.y: any;
|
||||
}
|
||||
}
|
||||
|
||||
class C extends B implements I {
|
||||
constructor() {
|
||||
this.x: any;
|
||||
}
|
||||
}
|
||||
|
||||
new C().x;
|
||||
new C().y;
|
||||
|
||||
|
||||
|
||||
//// [bases.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var B = (function () {
|
||||
function B() {
|
||||
this.y;
|
||||
any;
|
||||
}
|
||||
return B;
|
||||
})();
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
this.x;
|
||||
any;
|
||||
}
|
||||
return C;
|
||||
})(B);
|
||||
new C().x;
|
||||
new C().y;
|
||||
@@ -0,0 +1,23 @@
|
||||
//// [binaryIntegerLiteralError.ts]
|
||||
// error
|
||||
var bin1 = 0B1102110;
|
||||
var bin1 = 0b11023410;
|
||||
|
||||
var obj1 = {
|
||||
0b11010: "hi",
|
||||
26: "Hello",
|
||||
"26": "world",
|
||||
};
|
||||
|
||||
|
||||
//// [binaryIntegerLiteralError.js]
|
||||
// error
|
||||
var bin1 = 6;
|
||||
2110;
|
||||
var bin1 = 6;
|
||||
23410;
|
||||
var obj1 = {
|
||||
26: "hi",
|
||||
26: "Hello",
|
||||
"26": "world"
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
//// [bitwiseNotOperatorInvalidOperations.ts]
|
||||
// Unary operator ~
|
||||
var q;
|
||||
|
||||
// operand before ~
|
||||
var a = q~; //expect error
|
||||
|
||||
// multiple operands after ~
|
||||
var mul = ~[1, 2, "abc"], ""; //expect error
|
||||
|
||||
// miss an operand
|
||||
var b =~;
|
||||
|
||||
//// [bitwiseNotOperatorInvalidOperations.js]
|
||||
// Unary operator ~
|
||||
var q;
|
||||
// operand before ~
|
||||
var a = q;
|
||||
~; //expect error
|
||||
// multiple operands after ~
|
||||
var mul = ~[1, 2, "abc"];
|
||||
""; //expect error
|
||||
// miss an operand
|
||||
var b = ~;
|
||||
@@ -0,0 +1,5 @@
|
||||
//// [callExpressionWithMissingTypeArgument1.ts]
|
||||
Foo<a,,b>();
|
||||
|
||||
//// [callExpressionWithMissingTypeArgument1.js]
|
||||
Foo();
|
||||
@@ -0,0 +1,56 @@
|
||||
//// [callSignaturesWithParameterInitializers2.ts]
|
||||
// Optional parameters allow initializers only in implementation signatures
|
||||
// All the below declarations are errors
|
||||
|
||||
function foo(x = 2);
|
||||
function foo(x = 1) { }
|
||||
|
||||
foo(1);
|
||||
foo();
|
||||
|
||||
class C {
|
||||
foo(x = 2);
|
||||
foo(x = 1) { }
|
||||
}
|
||||
|
||||
var c: C;
|
||||
c.foo();
|
||||
c.foo(1);
|
||||
|
||||
var b = {
|
||||
foo(x = 1), // error
|
||||
foo(x = 1) { }, // error
|
||||
}
|
||||
|
||||
b.foo();
|
||||
b.foo(1);
|
||||
|
||||
//// [callSignaturesWithParameterInitializers2.js]
|
||||
// Optional parameters allow initializers only in implementation signatures
|
||||
// All the below declarations are errors
|
||||
function foo(x) {
|
||||
if (x === void 0) { x = 1; }
|
||||
}
|
||||
foo(1);
|
||||
foo();
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function (x) {
|
||||
if (x === void 0) { x = 1; }
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
var c;
|
||||
c.foo();
|
||||
c.foo(1);
|
||||
var b = {
|
||||
foo: function (x) {
|
||||
if (x === void 0) { x = 1; }
|
||||
},
|
||||
foo: function (x) {
|
||||
if (x === void 0) { x = 1; }
|
||||
}
|
||||
};
|
||||
b.foo();
|
||||
b.foo(1);
|
||||
@@ -0,0 +1,66 @@
|
||||
//// [tests/cases/conformance/externalModules/circularReference.ts] ////
|
||||
|
||||
//// [foo1.ts]
|
||||
import foo2 = require('./foo2');
|
||||
export module M1 {
|
||||
export class C1 {
|
||||
m1: foo2.M1.C1;
|
||||
x: number;
|
||||
constructor(){
|
||||
this.m1 = new foo2.M1.C1();
|
||||
this.m1.y = 10; // OK
|
||||
this.m1.x = 20; // Error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [foo2.ts]
|
||||
import foo1 = require('./foo1');
|
||||
export module M1 {
|
||||
export class C1 {
|
||||
m1: foo1.M1.C1;
|
||||
y: number
|
||||
constructor(){
|
||||
this.m1 = new foo1.M1.C1();
|
||||
this.m1.y = 10; // Error
|
||||
this.m1.x = 20; // OK
|
||||
|
||||
var tmp = new M1.C1();
|
||||
tmp.y = 10; // OK
|
||||
tmp.x = 20; // Error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [foo1.js]
|
||||
var foo2 = require('./foo2');
|
||||
var M1;
|
||||
(function (M1) {
|
||||
var C1 = (function () {
|
||||
function C1() {
|
||||
this.m1 = new foo2.M1.C1();
|
||||
this.m1.y = 10; // OK
|
||||
this.m1.x = 20; // Error
|
||||
}
|
||||
return C1;
|
||||
})();
|
||||
M1.C1 = C1;
|
||||
})(M1 = exports.M1 || (exports.M1 = {}));
|
||||
//// [foo2.js]
|
||||
var foo1 = require('./foo1');
|
||||
var M1;
|
||||
(function (M1) {
|
||||
var C1 = (function () {
|
||||
function C1() {
|
||||
this.m1 = new foo1.M1.C1();
|
||||
this.m1.y = 10; // Error
|
||||
this.m1.x = 20; // OK
|
||||
var tmp = new M1.C1();
|
||||
tmp.y = 10; // OK
|
||||
tmp.x = 20; // Error
|
||||
}
|
||||
return C1;
|
||||
})();
|
||||
M1.C1 = C1;
|
||||
})(M1 = exports.M1 || (exports.M1 = {}));
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [class2.ts]
|
||||
class foo { constructor() { static f = 3; } }
|
||||
|
||||
//// [class2.js]
|
||||
var foo = (function () {
|
||||
function foo() {
|
||||
}
|
||||
foo.f = 3;
|
||||
return foo;
|
||||
})();
|
||||
@@ -0,0 +1,37 @@
|
||||
//// [classBodyWithStatements.ts]
|
||||
class C {
|
||||
var x = 1;
|
||||
}
|
||||
|
||||
class C2 {
|
||||
function foo() {}
|
||||
}
|
||||
|
||||
var x = 1;
|
||||
var y = 2;
|
||||
class C3 {
|
||||
x: number = y + 1; // ok, need a var in the statement production
|
||||
}
|
||||
|
||||
//// [classBodyWithStatements.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
var x = 1;
|
||||
var C2 = (function () {
|
||||
function C2() {
|
||||
}
|
||||
return C2;
|
||||
})();
|
||||
function foo() {
|
||||
}
|
||||
var x = 1;
|
||||
var y = 2;
|
||||
var C3 = (function () {
|
||||
function C3() {
|
||||
this.x = y + 1; // ok, need a var in the statement production
|
||||
}
|
||||
return C3;
|
||||
})();
|
||||
@@ -0,0 +1,34 @@
|
||||
//// [classExpression.ts]
|
||||
var x = class C {
|
||||
}
|
||||
|
||||
var y = {
|
||||
foo: class C2 {
|
||||
}
|
||||
}
|
||||
|
||||
module M {
|
||||
var z = class C4 {
|
||||
}
|
||||
}
|
||||
|
||||
//// [classExpression.js]
|
||||
var x = ;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
var y = {
|
||||
foo: ,
|
||||
class: C2
|
||||
}, _a = void 0;
|
||||
var M;
|
||||
(function (M) {
|
||||
var z = ;
|
||||
var C4 = (function () {
|
||||
function C4() {
|
||||
}
|
||||
return C4;
|
||||
})();
|
||||
})(M || (M = {}));
|
||||
@@ -0,0 +1,98 @@
|
||||
//// [classExtendingPrimitive.ts]
|
||||
// classes cannot extend primitives
|
||||
|
||||
class C extends number { }
|
||||
class C2 extends string { }
|
||||
class C3 extends boolean { }
|
||||
class C4 extends Void { }
|
||||
class C4a extends void {}
|
||||
class C5 extends Null { }
|
||||
class C5a extends null { }
|
||||
class C6 extends undefined { }
|
||||
class C7 extends Undefined { }
|
||||
|
||||
enum E { A }
|
||||
class C8 extends E { }
|
||||
|
||||
//// [classExtendingPrimitive.js]
|
||||
// classes cannot extend primitives
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C;
|
||||
})(number);
|
||||
var C2 = (function (_super) {
|
||||
__extends(C2, _super);
|
||||
function C2() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C2;
|
||||
})(string);
|
||||
var C3 = (function (_super) {
|
||||
__extends(C3, _super);
|
||||
function C3() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C3;
|
||||
})(boolean);
|
||||
var C4 = (function (_super) {
|
||||
__extends(C4, _super);
|
||||
function C4() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C4;
|
||||
})(Void);
|
||||
var C4a = (function () {
|
||||
function C4a() {
|
||||
}
|
||||
return C4a;
|
||||
})();
|
||||
void {};
|
||||
var C5 = (function (_super) {
|
||||
__extends(C5, _super);
|
||||
function C5() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C5;
|
||||
})(Null);
|
||||
var C5a = (function () {
|
||||
function C5a() {
|
||||
}
|
||||
return C5a;
|
||||
})();
|
||||
null;
|
||||
{
|
||||
}
|
||||
var C6 = (function (_super) {
|
||||
__extends(C6, _super);
|
||||
function C6() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C6;
|
||||
})(undefined);
|
||||
var C7 = (function (_super) {
|
||||
__extends(C7, _super);
|
||||
function C7() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C7;
|
||||
})(Undefined);
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["A"] = 0] = "A";
|
||||
})(E || (E = {}));
|
||||
var C8 = (function (_super) {
|
||||
__extends(C8, _super);
|
||||
function C8() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C8;
|
||||
})(E);
|
||||
@@ -0,0 +1,22 @@
|
||||
//// [classExtendingPrimitive2.ts]
|
||||
// classes cannot extend primitives
|
||||
|
||||
class C4a extends void {}
|
||||
class C5a extends null { }
|
||||
|
||||
//// [classExtendingPrimitive2.js]
|
||||
// classes cannot extend primitives
|
||||
var C4a = (function () {
|
||||
function C4a() {
|
||||
}
|
||||
return C4a;
|
||||
})();
|
||||
void {};
|
||||
var C5a = (function () {
|
||||
function C5a() {
|
||||
}
|
||||
return C5a;
|
||||
})();
|
||||
null;
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
//// [classExtendsEveryObjectType.ts]
|
||||
interface I {
|
||||
foo: string;
|
||||
}
|
||||
class C extends I { } // error
|
||||
|
||||
class C2 extends { foo: string; } { } // error
|
||||
var x: { foo: string; }
|
||||
class C3 extends x { } // error
|
||||
|
||||
module M { export var x = 1; }
|
||||
class C4 extends M { } // error
|
||||
|
||||
function foo() { }
|
||||
class C5 extends foo { } // error
|
||||
|
||||
class C6 extends []{ } // error
|
||||
|
||||
//// [classExtendsEveryObjectType.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C;
|
||||
})(I); // error
|
||||
var C2 = (function () {
|
||||
function C2() {
|
||||
}
|
||||
return C2;
|
||||
})();
|
||||
{
|
||||
} // error
|
||||
var x;
|
||||
var C3 = (function (_super) {
|
||||
__extends(C3, _super);
|
||||
function C3() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C3;
|
||||
})(x); // error
|
||||
var M;
|
||||
(function (M) {
|
||||
M.x = 1;
|
||||
})(M || (M = {}));
|
||||
var C4 = (function (_super) {
|
||||
__extends(C4, _super);
|
||||
function C4() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C4;
|
||||
})(M); // error
|
||||
function foo() {
|
||||
}
|
||||
var C5 = (function (_super) {
|
||||
__extends(C5, _super);
|
||||
function C5() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
return C5;
|
||||
})(foo); // error
|
||||
var C6 = (function () {
|
||||
function C6() {
|
||||
}
|
||||
return C6;
|
||||
})();
|
||||
[];
|
||||
{
|
||||
} // error
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [classExtendsEveryObjectType2.ts]
|
||||
class C2 extends { foo: string; } { } // error
|
||||
|
||||
class C6 extends []{ } // error
|
||||
|
||||
//// [classExtendsEveryObjectType2.js]
|
||||
var C2 = (function () {
|
||||
function C2() {
|
||||
}
|
||||
return C2;
|
||||
})();
|
||||
{
|
||||
} // error
|
||||
var C6 = (function () {
|
||||
function C6() {
|
||||
}
|
||||
return C6;
|
||||
})();
|
||||
[];
|
||||
{
|
||||
} // error
|
||||
@@ -0,0 +1,34 @@
|
||||
//// [tests/cases/compiler/classMemberInitializerWithLamdaScoping3.ts] ////
|
||||
|
||||
//// [classMemberInitializerWithLamdaScoping3_0.ts]
|
||||
var field1: string;
|
||||
|
||||
//// [classMemberInitializerWithLamdaScoping3_1.ts]
|
||||
declare var console: {
|
||||
log(msg?: any): void;
|
||||
};
|
||||
export class Test1 {
|
||||
constructor(private field1: string) {
|
||||
}
|
||||
messageHandler = () => {
|
||||
console.log(field1); // But this should be error as the field1 will resolve to var field1
|
||||
// but since this code would be generated inside constructor, in generated js
|
||||
// it would resolve to private field1 and thats not what user intended here.
|
||||
};
|
||||
}
|
||||
|
||||
//// [classMemberInitializerWithLamdaScoping3_0.js]
|
||||
var field1;
|
||||
//// [classMemberInitializerWithLamdaScoping3_1.js]
|
||||
var Test1 = (function () {
|
||||
function Test1(field1) {
|
||||
this.field1 = field1;
|
||||
this.messageHandler = function () {
|
||||
console.log(field1); // But this should be error as the field1 will resolve to var field1
|
||||
// but since this code would be generated inside constructor, in generated js
|
||||
// it would resolve to private field1 and thats not what user intended here.
|
||||
};
|
||||
}
|
||||
return Test1;
|
||||
})();
|
||||
exports.Test1 = Test1;
|
||||
@@ -0,0 +1,30 @@
|
||||
//// [tests/cases/compiler/classMemberInitializerWithLamdaScoping4.ts] ////
|
||||
|
||||
//// [classMemberInitializerWithLamdaScoping3_0.ts]
|
||||
export var field1: string;
|
||||
|
||||
//// [classMemberInitializerWithLamdaScoping3_1.ts]
|
||||
declare var console: {
|
||||
log(msg?: any): void;
|
||||
};
|
||||
export class Test1 {
|
||||
constructor(private field1: string) {
|
||||
}
|
||||
messageHandler = () => {
|
||||
console.log(field1); // Should be error that couldnt find symbol field1
|
||||
};
|
||||
}
|
||||
|
||||
//// [classMemberInitializerWithLamdaScoping3_0.js]
|
||||
exports.field1;
|
||||
//// [classMemberInitializerWithLamdaScoping3_1.js]
|
||||
var Test1 = (function () {
|
||||
function Test1(field1) {
|
||||
this.field1 = field1;
|
||||
this.messageHandler = function () {
|
||||
console.log(field1); // Should be error that couldnt find symbol field1
|
||||
};
|
||||
}
|
||||
return Test1;
|
||||
})();
|
||||
exports.Test1 = Test1;
|
||||
@@ -0,0 +1,264 @@
|
||||
//// [classUpdateTests.ts]
|
||||
//
|
||||
// test codegen for instance properties
|
||||
//
|
||||
class A {
|
||||
public p1 = 0;
|
||||
private p2 = 0;
|
||||
p3;
|
||||
}
|
||||
|
||||
class B {
|
||||
public p1 = 0;
|
||||
private p2 = 0;
|
||||
p3;
|
||||
|
||||
constructor() {}
|
||||
}
|
||||
|
||||
class C {
|
||||
constructor(public p1=0, private p2=0, p3=0) {}
|
||||
}
|
||||
|
||||
//
|
||||
// test requirements for super calls
|
||||
//
|
||||
class D { // NO ERROR
|
||||
|
||||
}
|
||||
|
||||
class E extends D { // NO ERROR
|
||||
public p1 = 0;
|
||||
}
|
||||
|
||||
class F extends E {
|
||||
constructor() {} // ERROR - super call required
|
||||
}
|
||||
|
||||
class G extends D {
|
||||
public p1 = 0;
|
||||
constructor() { super(); } // NO ERROR
|
||||
}
|
||||
|
||||
class H {
|
||||
constructor() { super(); } // ERROR - no super call allowed
|
||||
}
|
||||
|
||||
class I extends Object {
|
||||
constructor() { super(); } // ERROR - no super call allowed
|
||||
}
|
||||
|
||||
class J extends G {
|
||||
constructor(public p1:number) {
|
||||
super(); // NO ERROR
|
||||
}
|
||||
}
|
||||
|
||||
class K extends G {
|
||||
constructor(public p1:number) { // ERROR
|
||||
var i = 0;
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
class L extends G {
|
||||
constructor(private p1:number) {
|
||||
super(); // NO ERROR
|
||||
}
|
||||
}
|
||||
|
||||
class M extends G {
|
||||
constructor(private p1:number) { // ERROR
|
||||
var i = 0;
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// test this reference in field initializers
|
||||
//
|
||||
class N {
|
||||
public p1 = 0;
|
||||
public p2 = this.p1;
|
||||
|
||||
constructor() {
|
||||
this.p2 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// test error on property declarations within class constructors
|
||||
//
|
||||
class O {
|
||||
constructor() {
|
||||
public p1 = 0; // ERROR
|
||||
}
|
||||
}
|
||||
|
||||
class P {
|
||||
constructor() {
|
||||
private p1 = 0; // ERROR
|
||||
}
|
||||
}
|
||||
|
||||
class Q {
|
||||
constructor() {
|
||||
public this.p1 = 0; // ERROR
|
||||
}
|
||||
}
|
||||
|
||||
class R {
|
||||
constructor() {
|
||||
private this.p1 = 0; // ERROR
|
||||
}
|
||||
}
|
||||
|
||||
//// [classUpdateTests.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
//
|
||||
// test codegen for instance properties
|
||||
//
|
||||
var A = (function () {
|
||||
function A() {
|
||||
this.p1 = 0;
|
||||
this.p2 = 0;
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
var B = (function () {
|
||||
function B() {
|
||||
this.p1 = 0;
|
||||
this.p2 = 0;
|
||||
}
|
||||
return B;
|
||||
})();
|
||||
var C = (function () {
|
||||
function C(p1, p2, p3) {
|
||||
if (p1 === void 0) { p1 = 0; }
|
||||
if (p2 === void 0) { p2 = 0; }
|
||||
if (p3 === void 0) { p3 = 0; }
|
||||
this.p1 = p1;
|
||||
this.p2 = p2;
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
//
|
||||
// test requirements for super calls
|
||||
//
|
||||
var D = (function () {
|
||||
function D() {
|
||||
}
|
||||
return D;
|
||||
})();
|
||||
var E = (function (_super) {
|
||||
__extends(E, _super);
|
||||
function E() {
|
||||
_super.apply(this, arguments);
|
||||
this.p1 = 0;
|
||||
}
|
||||
return E;
|
||||
})(D);
|
||||
var F = (function (_super) {
|
||||
__extends(F, _super);
|
||||
function F() {
|
||||
} // ERROR - super call required
|
||||
return F;
|
||||
})(E);
|
||||
var G = (function (_super) {
|
||||
__extends(G, _super);
|
||||
function G() {
|
||||
_super.call(this);
|
||||
this.p1 = 0;
|
||||
} // NO ERROR
|
||||
return G;
|
||||
})(D);
|
||||
var H = (function () {
|
||||
function H() {
|
||||
_super.call(this);
|
||||
} // ERROR - no super call allowed
|
||||
return H;
|
||||
})();
|
||||
var I = (function (_super) {
|
||||
__extends(I, _super);
|
||||
function I() {
|
||||
_super.call(this);
|
||||
} // ERROR - no super call allowed
|
||||
return I;
|
||||
})(Object);
|
||||
var J = (function (_super) {
|
||||
__extends(J, _super);
|
||||
function J(p1) {
|
||||
_super.call(this); // NO ERROR
|
||||
this.p1 = p1;
|
||||
}
|
||||
return J;
|
||||
})(G);
|
||||
var K = (function (_super) {
|
||||
__extends(K, _super);
|
||||
function K(p1) {
|
||||
this.p1 = p1;
|
||||
var i = 0;
|
||||
_super.call(this);
|
||||
}
|
||||
return K;
|
||||
})(G);
|
||||
var L = (function (_super) {
|
||||
__extends(L, _super);
|
||||
function L(p1) {
|
||||
_super.call(this); // NO ERROR
|
||||
this.p1 = p1;
|
||||
}
|
||||
return L;
|
||||
})(G);
|
||||
var M = (function (_super) {
|
||||
__extends(M, _super);
|
||||
function M(p1) {
|
||||
this.p1 = p1;
|
||||
var i = 0;
|
||||
_super.call(this);
|
||||
}
|
||||
return M;
|
||||
})(G);
|
||||
//
|
||||
// test this reference in field initializers
|
||||
//
|
||||
var N = (function () {
|
||||
function N() {
|
||||
this.p1 = 0;
|
||||
this.p2 = this.p1;
|
||||
this.p2 = 0;
|
||||
}
|
||||
return N;
|
||||
})();
|
||||
//
|
||||
// test error on property declarations within class constructors
|
||||
//
|
||||
var O = (function () {
|
||||
function O() {
|
||||
this.p1 = 0; // ERROR
|
||||
}
|
||||
return O;
|
||||
})();
|
||||
var P = (function () {
|
||||
function P() {
|
||||
this.p1 = 0; // ERROR
|
||||
}
|
||||
return P;
|
||||
})();
|
||||
var Q = (function () {
|
||||
function Q() {
|
||||
this.p1 = 0; // ERROR
|
||||
}
|
||||
return Q;
|
||||
})();
|
||||
var R = (function () {
|
||||
function R() {
|
||||
this.p1 = 0; // ERROR
|
||||
}
|
||||
return R;
|
||||
})();
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [classWithPredefinedTypesAsNames2.ts]
|
||||
// classes cannot use predefined types as names
|
||||
|
||||
class void {}
|
||||
|
||||
//// [classWithPredefinedTypesAsNames2.js]
|
||||
// classes cannot use predefined types as names
|
||||
var = (function () {
|
||||
function () {
|
||||
}
|
||||
return ;
|
||||
})();
|
||||
void {};
|
||||
@@ -0,0 +1,46 @@
|
||||
//// [commaOperatorWithoutOperand.ts]
|
||||
var ANY: any;
|
||||
var BOOLEAN: boolean;
|
||||
var NUMBER: number;
|
||||
var STRING: string;
|
||||
var OBJECT: Object;
|
||||
|
||||
// Expect to have compiler errors
|
||||
// Missing the second operand
|
||||
(ANY, );
|
||||
(BOOLEAN, );
|
||||
(NUMBER, );
|
||||
(STRING, );
|
||||
(OBJECT, );
|
||||
|
||||
// Missing the first operand
|
||||
(, ANY);
|
||||
(, BOOLEAN);
|
||||
(, NUMBER);
|
||||
(, STRING);
|
||||
(, OBJECT);
|
||||
|
||||
// Missing all operands
|
||||
( , );
|
||||
|
||||
//// [commaOperatorWithoutOperand.js]
|
||||
var ANY;
|
||||
var BOOLEAN;
|
||||
var NUMBER;
|
||||
var STRING;
|
||||
var OBJECT;
|
||||
// Expect to have compiler errors
|
||||
// Missing the second operand
|
||||
(ANY, );
|
||||
(BOOLEAN, );
|
||||
(NUMBER, );
|
||||
(STRING, );
|
||||
(OBJECT, );
|
||||
// Missing the first operand
|
||||
(, ANY);
|
||||
(, BOOLEAN);
|
||||
(, NUMBER);
|
||||
(, STRING);
|
||||
(, OBJECT);
|
||||
// Missing all operands
|
||||
(, );
|
||||
@@ -0,0 +1,204 @@
|
||||
//// [complicatedPrivacy.ts]
|
||||
module m1 {
|
||||
export module m2 {
|
||||
|
||||
|
||||
export function f1(c1: C1) {
|
||||
}
|
||||
export function f2(c2: C2) {
|
||||
}
|
||||
|
||||
export class C2 implements m3.i3 {
|
||||
public get p1(arg) {
|
||||
return new C1();
|
||||
}
|
||||
|
||||
public set p1(arg1: C1) {
|
||||
}
|
||||
|
||||
public f55() {
|
||||
return "Hello world";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function f2(arg1: { x?: C1, y: number }) {
|
||||
}
|
||||
|
||||
export function f3(): {
|
||||
(a: number) : C1;
|
||||
} {
|
||||
return null;
|
||||
}
|
||||
|
||||
export function f4(arg1:
|
||||
{
|
||||
[number]: C1; // Used to be indexer, now it is a computed property
|
||||
}) {
|
||||
}
|
||||
|
||||
|
||||
export function f5(arg2: {
|
||||
new (arg1: C1) : C1
|
||||
}) {
|
||||
}
|
||||
module m3 {
|
||||
function f2(f1: C1) {
|
||||
}
|
||||
|
||||
export interface i3 {
|
||||
f55(): string;
|
||||
}
|
||||
}
|
||||
|
||||
class C1 {
|
||||
}
|
||||
|
||||
interface i {
|
||||
x: number;
|
||||
}
|
||||
|
||||
export class C5 implements i {
|
||||
public x: number;
|
||||
}
|
||||
|
||||
export var v2: C1[];
|
||||
}
|
||||
|
||||
class C2 {
|
||||
}
|
||||
|
||||
module m2 {
|
||||
export module m3 {
|
||||
|
||||
export class c_pr implements mglo5.i5, mglo5.i6 {
|
||||
f1() {
|
||||
return "Hello";
|
||||
}
|
||||
}
|
||||
|
||||
module m4 {
|
||||
class C {
|
||||
}
|
||||
module m5 {
|
||||
|
||||
export module m6 {
|
||||
function f1() {
|
||||
return new C();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module mglo5 {
|
||||
export interface i5 {
|
||||
f1(): string;
|
||||
}
|
||||
|
||||
interface i6 {
|
||||
f6(): number;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [complicatedPrivacy.js]
|
||||
var m1;
|
||||
(function (m1) {
|
||||
var m2;
|
||||
(function (m2) {
|
||||
function f1(c1) {
|
||||
}
|
||||
m2.f1 = f1;
|
||||
function f2(c2) {
|
||||
}
|
||||
m2.f2 = f2;
|
||||
var C2 = (function () {
|
||||
function C2() {
|
||||
}
|
||||
Object.defineProperty(C2.prototype, "p1", {
|
||||
get: function (arg) {
|
||||
return new C1();
|
||||
},
|
||||
set: function (arg1) {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
C2.prototype.f55 = function () {
|
||||
return "Hello world";
|
||||
};
|
||||
return C2;
|
||||
})();
|
||||
m2.C2 = C2;
|
||||
})(m2 = m1.m2 || (m1.m2 = {}));
|
||||
function f2(arg1) {
|
||||
}
|
||||
m1.f2 = f2;
|
||||
function f3() {
|
||||
return null;
|
||||
}
|
||||
m1.f3 = f3;
|
||||
function f4(arg1) {
|
||||
}
|
||||
m1.f4 = f4;
|
||||
function f5(arg2) {
|
||||
}
|
||||
m1.f5 = f5;
|
||||
var m3;
|
||||
(function (m3) {
|
||||
function f2(f1) {
|
||||
}
|
||||
})(m3 || (m3 = {}));
|
||||
var C1 = (function () {
|
||||
function C1() {
|
||||
}
|
||||
return C1;
|
||||
})();
|
||||
var C5 = (function () {
|
||||
function C5() {
|
||||
}
|
||||
return C5;
|
||||
})();
|
||||
m1.C5 = C5;
|
||||
m1.v2;
|
||||
})(m1 || (m1 = {}));
|
||||
var C2 = (function () {
|
||||
function C2() {
|
||||
}
|
||||
return C2;
|
||||
})();
|
||||
var m2;
|
||||
(function (m2) {
|
||||
var m3;
|
||||
(function (m3) {
|
||||
var c_pr = (function () {
|
||||
function c_pr() {
|
||||
}
|
||||
c_pr.prototype.f1 = function () {
|
||||
return "Hello";
|
||||
};
|
||||
return c_pr;
|
||||
})();
|
||||
m3.c_pr = c_pr;
|
||||
var m4;
|
||||
(function (m4) {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
var m5;
|
||||
(function (m5) {
|
||||
var m6;
|
||||
(function (m6) {
|
||||
function f1() {
|
||||
return new C();
|
||||
}
|
||||
})(m6 = m5.m6 || (m5.m6 = {}));
|
||||
})(m5 || (m5 = {}));
|
||||
})(m4 || (m4 = {}));
|
||||
})(m3 = m2.m3 || (m2.m3 = {}));
|
||||
})(m2 || (m2 = {}));
|
||||
@@ -0,0 +1,261 @@
|
||||
//// [compoundAssignmentLHSIsValue.ts]
|
||||
// expected error for all the LHS of compound assignments (arithmetic and addition)
|
||||
var value;
|
||||
|
||||
// this
|
||||
class C {
|
||||
constructor() {
|
||||
this *= value;
|
||||
this += value;
|
||||
}
|
||||
foo() {
|
||||
this *= value;
|
||||
this += value;
|
||||
}
|
||||
static sfoo() {
|
||||
this *= value;
|
||||
this += value;
|
||||
}
|
||||
}
|
||||
|
||||
function foo() {
|
||||
this *= value;
|
||||
this += value;
|
||||
}
|
||||
|
||||
this *= value;
|
||||
this += value;
|
||||
|
||||
// identifiers: module, class, enum, function
|
||||
module M { export var a; }
|
||||
M *= value;
|
||||
M += value;
|
||||
|
||||
C *= value;
|
||||
C += value;
|
||||
|
||||
enum E { }
|
||||
E *= value;
|
||||
E += value;
|
||||
|
||||
foo *= value;
|
||||
foo += value;
|
||||
|
||||
// literals
|
||||
null *= value;
|
||||
null += value;
|
||||
true *= value;
|
||||
true += value;
|
||||
false *= value;
|
||||
false += value;
|
||||
0 *= value;
|
||||
0 += value;
|
||||
'' *= value;
|
||||
'' += value;
|
||||
/d+/ *= value;
|
||||
/d+/ += value;
|
||||
|
||||
// object literals
|
||||
{ a: 0} *= value;
|
||||
{ a: 0} += value;
|
||||
|
||||
// array literals
|
||||
['', ''] *= value;
|
||||
['', ''] += value;
|
||||
|
||||
// super
|
||||
class Derived extends C {
|
||||
constructor() {
|
||||
super();
|
||||
super *= value;
|
||||
super += value;
|
||||
}
|
||||
|
||||
foo() {
|
||||
super *= value;
|
||||
super += value;
|
||||
}
|
||||
|
||||
static sfoo() {
|
||||
super *= value;
|
||||
super += value;
|
||||
}
|
||||
}
|
||||
|
||||
// function expression
|
||||
function bar1() { } *= value;
|
||||
function bar2() { } += value;
|
||||
() => { } *= value;
|
||||
() => { } += value;
|
||||
|
||||
// function calls
|
||||
foo() *= value;
|
||||
foo() += value;
|
||||
|
||||
// parentheses, the containted expression is value
|
||||
(this) *= value;
|
||||
(this) += value;
|
||||
(M) *= value;
|
||||
(M) += value;
|
||||
(C) *= value;
|
||||
(C) += value;
|
||||
(E) *= value;
|
||||
(E) += value;
|
||||
(foo) *= value;
|
||||
(foo) += value;
|
||||
(null) *= value;
|
||||
(null) += value;
|
||||
(true) *= value;
|
||||
(true) += value;
|
||||
(0) *= value;
|
||||
(0) += value;
|
||||
('') *= value;
|
||||
('') += value;
|
||||
(/d+/) *= value;
|
||||
(/d+/) += value;
|
||||
({}) *= value;
|
||||
({}) += value;
|
||||
([]) *= value;
|
||||
([]) += value;
|
||||
(function baz1() { }) *= value;
|
||||
(function baz2() { }) += value;
|
||||
(foo()) *= value;
|
||||
(foo()) += value;
|
||||
|
||||
//// [compoundAssignmentLHSIsValue.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
// expected error for all the LHS of compound assignments (arithmetic and addition)
|
||||
var value;
|
||||
// this
|
||||
var C = (function () {
|
||||
function C() {
|
||||
this *= value;
|
||||
this += value;
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
this *= value;
|
||||
this += value;
|
||||
};
|
||||
C.sfoo = function () {
|
||||
this *= value;
|
||||
this += value;
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
function foo() {
|
||||
this *= value;
|
||||
this += value;
|
||||
}
|
||||
this *= value;
|
||||
this += value;
|
||||
// identifiers: module, class, enum, function
|
||||
var M;
|
||||
(function (M) {
|
||||
M.a;
|
||||
})(M || (M = {}));
|
||||
M *= value;
|
||||
M += value;
|
||||
C *= value;
|
||||
C += value;
|
||||
var E;
|
||||
(function (E) {
|
||||
})(E || (E = {}));
|
||||
E *= value;
|
||||
E += value;
|
||||
foo *= value;
|
||||
foo += value;
|
||||
// literals
|
||||
null *= value;
|
||||
null += value;
|
||||
true *= value;
|
||||
true += value;
|
||||
false *= value;
|
||||
false += value;
|
||||
0 *= value;
|
||||
0 += value;
|
||||
'' *= value;
|
||||
'' += value;
|
||||
/d+/ *= value;
|
||||
/d+/ += value;
|
||||
// object literals
|
||||
{
|
||||
a: 0;
|
||||
}
|
||||
value;
|
||||
{
|
||||
a: 0;
|
||||
}
|
||||
value;
|
||||
// array literals
|
||||
['', ''] *= value;
|
||||
['', ''] += value;
|
||||
// super
|
||||
var Derived = (function (_super) {
|
||||
__extends(Derived, _super);
|
||||
function Derived() {
|
||||
_super.call(this);
|
||||
_super.prototype. *= value;
|
||||
_super.prototype. += value;
|
||||
}
|
||||
Derived.prototype.foo = function () {
|
||||
_super.prototype. *= value;
|
||||
_super.prototype. += value;
|
||||
};
|
||||
Derived.sfoo = function () {
|
||||
_super. *= value;
|
||||
_super. += value;
|
||||
};
|
||||
return Derived;
|
||||
})(C);
|
||||
// function expression
|
||||
function bar1() {
|
||||
}
|
||||
value;
|
||||
function bar2() {
|
||||
}
|
||||
value;
|
||||
(function () {
|
||||
});
|
||||
value;
|
||||
(function () {
|
||||
});
|
||||
value;
|
||||
// function calls
|
||||
foo() *= value;
|
||||
foo() += value;
|
||||
// parentheses, the containted expression is value
|
||||
(this) *= value;
|
||||
(this) += value;
|
||||
(M) *= value;
|
||||
(M) += value;
|
||||
(C) *= value;
|
||||
(C) += value;
|
||||
(E) *= value;
|
||||
(E) += value;
|
||||
(foo) *= value;
|
||||
(foo) += value;
|
||||
(null) *= value;
|
||||
(null) += value;
|
||||
(true) *= value;
|
||||
(true) += value;
|
||||
(0) *= value;
|
||||
(0) += value;
|
||||
('') *= value;
|
||||
('') += value;
|
||||
(/d+/) *= value;
|
||||
(/d+/) += value;
|
||||
({}) *= value;
|
||||
({}) += value;
|
||||
([]) *= value;
|
||||
([]) += value;
|
||||
(function baz1() {
|
||||
}) *= value;
|
||||
(function baz2() {
|
||||
}) += value;
|
||||
(foo()) *= value;
|
||||
(foo()) += value;
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [conflictMarkerTrivia1.ts]
|
||||
class C {
|
||||
<<<<<<< HEAD
|
||||
v = 1;
|
||||
=======
|
||||
v = 2;
|
||||
>>>>>>> Branch-a
|
||||
}
|
||||
|
||||
//// [conflictMarkerTrivia1.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
this.v = 1;
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [conflictMarkerTrivia2.ts]
|
||||
class C {
|
||||
foo() {
|
||||
<<<<<<< B
|
||||
a();
|
||||
}
|
||||
=======
|
||||
b();
|
||||
}
|
||||
>>>>>>> A
|
||||
|
||||
public bar() { }
|
||||
}
|
||||
|
||||
|
||||
//// [conflictMarkerTrivia2.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
a();
|
||||
};
|
||||
C.prototype.bar = function () {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [constructorStaticParamNameErrors.ts]
|
||||
'use strict'
|
||||
// static as constructor parameter name should give error if 'use strict'
|
||||
class test {
|
||||
constructor (static) { }
|
||||
}
|
||||
|
||||
//// [constructorStaticParamNameErrors.js]
|
||||
'use strict';
|
||||
// static as constructor parameter name should give error if 'use strict'
|
||||
var test = (function () {
|
||||
function test() {
|
||||
}
|
||||
return test;
|
||||
})();
|
||||
@@ -0,0 +1,569 @@
|
||||
//// [constructorWithIncompleteTypeAnnotation.ts]
|
||||
declare module "fs" {
|
||||
export class File {
|
||||
constructor(filename: string);
|
||||
public ReadAllText(): string;
|
||||
}
|
||||
export interface IFile {
|
||||
[index: number]: string;
|
||||
}
|
||||
}
|
||||
|
||||
import fs = module("fs");
|
||||
|
||||
|
||||
module TypeScriptAllInOne {
|
||||
export class Program {
|
||||
static Main(...args: string[]) {
|
||||
try {
|
||||
var bfs = new BasicFeatures();
|
||||
var retValue: number = 0;
|
||||
|
||||
retValue = bfs.VARIABLES();
|
||||
if (retValue != 0 ^= {
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
case = bfs.STATEMENTS(4);
|
||||
if (retValue != 0) {
|
||||
|
||||
return 1;
|
||||
^
|
||||
|
||||
|
||||
retValue = bfs.TYPES();
|
||||
if (retValue != 0) {
|
||||
|
||||
return 1 &&
|
||||
}
|
||||
|
||||
retValue = bfs.OPERATOR ' );
|
||||
if (retValue != 0) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
finally {
|
||||
|
||||
}
|
||||
|
||||
console.log('Done');
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class BasicFeatures {
|
||||
/// <summary>
|
||||
/// Test various of variables. Including nullable,key world as variable,special format
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public VARIABLES(): number {
|
||||
var local = Number.MAX_VALUE;
|
||||
var min = Number.MIN_VALUE;
|
||||
var inf = Number.NEGATIVE_INFINITY -
|
||||
var nan = Number.NaN;
|
||||
var undef = undefined;
|
||||
|
||||
var _\uD4A5\u7204\uC316\uE59F = local;
|
||||
var мир = local;
|
||||
|
||||
var local5 = <fs.File>null;
|
||||
var local6 = local5 instanceof fs.File;
|
||||
|
||||
var hex = 0xBADC0DE, Hex = 0XDEADBEEF;
|
||||
var float = 6.02e23, float2 = 6.02E-23
|
||||
var char = 'c', \u0066 = '\u0066', hexchar = '\x42' !=
|
||||
var quoted = '"', quoted2 = "'";
|
||||
var reg = /\w*/;
|
||||
var objLit = { "var": number = 42, equals: function (x) { return x["var"] === 42; }, instanceof : () => 'objLit{42}' };
|
||||
var weekday = Weekdays.Monday;
|
||||
|
||||
var con = char + f + hexchar + float.toString() + float2.toString() + reg.toString() + objLit + weekday;
|
||||
|
||||
//
|
||||
var any = 0 ^=
|
||||
var bool = 0;
|
||||
var declare = 0;
|
||||
var constructor = 0;
|
||||
var get = 0;
|
||||
var implements = 0;
|
||||
var interface = 0;
|
||||
var let = 0;
|
||||
var module = 0;
|
||||
var number = 0;
|
||||
var package = 0;
|
||||
var private = 0;
|
||||
var protected = 0;
|
||||
var public = 0;
|
||||
var set = 0;
|
||||
var static = 0;
|
||||
var string = 0 />
|
||||
var yield = 0;
|
||||
|
||||
var sum3 = any + bool + declare + constructor + get + implements + interface + let + module + number + package + private + protected + public + set + static + string + yield;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test different statements. Including if-else,swith,foreach,(un)checked,lock,using,try-catch-finally
|
||||
/// </summary>
|
||||
/// <param name="i"></param>
|
||||
/// <returns></returns>
|
||||
STATEMENTS(i: number): number {
|
||||
var retVal = 0;
|
||||
if (i == 1)
|
||||
retVal = 1;
|
||||
else
|
||||
retVal = 0;
|
||||
switch (i) {
|
||||
case 2:
|
||||
retVal = 1;
|
||||
break;
|
||||
case 3:
|
||||
retVal = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (var x in { x: 0, y: 1 }) {
|
||||
!
|
||||
|
||||
try {
|
||||
throw null;
|
||||
}
|
||||
catch (Exception) ?
|
||||
}
|
||||
finally {
|
||||
try { }
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test types in ts language. Including class,struct,interface,delegate,anonymous type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TYPES(): number {
|
||||
var retVal = 0;
|
||||
var c = new CLASS();
|
||||
var xx: IF = c;
|
||||
retVal += catch .Property;
|
||||
retVal += c.Member();
|
||||
retVal += xx.Foo() ? 0 : 1;
|
||||
|
||||
//anonymous type
|
||||
var anony = { a: new CLASS() };
|
||||
|
||||
retVal += anony.a.d();
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
///// <summary>
|
||||
///// Test different operators
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
public OPERATOR(): number {
|
||||
var a: number[] = [1, 2, 3, 4, 5, ];/*[] bug*/ // YES []
|
||||
var i = a[1];/*[]*/
|
||||
i = i + i - i * i / i % i & i | i ^ i;/*+ - * / % & | ^*/
|
||||
var b = true && false || true ^ false;/*& | ^*/
|
||||
b = !b;/*!*/
|
||||
i = ~i;/*~i*/
|
||||
b = i < (i - 1) && (i + 1) > i;/*< && >*/
|
||||
var f = true ? 1 : 0;/*? :*/ // YES :
|
||||
i++;/*++*/
|
||||
i--;/*--*/
|
||||
b = true && false || true;/*&& ||*/
|
||||
i = i << 5;/*<<*/
|
||||
i = i >> 5;/*>>*/
|
||||
var j = i;
|
||||
b = i == j && i != j && i <= j && i >= j;/*= == && != <= >=*/
|
||||
i += <number>5.0;/*+=*/
|
||||
i -= i;/*-=*/
|
||||
i *= i;/**=*/
|
||||
if (i == 0)
|
||||
i++;
|
||||
i /= i;/*/=*/
|
||||
i %= i;/*%=*/
|
||||
i &= i;/*&=*/
|
||||
i |= i;/*|=*/
|
||||
i ^= i;/*^=*/
|
||||
i <<= i;/*<<=*/
|
||||
i >>= i;/*>>=*/
|
||||
|
||||
if (i == 0 && != b && f == 1)
|
||||
return 0;
|
||||
else return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface IF {
|
||||
Foo(): bool;
|
||||
}
|
||||
|
||||
class CLASS implements IF {
|
||||
|
||||
case d = () => { yield 0; };
|
||||
public get Property() { return 0; }
|
||||
public Member() {
|
||||
return 0;
|
||||
}
|
||||
public Foo(): bool {
|
||||
var myEvent = () => { return 1; };
|
||||
if (myEvent() == 1)
|
||||
return true ?
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// todo: use these
|
||||
class A .
|
||||
public method1(val:number) {
|
||||
return val;
|
||||
}
|
||||
public method2() {
|
||||
return 2 * this.method1(2);
|
||||
}
|
||||
}
|
||||
|
||||
class B extends A {
|
||||
|
||||
public method2() {
|
||||
return this.method1(2);
|
||||
}
|
||||
}
|
||||
|
||||
class Overloading {
|
||||
|
||||
private otherValue = 42;
|
||||
|
||||
constructor(private value: number, public name: string) : }
|
||||
|
||||
public Overloads(value: string);
|
||||
public Overloads( while : string, ...rest: string[]) { &
|
||||
|
||||
public DefaultValue(value?: string = "Hello") { }
|
||||
}
|
||||
}
|
||||
|
||||
enum Weekdays {
|
||||
Monday,
|
||||
Tuesday,
|
||||
Weekend,
|
||||
}
|
||||
|
||||
enum Fruit {
|
||||
Apple,
|
||||
Pear
|
||||
}
|
||||
|
||||
interface IDisposable {
|
||||
Dispose(): void;
|
||||
}
|
||||
|
||||
TypeScriptAllInOne.Program.Main();
|
||||
|
||||
|
||||
//// [constructorWithIncompleteTypeAnnotation.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var fs = module;
|
||||
("fs");
|
||||
var TypeScriptAllInOne;
|
||||
(function (TypeScriptAllInOne) {
|
||||
var Program = (function () {
|
||||
function Program() {
|
||||
this.case = bfs.STATEMENTS(4);
|
||||
}
|
||||
Program.Main = function () {
|
||||
var args = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
args[_i - 0] = arguments[_i];
|
||||
}
|
||||
try {
|
||||
var bfs = new BasicFeatures();
|
||||
var retValue = 0;
|
||||
retValue = bfs.VARIABLES();
|
||||
if (retValue != 0)
|
||||
^= {
|
||||
return: 1
|
||||
};
|
||||
}
|
||||
finally {
|
||||
}
|
||||
};
|
||||
Program.prototype.if = function (retValue) {
|
||||
if (retValue === void 0) { retValue = != 0; }
|
||||
return 1;
|
||||
^ retValue;
|
||||
bfs.TYPES();
|
||||
if (retValue != 0) {
|
||||
return 1 && ;
|
||||
}
|
||||
retValue = bfs.OPERATOR;
|
||||
' );;
|
||||
if (retValue != 0) {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
Program.prototype.catch = function (e) {
|
||||
console.log(e);
|
||||
};
|
||||
return Program;
|
||||
})();
|
||||
TypeScriptAllInOne.Program = Program;
|
||||
try {
|
||||
}
|
||||
finally {
|
||||
}
|
||||
console.log('Done');
|
||||
return 0;
|
||||
})(TypeScriptAllInOne || (TypeScriptAllInOne = {}));
|
||||
var BasicFeatures = (function () {
|
||||
function BasicFeatures() {
|
||||
}
|
||||
/// <summary>
|
||||
/// Test various of variables. Including nullable,key world as variable,special format
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
BasicFeatures.prototype.VARIABLES = function () {
|
||||
var local = Number.MAX_VALUE;
|
||||
var min = Number.MIN_VALUE;
|
||||
var inf = Number.NEGATIVE_INFINITY - ;
|
||||
var nan = Number.NaN;
|
||||
var undef = undefined;
|
||||
var _\uD4A5\u7204\uC316, uE59F = local;
|
||||
var мир = local;
|
||||
var local5 = null;
|
||||
var local6 = local5 instanceof fs.File;
|
||||
var hex = 0xBADC0DE, Hex = 0XDEADBEEF;
|
||||
var float = 6.02e23, float2 = 6.02E-23;
|
||||
var char = 'c', \u0066 = '\u0066', hexchar = '\x42' != ;
|
||||
var quoted = '"', quoted2 = "'";
|
||||
var reg = /\w*/;
|
||||
var objLit = { "var": number = 42, equals: function (x) {
|
||||
return x["var"] === 42;
|
||||
}, instanceof: function () { return 'objLit{42}'; } };
|
||||
var weekday = 0 /* Monday */;
|
||||
var con = char + f + hexchar + float.toString() + float2.toString() + reg.toString() + objLit + weekday;
|
||||
//
|
||||
var any = 0 ^= ;
|
||||
var bool = 0;
|
||||
var declare = 0;
|
||||
var constructor = 0;
|
||||
var get = 0;
|
||||
var implements = 0;
|
||||
var interface = 0;
|
||||
var let = 0;
|
||||
var module = 0;
|
||||
var number = 0;
|
||||
var package = 0;
|
||||
var private = 0;
|
||||
var protected = 0;
|
||||
var public = 0;
|
||||
var set = 0;
|
||||
var static = 0;
|
||||
var string = 0 / > ;
|
||||
var yield = 0;
|
||||
var sum3 = any + bool + declare + constructor + get + implements + interface + let + module + number + package + private + protected + public + set + static + string + yield;
|
||||
return 0;
|
||||
};
|
||||
/// <summary>
|
||||
/// Test different statements. Including if-else,swith,foreach,(un)checked,lock,using,try-catch-finally
|
||||
/// </summary>
|
||||
/// <param name="i"></param>
|
||||
/// <returns></returns>
|
||||
BasicFeatures.prototype.STATEMENTS = function (i) {
|
||||
var retVal = 0;
|
||||
if (i == 1)
|
||||
retVal = 1;
|
||||
else
|
||||
retVal = 0;
|
||||
switch (i) {
|
||||
case 2:
|
||||
retVal = 1;
|
||||
break;
|
||||
case 3:
|
||||
retVal = 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
for (var x in { x: 0, y: 1 }) {
|
||||
!;
|
||||
try {
|
||||
throw null;
|
||||
}
|
||||
catch (Exception) {
|
||||
}
|
||||
}
|
||||
try {
|
||||
}
|
||||
finally {
|
||||
try {
|
||||
}
|
||||
catch (Exception) {
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
};
|
||||
/// <summary>
|
||||
/// Test types in ts language. Including class,struct,interface,delegate,anonymous type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
BasicFeatures.prototype.TYPES = function () {
|
||||
var retVal = 0;
|
||||
var c = new CLASS();
|
||||
var xx = c;
|
||||
retVal += ;
|
||||
try {
|
||||
}
|
||||
catch () {
|
||||
}
|
||||
Property;
|
||||
retVal += c.Member();
|
||||
retVal += xx.Foo() ? 0 : 1;
|
||||
//anonymous type
|
||||
var anony = { a: new CLASS() };
|
||||
retVal += anony.a.d();
|
||||
return retVal;
|
||||
};
|
||||
///// <summary>
|
||||
///// Test different operators
|
||||
///// </summary>
|
||||
///// <returns></returns>
|
||||
BasicFeatures.prototype.OPERATOR = function () {
|
||||
var a = [1, 2, 3, 4, 5,]; /*[] bug*/ // YES []
|
||||
var i = a[1]; /*[]*/
|
||||
i = i + i - i * i / i % i & i | i ^ i; /*+ - * / % & | ^*/
|
||||
var b = true && false || true ^ false; /*& | ^*/
|
||||
b = !b; /*!*/
|
||||
i = ~i; /*~i*/
|
||||
b = i < (i - 1) && (i + 1) > i; /*< && >*/
|
||||
var f = true ? 1 : 0; /*? :*/ // YES :
|
||||
i++; /*++*/
|
||||
i--; /*--*/
|
||||
b = true && false || true; /*&& ||*/
|
||||
i = i << 5; /*<<*/
|
||||
i = i >> 5; /*>>*/
|
||||
var j = i;
|
||||
b = i == j && i != j && i <= j && i >= j; /*= == && != <= >=*/
|
||||
i += 5.0; /*+=*/
|
||||
i -= i; /*-=*/
|
||||
i *= i; /**=*/
|
||||
if (i == 0)
|
||||
i++;
|
||||
i /= i; /*/=*/
|
||||
i %= i; /*%=*/
|
||||
i &= i; /*&=*/
|
||||
i |= i; /*|=*/
|
||||
i ^= i; /*^=*/
|
||||
i <<= i; /*<<=*/
|
||||
i >>= i; /*>>=*/
|
||||
if (i == 0 && != b && f == 1)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
};
|
||||
return BasicFeatures;
|
||||
})();
|
||||
var CLASS = (function () {
|
||||
function CLASS() {
|
||||
this.d = function () {
|
||||
yield;
|
||||
0;
|
||||
};
|
||||
}
|
||||
Object.defineProperty(CLASS.prototype, "Property", {
|
||||
get: function () {
|
||||
return 0;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
CLASS.prototype.Member = function () {
|
||||
return 0;
|
||||
};
|
||||
CLASS.prototype.Foo = function () {
|
||||
var myEvent = function () {
|
||||
return 1;
|
||||
};
|
||||
if (myEvent() == 1)
|
||||
return true ? : ;
|
||||
else
|
||||
return false;
|
||||
};
|
||||
return CLASS;
|
||||
})();
|
||||
// todo: use these
|
||||
var A = (function () {
|
||||
function A() {
|
||||
}
|
||||
return A;
|
||||
})();
|
||||
method1(val, number);
|
||||
{
|
||||
return val;
|
||||
}
|
||||
method2();
|
||||
{
|
||||
return 2 * this.method1(2);
|
||||
}
|
||||
var B = (function (_super) {
|
||||
__extends(B, _super);
|
||||
function B() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
B.prototype.method2 = function () {
|
||||
return this.method1(2);
|
||||
};
|
||||
return B;
|
||||
})(A);
|
||||
var Overloading = (function () {
|
||||
function Overloading() {
|
||||
this.otherValue = 42;
|
||||
}
|
||||
return Overloading;
|
||||
})();
|
||||
Overloads(value, string);
|
||||
Overloads();
|
||||
while ()
|
||||
: string, ;
|
||||
rest: string[];
|
||||
{
|
||||
& public;
|
||||
DefaultValue(value ? : string = "Hello");
|
||||
{
|
||||
}
|
||||
}
|
||||
var Weekdays;
|
||||
(function (Weekdays) {
|
||||
Weekdays[Weekdays["Monday"] = 0] = "Monday";
|
||||
Weekdays[Weekdays["Tuesday"] = 1] = "Tuesday";
|
||||
Weekdays[Weekdays["Weekend"] = 2] = "Weekend";
|
||||
})(Weekdays || (Weekdays = {}));
|
||||
var Fruit;
|
||||
(function (Fruit) {
|
||||
Fruit[Fruit["Apple"] = 0] = "Apple";
|
||||
Fruit[Fruit["Pear"] = 1] = "Pear";
|
||||
})(Fruit || (Fruit = {}));
|
||||
TypeScriptAllInOne.Program.Main();
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [declarationEmit_invalidReference2.ts]
|
||||
/// <reference path="invalid.ts" />
|
||||
var x = 0;
|
||||
|
||||
//// [declarationEmit_invalidReference2.js]
|
||||
/// <reference path="invalid.ts" />
|
||||
var x = 0;
|
||||
|
||||
|
||||
//// [declarationEmit_invalidReference2.d.ts]
|
||||
declare var x: number;
|
||||
@@ -0,0 +1,33 @@
|
||||
//// [deleteOperatorInvalidOperations.ts]
|
||||
// Unary operator delete
|
||||
var ANY;
|
||||
|
||||
// operand before delete operator
|
||||
var BOOLEAN1 = ANY delete ; //expect error
|
||||
|
||||
// miss an operand
|
||||
var BOOLEAN2 = delete ;
|
||||
|
||||
// delete global variable s
|
||||
class testADelx {
|
||||
constructor(public s: () => {}) {
|
||||
delete s; //expect error
|
||||
}
|
||||
}
|
||||
|
||||
//// [deleteOperatorInvalidOperations.js]
|
||||
// Unary operator delete
|
||||
var ANY;
|
||||
// operand before delete operator
|
||||
var BOOLEAN1 = ANY;
|
||||
delete ; //expect error
|
||||
// miss an operand
|
||||
var BOOLEAN2 = delete ;
|
||||
// delete global variable s
|
||||
var testADelx = (function () {
|
||||
function testADelx(s) {
|
||||
this.s = s;
|
||||
delete s; //expect error
|
||||
}
|
||||
return testADelx;
|
||||
})();
|
||||
@@ -0,0 +1,83 @@
|
||||
//// [derivedClassSuperCallsInNonConstructorMembers.ts]
|
||||
// error to use super calls outside a constructor
|
||||
|
||||
class Base {
|
||||
x: string;
|
||||
}
|
||||
|
||||
class Derived extends Base {
|
||||
a: super();
|
||||
b() {
|
||||
super();
|
||||
}
|
||||
get C() {
|
||||
super();
|
||||
return 1;
|
||||
}
|
||||
set C(v) {
|
||||
super();
|
||||
}
|
||||
|
||||
static a: super();
|
||||
static b() {
|
||||
super();
|
||||
}
|
||||
static get C() {
|
||||
super();
|
||||
return 1;
|
||||
}
|
||||
static set C(v) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
//// [derivedClassSuperCallsInNonConstructorMembers.js]
|
||||
// error to use super calls outside a constructor
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
}
|
||||
return Base;
|
||||
})();
|
||||
var Derived = (function (_super) {
|
||||
__extends(Derived, _super);
|
||||
function Derived() {
|
||||
_super.apply(this, arguments);
|
||||
this.a = _super.call(this);
|
||||
}
|
||||
Derived.prototype.b = function () {
|
||||
_super.call(this);
|
||||
};
|
||||
Object.defineProperty(Derived.prototype, "C", {
|
||||
get: function () {
|
||||
_super.call(this);
|
||||
return 1;
|
||||
},
|
||||
set: function (v) {
|
||||
_super.call(this);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Derived.b = function () {
|
||||
_super.call(this);
|
||||
};
|
||||
Object.defineProperty(Derived, "C", {
|
||||
get: function () {
|
||||
_super.call(this);
|
||||
return 1;
|
||||
},
|
||||
set: function (v) {
|
||||
_super.call(this);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Derived.a = _super.call(this);
|
||||
return Derived;
|
||||
})(Base);
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [dontShowCompilerGeneratedMembers.ts]
|
||||
var f: {
|
||||
x: number;
|
||||
<-
|
||||
};
|
||||
|
||||
//// [dontShowCompilerGeneratedMembers.js]
|
||||
var f = -;
|
||||
;
|
||||
@@ -0,0 +1,55 @@
|
||||
//// [dottedModuleName.ts]
|
||||
module M {
|
||||
export module N {
|
||||
export function f(x:number)=>2*x;
|
||||
export module X.Y.Z {
|
||||
export var v2=f(v);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
module M.N {
|
||||
export module X {
|
||||
export module Y.Z {
|
||||
export var v=f(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [dottedModuleName.js]
|
||||
var M;
|
||||
(function (M) {
|
||||
var N;
|
||||
(function (N) {
|
||||
2 * x;
|
||||
var X;
|
||||
(function (X) {
|
||||
var Y;
|
||||
(function (Y) {
|
||||
var Z;
|
||||
(function (Z) {
|
||||
Z.v2 = f(Z.v);
|
||||
})(Z = Y.Z || (Y.Z = {}));
|
||||
})(Y = X.Y || (X.Y = {}));
|
||||
})(X = N.X || (N.X = {}));
|
||||
})(N = M.N || (M.N = {}));
|
||||
})(M || (M = {}));
|
||||
var M;
|
||||
(function (M) {
|
||||
var N;
|
||||
(function (N) {
|
||||
var X;
|
||||
(function (X) {
|
||||
var Y;
|
||||
(function (Y) {
|
||||
var Z;
|
||||
(function (Z) {
|
||||
Z.v = N.f(10);
|
||||
})(Z = Y.Z || (Y.Z = {}));
|
||||
})(Y = X.Y || (X.Y = {}));
|
||||
})(X = N.X || (N.X = {}));
|
||||
})(N = M.N || (M.N = {}));
|
||||
})(M || (M = {}));
|
||||
@@ -0,0 +1,80 @@
|
||||
//// [tests/cases/conformance/externalModules/duplicateExportAssignments.ts] ////
|
||||
|
||||
//// [foo1.ts]
|
||||
var x = 10;
|
||||
var y = 20;
|
||||
export = x;
|
||||
export = y;
|
||||
|
||||
//// [foo2.ts]
|
||||
var x = 10;
|
||||
class y {};
|
||||
export = x;
|
||||
export = y;
|
||||
|
||||
//// [foo3.ts]
|
||||
module x {
|
||||
export var x = 10;
|
||||
}
|
||||
class y {
|
||||
y: number;
|
||||
}
|
||||
export = x;
|
||||
export = y;
|
||||
|
||||
//// [foo4.ts]
|
||||
export = x;
|
||||
function x(){
|
||||
return 42;
|
||||
}
|
||||
function y(){
|
||||
return 42;
|
||||
}
|
||||
export = y;
|
||||
|
||||
//// [foo5.ts]
|
||||
var x = 5;
|
||||
var y = "test";
|
||||
var z = {};
|
||||
export = x;
|
||||
export = y;
|
||||
export = z;
|
||||
|
||||
|
||||
//// [foo1.js]
|
||||
var x = 10;
|
||||
var y = 20;
|
||||
module.exports = x;
|
||||
//// [foo2.js]
|
||||
var x = 10;
|
||||
var y = (function () {
|
||||
function y() {
|
||||
}
|
||||
return y;
|
||||
})();
|
||||
;
|
||||
module.exports = x;
|
||||
//// [foo3.js]
|
||||
var x;
|
||||
(function (_x) {
|
||||
_x.x = 10;
|
||||
})(x || (x = {}));
|
||||
var y = (function () {
|
||||
function y() {
|
||||
}
|
||||
return y;
|
||||
})();
|
||||
module.exports = x;
|
||||
//// [foo4.js]
|
||||
function x() {
|
||||
return 42;
|
||||
}
|
||||
function y() {
|
||||
return 42;
|
||||
}
|
||||
module.exports = x;
|
||||
//// [foo5.js]
|
||||
var x = 5;
|
||||
var y = "test";
|
||||
var z = {};
|
||||
module.exports = x;
|
||||
@@ -0,0 +1,12 @@
|
||||
//// [emptyMemberAccess.ts]
|
||||
function getObj() {
|
||||
|
||||
().toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//// [emptyMemberAccess.js]
|
||||
function getObj() {
|
||||
().toString();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [enumConflictsWithGlobalIdentifier.ts]
|
||||
enum Position {
|
||||
IgnoreRulesSpecific = 0,
|
||||
}
|
||||
var x = IgnoreRulesSpecific.
|
||||
var y = Position.IgnoreRulesSpecific;
|
||||
|
||||
|
||||
//// [enumConflictsWithGlobalIdentifier.js]
|
||||
var Position;
|
||||
(function (Position) {
|
||||
Position[Position["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific";
|
||||
})(Position || (Position = {}));
|
||||
var x = IgnoreRulesSpecific.;
|
||||
var y = 0 /* IgnoreRulesSpecific */;
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [enumMemberResolution.ts]
|
||||
enum Position2 {
|
||||
IgnoreRulesSpecific = 0
|
||||
}
|
||||
var x = IgnoreRulesSpecific. // error
|
||||
var y = 1;
|
||||
var z = Position2.IgnoreRulesSpecific; // no error
|
||||
|
||||
|
||||
//// [enumMemberResolution.js]
|
||||
var Position2;
|
||||
(function (Position2) {
|
||||
Position2[Position2["IgnoreRulesSpecific"] = 0] = "IgnoreRulesSpecific";
|
||||
})(Position2 || (Position2 = {}));
|
||||
var x = IgnoreRulesSpecific.; // error
|
||||
var y = 1;
|
||||
var z = 0 /* IgnoreRulesSpecific */; // no error
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [enumWithParenthesizedInitializer1.ts]
|
||||
enum E {
|
||||
e = -(3
|
||||
}
|
||||
|
||||
//// [enumWithParenthesizedInitializer1.js]
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["e"] = -(3)] = "e";
|
||||
})(E || (E = {}));
|
||||
@@ -0,0 +1,170 @@
|
||||
//// [errorSuperCalls.ts]
|
||||
//super call in class constructor with no base type
|
||||
class NoBase {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
//super call in class member function with no base type
|
||||
fn() {
|
||||
super();
|
||||
}
|
||||
|
||||
//super call in class accessor (get and set) with no base type
|
||||
get foo() {
|
||||
super();
|
||||
return null;
|
||||
}
|
||||
set foo(v) {
|
||||
super();
|
||||
}
|
||||
|
||||
//super call in class member initializer with no base type
|
||||
p = super();
|
||||
|
||||
//super call in static class member function with no base type
|
||||
static fn() {
|
||||
super();
|
||||
}
|
||||
|
||||
//super call in static class member initializer with no base type
|
||||
static k = super();
|
||||
|
||||
//super call in static class accessor (get and set) with no base type
|
||||
static get q() {
|
||||
super();
|
||||
return null;
|
||||
}
|
||||
static set q(n) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
class Base<T> { private n: T; }
|
||||
class Derived<T> extends Base<T> {
|
||||
//super call with type arguments
|
||||
constructor() {
|
||||
super<string>();
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class OtherBase {
|
||||
private n: string;
|
||||
}
|
||||
|
||||
class OtherDerived extends OtherBase {
|
||||
//super call in class member initializer of derived type
|
||||
t = super();
|
||||
|
||||
fn() {
|
||||
//super call in class member function of derived type
|
||||
super();
|
||||
}
|
||||
|
||||
//super call in class accessor (get and set) of derived type
|
||||
get foo() {
|
||||
super();
|
||||
return null;
|
||||
}
|
||||
set foo(n) {
|
||||
super();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [errorSuperCalls.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
//super call in class constructor with no base type
|
||||
var NoBase = (function () {
|
||||
function NoBase() {
|
||||
//super call in class member initializer with no base type
|
||||
this.p = _super.call(this);
|
||||
_super.call(this);
|
||||
}
|
||||
//super call in class member function with no base type
|
||||
NoBase.prototype.fn = function () {
|
||||
_super.call(this);
|
||||
};
|
||||
Object.defineProperty(NoBase.prototype, "foo", {
|
||||
//super call in class accessor (get and set) with no base type
|
||||
get: function () {
|
||||
_super.call(this);
|
||||
return null;
|
||||
},
|
||||
set: function (v) {
|
||||
_super.call(this);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
//super call in static class member function with no base type
|
||||
NoBase.fn = function () {
|
||||
_super.call(this);
|
||||
};
|
||||
Object.defineProperty(NoBase, "q", {
|
||||
//super call in static class accessor (get and set) with no base type
|
||||
get: function () {
|
||||
_super.call(this);
|
||||
return null;
|
||||
},
|
||||
set: function (n) {
|
||||
_super.call(this);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
//super call in static class member initializer with no base type
|
||||
NoBase.k = _super.call(this);
|
||||
return NoBase;
|
||||
})();
|
||||
var Base = (function () {
|
||||
function Base() {
|
||||
}
|
||||
return Base;
|
||||
})();
|
||||
var Derived = (function (_super) {
|
||||
__extends(Derived, _super);
|
||||
//super call with type arguments
|
||||
function Derived() {
|
||||
_super.prototype..call(this);
|
||||
_super.call(this);
|
||||
}
|
||||
return Derived;
|
||||
})(Base);
|
||||
var OtherBase = (function () {
|
||||
function OtherBase() {
|
||||
}
|
||||
return OtherBase;
|
||||
})();
|
||||
var OtherDerived = (function (_super) {
|
||||
__extends(OtherDerived, _super);
|
||||
function OtherDerived() {
|
||||
_super.apply(this, arguments);
|
||||
//super call in class member initializer of derived type
|
||||
this.t = _super.call(this);
|
||||
}
|
||||
OtherDerived.prototype.fn = function () {
|
||||
//super call in class member function of derived type
|
||||
_super.call(this);
|
||||
};
|
||||
Object.defineProperty(OtherDerived.prototype, "foo", {
|
||||
//super call in class accessor (get and set) of derived type
|
||||
get: function () {
|
||||
_super.call(this);
|
||||
return null;
|
||||
},
|
||||
set: function (n) {
|
||||
_super.call(this);
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return OtherDerived;
|
||||
})(OtherBase);
|
||||
@@ -0,0 +1,31 @@
|
||||
//// [es6ClassTest3.ts]
|
||||
module M {
|
||||
class Visibility {
|
||||
public foo() { };
|
||||
private bar() { };
|
||||
private x: number;
|
||||
public y: number;
|
||||
public z: number;
|
||||
|
||||
constructor() {
|
||||
this.x = 1;
|
||||
this.y = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//// [es6ClassTest3.js]
|
||||
var M;
|
||||
(function (M) {
|
||||
var Visibility = (function () {
|
||||
function Visibility() {
|
||||
this.x = 1;
|
||||
this.y = 2;
|
||||
}
|
||||
Visibility.prototype.foo = function () {
|
||||
};
|
||||
Visibility.prototype.bar = function () {
|
||||
};
|
||||
return Visibility;
|
||||
})();
|
||||
})(M || (M = {}));
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [es6ClassTest9.ts]
|
||||
declare class foo();
|
||||
function foo() {}
|
||||
|
||||
|
||||
//// [es6ClassTest9.js]
|
||||
();
|
||||
function foo() {
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [tests/cases/conformance/externalModules/exportAssignDottedName.ts] ////
|
||||
|
||||
//// [foo1.ts]
|
||||
export function x(){
|
||||
return true;
|
||||
}
|
||||
|
||||
//// [foo2.ts]
|
||||
import foo1 = require('./foo1');
|
||||
export = foo1.x; // Error, export assignment must be identifier only
|
||||
|
||||
|
||||
//// [foo1.js]
|
||||
function x() {
|
||||
return true;
|
||||
}
|
||||
exports.x = x;
|
||||
//// [foo2.js]
|
||||
var foo1 = require('./foo1');
|
||||
x; // Error, export assignment must be identifier only
|
||||
module.exports = foo1;
|
||||
@@ -0,0 +1,28 @@
|
||||
//// [tests/cases/conformance/externalModules/exportAssignImportedIdentifier.ts] ////
|
||||
|
||||
//// [foo1.ts]
|
||||
export function x(){
|
||||
return true;
|
||||
}
|
||||
|
||||
//// [foo2.ts]
|
||||
import foo1 = require('./foo1');
|
||||
var x = foo1.x;
|
||||
export = x;
|
||||
|
||||
//// [foo3.ts]
|
||||
import foo2 = require('./foo2');
|
||||
var x = foo2(); // should be boolean
|
||||
|
||||
//// [foo1.js]
|
||||
function x() {
|
||||
return true;
|
||||
}
|
||||
exports.x = x;
|
||||
//// [foo2.js]
|
||||
var foo1 = require('./foo1');
|
||||
var x = foo1.x;
|
||||
module.exports = x;
|
||||
//// [foo3.js]
|
||||
var foo2 = require('./foo2');
|
||||
var x = foo2(); // should be boolean
|
||||
@@ -0,0 +1,52 @@
|
||||
//// [tests/cases/conformance/externalModules/exportAssignNonIdentifier.ts] ////
|
||||
|
||||
//// [foo1.ts]
|
||||
var x = 10;
|
||||
export = typeof x; // Error
|
||||
|
||||
//// [foo2.ts]
|
||||
export = "sausages"; // Error
|
||||
|
||||
//// [foo3.ts]
|
||||
export = class Foo3 {}; // Error
|
||||
|
||||
//// [foo4.ts]
|
||||
export = true; // Error
|
||||
|
||||
//// [foo5.ts]
|
||||
export = undefined; // Valid. undefined is an identifier in JavaScript/TypeScript
|
||||
|
||||
//// [foo6.ts]
|
||||
export = void; // Error
|
||||
|
||||
//// [foo7.ts]
|
||||
export = Date || String; // Error
|
||||
|
||||
//// [foo8.ts]
|
||||
export = null; // Error
|
||||
|
||||
|
||||
|
||||
//// [foo1.js]
|
||||
var x = 10;
|
||||
typeof x; // Error
|
||||
//// [foo2.js]
|
||||
"sausages"; // Error
|
||||
//// [foo3.js]
|
||||
var Foo3 = (function () {
|
||||
function Foo3() {
|
||||
}
|
||||
return Foo3;
|
||||
})();
|
||||
; // Error
|
||||
//// [foo4.js]
|
||||
true; // Error
|
||||
//// [foo5.js]
|
||||
module.exports = undefined;
|
||||
//// [foo6.js]
|
||||
void ; // Error
|
||||
//// [foo7.js]
|
||||
|| String; // Error
|
||||
module.exports = Date;
|
||||
//// [foo8.js]
|
||||
null; // Error
|
||||
@@ -0,0 +1,93 @@
|
||||
//// [tests/cases/conformance/externalModules/exportAssignTypes.ts] ////
|
||||
|
||||
//// [expString.ts]
|
||||
var x = "test";
|
||||
export = x;
|
||||
|
||||
//// [expNumber.ts]
|
||||
var x = 42;
|
||||
export = x;
|
||||
|
||||
//// [expBoolean.ts]
|
||||
var x = true;
|
||||
export = x;
|
||||
|
||||
//// [expArray.ts]
|
||||
var x = [1,2];
|
||||
export = x;
|
||||
|
||||
//// [expObject.ts]
|
||||
var x = { answer: 42, when: 1776};
|
||||
export = x;
|
||||
|
||||
//// [expAny.ts]
|
||||
var x;
|
||||
export = x;
|
||||
|
||||
//// [expGeneric.ts]
|
||||
function x<T>(a: T){
|
||||
return a;
|
||||
}
|
||||
export = x;
|
||||
|
||||
//// [consumer.ts]
|
||||
import iString = require('./expString');
|
||||
var v1: string = iString;
|
||||
|
||||
import iNumber = require('./expNumber');
|
||||
var v2: number = iNumber;
|
||||
|
||||
import iBoolean = require('./expBoolean');
|
||||
var v3: boolean = iBoolean;
|
||||
|
||||
import iArray = require('./expArray');
|
||||
var v4: Array<number> = iArray;
|
||||
|
||||
import iObject = require('./expObject');
|
||||
var v5: Object = iObject;
|
||||
|
||||
import iAny = require('./expAny');
|
||||
var v6 = iAny;
|
||||
|
||||
import iGeneric = require('./expGeneric');
|
||||
var v7: {<x>(p1: x): x} = iGeneric;
|
||||
|
||||
|
||||
//// [expString.js]
|
||||
var x = "test";
|
||||
module.exports = x;
|
||||
//// [expNumber.js]
|
||||
var x = 42;
|
||||
module.exports = x;
|
||||
//// [expBoolean.js]
|
||||
var x = true;
|
||||
module.exports = x;
|
||||
//// [expArray.js]
|
||||
var x = [1, 2];
|
||||
module.exports = x;
|
||||
//// [expObject.js]
|
||||
var x = { answer: 42, when: 1776 };
|
||||
module.exports = x;
|
||||
//// [expAny.js]
|
||||
var x;
|
||||
module.exports = x;
|
||||
//// [expGeneric.js]
|
||||
function x(a) {
|
||||
return a;
|
||||
}
|
||||
module.exports = x;
|
||||
//// [consumer.js]
|
||||
var iString = require('./expString');
|
||||
var v1 = iString;
|
||||
var iNumber = require('./expNumber');
|
||||
var v2 = iNumber;
|
||||
var iBoolean = require('./expBoolean');
|
||||
var v3 = iBoolean;
|
||||
var iArray = require('./expArray');
|
||||
var v4 = iArray;
|
||||
var iObject = require('./expObject');
|
||||
var v5 = iObject;
|
||||
var iAny = require('./expAny');
|
||||
var v6 = iAny;
|
||||
var iGeneric = require('./expGeneric');
|
||||
var v7 = iGeneric;
|
||||
@@ -0,0 +1,18 @@
|
||||
//// [exportAssignmentWithoutIdentifier1.ts]
|
||||
function Greeter() {
|
||||
//...
|
||||
}
|
||||
Greeter.prototype.greet = function () {
|
||||
//...
|
||||
}
|
||||
export = new Greeter();
|
||||
|
||||
|
||||
//// [exportAssignmentWithoutIdentifier1.js]
|
||||
function Greeter() {
|
||||
//...
|
||||
}
|
||||
Greeter.prototype.greet = function () {
|
||||
//...
|
||||
};
|
||||
new Greeter();
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [exportDeclareClass1.ts]
|
||||
export declare class eaC {
|
||||
static tF() { };
|
||||
static tsF(param:any) { };
|
||||
};
|
||||
|
||||
export declare class eaC2 {
|
||||
static tF();
|
||||
static tsF(param:any);
|
||||
};
|
||||
|
||||
//// [exportDeclareClass1.js]
|
||||
define(["require", "exports"], function (require, exports) {
|
||||
;
|
||||
;
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [tests/cases/conformance/externalModules/exportDeclaredModule.ts] ////
|
||||
|
||||
//// [foo1.ts]
|
||||
|
||||
declare module M1 {
|
||||
export var a: string;
|
||||
export function b(): number;
|
||||
}
|
||||
export = M1;
|
||||
|
||||
//// [foo2.ts]
|
||||
import foo1 = require('./foo1');
|
||||
var x: number = foo1.b();
|
||||
|
||||
//// [foo1.js]
|
||||
module.exports = M1;
|
||||
//// [foo2.js]
|
||||
var foo1 = require('./foo1');
|
||||
var x = foo1.b();
|
||||
@@ -0,0 +1,54 @@
|
||||
//// [tests/cases/conformance/externalModules/exportNonVisibleType.ts] ////
|
||||
|
||||
//// [foo1.ts]
|
||||
interface I1 {
|
||||
a: string;
|
||||
b: number;
|
||||
}
|
||||
|
||||
var x: I1 = {a: "test", b: 42};
|
||||
export = x; // Should fail, I1 not exported.
|
||||
|
||||
|
||||
//// [foo2.ts]
|
||||
interface I1 {
|
||||
a: string;
|
||||
b: number;
|
||||
}
|
||||
|
||||
class C1 {
|
||||
m1: I1;
|
||||
}
|
||||
|
||||
export = C1; // Should fail, type I1 of visible member C1.m1 not exported.
|
||||
|
||||
//// [foo3.ts]
|
||||
interface I1 {
|
||||
a: string;
|
||||
b: number;
|
||||
}
|
||||
|
||||
class C1 {
|
||||
private m1: I1;
|
||||
}
|
||||
|
||||
export = C1; // Should work, private type I1 of visible class C1 only used in private member m1.
|
||||
|
||||
|
||||
//// [foo1.js]
|
||||
var x = { a: "test", b: 42 };
|
||||
module.exports = x;
|
||||
//// [foo2.js]
|
||||
var C1 = (function () {
|
||||
function C1() {
|
||||
}
|
||||
return C1;
|
||||
})();
|
||||
module.exports = C1;
|
||||
//// [foo3.js]
|
||||
var C1 = (function () {
|
||||
function C1() {
|
||||
}
|
||||
return C1;
|
||||
})();
|
||||
module.exports = C1;
|
||||
@@ -0,0 +1,37 @@
|
||||
//// [extension.ts]
|
||||
interface I {
|
||||
x;
|
||||
}
|
||||
|
||||
interface I {
|
||||
y;
|
||||
}
|
||||
|
||||
declare module M {
|
||||
export class C {
|
||||
public p:number;
|
||||
}
|
||||
}
|
||||
|
||||
declare module M {
|
||||
export extension class C {
|
||||
public pe:string;
|
||||
}
|
||||
}
|
||||
|
||||
var c=new M.C();
|
||||
c.pe;
|
||||
c.p;
|
||||
var i:I;
|
||||
i.x;
|
||||
i.y;
|
||||
|
||||
|
||||
|
||||
//// [extension.js]
|
||||
var c = new M.C();
|
||||
c.pe;
|
||||
c.p;
|
||||
var i;
|
||||
i.x;
|
||||
i.y;
|
||||
@@ -0,0 +1,58 @@
|
||||
//// [externModule.ts]
|
||||
declare module {
|
||||
export class XDate {
|
||||
public getDay():number;
|
||||
public getXDate():number;
|
||||
// etc.
|
||||
|
||||
// Called as a function
|
||||
// Not supported anymore? public (): string;
|
||||
|
||||
// Called as a constructor
|
||||
constructor(year: number, month: number);
|
||||
constructor(year: number, month: number, date: number);
|
||||
constructor(year: number, month: number, date: number, hours: number);
|
||||
constructor(year: number, month: number, date: number, hours: number, minutes: number);
|
||||
constructor(year: number, month: number, date: number, hours: number, minutes: number, seconds: number);
|
||||
constructor(year: number, month: number, date: number, hours: number, minutes: number, seconds: number, ms: number);
|
||||
constructor(value: number);
|
||||
constructor();
|
||||
|
||||
static parse(string: string): number;
|
||||
static UTC(year: number, month: number): number;
|
||||
static UTC(year: number, month: number, date: number): number;
|
||||
static UTC(year: number, month: number, date: number, hours: number): number;
|
||||
static UTC(year: number, month: number, date: number, hours: number, minutes: number): number;
|
||||
static UTC(year: number, month: number, date: number, hours: number, minutes: number, seconds: number): number;
|
||||
static UTC(year: number, month: number, date: number, hours: number, minutes: number, seconds: number,
|
||||
ms: number): number;
|
||||
static now(): number;
|
||||
}
|
||||
}
|
||||
|
||||
var d=new XDate();
|
||||
d.getDay();
|
||||
d=new XDate(1978,2);
|
||||
d.getXDate();
|
||||
var n=XDate.parse("3/2/2004");
|
||||
n=XDate.UTC(1964,2,1);
|
||||
|
||||
|
||||
|
||||
//// [externModule.js]
|
||||
declare;
|
||||
module;
|
||||
{
|
||||
}
|
||||
var XDate = (function () {
|
||||
function XDate() {
|
||||
}
|
||||
return XDate;
|
||||
})();
|
||||
exports.XDate = XDate;
|
||||
var d = new XDate();
|
||||
d.getDay();
|
||||
d = new XDate(1978, 2);
|
||||
d.getXDate();
|
||||
var n = XDate.parse("3/2/2004");
|
||||
n = XDate.UTC(1964, 2, 1);
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [externalModuleWithoutCompilerFlag1.ts]
|
||||
|
||||
// Not on line 0 because we want to verify the error is placed in the appropriate location.
|
||||
export module M {
|
||||
}
|
||||
|
||||
//// [externalModuleWithoutCompilerFlag1.js]
|
||||
@@ -0,0 +1,47 @@
|
||||
//// [fatarrowfunctionsErrors.ts]
|
||||
foo((...Far:any[])=>{return 0;})
|
||||
foo((1)=>{return 0;});
|
||||
foo((x?)=>{return x;})
|
||||
foo((x=0)=>{return x;})
|
||||
var y = x:number => x*x;
|
||||
false? (() => null): null;
|
||||
|
||||
// missing fatarrow
|
||||
var x1 = () :void {};
|
||||
var x2 = (a:number) :void {};
|
||||
var x3 = (a:number) {};
|
||||
var x4= (...a: any[]) { };
|
||||
|
||||
//// [fatarrowfunctionsErrors.js]
|
||||
foo(function () {
|
||||
var Far = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
Far[_i - 0] = arguments[_i];
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
foo((1), { return: 0 });
|
||||
;
|
||||
foo(function (x) {
|
||||
return x;
|
||||
});
|
||||
foo(function (x) {
|
||||
if (x === void 0) { x = 0; }
|
||||
return x;
|
||||
});
|
||||
var y = x, number;
|
||||
x * x;
|
||||
false ? (function () { return null; }) : null;
|
||||
// missing fatarrow
|
||||
var x1 = function () {
|
||||
};
|
||||
var x2 = function (a) {
|
||||
};
|
||||
var x3 = function (a) {
|
||||
};
|
||||
var x4 = function () {
|
||||
var a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
a[_i - 0] = arguments[_i];
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,394 @@
|
||||
//// [fatarrowfunctionsOptionalArgs.ts]
|
||||
// valid
|
||||
|
||||
// no params
|
||||
() => 1;
|
||||
|
||||
// one param, no type
|
||||
(arg) => 2;
|
||||
|
||||
// one param, no type
|
||||
arg => 2;
|
||||
|
||||
// one param, no type with default value
|
||||
(arg = 1) => 3;
|
||||
|
||||
// one param, no type, optional
|
||||
(arg?) => 4;
|
||||
|
||||
// typed param
|
||||
(arg: number) => 5;
|
||||
|
||||
// typed param with default value
|
||||
(arg: number = 0) => 6;
|
||||
|
||||
// optional param
|
||||
(arg?: number) => 7;
|
||||
|
||||
// var arg param
|
||||
(...arg: number[]) => 8;
|
||||
|
||||
// multiple arguments
|
||||
(arg1, arg2) => 12;
|
||||
(arg1 = 1, arg2 =3) => 13;
|
||||
(arg1?, arg2?) => 14;
|
||||
(arg1: number, arg2: number) => 15;
|
||||
(arg1: number = 0, arg2: number = 1) => 16;
|
||||
(arg1?: number, arg2?: number) => 17;
|
||||
(arg1, ...arg2: number[]) => 18;
|
||||
(arg1, arg2?: number) => 19;
|
||||
|
||||
// in paren
|
||||
(() => 21);
|
||||
((arg) => 22);
|
||||
((arg = 1) => 23);
|
||||
((arg?) => 24);
|
||||
((arg: number) => 25);
|
||||
((arg: number = 0) => 26);
|
||||
((arg?: number) => 27);
|
||||
((...arg: number[]) => 28);
|
||||
|
||||
// in multiple paren
|
||||
(((((arg) => { return 32; }))));
|
||||
|
||||
// in ternary exression
|
||||
false ? () => 41 : null;
|
||||
false ? (arg) => 42 : null;
|
||||
false ? (arg = 1) => 43 : null;
|
||||
false ? (arg?) => 44 : null;
|
||||
false ? (arg: number) => 45 : null;
|
||||
false ? (arg?: number) => 46 : null;
|
||||
false ? (arg?: number = 0) => 47 : null;
|
||||
false ? (...arg: number[]) => 48 : null;
|
||||
|
||||
// in ternary exression within paren
|
||||
false ? (() => 51) : null;
|
||||
false ? ((arg) => 52) : null;
|
||||
false ? ((arg = 1) => 53) : null;
|
||||
false ? ((arg?) => 54) : null;
|
||||
false ? ((arg: number) => 55) : null;
|
||||
false ? ((arg?: number) => 56) : null;
|
||||
false ? ((arg?: number = 0) => 57) : null;
|
||||
false ? ((...arg: number[]) => 58) : null;
|
||||
|
||||
// ternary exression's else clause
|
||||
false ? null : () => 61;
|
||||
false ? null : (arg) => 62;
|
||||
false ? null : (arg = 1) => 63;
|
||||
false ? null : (arg?) => 64;
|
||||
false ? null : (arg: number) => 65;
|
||||
false ? null : (arg?: number) => 66;
|
||||
false ? null : (arg?: number = 0) => 67;
|
||||
false ? null : (...arg: number[]) => 68;
|
||||
|
||||
|
||||
// nested ternary expressions
|
||||
((a?) => { return a; }) ? (b? ) => { return b; } : (c? ) => { return c; };
|
||||
|
||||
//multiple levels
|
||||
(a?) => { return a; } ? (b)=>(c)=>81 : (c)=>(d)=>82;
|
||||
|
||||
|
||||
// In Expressions
|
||||
((arg) => 90) instanceof Function;
|
||||
((arg = 1) => 91) instanceof Function;
|
||||
((arg? ) => 92) instanceof Function;
|
||||
((arg: number) => 93) instanceof Function;
|
||||
((arg: number = 1) => 94) instanceof Function;
|
||||
((arg?: number) => 95) instanceof Function;
|
||||
((...arg: number[]) => 96) instanceof Function;
|
||||
|
||||
'' + ((arg) => 100);
|
||||
((arg) => 0) + '' + ((arg) => 101);
|
||||
((arg = 1) => 0) + '' + ((arg = 2) => 102);
|
||||
((arg?) => 0) + '' + ((arg?) => 103);
|
||||
((arg:number) => 0) + '' + ((arg:number) => 104);
|
||||
((arg:number = 1) => 0) + '' + ((arg:number = 2) => 105);
|
||||
((arg?:number = 1) => 0) + '' + ((arg?:number = 2) => 106);
|
||||
((...arg:number[]) => 0) + '' + ((...arg:number[]) => 107);
|
||||
((arg1, arg2?) => 0) + '' + ((arg1,arg2?) => 108);
|
||||
((arg1, ...arg2:number[]) => 0) + '' + ((arg1, ...arg2:number[]) => 108);
|
||||
|
||||
|
||||
// Function Parameters
|
||||
function foo(...arg: any[]) { }
|
||||
|
||||
foo(
|
||||
(a) => 110,
|
||||
((a) => 111),
|
||||
(a) => {
|
||||
return 112;
|
||||
},
|
||||
(a? ) => 113,
|
||||
(a, b? ) => 114,
|
||||
(a: number) => 115,
|
||||
(a: number = 0) => 116,
|
||||
(a = 0) => 117,
|
||||
(a?: number = 0) => 118,
|
||||
(...a: number[]) => 119,
|
||||
(a, b? = 0, ...c: number[]) => 120,
|
||||
(a) => (b) => (c) => 121,
|
||||
false? (a) => 0 : (b) => 122
|
||||
);
|
||||
|
||||
//// [fatarrowfunctionsOptionalArgs.js]
|
||||
// valid
|
||||
// no params
|
||||
(function () { return 1; });
|
||||
// one param, no type
|
||||
(function (arg) { return 2; });
|
||||
// one param, no type
|
||||
(function (arg) { return 2; });
|
||||
// one param, no type with default value
|
||||
(function (arg) {
|
||||
if (arg === void 0) { arg = 1; }
|
||||
return 3;
|
||||
});
|
||||
// one param, no type, optional
|
||||
(function (arg) { return 4; });
|
||||
// typed param
|
||||
(function (arg) { return 5; });
|
||||
// typed param with default value
|
||||
(function (arg) {
|
||||
if (arg === void 0) { arg = 0; }
|
||||
return 6;
|
||||
});
|
||||
// optional param
|
||||
(function (arg) { return 7; });
|
||||
// var arg param
|
||||
(function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
}
|
||||
return 8;
|
||||
});
|
||||
// multiple arguments
|
||||
(function (arg1, arg2) { return 12; });
|
||||
(function (arg1, arg2) {
|
||||
if (arg1 === void 0) { arg1 = 1; }
|
||||
if (arg2 === void 0) { arg2 = 3; }
|
||||
return 13;
|
||||
});
|
||||
(function (arg1, arg2) { return 14; });
|
||||
(function (arg1, arg2) { return 15; });
|
||||
(function (arg1, arg2) {
|
||||
if (arg1 === void 0) { arg1 = 0; }
|
||||
if (arg2 === void 0) { arg2 = 1; }
|
||||
return 16;
|
||||
});
|
||||
(function (arg1, arg2) { return 17; });
|
||||
(function (arg1) {
|
||||
var arg2 = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
arg2[_i - 1] = arguments[_i];
|
||||
}
|
||||
return 18;
|
||||
});
|
||||
(function (arg1, arg2) { return 19; });
|
||||
// in paren
|
||||
(function () { return 21; });
|
||||
(function (arg) { return 22; });
|
||||
(function (arg) {
|
||||
if (arg === void 0) { arg = 1; }
|
||||
return 23;
|
||||
});
|
||||
(function (arg) { return 24; });
|
||||
(function (arg) { return 25; });
|
||||
(function (arg) {
|
||||
if (arg === void 0) { arg = 0; }
|
||||
return 26;
|
||||
});
|
||||
(function (arg) { return 27; });
|
||||
(function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
}
|
||||
return 28;
|
||||
});
|
||||
// in multiple paren
|
||||
((((function (arg) {
|
||||
return 32;
|
||||
}))));
|
||||
// in ternary exression
|
||||
false ? function () { return 41; } : null;
|
||||
false ? function (arg) { return 42; } : null;
|
||||
false ? function (arg) {
|
||||
if (arg === void 0) { arg = 1; }
|
||||
return 43;
|
||||
} : null;
|
||||
false ? function (arg) { return 44; } : null;
|
||||
false ? function (arg) { return 45; } : null;
|
||||
false ? function (arg) { return 46; } : null;
|
||||
false ? function (arg) {
|
||||
if (arg === void 0) { arg = 0; }
|
||||
return 47;
|
||||
} : null;
|
||||
false ? function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
}
|
||||
return 48;
|
||||
} : null;
|
||||
// in ternary exression within paren
|
||||
false ? (function () { return 51; }) : null;
|
||||
false ? (function (arg) { return 52; }) : null;
|
||||
false ? (function (arg) {
|
||||
if (arg === void 0) { arg = 1; }
|
||||
return 53;
|
||||
}) : null;
|
||||
false ? (function (arg) { return 54; }) : null;
|
||||
false ? (function (arg) { return 55; }) : null;
|
||||
false ? (function (arg) { return 56; }) : null;
|
||||
false ? (function (arg) {
|
||||
if (arg === void 0) { arg = 0; }
|
||||
return 57;
|
||||
}) : null;
|
||||
false ? (function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
}
|
||||
return 58;
|
||||
}) : null;
|
||||
// ternary exression's else clause
|
||||
false ? null : function () { return 61; };
|
||||
false ? null : function (arg) { return 62; };
|
||||
false ? null : function (arg) {
|
||||
if (arg === void 0) { arg = 1; }
|
||||
return 63;
|
||||
};
|
||||
false ? null : function (arg) { return 64; };
|
||||
false ? null : function (arg) { return 65; };
|
||||
false ? null : function (arg) { return 66; };
|
||||
false ? null : function (arg) {
|
||||
if (arg === void 0) { arg = 0; }
|
||||
return 67;
|
||||
};
|
||||
false ? null : function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
}
|
||||
return 68;
|
||||
};
|
||||
// nested ternary expressions
|
||||
(function (a) {
|
||||
return a;
|
||||
}) ? function (b) {
|
||||
return b;
|
||||
} : function (c) {
|
||||
return c;
|
||||
};
|
||||
//multiple levels
|
||||
(function (a) {
|
||||
return a;
|
||||
});
|
||||
(function (b) { return function (c) { return 81; }; });
|
||||
(function (c) { return function (d) { return 82; }; });
|
||||
// In Expressions
|
||||
(function (arg) { return 90; }) instanceof Function;
|
||||
(function (arg) {
|
||||
if (arg === void 0) { arg = 1; }
|
||||
return 91;
|
||||
}) instanceof Function;
|
||||
(function (arg) { return 92; }) instanceof Function;
|
||||
(function (arg) { return 93; }) instanceof Function;
|
||||
(function (arg) {
|
||||
if (arg === void 0) { arg = 1; }
|
||||
return 94;
|
||||
}) instanceof Function;
|
||||
(function (arg) { return 95; }) instanceof Function;
|
||||
(function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
}
|
||||
return 96;
|
||||
}) instanceof Function;
|
||||
'' + (function (arg) { return 100; });
|
||||
(function (arg) { return 0; }) + '' + (function (arg) { return 101; });
|
||||
(function (arg) {
|
||||
if (arg === void 0) { arg = 1; }
|
||||
return 0;
|
||||
}) + '' + (function (arg) {
|
||||
if (arg === void 0) { arg = 2; }
|
||||
return 102;
|
||||
});
|
||||
(function (arg) { return 0; }) + '' + (function (arg) { return 103; });
|
||||
(function (arg) { return 0; }) + '' + (function (arg) { return 104; });
|
||||
(function (arg) {
|
||||
if (arg === void 0) { arg = 1; }
|
||||
return 0;
|
||||
}) + '' + (function (arg) {
|
||||
if (arg === void 0) { arg = 2; }
|
||||
return 105;
|
||||
});
|
||||
(function (arg) {
|
||||
if (arg === void 0) { arg = 1; }
|
||||
return 0;
|
||||
}) + '' + (function (arg) {
|
||||
if (arg === void 0) { arg = 2; }
|
||||
return 106;
|
||||
});
|
||||
(function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
}
|
||||
return 0;
|
||||
}) + '' + (function () {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
}
|
||||
return 107;
|
||||
});
|
||||
(function (arg1, arg2) { return 0; }) + '' + (function (arg1, arg2) { return 108; });
|
||||
(function (arg1) {
|
||||
var arg2 = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
arg2[_i - 1] = arguments[_i];
|
||||
}
|
||||
return 0;
|
||||
}) + '' + (function (arg1) {
|
||||
var arg2 = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
arg2[_i - 1] = arguments[_i];
|
||||
}
|
||||
return 108;
|
||||
});
|
||||
// Function Parameters
|
||||
function foo() {
|
||||
var arg = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
arg[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
foo(function (a) { return 110; }, (function (a) { return 111; }), function (a) {
|
||||
return 112;
|
||||
}, function (a) { return 113; }, function (a, b) { return 114; }, function (a) { return 115; }, function (a) {
|
||||
if (a === void 0) { a = 0; }
|
||||
return 116;
|
||||
}, function (a) {
|
||||
if (a === void 0) { a = 0; }
|
||||
return 117;
|
||||
}, function (a) {
|
||||
if (a === void 0) { a = 0; }
|
||||
return 118;
|
||||
}, function () {
|
||||
var a = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
a[_i - 0] = arguments[_i];
|
||||
}
|
||||
return 119;
|
||||
}, function (a, b) {
|
||||
if (b === void 0) { b = 0; }
|
||||
var c = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
c[_i - 2] = arguments[_i];
|
||||
}
|
||||
return 120;
|
||||
}, function (a) { return function (b) { return function (c) { return 121; }; }; }, false ? function (a) { return 0; } : function (b) { return 122; });
|
||||
@@ -0,0 +1,13 @@
|
||||
//// [fatarrowfunctionsOptionalArgsErrors2.ts]
|
||||
var tt1 = (a, (b, c)) => a+b+c;
|
||||
var tt2 = ((a), b, c) => a+b+c;
|
||||
|
||||
var tt3 = ((a)) => a;
|
||||
|
||||
//// [fatarrowfunctionsOptionalArgsErrors2.js]
|
||||
var tt1 = (a, (b, c));
|
||||
a + b + c;
|
||||
var tt2 = ((a), b, c);
|
||||
a + b + c;
|
||||
var tt3 = ((a));
|
||||
a;
|
||||
@@ -0,0 +1,12 @@
|
||||
//// [fatarrowfunctionsOptionalArgsErrors3.ts]
|
||||
(...) => 105;
|
||||
|
||||
|
||||
//// [fatarrowfunctionsOptionalArgsErrors3.js]
|
||||
(function () {
|
||||
var = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
[_i - 0] = arguments[_i];
|
||||
}
|
||||
return 105;
|
||||
});
|
||||
@@ -0,0 +1,56 @@
|
||||
//// [for.ts]
|
||||
for (var i = 0; i < 10; i++) { // ok
|
||||
var x1 = i;
|
||||
}
|
||||
|
||||
for (var j: number = 0; j < 10; j++) { // ok
|
||||
var x2 = j;
|
||||
}
|
||||
|
||||
for (var k = 0; k < 10;) { // ok
|
||||
k++;
|
||||
}
|
||||
|
||||
for (; i < 10;) { // ok
|
||||
i++;
|
||||
}
|
||||
|
||||
for (; i > 1; i--) { // ok
|
||||
}
|
||||
|
||||
for (var l = 0; ; l++) { // ok
|
||||
if (l > 10) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (; ;) { // ok
|
||||
}
|
||||
|
||||
for () { // error
|
||||
}
|
||||
|
||||
//// [for.js]
|
||||
for (var i = 0; i < 10; i++) {
|
||||
var x1 = i;
|
||||
}
|
||||
for (var j = 0; j < 10; j++) {
|
||||
var x2 = j;
|
||||
}
|
||||
for (var k = 0; k < 10;) {
|
||||
k++;
|
||||
}
|
||||
for (; i < 10;) {
|
||||
i++;
|
||||
}
|
||||
for (; i > 1; i--) {
|
||||
}
|
||||
for (var l = 0;; l++) {
|
||||
if (l > 10) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (;;) {
|
||||
}
|
||||
for (;;) {
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//// [functionTypesLackingReturnTypes.ts]
|
||||
|
||||
// Error (no '=>')
|
||||
function f(x: ()) {
|
||||
}
|
||||
|
||||
// Error (no '=>')
|
||||
var g: (param);
|
||||
|
||||
// Okay
|
||||
var h: { () }
|
||||
|
||||
// Okay
|
||||
var i: { new () }
|
||||
|
||||
//// [functionTypesLackingReturnTypes.js]
|
||||
// Error (no '=>')
|
||||
function f(x) {
|
||||
}
|
||||
// Error (no '=>')
|
||||
var g;
|
||||
// Okay
|
||||
var h;
|
||||
// Okay
|
||||
var i;
|
||||
@@ -0,0 +1,237 @@
|
||||
//// [functionsMissingReturnStatementsAndExpressions.ts]
|
||||
|
||||
function f1(): string {
|
||||
// errors because there are no return statements
|
||||
}
|
||||
|
||||
function f2(): string {
|
||||
// Permissible; returns undefined.
|
||||
return;
|
||||
}
|
||||
|
||||
function f3(): string {
|
||||
return "Okay, because this is a return expression.";
|
||||
}
|
||||
|
||||
function f4(): void {
|
||||
// Fine since we are typed void.
|
||||
}
|
||||
|
||||
function f5(): void {
|
||||
// Fine since we are typed void.
|
||||
return;
|
||||
}
|
||||
|
||||
function f6(): void {
|
||||
// Fine since we are typed void and return undefined
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function f7(): void {
|
||||
// Fine since we are typed void and return null
|
||||
return null;
|
||||
}
|
||||
|
||||
function f8(): void {
|
||||
// Fine since are typed any.
|
||||
return;
|
||||
}
|
||||
|
||||
function f9(): void {
|
||||
// Fine since we are typed any and return undefined
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function f10(): void {
|
||||
// Fine since we are typed any and return null
|
||||
return null;
|
||||
}
|
||||
|
||||
function f11(): string {
|
||||
// Fine since we consist of a single throw statement.
|
||||
throw undefined;
|
||||
}
|
||||
|
||||
function f12(): void {
|
||||
// Fine since we consist of a single throw statement.
|
||||
throw undefined;
|
||||
}
|
||||
|
||||
function f13(): any {
|
||||
// Fine since we consist of a single throw statement.
|
||||
throw undefined;
|
||||
}
|
||||
|
||||
function f14(): number {
|
||||
// Not fine, since we can *only* consist of a single throw statement
|
||||
// if no return statements are present but we are annotated.
|
||||
throw undefined;
|
||||
throw null;
|
||||
}
|
||||
|
||||
function f15(): number {
|
||||
// Fine, since we have a return statement somewhere.
|
||||
throw undefined;
|
||||
throw null;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
function f16() {
|
||||
// Okay; not type annotated.
|
||||
}
|
||||
|
||||
function f17() {
|
||||
// Okay; not type annotated.
|
||||
return;
|
||||
}
|
||||
|
||||
function f18() {
|
||||
return "Okay, not type annotated.";
|
||||
}
|
||||
|
||||
|
||||
class C {
|
||||
public get m1() {
|
||||
// Errors; get accessors must return a value.
|
||||
}
|
||||
|
||||
public get m2() {
|
||||
// Permissible; returns undefined.
|
||||
return;
|
||||
}
|
||||
|
||||
public get m3() {
|
||||
return "Okay, because this is a return expression.";
|
||||
}
|
||||
|
||||
public get m4() {
|
||||
// Fine since this consists of a single throw statement.
|
||||
throw null;
|
||||
}
|
||||
|
||||
public get m5() {
|
||||
// Not fine, since we can *only* consist of a single throw statement
|
||||
// if no return statements are present but we are a get accessor.
|
||||
throw null;
|
||||
throw undefined.
|
||||
}
|
||||
}
|
||||
|
||||
//// [functionsMissingReturnStatementsAndExpressions.js]
|
||||
function f1() {
|
||||
// errors because there are no return statements
|
||||
}
|
||||
function f2() {
|
||||
// Permissible; returns undefined.
|
||||
return;
|
||||
}
|
||||
function f3() {
|
||||
return "Okay, because this is a return expression.";
|
||||
}
|
||||
function f4() {
|
||||
// Fine since we are typed void.
|
||||
}
|
||||
function f5() {
|
||||
// Fine since we are typed void.
|
||||
return;
|
||||
}
|
||||
function f6() {
|
||||
// Fine since we are typed void and return undefined
|
||||
return undefined;
|
||||
}
|
||||
function f7() {
|
||||
// Fine since we are typed void and return null
|
||||
return null;
|
||||
}
|
||||
function f8() {
|
||||
// Fine since are typed any.
|
||||
return;
|
||||
}
|
||||
function f9() {
|
||||
// Fine since we are typed any and return undefined
|
||||
return undefined;
|
||||
}
|
||||
function f10() {
|
||||
// Fine since we are typed any and return null
|
||||
return null;
|
||||
}
|
||||
function f11() {
|
||||
// Fine since we consist of a single throw statement.
|
||||
throw undefined;
|
||||
}
|
||||
function f12() {
|
||||
// Fine since we consist of a single throw statement.
|
||||
throw undefined;
|
||||
}
|
||||
function f13() {
|
||||
// Fine since we consist of a single throw statement.
|
||||
throw undefined;
|
||||
}
|
||||
function f14() {
|
||||
// Not fine, since we can *only* consist of a single throw statement
|
||||
// if no return statements are present but we are annotated.
|
||||
throw undefined;
|
||||
throw null;
|
||||
}
|
||||
function f15() {
|
||||
// Fine, since we have a return statement somewhere.
|
||||
throw undefined;
|
||||
throw null;
|
||||
return;
|
||||
}
|
||||
function f16() {
|
||||
// Okay; not type annotated.
|
||||
}
|
||||
function f17() {
|
||||
// Okay; not type annotated.
|
||||
return;
|
||||
}
|
||||
function f18() {
|
||||
return "Okay, not type annotated.";
|
||||
}
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
Object.defineProperty(C.prototype, "m1", {
|
||||
get: function () {
|
||||
// Errors; get accessors must return a value.
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, "m2", {
|
||||
get: function () {
|
||||
// Permissible; returns undefined.
|
||||
return;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, "m3", {
|
||||
get: function () {
|
||||
return "Okay, because this is a return expression.";
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, "m4", {
|
||||
get: function () {
|
||||
// Fine since this consists of a single throw statement.
|
||||
throw null;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(C.prototype, "m5", {
|
||||
get: function () {
|
||||
// Not fine, since we can *only* consist of a single throw statement
|
||||
// if no return statements are present but we are a get accessor.
|
||||
throw null;
|
||||
throw undefined.;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return C;
|
||||
})();
|
||||
@@ -0,0 +1,8 @@
|
||||
//// [genericArrayExtenstions.ts]
|
||||
export declare class ObservableArray<T> implements Array<T> { // MS.Entertainment.ObservableArray
|
||||
concat<U extends T[]>(...items: U[]): T[];
|
||||
concat(...items: T[]): T[];
|
||||
}
|
||||
|
||||
|
||||
//// [genericArrayExtenstions.js]
|
||||
@@ -0,0 +1,10 @@
|
||||
//// [genericCallWithoutArgs.ts]
|
||||
function f<X, Y>(x: X, y: Y) {
|
||||
}
|
||||
|
||||
f<number,string>.
|
||||
|
||||
//// [genericCallWithoutArgs.js]
|
||||
function f(x, y) {
|
||||
}
|
||||
f();
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [genericCallsWithoutParens.ts]
|
||||
function f<T>() { }
|
||||
var r = f<number>; // parse error
|
||||
|
||||
class C<T> {
|
||||
foo: T;
|
||||
}
|
||||
var c = new C<number>; // parse error
|
||||
|
||||
|
||||
|
||||
//// [genericCallsWithoutParens.js]
|
||||
function f() {
|
||||
}
|
||||
var r = f(); // parse error
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
var c = new C(); // parse error
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [genericConstructExpressionWithoutArgs.ts]
|
||||
class B { }
|
||||
var b = new B; // no error
|
||||
|
||||
class C<T> {
|
||||
x: T;
|
||||
}
|
||||
|
||||
var c = new C // C<any>
|
||||
var c2 = new C<number> // error, type params are actually part of the arg list so you need both
|
||||
|
||||
|
||||
//// [genericConstructExpressionWithoutArgs.js]
|
||||
var B = (function () {
|
||||
function B() {
|
||||
}
|
||||
return B;
|
||||
})();
|
||||
var b = new B; // no error
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
var c = new C; // C<any>
|
||||
var c2 = new C(); // error, type params are actually part of the arg list so you need both
|
||||
@@ -0,0 +1,21 @@
|
||||
//// [genericObjectCreationWithoutTypeArgs.ts]
|
||||
class SS<T>{
|
||||
|
||||
}
|
||||
|
||||
var x1 = new SS<number>(); // OK
|
||||
var x2 = new SS < number>; // Correctly give error
|
||||
var x3 = new SS(); // OK
|
||||
var x4 = new SS; // Should be allowed, but currently give error ('supplied parameters do not match any signature of the call target')
|
||||
|
||||
|
||||
//// [genericObjectCreationWithoutTypeArgs.js]
|
||||
var SS = (function () {
|
||||
function SS() {
|
||||
}
|
||||
return SS;
|
||||
})();
|
||||
var x1 = new SS(); // OK
|
||||
var x2 = new SS(); // Correctly give error
|
||||
var x3 = new SS(); // OK
|
||||
var x4 = new SS; // Should be allowed, but currently give error ('supplied parameters do not match any signature of the call target')
|
||||
+7
-1
@@ -1,2 +1,8 @@
|
||||
EmitOutputStatus : AllOutputGenerationSkipped
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : out.js
|
||||
// File to emit, does not contain syntactic errors, but --out is passed
|
||||
// expected to not generate outputs because of the syntactic errors in the other file.
|
||||
var noErrors = true;
|
||||
// File not emitted, and contains syntactic errors
|
||||
var syntactic = Error;
|
||||
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
EmitOutputStatus : AllOutputGenerationSkipped
|
||||
EmitOutputStatus : Succeeded
|
||||
Filename : tests/cases/fourslash/inputFile.js
|
||||
var x;
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
//// [tests/cases/compiler/importAliasAnExternalModuleInsideAnInternalModule.ts] ////
|
||||
|
||||
//// [importAliasAnExternalModuleInsideAnInternalModule_file0.ts]
|
||||
export module m {
|
||||
export function foo() { }
|
||||
}
|
||||
|
||||
//// [importAliasAnExternalModuleInsideAnInternalModule_file1.ts]
|
||||
import r = require('importAliasAnExternalModuleInsideAnInternalModule_file0');
|
||||
module m_private {
|
||||
//import r2 = require('m'); // would be error
|
||||
export import C = r; // no error
|
||||
C.m.foo();
|
||||
}
|
||||
|
||||
|
||||
//// [importAliasAnExternalModuleInsideAnInternalModule_file0.js]
|
||||
var m;
|
||||
(function (m) {
|
||||
function foo() {
|
||||
}
|
||||
m.foo = foo;
|
||||
})(m = exports.m || (exports.m = {}));
|
||||
//// [importAliasAnExternalModuleInsideAnInternalModule_file1.js]
|
||||
var r = require('importAliasAnExternalModuleInsideAnInternalModule_file0');
|
||||
var m_private;
|
||||
(function (m_private) {
|
||||
//import r2 = require('m'); // would be error
|
||||
m_private.C = r; // no error
|
||||
m_private.C.m.foo();
|
||||
})(m_private || (m_private = {}));
|
||||
@@ -0,0 +1,8 @@
|
||||
//// [importDeclRefereingExternalModuleWithNoResolve.ts]
|
||||
import b = require("externalModule");
|
||||
declare module "m1" {
|
||||
import im2 = require("externalModule");
|
||||
}
|
||||
|
||||
|
||||
//// [importDeclRefereingExternalModuleWithNoResolve.js]
|
||||
@@ -0,0 +1,11 @@
|
||||
//// [importDeclWithDeclareModifier.ts]
|
||||
module x {
|
||||
interface c {
|
||||
}
|
||||
}
|
||||
declare export import a = x.c;
|
||||
var b: a;
|
||||
|
||||
|
||||
//// [importDeclWithDeclareModifier.js]
|
||||
var b;
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [incompleteDottedExpressionAtEOF.ts]
|
||||
// used to leak __missing into error message
|
||||
var p2 = window.
|
||||
|
||||
//// [incompleteDottedExpressionAtEOF.js]
|
||||
// used to leak __missing into error message
|
||||
var p2 = window.;
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [incompleteObjectLiteral1.ts]
|
||||
var tt = { aa; }
|
||||
var x = tt;
|
||||
|
||||
//// [incompleteObjectLiteral1.js]
|
||||
var tt = { aa: };
|
||||
var x = tt;
|
||||
@@ -0,0 +1,123 @@
|
||||
//// [incrementAndDecrement.ts]
|
||||
enum E { A, B, C };
|
||||
var x = 4;
|
||||
var e = E.B;
|
||||
var a: any;
|
||||
var w = window;
|
||||
|
||||
// Assign to expression++
|
||||
x++ = 4; // Error
|
||||
|
||||
// Assign to expression--
|
||||
x-- = 5; // Error
|
||||
|
||||
// Assign to++expression
|
||||
++x = 4; // Error
|
||||
|
||||
// Assign to--expression
|
||||
--x = 5; // Error
|
||||
|
||||
// Pre and postfix++ on number
|
||||
x++;
|
||||
x--;
|
||||
++x;
|
||||
--x;
|
||||
++x++; // Error
|
||||
--x--; // Error
|
||||
++x--; // Error
|
||||
--x++; // Error
|
||||
|
||||
// Pre and postfix++ on enum
|
||||
e++;
|
||||
e--;
|
||||
++e;
|
||||
--e;
|
||||
++e++; // Error
|
||||
--e--; // Error
|
||||
++e--; // Error
|
||||
--e++; // Error
|
||||
|
||||
// Pre and postfix++ on value of type 'any'
|
||||
a++;
|
||||
a--;
|
||||
++a;
|
||||
--a;
|
||||
++a++; // Error
|
||||
--a--; // Error
|
||||
++a--; // Error
|
||||
--a++; // Error
|
||||
|
||||
|
||||
// Pre and postfix++ on other types
|
||||
w++; // Error
|
||||
w--; // Error
|
||||
++w; // Error
|
||||
--w; // Error
|
||||
++w++; // Error
|
||||
--w--; // Error
|
||||
++w--; // Error
|
||||
--w++; // Error
|
||||
|
||||
|
||||
|
||||
|
||||
//// [incrementAndDecrement.js]
|
||||
var E;
|
||||
(function (E) {
|
||||
E[E["A"] = 0] = "A";
|
||||
E[E["B"] = 1] = "B";
|
||||
E[E["C"] = 2] = "C";
|
||||
})(E || (E = {}));
|
||||
;
|
||||
var x = 4;
|
||||
var e = 1 /* B */;
|
||||
var a;
|
||||
var w = window;
|
||||
// Assign to expression++
|
||||
x++;
|
||||
4; // Error
|
||||
// Assign to expression--
|
||||
x--;
|
||||
5; // Error
|
||||
// Assign to++expression
|
||||
++x;
|
||||
4; // Error
|
||||
// Assign to--expression
|
||||
--x;
|
||||
5; // Error
|
||||
// Pre and postfix++ on number
|
||||
x++;
|
||||
x--;
|
||||
++x;
|
||||
--x;
|
||||
++x++; // Error
|
||||
--x--; // Error
|
||||
++x--; // Error
|
||||
--x++; // Error
|
||||
// Pre and postfix++ on enum
|
||||
e++;
|
||||
e--;
|
||||
++e;
|
||||
--e;
|
||||
++e++; // Error
|
||||
--e--; // Error
|
||||
++e--; // Error
|
||||
--e++; // Error
|
||||
// Pre and postfix++ on value of type 'any'
|
||||
a++;
|
||||
a--;
|
||||
++a;
|
||||
--a;
|
||||
++a++; // Error
|
||||
--a--; // Error
|
||||
++a--; // Error
|
||||
--a++; // Error
|
||||
// Pre and postfix++ on other types
|
||||
w++; // Error
|
||||
w--; // Error
|
||||
++w; // Error
|
||||
--w; // Error
|
||||
++w++; // Error
|
||||
--w--; // Error
|
||||
++w--; // Error
|
||||
--w++; // Error
|
||||
@@ -0,0 +1,43 @@
|
||||
//// [initializerReferencingConstructorLocals.ts]
|
||||
// Initializer expressions for instance member variables are evaluated in the scope of the class constructor body but are not permitted to reference parameters or local variables of the constructor.
|
||||
|
||||
class C {
|
||||
a = z; // error
|
||||
b: typeof z; // error
|
||||
c = this.z; // error
|
||||
d: typeof this.z; // error
|
||||
constructor(x) {
|
||||
z = 1;
|
||||
}
|
||||
}
|
||||
|
||||
class D<T> {
|
||||
a = z; // error
|
||||
b: typeof z; // error
|
||||
c = this.z; // error
|
||||
d: typeof this.z; // error
|
||||
constructor(x: T) {
|
||||
z = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//// [initializerReferencingConstructorLocals.js]
|
||||
// Initializer expressions for instance member variables are evaluated in the scope of the class constructor body but are not permitted to reference parameters or local variables of the constructor.
|
||||
var C = (function () {
|
||||
function C(x) {
|
||||
this.a = z; // error
|
||||
this.c = this.z; // error
|
||||
this.d = this.z; // error
|
||||
z = 1;
|
||||
}
|
||||
return C;
|
||||
})();
|
||||
var D = (function () {
|
||||
function D(x) {
|
||||
this.a = z; // error
|
||||
this.c = this.z; // error
|
||||
this.d = this.z; // error
|
||||
z = 1;
|
||||
}
|
||||
return D;
|
||||
})();
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user