-
Notifications
You must be signed in to change notification settings - Fork 12.8k
/
Copy pathimplementedPropertyContextualTyping1.js
69 lines (66 loc) · 1.61 KB
/
implementedPropertyContextualTyping1.js
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
//// [implementedPropertyContextualTyping1.ts]
interface Event {
time: number;
}
interface Base {
superHandle: (e: Event) => number;
}
interface Listener extends Base {
handle: (e: Event) => void;
}
interface Ringer {
ring: (times: number) => void;
}
abstract class Watcher {
abstract watch(e: Event): number;
}
class Alarm extends Watcher implements Listener, Ringer {
str: string;
handle = e => {
this.str = e.time; // error
}
superHandle = e => {
this.str = e.time; // error
return e.time;
}
ring(times) {
this.str = times; // error
}
watch(e) {
this.str = e.time; // error
return e.time;
}
}
//// [implementedPropertyContextualTyping1.js]
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var Watcher = (function () {
function Watcher() {
}
return Watcher;
}());
var Alarm = (function (_super) {
__extends(Alarm, _super);
function Alarm() {
var _this = this;
_super.apply(this, arguments);
this.handle = function (e) {
_this.str = e.time; // error
};
this.superHandle = function (e) {
_this.str = e.time; // error
return e.time;
};
}
Alarm.prototype.ring = function (times) {
this.str = times; // error
};
Alarm.prototype.watch = function (e) {
this.str = e.time; // error
return e.time;
};
return Alarm;
}(Watcher));