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
|
=== tests/cases/compiler/divergentAccessorsTypes5.ts ===
// Not really different from divergentAccessorsTypes4.ts,
// but goes through the deferred type code
class One {
>One : One
get prop1(): string { return ""; }
>prop1 : string
>"" : ""
set prop1(s: string | number) { }
>prop1 : string
>s : string | number
prop2: number;
>prop2 : number
}
class Two {
>Two : Two
get prop1(): "hello" { return "hello"; }
>prop1 : "hello"
>"hello" : "hello"
set prop1(s: "hello" | number) { }
>prop1 : "hello"
>s : number | "hello"
get prop2(): string { return ""; }
>prop2 : string
>"" : ""
set prop2(s: string | 42) { }
>prop2 : string
>s : string | 42
}
class Three {
>Three : Three
get prop1(): "hello" { return "hello"; }
>prop1 : "hello"
>"hello" : "hello"
set prop1(s: "hello" | boolean) { }
>prop1 : "hello"
>s : boolean | "hello"
get prop2(): string { return ""; }
>prop2 : string
>"" : ""
set prop2(s: string | number | boolean) { }
>prop2 : string
>s : string | number | boolean
}
declare const i: One & Two & Three;
>i : One & Two & Three
// "hello"
i.prop1 = 42; // error
>i.prop1 = 42 : 42
>i.prop1 : "hello"
>i : One & Two & Three
>prop1 : "hello"
>42 : 42
i.prop1 = "hello";
>i.prop1 = "hello" : "hello"
>i.prop1 : "hello"
>i : One & Two & Three
>prop1 : "hello"
>"hello" : "hello"
// 42
i.prop2 = 42;
>i.prop2 = 42 : 42
>i.prop2 : 42
>i : One & Two & Three
>prop2 : 42
>42 : 42
i.prop2 = "hello"; // error
>i.prop2 = "hello" : "hello"
>i.prop2 : 42
>i : One & Two & Three
>prop2 : 42
>"hello" : "hello"
|