Make Serializable a generic. Make fromJson() and fromBinary() return the generic type.
This commit is contained in:
@@ -1,18 +1,19 @@
|
||||
/// <reference path="KeyAction.ts" />
|
||||
/// <reference path="Serializable.ts" />
|
||||
|
||||
class KeyActionNone extends KeyAction implements Serializable {
|
||||
class KeyActionNone extends KeyAction implements Serializable<KeyActionNone> {
|
||||
static actionTypeString = 'none';
|
||||
static keyActionNoneId = 0;
|
||||
static keyActionNoneParam = 0;
|
||||
|
||||
fromJsObject(jsObject: any) {
|
||||
fromJsObject(jsObject: any): KeyActionNone {
|
||||
if (jsObject.actionType !== 'none') {
|
||||
throw 'KeyActionNone: The actionType is not "none"';
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
fromBinary(buffer: UhkBuffer) {
|
||||
fromBinary(buffer: UhkBuffer): KeyActionNone {
|
||||
let keyActionId = buffer.readUInt8();
|
||||
if (keyActionId !== KeyActionNone.keyActionNoneId) {
|
||||
throw 'KeyActionNone: id is ${keyActionId} instead of ${KeyActionNone.keyActionNoneId}';
|
||||
@@ -22,6 +23,8 @@ class KeyActionNone extends KeyAction implements Serializable {
|
||||
if (keyActionParam !== KeyActionNone.keyActionNoneParam) {
|
||||
throw 'KeyActionNone: The param is ${keyActionParam} instead of ${KeyActionNone.keyActionNoneParam}';
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
toJsObject(): any {
|
||||
|
||||
Reference in New Issue
Block a user