Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Accept new baselines
  • Loading branch information
ahejlsberg committed Sep 11, 2018
commit 8a41f5f04b3df9996954307f0c823a7ee42f21e9
139 changes: 139 additions & 0 deletions tests/baselines/reference/strictBindCallApply1.errors.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
tests/cases/conformance/functions/strictBindCallApply1.ts(6,35): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(9,11): error TS2554: Expected 3 arguments, but got 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(10,35): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(11,11): error TS2554: Expected 3 arguments, but got 4.
tests/cases/conformance/functions/strictBindCallApply1.ts(14,32): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
Property '1' is missing in type '[number]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(15,37): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(16,32): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
Types of property 'length' are incompatible.
Type '3' is not assignable to type '2'.
tests/cases/conformance/functions/strictBindCallApply1.ts(29,29): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(30,22): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
tests/cases/conformance/functions/strictBindCallApply1.ts(33,11): error TS2554: Expected 3 arguments, but got 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(34,29): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(35,11): error TS2554: Expected 3 arguments, but got 4.
tests/cases/conformance/functions/strictBindCallApply1.ts(36,22): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
tests/cases/conformance/functions/strictBindCallApply1.ts(39,26): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(40,31): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(41,26): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(42,23): error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.
tests/cases/conformance/functions/strictBindCallApply1.ts(47,33): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(50,1): error TS2554: Expected 3 arguments, but got 2.
tests/cases/conformance/functions/strictBindCallApply1.ts(51,15): error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(52,1): error TS2554: Expected 3 arguments, but got 4.
tests/cases/conformance/functions/strictBindCallApply1.ts(55,12): error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
tests/cases/conformance/functions/strictBindCallApply1.ts(56,17): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/functions/strictBindCallApply1.ts(57,12): error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.


==== tests/cases/conformance/functions/strictBindCallApply1.ts (24 errors) ====
declare function foo(a: number, b: string): string;

let f00 = foo.bind(undefined);
let f01 = foo.bind(undefined, 10);
let f02 = foo.bind(undefined, 10, "hello");
let f03 = foo.bind(undefined, 10, 20); // Error
~~
!!! error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.

let c00 = foo.call(undefined, 10, "hello");
let c01 = foo.call(undefined, 10); // Error
~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 2.
let c02 = foo.call(undefined, 10, 20); // Error
~~
!!! error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
let c03 = foo.call(undefined, 10, "hello", 30); // Error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 4.

let a00 = foo.apply(undefined, [10, "hello"]);
let a01 = foo.apply(undefined, [10]); // Error
~~~~
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
!!! error TS2345: Property '1' is missing in type '[number]'.
let a02 = foo.apply(undefined, [10, 20]); // Error
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
let a03 = foo.apply(undefined, [10, "hello", 30]); // Error
~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
!!! error TS2345: Types of property 'length' are incompatible.
!!! error TS2345: Type '3' is not assignable to type '2'.

class C {
constructor(a: number, b: string) {}
foo(this: this, a: number, b: string): string { return "" }
}

declare let c: C;
declare let obj: {};

let f10 = c.foo.bind(c);
let f11 = c.foo.bind(c, 10);
let f12 = c.foo.bind(c, 10, "hello");
let f13 = c.foo.bind(c, 10, 20); // Error
~~
!!! error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
let f14 = c.foo.bind(undefined); // Error
~~~~~~~~~
!!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.

let c10 = c.foo.call(c, 10, "hello");
let c11 = c.foo.call(c, 10); // Error
~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 2.
let c12 = c.foo.call(c, 10, 20); // Error
~~
!!! error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
let c13 = c.foo.call(c, 10, "hello", 30); // Error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 4.
let c14 = c.foo.call(undefined, 10, "hello"); // Error
~~~~~~~~~
!!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.

let a10 = c.foo.apply(c, [10, "hello"]);
let a11 = c.foo.apply(c, [10]); // Error
~~~~
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
let a12 = c.foo.apply(c, [10, 20]); // Error
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
let a13 = c.foo.apply(c, [10, "hello", 30]); // Error
~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.
let a14 = c.foo.apply(undefined, [10, "hello"]); // Error
~~~~~~~~~
!!! error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'C'.

let f20 = C.bind(undefined);
let f21 = C.bind(undefined, 10);
let f22 = C.bind(undefined, 10, "hello");
let f23 = C.bind(undefined, 10, 20); // Error
~~
!!! error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.

C.call(c, 10, "hello");
C.call(c, 10); // Error
~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 2.
C.call(c, 10, 20); // Error
~~
!!! error TS2345: Argument of type '20' is not assignable to parameter of type 'string'.
C.call(c, 10, "hello", 30); // Error
~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS2554: Expected 3 arguments, but got 4.

C.apply(c, [10, "hello"]);
C.apply(c, [10]); // Error
~~~~
!!! error TS2345: Argument of type '[number]' is not assignable to parameter of type '[number, string]'.
C.apply(c, [10, 20]); // Error
~~
!!! error TS2322: Type 'number' is not assignable to type 'string'.
C.apply(c, [10, "hello", 30]); // Error
~~~~~~~~~~~~~~~~~
!!! error TS2345: Argument of type '[number, string, number]' is not assignable to parameter of type '[number, string]'.

107 changes: 107 additions & 0 deletions tests/baselines/reference/strictBindCallApply1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
//// [strictBindCallApply1.ts]
declare function foo(a: number, b: string): string;

let f00 = foo.bind(undefined);
let f01 = foo.bind(undefined, 10);
let f02 = foo.bind(undefined, 10, "hello");
let f03 = foo.bind(undefined, 10, 20); // Error

let c00 = foo.call(undefined, 10, "hello");
let c01 = foo.call(undefined, 10); // Error
let c02 = foo.call(undefined, 10, 20); // Error
let c03 = foo.call(undefined, 10, "hello", 30); // Error

let a00 = foo.apply(undefined, [10, "hello"]);
let a01 = foo.apply(undefined, [10]); // Error
let a02 = foo.apply(undefined, [10, 20]); // Error
let a03 = foo.apply(undefined, [10, "hello", 30]); // Error

class C {
constructor(a: number, b: string) {}
foo(this: this, a: number, b: string): string { return "" }
}

declare let c: C;
declare let obj: {};

let f10 = c.foo.bind(c);
let f11 = c.foo.bind(c, 10);
let f12 = c.foo.bind(c, 10, "hello");
let f13 = c.foo.bind(c, 10, 20); // Error
let f14 = c.foo.bind(undefined); // Error

let c10 = c.foo.call(c, 10, "hello");
let c11 = c.foo.call(c, 10); // Error
let c12 = c.foo.call(c, 10, 20); // Error
let c13 = c.foo.call(c, 10, "hello", 30); // Error
let c14 = c.foo.call(undefined, 10, "hello"); // Error

let a10 = c.foo.apply(c, [10, "hello"]);
let a11 = c.foo.apply(c, [10]); // Error
let a12 = c.foo.apply(c, [10, 20]); // Error
let a13 = c.foo.apply(c, [10, "hello", 30]); // Error
let a14 = c.foo.apply(undefined, [10, "hello"]); // Error

let f20 = C.bind(undefined);
let f21 = C.bind(undefined, 10);
let f22 = C.bind(undefined, 10, "hello");
let f23 = C.bind(undefined, 10, 20); // Error

C.call(c, 10, "hello");
C.call(c, 10); // Error
C.call(c, 10, 20); // Error
C.call(c, 10, "hello", 30); // Error

C.apply(c, [10, "hello"]);
C.apply(c, [10]); // Error
C.apply(c, [10, 20]); // Error
C.apply(c, [10, "hello", 30]); // Error


//// [strictBindCallApply1.js]
"use strict";
var f00 = foo.bind(undefined);
var f01 = foo.bind(undefined, 10);
var f02 = foo.bind(undefined, 10, "hello");
var f03 = foo.bind(undefined, 10, 20); // Error
var c00 = foo.call(undefined, 10, "hello");
var c01 = foo.call(undefined, 10); // Error
var c02 = foo.call(undefined, 10, 20); // Error
var c03 = foo.call(undefined, 10, "hello", 30); // Error
var a00 = foo.apply(undefined, [10, "hello"]);
var a01 = foo.apply(undefined, [10]); // Error
var a02 = foo.apply(undefined, [10, 20]); // Error
var a03 = foo.apply(undefined, [10, "hello", 30]); // Error
var C = /** @class */ (function () {
function C(a, b) {
}
C.prototype.foo = function (a, b) { return ""; };
return C;
}());
var f10 = c.foo.bind(c);
var f11 = c.foo.bind(c, 10);
var f12 = c.foo.bind(c, 10, "hello");
var f13 = c.foo.bind(c, 10, 20); // Error
var f14 = c.foo.bind(undefined); // Error
var c10 = c.foo.call(c, 10, "hello");
var c11 = c.foo.call(c, 10); // Error
var c12 = c.foo.call(c, 10, 20); // Error
var c13 = c.foo.call(c, 10, "hello", 30); // Error
var c14 = c.foo.call(undefined, 10, "hello"); // Error
var a10 = c.foo.apply(c, [10, "hello"]);
var a11 = c.foo.apply(c, [10]); // Error
var a12 = c.foo.apply(c, [10, 20]); // Error
var a13 = c.foo.apply(c, [10, "hello", 30]); // Error
var a14 = c.foo.apply(undefined, [10, "hello"]); // Error
var f20 = C.bind(undefined);
var f21 = C.bind(undefined, 10);
var f22 = C.bind(undefined, 10, "hello");
var f23 = C.bind(undefined, 10, 20); // Error
C.call(c, 10, "hello");
C.call(c, 10); // Error
C.call(c, 10, 20); // Error
C.call(c, 10, "hello", 30); // Error
C.apply(c, [10, "hello"]);
C.apply(c, [10]); // Error
C.apply(c, [10, 20]); // Error
C.apply(c, [10, "hello", 30]); // Error
Loading