mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into LSAPICleanup
Conflicts: src/services/services.ts
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
//// [TypeGuardWithArrayUnion.ts]
|
||||
class Message {
|
||||
value: string;
|
||||
}
|
||||
|
||||
function saySize(message: Message | Message[]) {
|
||||
if (message instanceof Array) {
|
||||
return message.length; // Should have type Message[] here
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [TypeGuardWithArrayUnion.js]
|
||||
var Message = (function () {
|
||||
function Message() {
|
||||
}
|
||||
return Message;
|
||||
})();
|
||||
function saySize(message) {
|
||||
if (message instanceof Array) {
|
||||
return message.length; // Should have type Message[] here
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
=== tests/cases/conformance/expressions/typeGuards/TypeGuardWithArrayUnion.ts ===
|
||||
class Message {
|
||||
>Message : Message
|
||||
|
||||
value: string;
|
||||
>value : string
|
||||
}
|
||||
|
||||
function saySize(message: Message | Message[]) {
|
||||
>saySize : (message: Message | Message[]) => number
|
||||
>message : Message | Message[]
|
||||
>Message : Message
|
||||
>Message : Message
|
||||
|
||||
if (message instanceof Array) {
|
||||
>message instanceof Array : boolean
|
||||
>message : Message | Message[]
|
||||
>Array : ArrayConstructor
|
||||
|
||||
return message.length; // Should have type Message[] here
|
||||
>message.length : number
|
||||
>message : Message[]
|
||||
>length : number
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ var p_cast = <Point> ({
|
||||
>p_cast : Point
|
||||
><Point> ({ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }}) : Point
|
||||
>Point : Point
|
||||
>({ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }}) : { x: number; y: number; add: (dx: any, dy: any) => Point; mult: (p: any) => any; }
|
||||
>{ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }} : { x: number; y: number; add: (dx: any, dy: any) => Point; mult: (p: any) => any; }
|
||||
>({ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }}) : { x: number; y: number; add: (dx: number, dy: number) => Point; mult: (p: Point) => Point; }
|
||||
>{ x: 0, y: 0, add: function(dx, dy) { return new Point(this.x + dx, this.y + dy); }, mult: function(p) { return p; }} : { x: number; y: number; add: (dx: number, dy: number) => Point; mult: (p: Point) => Point; }
|
||||
|
||||
x: 0,
|
||||
>x : number
|
||||
@@ -75,10 +75,10 @@ var p_cast = <Point> ({
|
||||
>y : number
|
||||
|
||||
add: function(dx, dy) {
|
||||
>add : (dx: any, dy: any) => Point
|
||||
>function(dx, dy) { return new Point(this.x + dx, this.y + dy); } : (dx: any, dy: any) => Point
|
||||
>dx : any
|
||||
>dy : any
|
||||
>add : (dx: number, dy: number) => Point
|
||||
>function(dx, dy) { return new Point(this.x + dx, this.y + dy); } : (dx: number, dy: number) => Point
|
||||
>dx : number
|
||||
>dy : number
|
||||
|
||||
return new Point(this.x + dx, this.y + dy);
|
||||
>new Point(this.x + dx, this.y + dy) : Point
|
||||
@@ -87,19 +87,19 @@ var p_cast = <Point> ({
|
||||
>this.x : any
|
||||
>this : any
|
||||
>x : any
|
||||
>dx : any
|
||||
>dx : number
|
||||
>this.y + dy : any
|
||||
>this.y : any
|
||||
>this : any
|
||||
>y : any
|
||||
>dy : any
|
||||
>dy : number
|
||||
|
||||
},
|
||||
mult: function(p) { return p; }
|
||||
>mult : (p: any) => any
|
||||
>function(p) { return p; } : (p: any) => any
|
||||
>p : any
|
||||
>p : any
|
||||
>mult : (p: Point) => Point
|
||||
>function(p) { return p; } : (p: Point) => Point
|
||||
>p : Point
|
||||
>p : Point
|
||||
|
||||
})
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
tests/cases/compiler/constEnumBadPropertyNames.ts(2,11): error TS4088: Property 'B' does not exist on 'const' enum 'E'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/constEnumBadPropertyNames.ts (1 errors) ====
|
||||
const enum E { A }
|
||||
var x = E["B"]
|
||||
~~~
|
||||
!!! error TS4088: Property 'B' does not exist on 'const' enum 'E'.
|
||||
@@ -3,8 +3,8 @@ tests/cases/compiler/constEnumErrors.ts(5,8): error TS2300: Duplicate identifier
|
||||
tests/cases/compiler/constEnumErrors.ts(12,9): error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
||||
tests/cases/compiler/constEnumErrors.ts(14,9): error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
||||
tests/cases/compiler/constEnumErrors.ts(15,10): error TS4083: In 'const' enum declarations member initializer must be constant expression.
|
||||
tests/cases/compiler/constEnumErrors.ts(22,13): error TS4085: Index expression arguments in 'const' enums must be of type 'string'.
|
||||
tests/cases/compiler/constEnumErrors.ts(24,13): error TS4085: Index expression arguments in 'const' enums must be of type 'string'.
|
||||
tests/cases/compiler/constEnumErrors.ts(22,13): error TS4085: A const enum member can only be accessed using a string literal.
|
||||
tests/cases/compiler/constEnumErrors.ts(24,13): error TS4085: A const enum member can only be accessed using a string literal.
|
||||
tests/cases/compiler/constEnumErrors.ts(26,9): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
||||
tests/cases/compiler/constEnumErrors.ts(27,10): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
||||
tests/cases/compiler/constEnumErrors.ts(32,5): error TS4084: 'const' enums can only be used in property or index access expressions or the right hand side of an import declaration or export assignment.
|
||||
@@ -47,11 +47,11 @@ tests/cases/compiler/constEnumErrors.ts(42,9): error TS4087: 'const' enum member
|
||||
|
||||
var y0 = E2[1]
|
||||
~
|
||||
!!! error TS4085: Index expression arguments in 'const' enums must be of type 'string'.
|
||||
!!! error TS4085: A const enum member can only be accessed using a string literal.
|
||||
var name = "A";
|
||||
var y1 = E2[name];
|
||||
~~~~
|
||||
!!! error TS4085: Index expression arguments in 'const' enums must be of type 'string'.
|
||||
!!! error TS4085: A const enum member can only be accessed using a string literal.
|
||||
|
||||
var x = E2;
|
||||
~~
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(2,22): error TS2339: Property 'foo' does not exist on type 'string'.
|
||||
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,10): error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'T'.
|
||||
tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts(3,32): error TS2339: Property 'foo' does not exist on type 'T'.
|
||||
|
||||
|
||||
==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (1 errors) ====
|
||||
==== tests/cases/compiler/contextualTypingWithFixedTypeParameters1.ts (3 errors) ====
|
||||
var f10: <T>(x: T, b: () => (a: T) => void, y: T) => T;
|
||||
f10('', () => a => a.foo, ''); // a is string
|
||||
~~~
|
||||
!!! error TS2339: Property 'foo' does not exist on type 'string'.
|
||||
var r9 = f10('', () => (a => a.foo), 1); // error
|
||||
var r9 = f10('', () => (a => a.foo), 1); // error
|
||||
~~~
|
||||
!!! error TS2453: The type argument for type parameter 'T' cannot be inferred from the usage. Consider specifying the type arguments explicitly.
|
||||
!!! error TS2453: Type argument candidate 'string' is not a valid type argument because it is not a supertype of candidate 'T'.
|
||||
~~~
|
||||
!!! error TS2339: Property 'foo' does not exist on type 'T'.
|
||||
@@ -0,0 +1,71 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(2,17): error TS1187: A parameter property may not be a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(9,17): error TS1187: A parameter property may not be a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(16,17): error TS1187: A parameter property may not be a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,26): error TS2339: Property 'x' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,35): error TS2339: Property 'y' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,43): error TS2339: Property 'y' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(22,52): error TS2339: Property 'z' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(25,30): error TS2339: Property 'x' does not exist on type 'C2'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(25,36): error TS2339: Property 'y' does not exist on type 'C2'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(25,42): error TS2339: Property 'z' does not exist on type 'C2'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(29,30): error TS2339: Property 'x' does not exist on type 'C3'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(29,36): error TS2339: Property 'y' does not exist on type 'C3'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts(29,42): error TS2339: Property 'z' does not exist on type 'C3'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties1.ts (13 errors) ====
|
||||
class C1 {
|
||||
constructor(public [x, y, z]: string[]) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1187: A parameter property may not be a binding pattern.
|
||||
}
|
||||
}
|
||||
|
||||
type TupleType1 = [string, number, boolean];
|
||||
|
||||
class C2 {
|
||||
constructor(public [x, y, z]: TupleType1) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1187: A parameter property may not be a binding pattern.
|
||||
}
|
||||
}
|
||||
|
||||
type ObjType1 = { x: number; y: string; z: boolean }
|
||||
|
||||
class C3 {
|
||||
constructor(public { x, y, z }: ObjType1) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1187: A parameter property may not be a binding pattern.
|
||||
}
|
||||
}
|
||||
|
||||
var c1 = new C1([]);
|
||||
c1 = new C1(["larry", "{curly}", "moe"]);
|
||||
var useC1Properties = c1.x === c1.y && c1.y === c1.z;
|
||||
~
|
||||
!!! error TS2339: Property 'x' does not exist on type 'C1'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'C1'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'C1'.
|
||||
~
|
||||
!!! error TS2339: Property 'z' does not exist on type 'C1'.
|
||||
|
||||
var c2 = new C2(["10", 10, !!10]);
|
||||
var [c2_x, c2_y, c2_z] = [c2.x, c2.y, c2.z];
|
||||
~
|
||||
!!! error TS2339: Property 'x' does not exist on type 'C2'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'C2'.
|
||||
~
|
||||
!!! error TS2339: Property 'z' does not exist on type 'C2'.
|
||||
|
||||
var c3 = new C3({x: 0, y: "", z: false});
|
||||
c3 = new C3({x: 0, "y": "y", z: true});
|
||||
var [c3_x, c3_y, c3_z] = [c3.x, c3.y, c3.z];
|
||||
~
|
||||
!!! error TS2339: Property 'x' does not exist on type 'C3'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'C3'.
|
||||
~
|
||||
!!! error TS2339: Property 'z' does not exist on type 'C3'.
|
||||
@@ -0,0 +1,61 @@
|
||||
//// [destructuringParameterProperties1.ts]
|
||||
class C1 {
|
||||
constructor(public [x, y, z]: string[]) {
|
||||
}
|
||||
}
|
||||
|
||||
type TupleType1 = [string, number, boolean];
|
||||
|
||||
class C2 {
|
||||
constructor(public [x, y, z]: TupleType1) {
|
||||
}
|
||||
}
|
||||
|
||||
type ObjType1 = { x: number; y: string; z: boolean }
|
||||
|
||||
class C3 {
|
||||
constructor(public { x, y, z }: ObjType1) {
|
||||
}
|
||||
}
|
||||
|
||||
var c1 = new C1([]);
|
||||
c1 = new C1(["larry", "{curly}", "moe"]);
|
||||
var useC1Properties = c1.x === c1.y && c1.y === c1.z;
|
||||
|
||||
var c2 = new C2(["10", 10, !!10]);
|
||||
var [c2_x, c2_y, c2_z] = [c2.x, c2.y, c2.z];
|
||||
|
||||
var c3 = new C3({x: 0, y: "", z: false});
|
||||
c3 = new C3({x: 0, "y": "y", z: true});
|
||||
var [c3_x, c3_y, c3_z] = [c3.x, c3.y, c3.z];
|
||||
|
||||
//// [destructuringParameterProperties1.js]
|
||||
var C1 = (function () {
|
||||
function C1(_a) {
|
||||
var x = _a[0], y = _a[1], z = _a[2];
|
||||
this.[x, y, z] = [x, y, z];
|
||||
}
|
||||
return C1;
|
||||
})();
|
||||
var C2 = (function () {
|
||||
function C2(_a) {
|
||||
var x = _a[0], y = _a[1], z = _a[2];
|
||||
this.[x, y, z] = [x, y, z];
|
||||
}
|
||||
return C2;
|
||||
})();
|
||||
var C3 = (function () {
|
||||
function C3(_a) {
|
||||
var x = _a.x, y = _a.y, z = _a.z;
|
||||
this.{ x, y, z } = { x, y, z };
|
||||
}
|
||||
return C3;
|
||||
})();
|
||||
var c1 = new C1([]);
|
||||
c1 = new C1(["larry", "{curly}", "moe"]);
|
||||
var useC1Properties = c1.x === c1.y && c1.y === c1.z;
|
||||
var c2 = new C2(["10", 10, !!10]);
|
||||
var _a = [c2.x, c2.y, c2.z], c2_x = _a[0], c2_y = _a[1], c2_z = _a[2];
|
||||
var c3 = new C3({ x: 0, y: "", z: false });
|
||||
c3 = new C3({ x: 0, "y": "y", z: true });
|
||||
var _b = [c3.x, c3.y, c3.z], c3_x = _b[0], c3_y = _b[1], c3_z = _b[2];
|
||||
@@ -0,0 +1,56 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(2,36): error TS1187: A parameter property may not be a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(3,59): error TS2339: Property 'b' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(3,83): error TS2339: Property 'c' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(4,18): error TS2339: Property 'a' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(9,21): error TS2339: Property 'a' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts(21,27): error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties2.ts (8 errors) ====
|
||||
class C1 {
|
||||
constructor(private k: number, private [a, b, c]: [number, string, boolean]) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1187: A parameter property may not be a binding pattern.
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'C1'.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'C1'.
|
||||
this.a = a || k;
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'C1'.
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'C1'.
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'C1'.
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'C1'.
|
||||
}
|
||||
}
|
||||
|
||||
var x = new C1(undefined, [0, undefined, ""]);
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[number, undefined, string]' is not assignable to parameter of type '[number, string, boolean]'.
|
||||
var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()];
|
||||
|
||||
var y = new C1(10, [0, "", true]);
|
||||
var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()];
|
||||
|
||||
var z = new C1(10, [undefined, "", null]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
//// [destructuringParameterProperties2.ts]
|
||||
class C1 {
|
||||
constructor(private k: number, private [a, b, c]: [number, string, boolean]) {
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
}
|
||||
}
|
||||
|
||||
var x = new C1(undefined, [0, undefined, ""]);
|
||||
var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()];
|
||||
|
||||
var y = new C1(10, [0, "", true]);
|
||||
var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()];
|
||||
|
||||
var z = new C1(10, [undefined, "", null]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
|
||||
|
||||
//// [destructuringParameterProperties2.js]
|
||||
var C1 = (function () {
|
||||
function C1(k, _a) {
|
||||
var a = _a[0], b = _a[1], c = _a[2];
|
||||
this.k = k;
|
||||
this.[a, b, c] = [a, b, c];
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
C1.prototype.getA = function () {
|
||||
return this.a;
|
||||
};
|
||||
C1.prototype.getB = function () {
|
||||
return this.b;
|
||||
};
|
||||
C1.prototype.getC = function () {
|
||||
return this.c;
|
||||
};
|
||||
return C1;
|
||||
})();
|
||||
var x = new C1(undefined, [0, undefined, ""]);
|
||||
var _a = [x.getA(), x.getB(), x.getC()], x_a = _a[0], x_b = _a[1], x_c = _a[2];
|
||||
var y = new C1(10, [0, "", true]);
|
||||
var _b = [y.getA(), y.getB(), y.getC()], y_a = _b[0], y_b = _b[1], y_c = _b[2];
|
||||
var z = new C1(10, [undefined, "", null]);
|
||||
var _c = [z.getA(), z.getB(), z.getC()], z_a = _c[0], z_b = _c[1], z_c = _c[2];
|
||||
@@ -0,0 +1,56 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(2,31): error TS1187: A parameter property may not be a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(3,59): error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(3,83): error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(4,18): error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(9,21): error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(13,21): error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts(17,21): error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties3.ts (7 errors) ====
|
||||
class C1<T, U, V> {
|
||||
constructor(private k: T, private [a, b, c]: [T,U,V]) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1187: A parameter property may not be a binding pattern.
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
this.a = a || k;
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
}
|
||||
|
||||
var x = new C1(undefined, [0, true, ""]);
|
||||
var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()];
|
||||
|
||||
var y = new C1(10, [0, true, true]);
|
||||
var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()];
|
||||
|
||||
var z = new C1(10, [undefined, "", ""]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
|
||||
var w = new C1(10, [undefined, undefined, undefined]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
//// [destructuringParameterProperties3.ts]
|
||||
class C1<T, U, V> {
|
||||
constructor(private k: T, private [a, b, c]: [T,U,V]) {
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
}
|
||||
}
|
||||
|
||||
var x = new C1(undefined, [0, true, ""]);
|
||||
var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()];
|
||||
|
||||
var y = new C1(10, [0, true, true]);
|
||||
var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()];
|
||||
|
||||
var z = new C1(10, [undefined, "", ""]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
|
||||
var w = new C1(10, [undefined, undefined, undefined]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
|
||||
|
||||
//// [destructuringParameterProperties3.js]
|
||||
var C1 = (function () {
|
||||
function C1(k, _a) {
|
||||
var a = _a[0], b = _a[1], c = _a[2];
|
||||
this.k = k;
|
||||
this.[a, b, c] = [a, b, c];
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
C1.prototype.getA = function () {
|
||||
return this.a;
|
||||
};
|
||||
C1.prototype.getB = function () {
|
||||
return this.b;
|
||||
};
|
||||
C1.prototype.getC = function () {
|
||||
return this.c;
|
||||
};
|
||||
return C1;
|
||||
})();
|
||||
var x = new C1(undefined, [0, true, ""]);
|
||||
var _a = [x.getA(), x.getB(), x.getC()], x_a = _a[0], x_b = _a[1], x_c = _a[2];
|
||||
var y = new C1(10, [0, true, true]);
|
||||
var _b = [y.getA(), y.getB(), y.getC()], y_a = _b[0], y_b = _b[1], y_c = _b[2];
|
||||
var z = new C1(10, [undefined, "", ""]);
|
||||
var _c = [z.getA(), z.getB(), z.getC()], z_a = _c[0], z_b = _c[1], z_c = _c[2];
|
||||
var w = new C1(10, [undefined, undefined, undefined]);
|
||||
var _d = [z.getA(), z.getB(), z.getC()], z_a = _d[0], z_b = _d[1], z_c = _d[2];
|
||||
@@ -0,0 +1,60 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(3,31): error TS1187: A parameter property may not be a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(4,59): error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(4,83): error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(5,18): error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(10,21): error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(14,21): error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(18,21): error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(24,24): error TS2339: Property 'a' does not exist on type 'C2'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(24,34): error TS2339: Property 'b' does not exist on type 'C2'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts(24,44): error TS2339: Property 'c' does not exist on type 'C2'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties4.ts (10 errors) ====
|
||||
|
||||
class C1<T, U, V> {
|
||||
constructor(private k: T, protected [a, b, c]: [T,U,V]) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1187: A parameter property may not be a binding pattern.
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
this.a = a || k;
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'C1<T, U, V>'.
|
||||
}
|
||||
}
|
||||
|
||||
class C2 extends C1<number, string, boolean> {
|
||||
public doSomethingWithSuperProperties() {
|
||||
return `${this.a} ${this.b} ${this.c}`;
|
||||
~
|
||||
!!! error TS2339: Property 'a' does not exist on type 'C2'.
|
||||
~
|
||||
!!! error TS2339: Property 'b' does not exist on type 'C2'.
|
||||
~
|
||||
!!! error TS2339: Property 'c' does not exist on type 'C2'.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
//// [destructuringParameterProperties4.ts]
|
||||
|
||||
class C1<T, U, V> {
|
||||
constructor(private k: T, protected [a, b, c]: [T,U,V]) {
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
}
|
||||
}
|
||||
|
||||
class C2 extends C1<number, string, boolean> {
|
||||
public doSomethingWithSuperProperties() {
|
||||
return `${this.a} ${this.b} ${this.c}`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//// [destructuringParameterProperties4.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 C1 = (function () {
|
||||
function C1(k, [a, b, c]) {
|
||||
this.k = k;
|
||||
this.[a, b, c] = [a, b, c];
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
C1.prototype.getA = function () {
|
||||
return this.a;
|
||||
};
|
||||
C1.prototype.getB = function () {
|
||||
return this.b;
|
||||
};
|
||||
C1.prototype.getC = function () {
|
||||
return this.c;
|
||||
};
|
||||
return C1;
|
||||
})();
|
||||
var C2 = (function (_super) {
|
||||
__extends(C2, _super);
|
||||
function C2() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
C2.prototype.doSomethingWithSuperProperties = function () {
|
||||
return `${this.a} ${this.b} ${this.c}`;
|
||||
};
|
||||
return C2;
|
||||
})(C1);
|
||||
@@ -0,0 +1,51 @@
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,17): error TS1187: A parameter property may not be a binding pattern.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,27): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x1' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,31): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x2' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(5,35): error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x3' and no string index signature.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,29): error TS2339: Property 'x1' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,40): error TS2339: Property 'x2' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,51): error TS2339: Property 'x3' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,62): error TS2339: Property 'y' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(7,72): error TS2339: Property 'z' does not exist on type 'C1'.
|
||||
tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts(11,16): error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'.
|
||||
Types of property '0' are incompatible.
|
||||
Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'.
|
||||
Property 'x' is missing in type '{ x1: number; x2: string; x3: boolean; }'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/destructuringParameterProperties5.ts (10 errors) ====
|
||||
type ObjType1 = { x: number; y: string; z: boolean }
|
||||
type TupleType1 = [ObjType1, number, string]
|
||||
|
||||
class C1 {
|
||||
constructor(public [{ x1, x2, x3 }, y, z]: TupleType1) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1187: A parameter property may not be a binding pattern.
|
||||
~~
|
||||
!!! error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x1' and no string index signature.
|
||||
~~
|
||||
!!! error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x2' and no string index signature.
|
||||
~~
|
||||
!!! error TS2459: Type '{ x: number; y: string; z: boolean; }' has no property 'x3' and no string index signature.
|
||||
var foo: any = x1 || x2 || x3 || y || z;
|
||||
var bar: any = this.x1 || this.x2 || this.x3 || this.y || this.z;
|
||||
~~
|
||||
!!! error TS2339: Property 'x1' does not exist on type 'C1'.
|
||||
~~
|
||||
!!! error TS2339: Property 'x2' does not exist on type 'C1'.
|
||||
~~
|
||||
!!! error TS2339: Property 'x3' does not exist on type 'C1'.
|
||||
~
|
||||
!!! error TS2339: Property 'y' does not exist on type 'C1'.
|
||||
~
|
||||
!!! error TS2339: Property 'z' does not exist on type 'C1'.
|
||||
}
|
||||
}
|
||||
|
||||
var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]);
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[{ x1: number; x2: string; x3: boolean; }, string, boolean]' is not assignable to parameter of type '[{ x: number; y: string; z: boolean; }, number, string]'.
|
||||
!!! error TS2345: Types of property '0' are incompatible.
|
||||
!!! error TS2345: Type '{ x1: number; x2: string; x3: boolean; }' is not assignable to type '{ x: number; y: string; z: boolean; }'.
|
||||
!!! error TS2345: Property 'x' is missing in type '{ x1: number; x2: string; x3: boolean; }'.
|
||||
var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z];
|
||||
@@ -0,0 +1,26 @@
|
||||
//// [destructuringParameterProperties5.ts]
|
||||
type ObjType1 = { x: number; y: string; z: boolean }
|
||||
type TupleType1 = [ObjType1, number, string]
|
||||
|
||||
class C1 {
|
||||
constructor(public [{ x1, x2, x3 }, y, z]: TupleType1) {
|
||||
var foo: any = x1 || x2 || x3 || y || z;
|
||||
var bar: any = this.x1 || this.x2 || this.x3 || this.y || this.z;
|
||||
}
|
||||
}
|
||||
|
||||
var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]);
|
||||
var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z];
|
||||
|
||||
//// [destructuringParameterProperties5.js]
|
||||
var C1 = (function () {
|
||||
function C1(_a) {
|
||||
var _b = _a[0], x1 = _b.x1, x2 = _b.x2, x3 = _b.x3, y = _a[1], z = _a[2];
|
||||
this.[{ x1, x2, x3 }, y, z] = [{ x1, x2, x3 }, y, z];
|
||||
var foo = x1 || x2 || x3 || y || z;
|
||||
var bar = this.x1 || this.x2 || this.x3 || this.y || this.z;
|
||||
}
|
||||
return C1;
|
||||
})();
|
||||
var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]);
|
||||
var _a = [a.x1, a.x2, a.x3, a.y, a.z], a_x1 = _a[0], a_x2 = _a[1], a_x3 = _a[2], a_y = _a[3], a_z = _a[4];
|
||||
@@ -0,0 +1,27 @@
|
||||
//// [emitDefaultParametersFunction.ts]
|
||||
function foo(x: string, y = 10) { }
|
||||
function baz(x: string, y = 5, ...rest) { }
|
||||
function bar(y = 10) { }
|
||||
function bar1(y = 10, ...rest) { }
|
||||
|
||||
//// [emitDefaultParametersFunction.js]
|
||||
function foo(x, y) {
|
||||
if (y === void 0) { y = 10; }
|
||||
}
|
||||
function baz(x, y) {
|
||||
if (y === void 0) { y = 5; }
|
||||
var rest = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
rest[_i - 2] = arguments[_i];
|
||||
}
|
||||
}
|
||||
function bar(y) {
|
||||
if (y === void 0) { y = 10; }
|
||||
}
|
||||
function bar1(y) {
|
||||
if (y === void 0) { y = 10; }
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunction.ts ===
|
||||
function foo(x: string, y = 10) { }
|
||||
>foo : (x: string, y?: number) => void
|
||||
>x : string
|
||||
>y : number
|
||||
|
||||
function baz(x: string, y = 5, ...rest) { }
|
||||
>baz : (x: string, y?: number, ...rest: any[]) => void
|
||||
>x : string
|
||||
>y : number
|
||||
>rest : any[]
|
||||
|
||||
function bar(y = 10) { }
|
||||
>bar : (y?: number) => void
|
||||
>y : number
|
||||
|
||||
function bar1(y = 10, ...rest) { }
|
||||
>bar1 : (y?: number, ...rest: any[]) => void
|
||||
>y : number
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [emitDefaultParametersFunctionES6.ts]
|
||||
function foo(x: string, y = 10) { }
|
||||
function baz(x: string, y = 5, ...rest) { }
|
||||
function bar(y = 10) { }
|
||||
function bar1(y = 10, ...rest) { }
|
||||
|
||||
//// [emitDefaultParametersFunctionES6.js]
|
||||
function foo(x, y = 10) {
|
||||
}
|
||||
function baz(x, y = 5, ...rest) {
|
||||
}
|
||||
function bar(y = 10) {
|
||||
}
|
||||
function bar1(y = 10, ...rest) {
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionES6.ts ===
|
||||
function foo(x: string, y = 10) { }
|
||||
>foo : (x: string, y?: number) => void
|
||||
>x : string
|
||||
>y : number
|
||||
|
||||
function baz(x: string, y = 5, ...rest) { }
|
||||
>baz : (x: string, y?: number, ...rest: any[]) => void
|
||||
>x : string
|
||||
>y : number
|
||||
>rest : any[]
|
||||
|
||||
function bar(y = 10) { }
|
||||
>bar : (y?: number) => void
|
||||
>y : number
|
||||
|
||||
function bar1(y = 10, ...rest) { }
|
||||
>bar1 : (y?: number, ...rest: any[]) => void
|
||||
>y : number
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//// [emitDefaultParametersFunctionExpression.ts]
|
||||
var lambda1 = (y = "hello") => { }
|
||||
var lambda2 = (x: number, y = "hello") => { }
|
||||
var lambda3 = (x: number, y = "hello", ...rest) => { }
|
||||
var lambda4 = (y = "hello", ...rest) => { }
|
||||
|
||||
var x = function (str = "hello", ...rest) { }
|
||||
var y = (function (num = 10, boo = false, ...rest) { })()
|
||||
var z = (function (num: number, boo = false, ...rest) { })(10)
|
||||
|
||||
|
||||
//// [emitDefaultParametersFunctionExpression.js]
|
||||
var lambda1 = function (y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
};
|
||||
var lambda2 = function (x, y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
};
|
||||
var lambda3 = function (x, y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
var rest = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
rest[_i - 2] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var lambda4 = function (y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var x = function (str) {
|
||||
if (str === void 0) { str = "hello"; }
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var y = (function (num, boo) {
|
||||
if (num === void 0) { num = 10; }
|
||||
if (boo === void 0) { boo = false; }
|
||||
var rest = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
rest[_i - 2] = arguments[_i];
|
||||
}
|
||||
})();
|
||||
var z = (function (num, boo) {
|
||||
if (boo === void 0) { boo = false; }
|
||||
var rest = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
rest[_i - 2] = arguments[_i];
|
||||
}
|
||||
})(10);
|
||||
@@ -0,0 +1,49 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionExpression.ts ===
|
||||
var lambda1 = (y = "hello") => { }
|
||||
>lambda1 : (y?: string) => void
|
||||
>(y = "hello") => { } : (y?: string) => void
|
||||
>y : string
|
||||
|
||||
var lambda2 = (x: number, y = "hello") => { }
|
||||
>lambda2 : (x: number, y?: string) => void
|
||||
>(x: number, y = "hello") => { } : (x: number, y?: string) => void
|
||||
>x : number
|
||||
>y : string
|
||||
|
||||
var lambda3 = (x: number, y = "hello", ...rest) => { }
|
||||
>lambda3 : (x: number, y?: string, ...rest: any[]) => void
|
||||
>(x: number, y = "hello", ...rest) => { } : (x: number, y?: string, ...rest: any[]) => void
|
||||
>x : number
|
||||
>y : string
|
||||
>rest : any[]
|
||||
|
||||
var lambda4 = (y = "hello", ...rest) => { }
|
||||
>lambda4 : (y?: string, ...rest: any[]) => void
|
||||
>(y = "hello", ...rest) => { } : (y?: string, ...rest: any[]) => void
|
||||
>y : string
|
||||
>rest : any[]
|
||||
|
||||
var x = function (str = "hello", ...rest) { }
|
||||
>x : (str?: string, ...rest: any[]) => void
|
||||
>function (str = "hello", ...rest) { } : (str?: string, ...rest: any[]) => void
|
||||
>str : string
|
||||
>rest : any[]
|
||||
|
||||
var y = (function (num = 10, boo = false, ...rest) { })()
|
||||
>y : void
|
||||
>(function (num = 10, boo = false, ...rest) { })() : void
|
||||
>(function (num = 10, boo = false, ...rest) { }) : (num?: number, boo?: boolean, ...rest: any[]) => void
|
||||
>function (num = 10, boo = false, ...rest) { } : (num?: number, boo?: boolean, ...rest: any[]) => void
|
||||
>num : number
|
||||
>boo : boolean
|
||||
>rest : any[]
|
||||
|
||||
var z = (function (num: number, boo = false, ...rest) { })(10)
|
||||
>z : void
|
||||
>(function (num: number, boo = false, ...rest) { })(10) : void
|
||||
>(function (num: number, boo = false, ...rest) { }) : (num: number, boo?: boolean, ...rest: any[]) => void
|
||||
>function (num: number, boo = false, ...rest) { } : (num: number, boo?: boolean, ...rest: any[]) => void
|
||||
>num : number
|
||||
>boo : boolean
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//// [emitDefaultParametersFunctionExpressionES6.ts]
|
||||
var lambda1 = (y = "hello") => { }
|
||||
var lambda2 = (x: number, y = "hello") => { }
|
||||
var lambda3 = (x: number, y = "hello", ...rest) => { }
|
||||
var lambda4 = (y = "hello", ...rest) => { }
|
||||
|
||||
var x = function (str = "hello", ...rest) { }
|
||||
var y = (function (num = 10, boo = false, ...rest) { })()
|
||||
var z = (function (num: number, boo = false, ...rest) { })(10)
|
||||
|
||||
//// [emitDefaultParametersFunctionExpressionES6.js]
|
||||
var lambda1 = function (y = "hello") {
|
||||
};
|
||||
var lambda2 = function (x, y = "hello") {
|
||||
};
|
||||
var lambda3 = function (x, y = "hello", ...rest) {
|
||||
};
|
||||
var lambda4 = function (y = "hello", ...rest) {
|
||||
};
|
||||
var x = function (str = "hello", ...rest) {
|
||||
};
|
||||
var y = (function (num = 10, boo = false, ...rest) {
|
||||
})();
|
||||
var z = (function (num, boo = false, ...rest) {
|
||||
})(10);
|
||||
@@ -0,0 +1,49 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionExpressionES6.ts ===
|
||||
var lambda1 = (y = "hello") => { }
|
||||
>lambda1 : (y?: string) => void
|
||||
>(y = "hello") => { } : (y?: string) => void
|
||||
>y : string
|
||||
|
||||
var lambda2 = (x: number, y = "hello") => { }
|
||||
>lambda2 : (x: number, y?: string) => void
|
||||
>(x: number, y = "hello") => { } : (x: number, y?: string) => void
|
||||
>x : number
|
||||
>y : string
|
||||
|
||||
var lambda3 = (x: number, y = "hello", ...rest) => { }
|
||||
>lambda3 : (x: number, y?: string, ...rest: any[]) => void
|
||||
>(x: number, y = "hello", ...rest) => { } : (x: number, y?: string, ...rest: any[]) => void
|
||||
>x : number
|
||||
>y : string
|
||||
>rest : any[]
|
||||
|
||||
var lambda4 = (y = "hello", ...rest) => { }
|
||||
>lambda4 : (y?: string, ...rest: any[]) => void
|
||||
>(y = "hello", ...rest) => { } : (y?: string, ...rest: any[]) => void
|
||||
>y : string
|
||||
>rest : any[]
|
||||
|
||||
var x = function (str = "hello", ...rest) { }
|
||||
>x : (str?: string, ...rest: any[]) => void
|
||||
>function (str = "hello", ...rest) { } : (str?: string, ...rest: any[]) => void
|
||||
>str : string
|
||||
>rest : any[]
|
||||
|
||||
var y = (function (num = 10, boo = false, ...rest) { })()
|
||||
>y : void
|
||||
>(function (num = 10, boo = false, ...rest) { })() : void
|
||||
>(function (num = 10, boo = false, ...rest) { }) : (num?: number, boo?: boolean, ...rest: any[]) => void
|
||||
>function (num = 10, boo = false, ...rest) { } : (num?: number, boo?: boolean, ...rest: any[]) => void
|
||||
>num : number
|
||||
>boo : boolean
|
||||
>rest : any[]
|
||||
|
||||
var z = (function (num: number, boo = false, ...rest) { })(10)
|
||||
>z : void
|
||||
>(function (num: number, boo = false, ...rest) { })(10) : void
|
||||
>(function (num: number, boo = false, ...rest) { }) : (num: number, boo?: boolean, ...rest: any[]) => void
|
||||
>function (num: number, boo = false, ...rest) { } : (num: number, boo?: boolean, ...rest: any[]) => void
|
||||
>num : number
|
||||
>boo : boolean
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
//// [emitDefaultParametersFunctionProperty.ts]
|
||||
var obj2 = {
|
||||
func1(y = 10, ...rest) { },
|
||||
func2(x = "hello") { },
|
||||
func3(x: string, z: number, y = "hello") { },
|
||||
func4(x: string, z: number, y = "hello", ...rest) { },
|
||||
}
|
||||
|
||||
|
||||
//// [emitDefaultParametersFunctionProperty.js]
|
||||
var obj2 = {
|
||||
func1: function (y) {
|
||||
if (y === void 0) { y = 10; }
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
},
|
||||
func2: function (x) {
|
||||
if (x === void 0) { x = "hello"; }
|
||||
},
|
||||
func3: function (x, z, y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
},
|
||||
func4: function (x, z, y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
var rest = [];
|
||||
for (var _i = 3; _i < arguments.length; _i++) {
|
||||
rest[_i - 3] = arguments[_i];
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,28 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionProperty.ts ===
|
||||
var obj2 = {
|
||||
>obj2 : { func1(y?: number, ...rest: any[]): void; func2(x?: string): void; func3(x: string, z: number, y?: string): void; func4(x: string, z: number, y?: string, ...rest: any[]): void; }
|
||||
>{ func1(y = 10, ...rest) { }, func2(x = "hello") { }, func3(x: string, z: number, y = "hello") { }, func4(x: string, z: number, y = "hello", ...rest) { },} : { func1(y?: number, ...rest: any[]): void; func2(x?: string): void; func3(x: string, z: number, y?: string): void; func4(x: string, z: number, y?: string, ...rest: any[]): void; }
|
||||
|
||||
func1(y = 10, ...rest) { },
|
||||
>func1 : (y?: number, ...rest: any[]) => void
|
||||
>y : number
|
||||
>rest : any[]
|
||||
|
||||
func2(x = "hello") { },
|
||||
>func2 : (x?: string) => void
|
||||
>x : string
|
||||
|
||||
func3(x: string, z: number, y = "hello") { },
|
||||
>func3 : (x: string, z: number, y?: string) => void
|
||||
>x : string
|
||||
>z : number
|
||||
>y : string
|
||||
|
||||
func4(x: string, z: number, y = "hello", ...rest) { },
|
||||
>func4 : (x: string, z: number, y?: string, ...rest: any[]) => void
|
||||
>x : string
|
||||
>z : number
|
||||
>y : string
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [emitDefaultParametersFunctionPropertyES6.ts]
|
||||
var obj2 = {
|
||||
func1(y = 10, ...rest) { },
|
||||
func2(x = "hello") { },
|
||||
func3(x: string, z: number, y = "hello") { },
|
||||
func4(x: string, z: number, y = "hello", ...rest) { },
|
||||
}
|
||||
|
||||
//// [emitDefaultParametersFunctionPropertyES6.js]
|
||||
var obj2 = {
|
||||
func1(y = 10, ...rest) {
|
||||
},
|
||||
func2(x = "hello") {
|
||||
},
|
||||
func3(x, z, y = "hello") {
|
||||
},
|
||||
func4(x, z, y = "hello", ...rest) {
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersFunctionPropertyES6.ts ===
|
||||
var obj2 = {
|
||||
>obj2 : { func1(y?: number, ...rest: any[]): void; func2(x?: string): void; func3(x: string, z: number, y?: string): void; func4(x: string, z: number, y?: string, ...rest: any[]): void; }
|
||||
>{ func1(y = 10, ...rest) { }, func2(x = "hello") { }, func3(x: string, z: number, y = "hello") { }, func4(x: string, z: number, y = "hello", ...rest) { },} : { func1(y?: number, ...rest: any[]): void; func2(x?: string): void; func3(x: string, z: number, y?: string): void; func4(x: string, z: number, y?: string, ...rest: any[]): void; }
|
||||
|
||||
func1(y = 10, ...rest) { },
|
||||
>func1 : (y?: number, ...rest: any[]) => void
|
||||
>y : number
|
||||
>rest : any[]
|
||||
|
||||
func2(x = "hello") { },
|
||||
>func2 : (x?: string) => void
|
||||
>x : string
|
||||
|
||||
func3(x: string, z: number, y = "hello") { },
|
||||
>func3 : (x: string, z: number, y?: string) => void
|
||||
>x : string
|
||||
>z : number
|
||||
>y : string
|
||||
|
||||
func4(x: string, z: number, y = "hello", ...rest) { },
|
||||
>func4 : (x: string, z: number, y?: string, ...rest: any[]) => void
|
||||
>x : string
|
||||
>z : number
|
||||
>y : string
|
||||
>rest : any[]
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
//// [emitDefaultParametersMethod.ts]
|
||||
class C {
|
||||
constructor(t: boolean, z: string, x: number, y = "hello") { }
|
||||
|
||||
public foo(x: string, t = false) { }
|
||||
public foo1(x: string, t = false, ...rest) { }
|
||||
public bar(t = false) { }
|
||||
public boo(t = false, ...rest) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
constructor(y = "hello") { }
|
||||
}
|
||||
|
||||
class E {
|
||||
constructor(y = "hello", ...rest) { }
|
||||
}
|
||||
|
||||
|
||||
//// [emitDefaultParametersMethod.js]
|
||||
var C = (function () {
|
||||
function C(t, z, x, y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
}
|
||||
C.prototype.foo = function (x, t) {
|
||||
if (t === void 0) { t = false; }
|
||||
};
|
||||
C.prototype.foo1 = function (x, t) {
|
||||
if (t === void 0) { t = false; }
|
||||
var rest = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
rest[_i - 2] = arguments[_i];
|
||||
}
|
||||
};
|
||||
C.prototype.bar = function (t) {
|
||||
if (t === void 0) { t = false; }
|
||||
};
|
||||
C.prototype.boo = function (t) {
|
||||
if (t === void 0) { t = false; }
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
var D = (function () {
|
||||
function D(y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
}
|
||||
return D;
|
||||
})();
|
||||
var E = (function () {
|
||||
function E(y) {
|
||||
if (y === void 0) { y = "hello"; }
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
}
|
||||
return E;
|
||||
})();
|
||||
@@ -0,0 +1,46 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersMethod.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
constructor(t: boolean, z: string, x: number, y = "hello") { }
|
||||
>t : boolean
|
||||
>z : string
|
||||
>x : number
|
||||
>y : string
|
||||
|
||||
public foo(x: string, t = false) { }
|
||||
>foo : (x: string, t?: boolean) => void
|
||||
>x : string
|
||||
>t : boolean
|
||||
|
||||
public foo1(x: string, t = false, ...rest) { }
|
||||
>foo1 : (x: string, t?: boolean, ...rest: any[]) => void
|
||||
>x : string
|
||||
>t : boolean
|
||||
>rest : any[]
|
||||
|
||||
public bar(t = false) { }
|
||||
>bar : (t?: boolean) => void
|
||||
>t : boolean
|
||||
|
||||
public boo(t = false, ...rest) { }
|
||||
>boo : (t?: boolean, ...rest: any[]) => void
|
||||
>t : boolean
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
class D {
|
||||
>D : D
|
||||
|
||||
constructor(y = "hello") { }
|
||||
>y : string
|
||||
}
|
||||
|
||||
class E {
|
||||
>E : E
|
||||
|
||||
constructor(y = "hello", ...rest) { }
|
||||
>y : string
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//// [emitDefaultParametersMethodES6.ts]
|
||||
class C {
|
||||
constructor(t: boolean, z: string, x: number, y = "hello") { }
|
||||
|
||||
public foo(x: string, t = false) { }
|
||||
public foo1(x: string, t = false, ...rest) { }
|
||||
public bar(t = false) { }
|
||||
public boo(t = false, ...rest) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
constructor(y = "hello") { }
|
||||
}
|
||||
|
||||
class E {
|
||||
constructor(y = "hello", ...rest) { }
|
||||
}
|
||||
|
||||
//// [emitDefaultParametersMethodES6.js]
|
||||
var C = (function () {
|
||||
function C(t, z, x, y = "hello") {
|
||||
}
|
||||
C.prototype.foo = function (x, t = false) {
|
||||
};
|
||||
C.prototype.foo1 = function (x, t = false, ...rest) {
|
||||
};
|
||||
C.prototype.bar = function (t = false) {
|
||||
};
|
||||
C.prototype.boo = function (t = false, ...rest) {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
var D = (function () {
|
||||
function D(y = "hello") {
|
||||
}
|
||||
return D;
|
||||
})();
|
||||
var E = (function () {
|
||||
function E(y = "hello", ...rest) {
|
||||
}
|
||||
return E;
|
||||
})();
|
||||
@@ -0,0 +1,45 @@
|
||||
=== tests/cases/conformance/es6/defaultParameters/emitDefaultParametersMethodES6.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
constructor(t: boolean, z: string, x: number, y = "hello") { }
|
||||
>t : boolean
|
||||
>z : string
|
||||
>x : number
|
||||
>y : string
|
||||
|
||||
public foo(x: string, t = false) { }
|
||||
>foo : (x: string, t?: boolean) => void
|
||||
>x : string
|
||||
>t : boolean
|
||||
|
||||
public foo1(x: string, t = false, ...rest) { }
|
||||
>foo1 : (x: string, t?: boolean, ...rest: any[]) => void
|
||||
>x : string
|
||||
>t : boolean
|
||||
>rest : any[]
|
||||
|
||||
public bar(t = false) { }
|
||||
>bar : (t?: boolean) => void
|
||||
>t : boolean
|
||||
|
||||
public boo(t = false, ...rest) { }
|
||||
>boo : (t?: boolean, ...rest: any[]) => void
|
||||
>t : boolean
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
class D {
|
||||
>D : D
|
||||
|
||||
constructor(y = "hello") { }
|
||||
>y : string
|
||||
}
|
||||
|
||||
class E {
|
||||
>E : E
|
||||
|
||||
constructor(y = "hello", ...rest) { }
|
||||
>y : string
|
||||
>rest : any[]
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//// [emitRestParametersFunction.ts]
|
||||
function bar(...rest) { }
|
||||
function foo(x: number, y: string, ...rest) { }
|
||||
|
||||
//// [emitRestParametersFunction.js]
|
||||
function bar() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
function foo(x, y) {
|
||||
var rest = [];
|
||||
for (var _i = 2; _i < arguments.length; _i++) {
|
||||
rest[_i - 2] = arguments[_i];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersFunction.ts ===
|
||||
function bar(...rest) { }
|
||||
>bar : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
function foo(x: number, y: string, ...rest) { }
|
||||
>foo : (x: number, y: string, ...rest: any[]) => void
|
||||
>x : number
|
||||
>y : string
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [emitRestParametersFunctionES6.ts]
|
||||
function bar(...rest) { }
|
||||
function foo(x: number, y: string, ...rest) { }
|
||||
|
||||
//// [emitRestParametersFunctionES6.js]
|
||||
function bar(...rest) {
|
||||
}
|
||||
function foo(x, y, ...rest) {
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionES6.ts ===
|
||||
function bar(...rest) { }
|
||||
>bar : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
function foo(x: number, y: string, ...rest) { }
|
||||
>foo : (x: number, y: string, ...rest: any[]) => void
|
||||
>x : number
|
||||
>y : string
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
//// [emitRestParametersFunctionExpression.ts]
|
||||
var funcExp = (...rest) => { }
|
||||
var funcExp1 = (X: number, ...rest) => { }
|
||||
var funcExp2 = function (...rest) { }
|
||||
var funcExp3 = (function (...rest) { })()
|
||||
|
||||
|
||||
//// [emitRestParametersFunctionExpression.js]
|
||||
var funcExp = function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var funcExp1 = function (X) {
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var funcExp2 = function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
};
|
||||
var funcExp3 = (function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionExpression.ts ===
|
||||
var funcExp = (...rest) => { }
|
||||
>funcExp : (...rest: any[]) => void
|
||||
>(...rest) => { } : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
var funcExp1 = (X: number, ...rest) => { }
|
||||
>funcExp1 : (X: number, ...rest: any[]) => void
|
||||
>(X: number, ...rest) => { } : (X: number, ...rest: any[]) => void
|
||||
>X : number
|
||||
>rest : any[]
|
||||
|
||||
var funcExp2 = function (...rest) { }
|
||||
>funcExp2 : (...rest: any[]) => void
|
||||
>function (...rest) { } : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
var funcExp3 = (function (...rest) { })()
|
||||
>funcExp3 : void
|
||||
>(function (...rest) { })() : void
|
||||
>(function (...rest) { }) : (...rest: any[]) => void
|
||||
>function (...rest) { } : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [emitRestParametersFunctionExpressionES6.ts]
|
||||
var funcExp = (...rest) => { }
|
||||
var funcExp1 = (X: number, ...rest) => { }
|
||||
var funcExp2 = function (...rest) { }
|
||||
var funcExp3 = (function (...rest) { })()
|
||||
|
||||
//// [emitRestParametersFunctionExpressionES6.js]
|
||||
var funcExp = function (...rest) {
|
||||
};
|
||||
var funcExp1 = function (X, ...rest) {
|
||||
};
|
||||
var funcExp2 = function (...rest) {
|
||||
};
|
||||
var funcExp3 = (function (...rest) {
|
||||
})();
|
||||
@@ -0,0 +1,24 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionExpressionES6.ts ===
|
||||
var funcExp = (...rest) => { }
|
||||
>funcExp : (...rest: any[]) => void
|
||||
>(...rest) => { } : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
var funcExp1 = (X: number, ...rest) => { }
|
||||
>funcExp1 : (X: number, ...rest: any[]) => void
|
||||
>(X: number, ...rest) => { } : (X: number, ...rest: any[]) => void
|
||||
>X : number
|
||||
>rest : any[]
|
||||
|
||||
var funcExp2 = function (...rest) { }
|
||||
>funcExp2 : (...rest: any[]) => void
|
||||
>function (...rest) { } : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
var funcExp3 = (function (...rest) { })()
|
||||
>funcExp3 : void
|
||||
>(function (...rest) { })() : void
|
||||
>(function (...rest) { }) : (...rest: any[]) => void
|
||||
>function (...rest) { } : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
//// [emitRestParametersFunctionProperty.ts]
|
||||
var obj: {
|
||||
func1: (...rest) => void
|
||||
}
|
||||
|
||||
var obj2 = {
|
||||
func(...rest) { }
|
||||
}
|
||||
|
||||
//// [emitRestParametersFunctionProperty.js]
|
||||
var obj;
|
||||
var obj2 = {
|
||||
func: function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionProperty.ts ===
|
||||
var obj: {
|
||||
>obj : { func1: (...rest: any[]) => void; }
|
||||
|
||||
func1: (...rest) => void
|
||||
>func1 : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
var obj2 = {
|
||||
>obj2 : { func(...rest: any[]): void; }
|
||||
>{ func(...rest) { }} : { func(...rest: any[]): void; }
|
||||
|
||||
func(...rest) { }
|
||||
>func : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//// [emitRestParametersFunctionPropertyES6.ts]
|
||||
var obj: {
|
||||
func1: (...rest) => void
|
||||
}
|
||||
|
||||
var obj2 = {
|
||||
func(...rest) { }
|
||||
}
|
||||
|
||||
//// [emitRestParametersFunctionPropertyES6.js]
|
||||
var obj;
|
||||
var obj2 = {
|
||||
func(...rest) {
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersFunctionPropertyES6.ts ===
|
||||
var obj: {
|
||||
>obj : { func1: (...rest: any[]) => void; }
|
||||
|
||||
func1: (...rest) => void
|
||||
>func1 : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
var obj2 = {
|
||||
>obj2 : { func(...rest: any[]): void; }
|
||||
>{ func(...rest) { }} : { func(...rest: any[]): void; }
|
||||
|
||||
func(...rest) { }
|
||||
>func : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//// [emitRestParametersMethod.ts]
|
||||
class C {
|
||||
constructor(name: string, ...rest) { }
|
||||
|
||||
public bar(...rest) { }
|
||||
public foo(x: number, ...rest) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
constructor(...rest) { }
|
||||
|
||||
public bar(...rest) { }
|
||||
public foo(x: number, ...rest) { }
|
||||
}
|
||||
|
||||
//// [emitRestParametersMethod.js]
|
||||
var C = (function () {
|
||||
function C(name) {
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
};
|
||||
C.prototype.foo = function (x) {
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
var D = (function () {
|
||||
function D() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
D.prototype.bar = function () {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
};
|
||||
D.prototype.foo = function (x) {
|
||||
var rest = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
rest[_i - 1] = arguments[_i];
|
||||
}
|
||||
};
|
||||
return D;
|
||||
})();
|
||||
@@ -0,0 +1,33 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersMethod.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
constructor(name: string, ...rest) { }
|
||||
>name : string
|
||||
>rest : any[]
|
||||
|
||||
public bar(...rest) { }
|
||||
>bar : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
public foo(x: number, ...rest) { }
|
||||
>foo : (x: number, ...rest: any[]) => void
|
||||
>x : number
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
class D {
|
||||
>D : D
|
||||
|
||||
constructor(...rest) { }
|
||||
>rest : any[]
|
||||
|
||||
public bar(...rest) { }
|
||||
>bar : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
public foo(x: number, ...rest) { }
|
||||
>foo : (x: number, ...rest: any[]) => void
|
||||
>x : number
|
||||
>rest : any[]
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
//// [emitRestParametersMethodES6.ts]
|
||||
class C {
|
||||
constructor(name: string, ...rest) { }
|
||||
|
||||
public bar(...rest) { }
|
||||
public foo(x: number, ...rest) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
constructor(...rest) { }
|
||||
|
||||
public bar(...rest) { }
|
||||
public foo(x: number, ...rest) { }
|
||||
}
|
||||
|
||||
|
||||
//// [emitRestParametersMethodES6.js]
|
||||
var C = (function () {
|
||||
function C(name, ...rest) {
|
||||
}
|
||||
C.prototype.bar = function (...rest) {
|
||||
};
|
||||
C.prototype.foo = function (x, ...rest) {
|
||||
};
|
||||
return C;
|
||||
})();
|
||||
var D = (function () {
|
||||
function D(...rest) {
|
||||
}
|
||||
D.prototype.bar = function (...rest) {
|
||||
};
|
||||
D.prototype.foo = function (x, ...rest) {
|
||||
};
|
||||
return D;
|
||||
})();
|
||||
@@ -0,0 +1,34 @@
|
||||
=== tests/cases/conformance/es6/restParameters/emitRestParametersMethodES6.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
constructor(name: string, ...rest) { }
|
||||
>name : string
|
||||
>rest : any[]
|
||||
|
||||
public bar(...rest) { }
|
||||
>bar : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
public foo(x: number, ...rest) { }
|
||||
>foo : (x: number, ...rest: any[]) => void
|
||||
>x : number
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
class D {
|
||||
>D : D
|
||||
|
||||
constructor(...rest) { }
|
||||
>rest : any[]
|
||||
|
||||
public bar(...rest) { }
|
||||
>bar : (...rest: any[]) => void
|
||||
>rest : any[]
|
||||
|
||||
public foo(x: number, ...rest) { }
|
||||
>foo : (x: number, ...rest: any[]) => void
|
||||
>x : number
|
||||
>rest : any[]
|
||||
}
|
||||
|
||||
@@ -28,22 +28,43 @@ interface B {
|
||||
(x: 'B2'): string[];
|
||||
}
|
||||
|
||||
var b: B;
|
||||
// non of these lines should error
|
||||
var x1: string[] = b('B2');
|
||||
var x2: number = b('B1');
|
||||
var x3: boolean = b('A2');
|
||||
var x4: string = b('A1');
|
||||
var x5: void = b('A0');
|
||||
interface C1 extends B {
|
||||
(x: 'C1'): number[];
|
||||
}
|
||||
|
||||
interface C2 extends B {
|
||||
(x: 'C2'): boolean[];
|
||||
}
|
||||
|
||||
interface C extends C1, C2 {
|
||||
(x: 'C'): string;
|
||||
}
|
||||
|
||||
var c: C;
|
||||
// none of these lines should error
|
||||
var x1: string[] = c('B2');
|
||||
var x2: number = c('B1');
|
||||
var x3: boolean = c('A2');
|
||||
var x4: string = c('A1');
|
||||
var x5: void = c('A0');
|
||||
var x6: number[] = c('C1');
|
||||
var x7: boolean[] = c('C2');
|
||||
var x8: string = c('C');
|
||||
var x9: void = c('generic');
|
||||
|
||||
|
||||
//// [inheritedOverloadedSpecializedSignatures.js]
|
||||
var b;
|
||||
// Should not error
|
||||
b('foo').charAt(0);
|
||||
var b;
|
||||
// non of these lines should error
|
||||
var x1 = b('B2');
|
||||
var x2 = b('B1');
|
||||
var x3 = b('A2');
|
||||
var x4 = b('A1');
|
||||
var x5 = b('A0');
|
||||
var c;
|
||||
// none of these lines should error
|
||||
var x1 = c('B2');
|
||||
var x2 = c('B1');
|
||||
var x3 = c('A2');
|
||||
var x4 = c('A1');
|
||||
var x5 = c('A0');
|
||||
var x6 = c('C1');
|
||||
var x7 = c('C2');
|
||||
var x8 = c('C');
|
||||
var x9 = c('generic');
|
||||
|
||||
@@ -58,33 +58,78 @@ interface B {
|
||||
>x : 'B2'
|
||||
}
|
||||
|
||||
var b: B;
|
||||
>b : B
|
||||
interface C1 extends B {
|
||||
>C1 : C1
|
||||
>B : B
|
||||
|
||||
// non of these lines should error
|
||||
var x1: string[] = b('B2');
|
||||
(x: 'C1'): number[];
|
||||
>x : 'C1'
|
||||
}
|
||||
|
||||
interface C2 extends B {
|
||||
>C2 : C2
|
||||
>B : B
|
||||
|
||||
(x: 'C2'): boolean[];
|
||||
>x : 'C2'
|
||||
}
|
||||
|
||||
interface C extends C1, C2 {
|
||||
>C : C
|
||||
>C1 : C1
|
||||
>C2 : C2
|
||||
|
||||
(x: 'C'): string;
|
||||
>x : 'C'
|
||||
}
|
||||
|
||||
var c: C;
|
||||
>c : C
|
||||
>C : C
|
||||
|
||||
// none of these lines should error
|
||||
var x1: string[] = c('B2');
|
||||
>x1 : string[]
|
||||
>b('B2') : string[]
|
||||
>b : B
|
||||
>c('B2') : string[]
|
||||
>c : C
|
||||
|
||||
var x2: number = b('B1');
|
||||
var x2: number = c('B1');
|
||||
>x2 : number
|
||||
>b('B1') : number
|
||||
>b : B
|
||||
>c('B1') : number
|
||||
>c : C
|
||||
|
||||
var x3: boolean = b('A2');
|
||||
var x3: boolean = c('A2');
|
||||
>x3 : boolean
|
||||
>b('A2') : boolean
|
||||
>b : B
|
||||
>c('A2') : boolean
|
||||
>c : C
|
||||
|
||||
var x4: string = b('A1');
|
||||
var x4: string = c('A1');
|
||||
>x4 : string
|
||||
>b('A1') : string
|
||||
>b : B
|
||||
>c('A1') : string
|
||||
>c : C
|
||||
|
||||
var x5: void = b('A0');
|
||||
var x5: void = c('A0');
|
||||
>x5 : void
|
||||
>b('A0') : void
|
||||
>b : B
|
||||
>c('A0') : void
|
||||
>c : C
|
||||
|
||||
var x6: number[] = c('C1');
|
||||
>x6 : number[]
|
||||
>c('C1') : number[]
|
||||
>c : C
|
||||
|
||||
var x7: boolean[] = c('C2');
|
||||
>x7 : boolean[]
|
||||
>c('C2') : boolean[]
|
||||
>c : C
|
||||
|
||||
var x8: string = c('C');
|
||||
>x8 : string
|
||||
>c('C') : string
|
||||
>c : C
|
||||
|
||||
var x9: void = c('generic');
|
||||
>x9 : void
|
||||
>c('generic') : void
|
||||
>c : C
|
||||
|
||||
|
||||
@@ -11,14 +11,14 @@ var a: (a: string) => string;
|
||||
|
||||
// bug 786110
|
||||
var r = a || ((a) => a.toLowerCase());
|
||||
>r : (a: any) => any
|
||||
>a || ((a) => a.toLowerCase()) : (a: any) => any
|
||||
>r : (a: string) => string
|
||||
>a || ((a) => a.toLowerCase()) : (a: string) => string
|
||||
>a : (a: string) => string
|
||||
>((a) => a.toLowerCase()) : (a: any) => any
|
||||
>(a) => a.toLowerCase() : (a: any) => any
|
||||
>a : any
|
||||
>a.toLowerCase() : any
|
||||
>a.toLowerCase : any
|
||||
>a : any
|
||||
>toLowerCase : any
|
||||
>((a) => a.toLowerCase()) : (a: string) => string
|
||||
>(a) => a.toLowerCase() : (a: string) => string
|
||||
>a : string
|
||||
>a.toLowerCase() : string
|
||||
>a.toLowerCase : () => string
|
||||
>a : string
|
||||
>toLowerCase : () => string
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(2,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature.
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts(8,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/optionalBindingParameters1.ts (2 errors) ====
|
||||
|
||||
function foo([x,y,z]?: [string, number, boolean]) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature.
|
||||
|
||||
}
|
||||
|
||||
foo(["", 0, false]);
|
||||
|
||||
foo([false, 0, ""]);
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'.
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [optionalBindingParameters1.ts]
|
||||
|
||||
function foo([x,y,z]?: [string, number, boolean]) {
|
||||
|
||||
}
|
||||
|
||||
foo(["", 0, false]);
|
||||
|
||||
foo([false, 0, ""]);
|
||||
|
||||
//// [optionalBindingParameters1.js]
|
||||
function foo(_a) {
|
||||
var x = _a[0], y = _a[1], z = _a[2];
|
||||
}
|
||||
foo(["", 0, false]);
|
||||
foo([false, 0, ""]);
|
||||
@@ -0,0 +1,21 @@
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(2,14): error TS2463: A binding pattern parameter cannot be optional in an implementation signature.
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts(8,5): error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/optionalBindingParameters2.ts (2 errors) ====
|
||||
|
||||
function foo({ x, y, z }?: { x: string; y: number; z: boolean }) {
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2463: A binding pattern parameter cannot be optional in an implementation signature.
|
||||
|
||||
}
|
||||
|
||||
foo({ x: "", y: 0, z: false });
|
||||
|
||||
foo({ x: false, y: 0, z: "" });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'.
|
||||
!!! error TS2345: Types of property 'x' are incompatible.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'string'.
|
||||
@@ -0,0 +1,16 @@
|
||||
//// [optionalBindingParameters2.ts]
|
||||
|
||||
function foo({ x, y, z }?: { x: string; y: number; z: boolean }) {
|
||||
|
||||
}
|
||||
|
||||
foo({ x: "", y: 0, z: false });
|
||||
|
||||
foo({ x: false, y: 0, z: "" });
|
||||
|
||||
//// [optionalBindingParameters2.js]
|
||||
function foo(_a) {
|
||||
var x = _a.x, y = _a.y, z = _a.z;
|
||||
}
|
||||
foo({ x: "", y: 0, z: false });
|
||||
foo({ x: false, y: 0, z: "" });
|
||||
@@ -0,0 +1,15 @@
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts(9,5): error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads1.ts (1 errors) ====
|
||||
|
||||
function foo([x, y, z] ?: [string, number, boolean]);
|
||||
function foo(...rest: any[]) {
|
||||
|
||||
}
|
||||
|
||||
foo(["", 0, false]);
|
||||
|
||||
foo([false, 0, ""]);
|
||||
~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '[boolean, number, string]' is not assignable to parameter of type '[string, number, boolean]'.
|
||||
@@ -0,0 +1,20 @@
|
||||
//// [optionalBindingParametersInOverloads1.ts]
|
||||
|
||||
function foo([x, y, z] ?: [string, number, boolean]);
|
||||
function foo(...rest: any[]) {
|
||||
|
||||
}
|
||||
|
||||
foo(["", 0, false]);
|
||||
|
||||
foo([false, 0, ""]);
|
||||
|
||||
//// [optionalBindingParametersInOverloads1.js]
|
||||
function foo() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
foo(["", 0, false]);
|
||||
foo([false, 0, ""]);
|
||||
@@ -0,0 +1,19 @@
|
||||
tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts(9,5): error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'.
|
||||
Types of property 'x' are incompatible.
|
||||
Type 'boolean' is not assignable to type 'string'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/optionalBindingParametersInOverloads2.ts (1 errors) ====
|
||||
|
||||
function foo({ x, y, z }?: { x: string; y: number; z: boolean });
|
||||
function foo(...rest: any[]) {
|
||||
|
||||
}
|
||||
|
||||
foo({ x: "", y: 0, z: false });
|
||||
|
||||
foo({ x: false, y: 0, z: "" });
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type '{ x: boolean; y: number; z: string; }' is not assignable to parameter of type '{ x: string; y: number; z: boolean; }'.
|
||||
!!! error TS2345: Types of property 'x' are incompatible.
|
||||
!!! error TS2345: Type 'boolean' is not assignable to type 'string'.
|
||||
@@ -0,0 +1,20 @@
|
||||
//// [optionalBindingParametersInOverloads2.ts]
|
||||
|
||||
function foo({ x, y, z }?: { x: string; y: number; z: boolean });
|
||||
function foo(...rest: any[]) {
|
||||
|
||||
}
|
||||
|
||||
foo({ x: "", y: 0, z: false });
|
||||
|
||||
foo({ x: false, y: 0, z: "" });
|
||||
|
||||
//// [optionalBindingParametersInOverloads2.js]
|
||||
function foo() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
}
|
||||
foo({ x: "", y: 0, z: false });
|
||||
foo({ x: false, y: 0, z: "" });
|
||||
@@ -0,0 +1,52 @@
|
||||
//// [parenthesizedContexualTyping1.ts]
|
||||
|
||||
function fun<T>(g: (x: T) => T, x: T): T;
|
||||
function fun<T>(g: (x: T) => T, h: (y: T) => T, x: T): T;
|
||||
function fun<T>(g: (x: T) => T, x: T): T {
|
||||
return g(x);
|
||||
}
|
||||
|
||||
var a = fun(x => x, 10);
|
||||
var b = fun((x => x), 10);
|
||||
var c = fun(((x => x)), 10);
|
||||
var d = fun((((x => x))), 10);
|
||||
|
||||
var e = fun(x => x, x => x, 10);
|
||||
var f = fun((x => x), (x => x), 10);
|
||||
var g = fun(((x => x)), ((x => x)), 10);
|
||||
var h = fun((((x => x))), ((x => x)), 10);
|
||||
|
||||
// Ternaries in parens
|
||||
var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10);
|
||||
var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10);
|
||||
var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10);
|
||||
var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10);
|
||||
|
||||
var lambda1: (x: number) => number = x => x;
|
||||
var lambda2: (x: number) => number = (x => x);
|
||||
|
||||
type ObjType = { x: (p: number) => string; y: (p: string) => number };
|
||||
var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) };
|
||||
var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) });
|
||||
|
||||
//// [parenthesizedContexualTyping1.js]
|
||||
function fun(g, x) {
|
||||
return g(x);
|
||||
}
|
||||
var a = fun(function (x) { return x; }, 10);
|
||||
var b = fun((function (x) { return x; }), 10);
|
||||
var c = fun(((function (x) { return x; })), 10);
|
||||
var d = fun((((function (x) { return x; }))), 10);
|
||||
var e = fun(function (x) { return x; }, function (x) { return x; }, 10);
|
||||
var f = fun((function (x) { return x; }), (function (x) { return x; }), 10);
|
||||
var g = fun(((function (x) { return x; })), ((function (x) { return x; })), 10);
|
||||
var h = fun((((function (x) { return x; }))), ((function (x) { return x; })), 10);
|
||||
// Ternaries in parens
|
||||
var i = fun((Math.random() < 0.5 ? function (x) { return x; } : function (x) { return undefined; }), 10);
|
||||
var j = fun((Math.random() < 0.5 ? (function (x) { return x; }) : (function (x) { return undefined; })), 10);
|
||||
var k = fun((Math.random() < 0.5 ? (function (x) { return x; }) : (function (x) { return undefined; })), function (x) { return x; }, 10);
|
||||
var l = fun(((Math.random() < 0.5 ? ((function (x) { return x; })) : ((function (x) { return undefined; })))), ((function (x) { return x; })), 10);
|
||||
var lambda1 = function (x) { return x; };
|
||||
var lambda2 = (function (x) { return x; });
|
||||
var obj1 = { x: function (x) { return (x, undefined); }, y: function (y) { return (y, undefined); } };
|
||||
var obj2 = ({ x: function (x) { return (x, undefined); }, y: function (y) { return (y, undefined); } });
|
||||
@@ -0,0 +1,289 @@
|
||||
=== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping1.ts ===
|
||||
|
||||
function fun<T>(g: (x: T) => T, x: T): T;
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>T : T
|
||||
>g : (x: T) => T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
function fun<T>(g: (x: T) => T, h: (y: T) => T, x: T): T;
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>T : T
|
||||
>g : (x: T) => T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
>h : (y: T) => T
|
||||
>y : T
|
||||
>T : T
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
function fun<T>(g: (x: T) => T, x: T): T {
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>T : T
|
||||
>g : (x: T) => T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return g(x);
|
||||
>g(x) : T
|
||||
>g : (x: T) => T
|
||||
>x : T
|
||||
}
|
||||
|
||||
var a = fun(x => x, 10);
|
||||
>a : number
|
||||
>fun(x => x, 10) : number
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var b = fun((x => x), 10);
|
||||
>b : number
|
||||
>fun((x => x), 10) : number
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var c = fun(((x => x)), 10);
|
||||
>c : number
|
||||
>fun(((x => x)), 10) : number
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>((x => x)) : (x: number) => number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var d = fun((((x => x))), 10);
|
||||
>d : number
|
||||
>fun((((x => x))), 10) : number
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>(((x => x))) : (x: number) => number
|
||||
>((x => x)) : (x: number) => number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var e = fun(x => x, x => x, 10);
|
||||
>e : number
|
||||
>fun(x => x, x => x, 10) : number
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var f = fun((x => x), (x => x), 10);
|
||||
>f : number
|
||||
>fun((x => x), (x => x), 10) : number
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var g = fun(((x => x)), ((x => x)), 10);
|
||||
>g : number
|
||||
>fun(((x => x)), ((x => x)), 10) : number
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>((x => x)) : (x: number) => number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
>((x => x)) : (x: number) => number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var h = fun((((x => x))), ((x => x)), 10);
|
||||
>h : number
|
||||
>fun((((x => x))), ((x => x)), 10) : number
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>(((x => x))) : (x: number) => number
|
||||
>((x => x)) : (x: number) => number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
>((x => x)) : (x: number) => number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
// Ternaries in parens
|
||||
var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10);
|
||||
>i : any
|
||||
>fun((Math.random() < 0.5 ? x => x : x => undefined), 10) : any
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>(Math.random() < 0.5 ? x => x : x => undefined) : (x: number) => any
|
||||
>Math.random() < 0.5 ? x => x : x => undefined : (x: number) => any
|
||||
>Math.random() < 0.5 : boolean
|
||||
>Math.random() : number
|
||||
>Math.random : () => number
|
||||
>Math : Math
|
||||
>random : () => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
>x => undefined : (x: number) => any
|
||||
>x : number
|
||||
>undefined : undefined
|
||||
|
||||
var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10);
|
||||
>j : any
|
||||
>fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10) : any
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any
|
||||
>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any
|
||||
>Math.random() < 0.5 : boolean
|
||||
>Math.random() : number
|
||||
>Math.random : () => number
|
||||
>Math : Math
|
||||
>random : () => number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
>(x => undefined) : (x: number) => any
|
||||
>x => undefined : (x: number) => any
|
||||
>x : number
|
||||
>undefined : undefined
|
||||
|
||||
var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10);
|
||||
>k : any
|
||||
>fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10) : any
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>(Math.random() < 0.5 ? (x => x) : (x => undefined)) : (x: number) => any
|
||||
>Math.random() < 0.5 ? (x => x) : (x => undefined) : (x: number) => any
|
||||
>Math.random() < 0.5 : boolean
|
||||
>Math.random() : number
|
||||
>Math.random : () => number
|
||||
>Math : Math
|
||||
>random : () => number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
>(x => undefined) : (x: number) => any
|
||||
>x => undefined : (x: number) => any
|
||||
>x : number
|
||||
>undefined : undefined
|
||||
>x => x : (x: any) => any
|
||||
>x : any
|
||||
>x : any
|
||||
|
||||
var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10);
|
||||
>l : any
|
||||
>fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10) : any
|
||||
>fun : { <T>(g: (x: T) => T, x: T): T; <T>(g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))) : (x: number) => any
|
||||
>(Math.random() < 0.5 ? ((x => x)) : ((x => undefined))) : (x: number) => any
|
||||
>Math.random() < 0.5 ? ((x => x)) : ((x => undefined)) : (x: number) => any
|
||||
>Math.random() < 0.5 : boolean
|
||||
>Math.random() : number
|
||||
>Math.random : () => number
|
||||
>Math : Math
|
||||
>random : () => number
|
||||
>((x => x)) : (x: number) => number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
>((x => undefined)) : (x: number) => any
|
||||
>(x => undefined) : (x: number) => any
|
||||
>x => undefined : (x: number) => any
|
||||
>x : number
|
||||
>undefined : undefined
|
||||
>((x => x)) : (x: number) => number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var lambda1: (x: number) => number = x => x;
|
||||
>lambda1 : (x: number) => number
|
||||
>x : number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var lambda2: (x: number) => number = (x => x);
|
||||
>lambda2 : (x: number) => number
|
||||
>x : number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
type ObjType = { x: (p: number) => string; y: (p: string) => number };
|
||||
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
|
||||
>x : (p: number) => string
|
||||
>p : number
|
||||
>y : (p: string) => number
|
||||
>p : string
|
||||
|
||||
var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) };
|
||||
>obj1 : { x: (p: number) => string; y: (p: string) => number; }
|
||||
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
|
||||
>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; }
|
||||
>x : (x: number) => any
|
||||
>x => (x, undefined) : (x: number) => any
|
||||
>x : number
|
||||
>(x, undefined) : undefined
|
||||
>x, undefined : undefined
|
||||
>x : number
|
||||
>undefined : undefined
|
||||
>y : (y: string) => any
|
||||
>y => (y, undefined) : (y: string) => any
|
||||
>y : string
|
||||
>(y, undefined) : undefined
|
||||
>y, undefined : undefined
|
||||
>y : string
|
||||
>undefined : undefined
|
||||
|
||||
var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) });
|
||||
>obj2 : { x: (p: number) => string; y: (p: string) => number; }
|
||||
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
|
||||
>({ x: x => (x, undefined), y: y => (y, undefined) }) : { x: (x: number) => any; y: (y: string) => any; }
|
||||
>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; }
|
||||
>x : (x: number) => any
|
||||
>x => (x, undefined) : (x: number) => any
|
||||
>x : number
|
||||
>(x, undefined) : undefined
|
||||
>x, undefined : undefined
|
||||
>x : number
|
||||
>undefined : undefined
|
||||
>y : (y: string) => any
|
||||
>y => (y, undefined) : (y: string) => any
|
||||
>y : string
|
||||
>(y, undefined) : undefined
|
||||
>y, undefined : undefined
|
||||
>y : string
|
||||
>undefined : undefined
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
//// [parenthesizedContexualTyping2.ts]
|
||||
// These tests ensure that in cases where it may *appear* that a value has a type,
|
||||
// they actually are properly being contextually typed. The way we test this is
|
||||
// that we invoke contextually typed arguments with type arguments.
|
||||
// Since 'any' cannot be invoked with type arguments, we should get errors
|
||||
// back if contextual typing is not taking effect.
|
||||
|
||||
type FuncType = (x: <T>(p: T) => T) => typeof x;
|
||||
|
||||
function fun<T>(f: FuncType, x: T): T;
|
||||
function fun<T>(f: FuncType, g: FuncType, x: T): T;
|
||||
function fun<T>(...rest: any[]): T {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var a = fun(x => { x<number>(undefined); return x; }, 10);
|
||||
var b = fun((x => { x<number>(undefined); return x; }), 10);
|
||||
var c = fun(((x => { x<number>(undefined); return x; })), 10);
|
||||
var d = fun((((x => { x<number>(undefined); return x; }))), 10);
|
||||
|
||||
var e = fun(x => { x<number>(undefined); return x; }, x => { x<number>(undefined); return x; }, 10);
|
||||
var f = fun((x => { x<number>(undefined); return x; }),(x => { x<number>(undefined); return x; }), 10);
|
||||
var g = fun(((x => { x<number>(undefined); return x; })),((x => { x<number>(undefined); return x; })), 10);
|
||||
var h = fun((((x => { x<number>(undefined); return x; }))),((x => { x<number>(undefined); return x; })), 10);
|
||||
|
||||
// Ternaries in parens
|
||||
var i = fun((Math.random() < 0.5 ? x => { x<number>(undefined); return x; } : x => undefined), 10);
|
||||
var j = fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), 10);
|
||||
var k = fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), x => { x<number>(undefined); return x; }, 10);
|
||||
var l = fun(((Math.random() < 0.5 ? ((x => { x<number>(undefined); return x; })) : ((x => undefined)))),((x => { x<number>(undefined); return x; })), 10);
|
||||
|
||||
var lambda1: FuncType = x => { x<number>(undefined); return x; };
|
||||
var lambda2: FuncType = (x => { x<number>(undefined); return x; });
|
||||
|
||||
type ObjType = { x: (p: number) => string; y: (p: string) => number };
|
||||
var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) };
|
||||
var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) });
|
||||
|
||||
//// [parenthesizedContexualTyping2.js]
|
||||
// These tests ensure that in cases where it may *appear* that a value has a type,
|
||||
// they actually are properly being contextually typed. The way we test this is
|
||||
// that we invoke contextually typed arguments with type arguments.
|
||||
// Since 'any' cannot be invoked with type arguments, we should get errors
|
||||
// back if contextual typing is not taking effect.
|
||||
function fun() {
|
||||
var rest = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
rest[_i - 0] = arguments[_i];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
var a = fun(function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
}, 10);
|
||||
var b = fun((function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
}), 10);
|
||||
var c = fun(((function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
})), 10);
|
||||
var d = fun((((function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
}))), 10);
|
||||
var e = fun(function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
}, function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
}, 10);
|
||||
var f = fun((function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
}), (function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
}), 10);
|
||||
var g = fun(((function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
})), ((function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
})), 10);
|
||||
var h = fun((((function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
}))), ((function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
})), 10);
|
||||
// Ternaries in parens
|
||||
var i = fun((Math.random() < 0.5 ? function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
} : function (x) { return undefined; }), 10);
|
||||
var j = fun((Math.random() < 0.5 ? (function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
}) : (function (x) { return undefined; })), 10);
|
||||
var k = fun((Math.random() < 0.5 ? (function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
}) : (function (x) { return undefined; })), function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
}, 10);
|
||||
var l = fun(((Math.random() < 0.5 ? ((function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
})) : ((function (x) { return undefined; })))), ((function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
})), 10);
|
||||
var lambda1 = function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
};
|
||||
var lambda2 = (function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
});
|
||||
var obj1 = { x: function (x) { return (x, undefined); }, y: function (y) { return (y, undefined); } };
|
||||
var obj2 = ({ x: function (x) { return (x, undefined); }, y: function (y) { return (y, undefined); } });
|
||||
@@ -0,0 +1,350 @@
|
||||
=== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping2.ts ===
|
||||
// These tests ensure that in cases where it may *appear* that a value has a type,
|
||||
// they actually are properly being contextually typed. The way we test this is
|
||||
// that we invoke contextually typed arguments with type arguments.
|
||||
// Since 'any' cannot be invoked with type arguments, we should get errors
|
||||
// back if contextual typing is not taking effect.
|
||||
|
||||
type FuncType = (x: <T>(p: T) => T) => typeof x;
|
||||
>FuncType : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>T : T
|
||||
>p : T
|
||||
>T : T
|
||||
>T : T
|
||||
>x : <T>(p: T) => T
|
||||
|
||||
function fun<T>(f: FuncType, x: T): T;
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>T : T
|
||||
>f : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>FuncType : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
function fun<T>(f: FuncType, g: FuncType, x: T): T;
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>T : T
|
||||
>f : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>FuncType : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>g : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>FuncType : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
function fun<T>(...rest: any[]): T {
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>T : T
|
||||
>rest : any[]
|
||||
>T : T
|
||||
|
||||
return undefined;
|
||||
>undefined : undefined
|
||||
}
|
||||
|
||||
var a = fun(x => { x<number>(undefined); return x; }, 10);
|
||||
>a : number
|
||||
>fun(x => { x<number>(undefined); return x; }, 10) : number
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
|
||||
var b = fun((x => { x<number>(undefined); return x; }), 10);
|
||||
>b : number
|
||||
>fun((x => { x<number>(undefined); return x; }), 10) : number
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
|
||||
var c = fun(((x => { x<number>(undefined); return x; })), 10);
|
||||
>c : number
|
||||
>fun(((x => { x<number>(undefined); return x; })), 10) : number
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>((x => { x<number>(undefined); return x; })) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
|
||||
var d = fun((((x => { x<number>(undefined); return x; }))), 10);
|
||||
>d : number
|
||||
>fun((((x => { x<number>(undefined); return x; }))), 10) : number
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>(((x => { x<number>(undefined); return x; }))) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>((x => { x<number>(undefined); return x; })) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
|
||||
var e = fun(x => { x<number>(undefined); return x; }, x => { x<number>(undefined); return x; }, 10);
|
||||
>e : number
|
||||
>fun(x => { x<number>(undefined); return x; }, x => { x<number>(undefined); return x; }, 10) : number
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
|
||||
var f = fun((x => { x<number>(undefined); return x; }),(x => { x<number>(undefined); return x; }), 10);
|
||||
>f : number
|
||||
>fun((x => { x<number>(undefined); return x; }),(x => { x<number>(undefined); return x; }), 10) : number
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
|
||||
var g = fun(((x => { x<number>(undefined); return x; })),((x => { x<number>(undefined); return x; })), 10);
|
||||
>g : number
|
||||
>fun(((x => { x<number>(undefined); return x; })),((x => { x<number>(undefined); return x; })), 10) : number
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>((x => { x<number>(undefined); return x; })) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
>((x => { x<number>(undefined); return x; })) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
|
||||
var h = fun((((x => { x<number>(undefined); return x; }))),((x => { x<number>(undefined); return x; })), 10);
|
||||
>h : number
|
||||
>fun((((x => { x<number>(undefined); return x; }))),((x => { x<number>(undefined); return x; })), 10) : number
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>(((x => { x<number>(undefined); return x; }))) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>((x => { x<number>(undefined); return x; })) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
>((x => { x<number>(undefined); return x; })) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
|
||||
// Ternaries in parens
|
||||
var i = fun((Math.random() < 0.5 ? x => { x<number>(undefined); return x; } : x => undefined), 10);
|
||||
>i : number
|
||||
>fun((Math.random() < 0.5 ? x => { x<number>(undefined); return x; } : x => undefined), 10) : number
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>(Math.random() < 0.5 ? x => { x<number>(undefined); return x; } : x => undefined) : (x: <T>(p: T) => T) => any
|
||||
>Math.random() < 0.5 ? x => { x<number>(undefined); return x; } : x => undefined : (x: <T>(p: T) => T) => any
|
||||
>Math.random() < 0.5 : boolean
|
||||
>Math.random() : number
|
||||
>Math.random : () => number
|
||||
>Math : Math
|
||||
>random : () => number
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
>x => undefined : (x: <T>(p: T) => T) => any
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
|
||||
var j = fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), 10);
|
||||
>j : number
|
||||
>fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), 10) : number
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>(Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)) : (x: <T>(p: T) => T) => any
|
||||
>Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined) : (x: <T>(p: T) => T) => any
|
||||
>Math.random() < 0.5 : boolean
|
||||
>Math.random() : number
|
||||
>Math.random : () => number
|
||||
>Math : Math
|
||||
>random : () => number
|
||||
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
>(x => undefined) : (x: <T>(p: T) => T) => any
|
||||
>x => undefined : (x: <T>(p: T) => T) => any
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
|
||||
var k = fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), x => { x<number>(undefined); return x; }, 10);
|
||||
>k : number
|
||||
>fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), x => { x<number>(undefined); return x; }, 10) : number
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>(Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)) : (x: <T>(p: T) => T) => any
|
||||
>Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined) : (x: <T>(p: T) => T) => any
|
||||
>Math.random() < 0.5 : boolean
|
||||
>Math.random() : number
|
||||
>Math.random : () => number
|
||||
>Math : Math
|
||||
>random : () => number
|
||||
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
>(x => undefined) : (x: <T>(p: T) => T) => any
|
||||
>x => undefined : (x: <T>(p: T) => T) => any
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
|
||||
var l = fun(((Math.random() < 0.5 ? ((x => { x<number>(undefined); return x; })) : ((x => undefined)))),((x => { x<number>(undefined); return x; })), 10);
|
||||
>l : number
|
||||
>fun(((Math.random() < 0.5 ? ((x => { x<number>(undefined); return x; })) : ((x => undefined)))),((x => { x<number>(undefined); return x; })), 10) : number
|
||||
>fun : { <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(f: (x: <T>(p: T) => T) => <T>(p: T) => T, g: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>((Math.random() < 0.5 ? ((x => { x<number>(undefined); return x; })) : ((x => undefined)))) : (x: <T>(p: T) => T) => any
|
||||
>(Math.random() < 0.5 ? ((x => { x<number>(undefined); return x; })) : ((x => undefined))) : (x: <T>(p: T) => T) => any
|
||||
>Math.random() < 0.5 ? ((x => { x<number>(undefined); return x; })) : ((x => undefined)) : (x: <T>(p: T) => T) => any
|
||||
>Math.random() < 0.5 : boolean
|
||||
>Math.random() : number
|
||||
>Math.random : () => number
|
||||
>Math : Math
|
||||
>random : () => number
|
||||
>((x => { x<number>(undefined); return x; })) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
>((x => undefined)) : (x: <T>(p: T) => T) => any
|
||||
>(x => undefined) : (x: <T>(p: T) => T) => any
|
||||
>x => undefined : (x: <T>(p: T) => T) => any
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>((x => { x<number>(undefined); return x; })) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
|
||||
var lambda1: FuncType = x => { x<number>(undefined); return x; };
|
||||
>lambda1 : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>FuncType : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
|
||||
var lambda2: FuncType = (x => { x<number>(undefined); return x; });
|
||||
>lambda2 : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>FuncType : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>(x => { x<number>(undefined); return x; }) : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
|
||||
type ObjType = { x: (p: number) => string; y: (p: string) => number };
|
||||
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
|
||||
>x : (p: number) => string
|
||||
>p : number
|
||||
>y : (p: string) => number
|
||||
>p : string
|
||||
|
||||
var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) };
|
||||
>obj1 : { x: (p: number) => string; y: (p: string) => number; }
|
||||
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
|
||||
>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; }
|
||||
>x : (x: number) => any
|
||||
>x => (x, undefined) : (x: number) => any
|
||||
>x : number
|
||||
>(x, undefined) : undefined
|
||||
>x, undefined : undefined
|
||||
>x : number
|
||||
>undefined : undefined
|
||||
>y : (y: string) => any
|
||||
>y => (y, undefined) : (y: string) => any
|
||||
>y : string
|
||||
>(y, undefined) : undefined
|
||||
>y, undefined : undefined
|
||||
>y : string
|
||||
>undefined : undefined
|
||||
|
||||
var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) });
|
||||
>obj2 : { x: (p: number) => string; y: (p: string) => number; }
|
||||
>ObjType : { x: (p: number) => string; y: (p: string) => number; }
|
||||
>({ x: x => (x, undefined), y: y => (y, undefined) }) : { x: (x: number) => any; y: (y: string) => any; }
|
||||
>{ x: x => (x, undefined), y: y => (y, undefined) } : { x: (x: number) => any; y: (y: string) => any; }
|
||||
>x : (x: number) => any
|
||||
>x => (x, undefined) : (x: number) => any
|
||||
>x : number
|
||||
>(x, undefined) : undefined
|
||||
>x, undefined : undefined
|
||||
>x : number
|
||||
>undefined : undefined
|
||||
>y : (y: string) => any
|
||||
>y => (y, undefined) : (y: string) => any
|
||||
>y : string
|
||||
>(y, undefined) : undefined
|
||||
>y, undefined : undefined
|
||||
>y : string
|
||||
>undefined : undefined
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//// [parenthesizedContexualTyping3.ts]
|
||||
|
||||
// Contextual typing for parenthesized substitution expressions in tagged templates.
|
||||
|
||||
/**
|
||||
* tempFun - Can't have fun for too long.
|
||||
*/
|
||||
function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T;
|
||||
function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T;
|
||||
function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T {
|
||||
return g(x);
|
||||
}
|
||||
|
||||
var a = tempFun `${ x => x } ${ 10 }`
|
||||
var b = tempFun `${ (x => x) } ${ 10 }`
|
||||
var c = tempFun `${ ((x => x)) } ${ 10 }`
|
||||
var d = tempFun `${ x => x } ${ x => x } ${ 10 }`
|
||||
var e = tempFun `${ x => x } ${ (x => x) } ${ 10 }`
|
||||
var f = tempFun `${ x => x } ${ ((x => x)) } ${ 10 }`
|
||||
var g = tempFun `${ (x => x) } ${ (((x => x))) } ${ 10 }`
|
||||
var h = tempFun `${ (x => x) } ${ (((x => x))) } ${ undefined }`
|
||||
|
||||
//// [parenthesizedContexualTyping3.js]
|
||||
// Contextual typing for parenthesized substitution expressions in tagged templates.
|
||||
function tempFun(tempStrs, g, x) {
|
||||
return g(x);
|
||||
}
|
||||
var a = tempFun `${function (x) { return x; }} ${10}`;
|
||||
var b = tempFun `${(function (x) { return x; })} ${10}`;
|
||||
var c = tempFun `${((function (x) { return x; }))} ${10}`;
|
||||
var d = tempFun `${function (x) { return x; }} ${function (x) { return x; }} ${10}`;
|
||||
var e = tempFun `${function (x) { return x; }} ${(function (x) { return x; })} ${10}`;
|
||||
var f = tempFun `${function (x) { return x; }} ${((function (x) { return x; }))} ${10}`;
|
||||
var g = tempFun `${(function (x) { return x; })} ${(((function (x) { return x; })))} ${10}`;
|
||||
var h = tempFun `${(function (x) { return x; })} ${(((function (x) { return x; })))} ${undefined}`;
|
||||
@@ -0,0 +1,142 @@
|
||||
=== tests/cases/conformance/expressions/contextualTyping/parenthesizedContexualTyping3.ts ===
|
||||
|
||||
// Contextual typing for parenthesized substitution expressions in tagged templates.
|
||||
|
||||
/**
|
||||
* tempFun - Can't have fun for too long.
|
||||
*/
|
||||
function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T;
|
||||
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>T : T
|
||||
>tempStrs : TemplateStringsArray
|
||||
>TemplateStringsArray : TemplateStringsArray
|
||||
>g : (x: T) => T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T;
|
||||
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>T : T
|
||||
>tempStrs : TemplateStringsArray
|
||||
>TemplateStringsArray : TemplateStringsArray
|
||||
>g : (x: T) => T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
>h : (y: T) => T
|
||||
>y : T
|
||||
>T : T
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
function tempFun<T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T {
|
||||
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>T : T
|
||||
>tempStrs : TemplateStringsArray
|
||||
>TemplateStringsArray : TemplateStringsArray
|
||||
>g : (x: T) => T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
>x : T
|
||||
>T : T
|
||||
>T : T
|
||||
|
||||
return g(x);
|
||||
>g(x) : T
|
||||
>g : (x: T) => T
|
||||
>x : T
|
||||
}
|
||||
|
||||
var a = tempFun `${ x => x } ${ 10 }`
|
||||
>a : number
|
||||
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var b = tempFun `${ (x => x) } ${ 10 }`
|
||||
>b : number
|
||||
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var c = tempFun `${ ((x => x)) } ${ 10 }`
|
||||
>c : number
|
||||
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>((x => x)) : (x: number) => number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var d = tempFun `${ x => x } ${ x => x } ${ 10 }`
|
||||
>d : number
|
||||
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var e = tempFun `${ x => x } ${ (x => x) } ${ 10 }`
|
||||
>e : number
|
||||
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var f = tempFun `${ x => x } ${ ((x => x)) } ${ 10 }`
|
||||
>f : number
|
||||
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
>((x => x)) : (x: number) => number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var g = tempFun `${ (x => x) } ${ (((x => x))) } ${ 10 }`
|
||||
>g : number
|
||||
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
>(((x => x))) : (x: number) => number
|
||||
>((x => x)) : (x: number) => number
|
||||
>(x => x) : (x: number) => number
|
||||
>x => x : (x: number) => number
|
||||
>x : number
|
||||
>x : number
|
||||
|
||||
var h = tempFun `${ (x => x) } ${ (((x => x))) } ${ undefined }`
|
||||
>h : any
|
||||
>tempFun : { <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, x: T): T; <T>(tempStrs: TemplateStringsArray, g: (x: T) => T, h: (y: T) => T, x: T): T; }
|
||||
>(x => x) : (x: any) => any
|
||||
>x => x : (x: any) => any
|
||||
>x : any
|
||||
>x : any
|
||||
>(((x => x))) : (x: any) => any
|
||||
>((x => x)) : (x: any) => any
|
||||
>(x => x) : (x: any) => any
|
||||
>x => x : (x: any) => any
|
||||
>x : any
|
||||
>x : any
|
||||
>undefined : undefined
|
||||
|
||||
@@ -12,6 +12,7 @@ function tempTag1<T>(...rest: any[]): T {
|
||||
// Otherwise, the arrow functions' parameters will be typed as 'any',
|
||||
// and it is an error to invoke an any-typed value with type arguments,
|
||||
// so this test will error.
|
||||
tempTag1 `${ x => { x<number>(undefined); return x; } }${ 10 }`;
|
||||
tempTag1 `${ x => { x<number>(undefined); return x; } }${ y => { y<number>(undefined); return y; } }${ 10 }`;
|
||||
tempTag1 `${ x => { x<number>(undefined); return x; } }${ (y: <T>(p: T) => T) => { y<number>(undefined); return y } }${ undefined }`;
|
||||
tempTag1 `${ (x: <T>(p: T) => T) => { x<number>(undefined); return x; } }${ y => { y<number>(undefined); return y; } }${ undefined }`;
|
||||
@@ -25,6 +26,10 @@ function tempTag1(...rest) {
|
||||
// Otherwise, the arrow functions' parameters will be typed as 'any',
|
||||
// and it is an error to invoke an any-typed value with type arguments,
|
||||
// so this test will error.
|
||||
tempTag1 `${function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
}}${10}`;
|
||||
tempTag1 `${function (x) {
|
||||
x(undefined);
|
||||
return x;
|
||||
|
||||
@@ -47,6 +47,15 @@ function tempTag1<T>(...rest: any[]): T {
|
||||
// Otherwise, the arrow functions' parameters will be typed as 'any',
|
||||
// and it is an error to invoke an any-typed value with type arguments,
|
||||
// so this test will error.
|
||||
tempTag1 `${ x => { x<number>(undefined); return x; } }${ 10 }`;
|
||||
>tempTag1 : { <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, h: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
>x : <T>(p: T) => T
|
||||
>x<number>(undefined) : number
|
||||
>x : <T>(p: T) => T
|
||||
>undefined : undefined
|
||||
>x : <T>(p: T) => T
|
||||
|
||||
tempTag1 `${ x => { x<number>(undefined); return x; } }${ y => { y<number>(undefined); return y; } }${ 10 }`;
|
||||
>tempTag1 : { <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; <T>(templateStrs: TemplateStringsArray, f: (x: <T>(p: T) => T) => <T>(p: T) => T, h: (x: <T>(p: T) => T) => <T>(p: T) => T, x: T): T; }
|
||||
>x => { x<number>(undefined); return x; } : (x: <T>(p: T) => T) => <T>(p: T) => T
|
||||
|
||||
@@ -124,9 +124,9 @@ var r2: D1 | C2 = c2Ord1 instanceof C1 && c2Ord1; // C2 | D1
|
||||
>r2 : C2 | D1
|
||||
>D1 : D1
|
||||
>C2 : C2
|
||||
>c2Ord1 instanceof C1 && c2Ord1 : C2 | D1
|
||||
>c2Ord1 instanceof C1 && c2Ord1 : D1
|
||||
>c2Ord1 instanceof C1 : boolean
|
||||
>c2Ord1 : C2 | D1
|
||||
>C1 : typeof C1
|
||||
>c2Ord1 : C2 | D1
|
||||
>c2Ord1 : D1
|
||||
|
||||
|
||||
@@ -154,9 +154,9 @@ var r2: D1 | C2 = c2Ord1 instanceof c1 && c2Ord1; // C2 | D1
|
||||
>r2 : C2 | D1
|
||||
>D1 : D1
|
||||
>C2 : C2
|
||||
>c2Ord1 instanceof c1 && c2Ord1 : C2 | D1
|
||||
>c2Ord1 instanceof c1 && c2Ord1 : D1
|
||||
>c2Ord1 instanceof c1 : boolean
|
||||
>c2Ord1 : C2 | D1
|
||||
>c1 : C1
|
||||
>c2Ord1 : C2 | D1
|
||||
>c2Ord1 : D1
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
//// [typeGuardsWithInstanceOf.ts]
|
||||
interface I { global: string; }
|
||||
var result: I;
|
||||
var result2: I;
|
||||
|
||||
if (!(result instanceof RegExp)) {
|
||||
result = result2;
|
||||
} else if (!result.global) {
|
||||
}
|
||||
|
||||
//// [typeGuardsWithInstanceOf.js]
|
||||
var result;
|
||||
var result2;
|
||||
if (!(result instanceof RegExp)) {
|
||||
result = result2;
|
||||
}
|
||||
else if (!result.global) {
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
=== tests/cases/conformance/expressions/typeGuards/typeGuardsWithInstanceOf.ts ===
|
||||
interface I { global: string; }
|
||||
>I : I
|
||||
>global : string
|
||||
|
||||
var result: I;
|
||||
>result : I
|
||||
>I : I
|
||||
|
||||
var result2: I;
|
||||
>result2 : I
|
||||
>I : I
|
||||
|
||||
if (!(result instanceof RegExp)) {
|
||||
>!(result instanceof RegExp) : boolean
|
||||
>(result instanceof RegExp) : boolean
|
||||
>result instanceof RegExp : boolean
|
||||
>result : I
|
||||
>RegExp : RegExpConstructor
|
||||
|
||||
result = result2;
|
||||
>result = result2 : I
|
||||
>result : I
|
||||
>result2 : I
|
||||
|
||||
} else if (!result.global) {
|
||||
>!result.global : boolean
|
||||
>result.global : string
|
||||
>result : I
|
||||
>global : string
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
const enum E { A }
|
||||
var x = E["B"]
|
||||
@@ -27,10 +27,26 @@ interface B {
|
||||
(x: 'B2'): string[];
|
||||
}
|
||||
|
||||
var b: B;
|
||||
// non of these lines should error
|
||||
var x1: string[] = b('B2');
|
||||
var x2: number = b('B1');
|
||||
var x3: boolean = b('A2');
|
||||
var x4: string = b('A1');
|
||||
var x5: void = b('A0');
|
||||
interface C1 extends B {
|
||||
(x: 'C1'): number[];
|
||||
}
|
||||
|
||||
interface C2 extends B {
|
||||
(x: 'C2'): boolean[];
|
||||
}
|
||||
|
||||
interface C extends C1, C2 {
|
||||
(x: 'C'): string;
|
||||
}
|
||||
|
||||
var c: C;
|
||||
// none of these lines should error
|
||||
var x1: string[] = c('B2');
|
||||
var x2: number = c('B1');
|
||||
var x3: boolean = c('A2');
|
||||
var x4: string = c('A1');
|
||||
var x5: void = c('A0');
|
||||
var x6: number[] = c('C1');
|
||||
var x7: boolean[] = c('C2');
|
||||
var x8: string = c('C');
|
||||
var x9: void = c('generic');
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// @target: es5
|
||||
function foo(x: string, y = 10) { }
|
||||
function baz(x: string, y = 5, ...rest) { }
|
||||
function bar(y = 10) { }
|
||||
function bar1(y = 10, ...rest) { }
|
||||
@@ -0,0 +1,5 @@
|
||||
// @target:es6
|
||||
function foo(x: string, y = 10) { }
|
||||
function baz(x: string, y = 5, ...rest) { }
|
||||
function bar(y = 10) { }
|
||||
function bar1(y = 10, ...rest) { }
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// @target: es5
|
||||
var lambda1 = (y = "hello") => { }
|
||||
var lambda2 = (x: number, y = "hello") => { }
|
||||
var lambda3 = (x: number, y = "hello", ...rest) => { }
|
||||
var lambda4 = (y = "hello", ...rest) => { }
|
||||
|
||||
var x = function (str = "hello", ...rest) { }
|
||||
var y = (function (num = 10, boo = false, ...rest) { })()
|
||||
var z = (function (num: number, boo = false, ...rest) { })(10)
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
// @target:es6
|
||||
var lambda1 = (y = "hello") => { }
|
||||
var lambda2 = (x: number, y = "hello") => { }
|
||||
var lambda3 = (x: number, y = "hello", ...rest) => { }
|
||||
var lambda4 = (y = "hello", ...rest) => { }
|
||||
|
||||
var x = function (str = "hello", ...rest) { }
|
||||
var y = (function (num = 10, boo = false, ...rest) { })()
|
||||
var z = (function (num: number, boo = false, ...rest) { })(10)
|
||||
@@ -0,0 +1,7 @@
|
||||
// @target: es5
|
||||
var obj2 = {
|
||||
func1(y = 10, ...rest) { },
|
||||
func2(x = "hello") { },
|
||||
func3(x: string, z: number, y = "hello") { },
|
||||
func4(x: string, z: number, y = "hello", ...rest) { },
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// @target:es6
|
||||
var obj2 = {
|
||||
func1(y = 10, ...rest) { },
|
||||
func2(x = "hello") { },
|
||||
func3(x: string, z: number, y = "hello") { },
|
||||
func4(x: string, z: number, y = "hello", ...rest) { },
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// @target: es5
|
||||
class C {
|
||||
constructor(t: boolean, z: string, x: number, y = "hello") { }
|
||||
|
||||
public foo(x: string, t = false) { }
|
||||
public foo1(x: string, t = false, ...rest) { }
|
||||
public bar(t = false) { }
|
||||
public boo(t = false, ...rest) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
constructor(y = "hello") { }
|
||||
}
|
||||
|
||||
class E {
|
||||
constructor(y = "hello", ...rest) { }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// @target:es6
|
||||
class C {
|
||||
constructor(t: boolean, z: string, x: number, y = "hello") { }
|
||||
|
||||
public foo(x: string, t = false) { }
|
||||
public foo1(x: string, t = false, ...rest) { }
|
||||
public bar(t = false) { }
|
||||
public boo(t = false, ...rest) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
constructor(y = "hello") { }
|
||||
}
|
||||
|
||||
class E {
|
||||
constructor(y = "hello", ...rest) { }
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
class C1 {
|
||||
constructor(public [x, y, z]: string[]) {
|
||||
}
|
||||
}
|
||||
|
||||
type TupleType1 = [string, number, boolean];
|
||||
|
||||
class C2 {
|
||||
constructor(public [x, y, z]: TupleType1) {
|
||||
}
|
||||
}
|
||||
|
||||
type ObjType1 = { x: number; y: string; z: boolean }
|
||||
|
||||
class C3 {
|
||||
constructor(public { x, y, z }: ObjType1) {
|
||||
}
|
||||
}
|
||||
|
||||
var c1 = new C1([]);
|
||||
c1 = new C1(["larry", "{curly}", "moe"]);
|
||||
var useC1Properties = c1.x === c1.y && c1.y === c1.z;
|
||||
|
||||
var c2 = new C2(["10", 10, !!10]);
|
||||
var [c2_x, c2_y, c2_z] = [c2.x, c2.y, c2.z];
|
||||
|
||||
var c3 = new C3({x: 0, y: "", z: false});
|
||||
c3 = new C3({x: 0, "y": "y", z: true});
|
||||
var [c3_x, c3_y, c3_z] = [c3.x, c3.y, c3.z];
|
||||
@@ -0,0 +1,28 @@
|
||||
class C1 {
|
||||
constructor(private k: number, private [a, b, c]: [number, string, boolean]) {
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
}
|
||||
}
|
||||
|
||||
var x = new C1(undefined, [0, undefined, ""]);
|
||||
var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()];
|
||||
|
||||
var y = new C1(10, [0, "", true]);
|
||||
var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()];
|
||||
|
||||
var z = new C1(10, [undefined, "", null]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
@@ -0,0 +1,31 @@
|
||||
class C1<T, U, V> {
|
||||
constructor(private k: T, private [a, b, c]: [T,U,V]) {
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
}
|
||||
}
|
||||
|
||||
var x = new C1(undefined, [0, true, ""]);
|
||||
var [x_a, x_b, x_c] = [x.getA(), x.getB(), x.getC()];
|
||||
|
||||
var y = new C1(10, [0, true, true]);
|
||||
var [y_a, y_b, y_c] = [y.getA(), y.getB(), y.getC()];
|
||||
|
||||
var z = new C1(10, [undefined, "", ""]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
|
||||
var w = new C1(10, [undefined, undefined, undefined]);
|
||||
var [z_a, z_b, z_c] = [z.getA(), z.getB(), z.getC()];
|
||||
@@ -0,0 +1,27 @@
|
||||
// @target: es6
|
||||
|
||||
class C1<T, U, V> {
|
||||
constructor(private k: T, protected [a, b, c]: [T,U,V]) {
|
||||
if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) {
|
||||
this.a = a || k;
|
||||
}
|
||||
}
|
||||
|
||||
public getA() {
|
||||
return this.a
|
||||
}
|
||||
|
||||
public getB() {
|
||||
return this.b
|
||||
}
|
||||
|
||||
public getC() {
|
||||
return this.c;
|
||||
}
|
||||
}
|
||||
|
||||
class C2 extends C1<number, string, boolean> {
|
||||
public doSomethingWithSuperProperties() {
|
||||
return `${this.a} ${this.b} ${this.c}`;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
type ObjType1 = { x: number; y: string; z: boolean }
|
||||
type TupleType1 = [ObjType1, number, string]
|
||||
|
||||
class C1 {
|
||||
constructor(public [{ x1, x2, x3 }, y, z]: TupleType1) {
|
||||
var foo: any = x1 || x2 || x3 || y || z;
|
||||
var bar: any = this.x1 || this.x2 || this.x3 || this.y || this.z;
|
||||
}
|
||||
}
|
||||
|
||||
var a = new C1([{ x1: 10, x2: "", x3: true }, "", false]);
|
||||
var [a_x1, a_x2, a_x3, a_y, a_z] = [a.x1, a.x2, a.x3, a.y, a.z];
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
function foo([x,y,z]?: [string, number, boolean]) {
|
||||
|
||||
}
|
||||
|
||||
foo(["", 0, false]);
|
||||
|
||||
foo([false, 0, ""]);
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
function foo({ x, y, z }?: { x: string; y: number; z: boolean }) {
|
||||
|
||||
}
|
||||
|
||||
foo({ x: "", y: 0, z: false });
|
||||
|
||||
foo({ x: false, y: 0, z: "" });
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
function foo([x, y, z] ?: [string, number, boolean]);
|
||||
function foo(...rest: any[]) {
|
||||
|
||||
}
|
||||
|
||||
foo(["", 0, false]);
|
||||
|
||||
foo([false, 0, ""]);
|
||||
@@ -0,0 +1,9 @@
|
||||
|
||||
function foo({ x, y, z }?: { x: string; y: number; z: boolean });
|
||||
function foo(...rest: any[]) {
|
||||
|
||||
}
|
||||
|
||||
foo({ x: "", y: 0, z: false });
|
||||
|
||||
foo({ x: false, y: 0, z: "" });
|
||||
@@ -0,0 +1,3 @@
|
||||
// @target: es5
|
||||
function bar(...rest) { }
|
||||
function foo(x: number, y: string, ...rest) { }
|
||||
@@ -0,0 +1,3 @@
|
||||
// @target: es6
|
||||
function bar(...rest) { }
|
||||
function foo(x: number, y: string, ...rest) { }
|
||||
@@ -0,0 +1,5 @@
|
||||
// @target: es5
|
||||
var funcExp = (...rest) => { }
|
||||
var funcExp1 = (X: number, ...rest) => { }
|
||||
var funcExp2 = function (...rest) { }
|
||||
var funcExp3 = (function (...rest) { })()
|
||||
@@ -0,0 +1,5 @@
|
||||
// @target: es6
|
||||
var funcExp = (...rest) => { }
|
||||
var funcExp1 = (X: number, ...rest) => { }
|
||||
var funcExp2 = function (...rest) { }
|
||||
var funcExp3 = (function (...rest) { })()
|
||||
@@ -0,0 +1,8 @@
|
||||
// @target: es5
|
||||
var obj: {
|
||||
func1: (...rest) => void
|
||||
}
|
||||
|
||||
var obj2 = {
|
||||
func(...rest) { }
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// @target: es6
|
||||
var obj: {
|
||||
func1: (...rest) => void
|
||||
}
|
||||
|
||||
var obj2 = {
|
||||
func(...rest) { }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// @target: es5
|
||||
class C {
|
||||
constructor(name: string, ...rest) { }
|
||||
|
||||
public bar(...rest) { }
|
||||
public foo(x: number, ...rest) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
constructor(...rest) { }
|
||||
|
||||
public bar(...rest) { }
|
||||
public foo(x: number, ...rest) { }
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// @target: es6
|
||||
class C {
|
||||
constructor(name: string, ...rest) { }
|
||||
|
||||
public bar(...rest) { }
|
||||
public foo(x: number, ...rest) { }
|
||||
}
|
||||
|
||||
class D {
|
||||
constructor(...rest) { }
|
||||
|
||||
public bar(...rest) { }
|
||||
public foo(x: number, ...rest) { }
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
function fun<T>(g: (x: T) => T, x: T): T;
|
||||
function fun<T>(g: (x: T) => T, h: (y: T) => T, x: T): T;
|
||||
function fun<T>(g: (x: T) => T, x: T): T {
|
||||
return g(x);
|
||||
}
|
||||
|
||||
var a = fun(x => x, 10);
|
||||
var b = fun((x => x), 10);
|
||||
var c = fun(((x => x)), 10);
|
||||
var d = fun((((x => x))), 10);
|
||||
|
||||
var e = fun(x => x, x => x, 10);
|
||||
var f = fun((x => x), (x => x), 10);
|
||||
var g = fun(((x => x)), ((x => x)), 10);
|
||||
var h = fun((((x => x))), ((x => x)), 10);
|
||||
|
||||
// Ternaries in parens
|
||||
var i = fun((Math.random() < 0.5 ? x => x : x => undefined), 10);
|
||||
var j = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), 10);
|
||||
var k = fun((Math.random() < 0.5 ? (x => x) : (x => undefined)), x => x, 10);
|
||||
var l = fun(((Math.random() < 0.5 ? ((x => x)) : ((x => undefined)))), ((x => x)), 10);
|
||||
|
||||
var lambda1: (x: number) => number = x => x;
|
||||
var lambda2: (x: number) => number = (x => x);
|
||||
|
||||
type ObjType = { x: (p: number) => string; y: (p: string) => number };
|
||||
var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) };
|
||||
var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) });
|
||||
@@ -0,0 +1,36 @@
|
||||
// These tests ensure that in cases where it may *appear* that a value has a type,
|
||||
// they actually are properly being contextually typed. The way we test this is
|
||||
// that we invoke contextually typed arguments with type arguments.
|
||||
// Since 'any' cannot be invoked with type arguments, we should get errors
|
||||
// back if contextual typing is not taking effect.
|
||||
|
||||
type FuncType = (x: <T>(p: T) => T) => typeof x;
|
||||
|
||||
function fun<T>(f: FuncType, x: T): T;
|
||||
function fun<T>(f: FuncType, g: FuncType, x: T): T;
|
||||
function fun<T>(...rest: any[]): T {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var a = fun(x => { x<number>(undefined); return x; }, 10);
|
||||
var b = fun((x => { x<number>(undefined); return x; }), 10);
|
||||
var c = fun(((x => { x<number>(undefined); return x; })), 10);
|
||||
var d = fun((((x => { x<number>(undefined); return x; }))), 10);
|
||||
|
||||
var e = fun(x => { x<number>(undefined); return x; }, x => { x<number>(undefined); return x; }, 10);
|
||||
var f = fun((x => { x<number>(undefined); return x; }),(x => { x<number>(undefined); return x; }), 10);
|
||||
var g = fun(((x => { x<number>(undefined); return x; })),((x => { x<number>(undefined); return x; })), 10);
|
||||
var h = fun((((x => { x<number>(undefined); return x; }))),((x => { x<number>(undefined); return x; })), 10);
|
||||
|
||||
// Ternaries in parens
|
||||
var i = fun((Math.random() < 0.5 ? x => { x<number>(undefined); return x; } : x => undefined), 10);
|
||||
var j = fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), 10);
|
||||
var k = fun((Math.random() < 0.5 ? (x => { x<number>(undefined); return x; }) : (x => undefined)), x => { x<number>(undefined); return x; }, 10);
|
||||
var l = fun(((Math.random() < 0.5 ? ((x => { x<number>(undefined); return x; })) : ((x => undefined)))),((x => { x<number>(undefined); return x; })), 10);
|
||||
|
||||
var lambda1: FuncType = x => { x<number>(undefined); return x; };
|
||||
var lambda2: FuncType = (x => { x<number>(undefined); return x; });
|
||||
|
||||
type ObjType = { x: (p: number) => string; y: (p: string) => number };
|
||||
var obj1: ObjType = { x: x => (x, undefined), y: y => (y, undefined) };
|
||||
var obj2: ObjType = ({ x: x => (x, undefined), y: y => (y, undefined) });
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user