1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
//// [specializedSignatureIsSubtypeOfNonSpecializedSignature.ts]
// Specialized signatures must be a subtype of a non-specialized signature
// All the below should not be errors
function foo(x: 'a');
function foo(x: string);
function foo(x: any) { }
class C {
foo(x: 'a');
foo(x: string);
foo(x: any) { }
}
class C2<T> {
foo(x: 'a');
foo(x: string);
foo(x: T);
foo(x: any) { }
}
class C3<T extends String> {
foo(x: 'a');
foo(x: string);
foo(x: T);
foo(x: any) { }
}
interface I {
(x: 'a');
(x: number);
(x: string);
foo(x: 'a');
foo(x: string);
foo(x: number);
}
interface I2<T> {
(x: 'a');
(x: T);
(x: string);
foo(x: 'a');
foo(x: string);
foo(x: T);
}
interface I3<T extends String> {
(x: 'a');
(x: string);
(x: T);
foo(x: 'a');
foo(x: string);
foo(x: T);
}
var a: {
(x: string);
(x: 'a');
(x: number);
foo(x: string);
foo(x: 'a');
foo(x: number);
}
var a2: {
(x: 'a');
(x: string);
<T>(x: T);
foo(x: string);
foo(x: 'a');
foo<T>(x: T);
}
var a3: {
(x: 'a');
<T>(x: T);
(x: string);
foo(x: string);
foo(x: 'a');
foo<T extends String>(x: T);
}
//// [specializedSignatureIsSubtypeOfNonSpecializedSignature.js]
// Specialized signatures must be a subtype of a non-specialized signature
// All the below should not be errors
function foo(x) { }
var C = (function () {
function C() {
}
C.prototype.foo = function (x) { };
return C;
}());
var C2 = (function () {
function C2() {
}
C2.prototype.foo = function (x) { };
return C2;
}());
var C3 = (function () {
function C3() {
}
C3.prototype.foo = function (x) { };
return C3;
}());
var a;
var a2;
var a3;
|