File: subtypingWithCallSignatures.js

package info (click to toggle)
node-typescript 3.3.3333-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 324,548 kB
  • sloc: makefile: 6; sh: 3
file content (21 lines) | stat: -rw-r--r-- 1,027 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//// [subtypingWithCallSignatures.ts]
module CallSignature {
    declare function foo1(cb: (x: number) => void): typeof cb;
    declare function foo1(cb: any): any;
    var r = foo1((x: number) => 1); // ok because base returns void
    var r2 = foo1(<T>(x: T) => ''); // ok because base returns void

    declare function foo2(cb: (x: number, y: number) => void): typeof cb;
    declare function foo2(cb: any): any;
    var r3 = foo2((x: number, y: number) => 1); // ok because base returns void
    var r4 = foo2(<T>(x: T) => ''); // ok because base returns void
}

//// [subtypingWithCallSignatures.js]
var CallSignature;
(function (CallSignature) {
    var r = foo1(function (x) { return 1; }); // ok because base returns void
    var r2 = foo1(function (x) { return ''; }); // ok because base returns void
    var r3 = foo2(function (x, y) { return 1; }); // ok because base returns void
    var r4 = foo2(function (x) { return ''; }); // ok because base returns void
})(CallSignature || (CallSignature = {}));