Skip to content

Commit 522b275

Browse files
committed
Remove prototype adjustments in Error subclasses
These `Object.setPrototypeOf` calls are now unnecessary, since our TypeScript compilation target is set to ES6. From <https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types>: > Note: If you don't plan to inherit from built-in types like `Array`, > `Error`, `Map`, etc. or your compilation target is explicitly set to > `ES6`/`ES2015` or above, you may skip this section
1 parent bb1a242 commit 522b275

1 file changed

Lines changed: 0 additions & 18 deletions

File tree

KaitaiStream.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,6 @@ namespace KaitaiStream {
10381038
*/
10391039
public constructor(bytesReq: number, bytesAvail: number) {
10401040
super("requested " + bytesReq + " bytes, but only " + bytesAvail + " bytes available");
1041-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1042-
Object.setPrototypeOf(this, KaitaiStream.EOFError.prototype);
10431041
this.bytesReq = bytesReq;
10441042
this.bytesAvail = bytesAvail;
10451043
}
@@ -1059,8 +1057,6 @@ namespace KaitaiStream {
10591057
*/
10601058
public constructor(expected: any, actual: any) {
10611059
super("expected [" + expected + "], but got [" + actual + "]");
1062-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1063-
Object.setPrototypeOf(this, KaitaiStream.UnexpectedDataError.prototype);
10641060
this.expected = expected;
10651061
this.actual = actual;
10661062
}
@@ -1071,8 +1067,6 @@ namespace KaitaiStream {
10711067

10721068
public constructor() {
10731069
super();
1074-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1075-
Object.setPrototypeOf(this, KaitaiStream.UndecidedEndiannessError.prototype);
10761070
}
10771071
};
10781072

@@ -1087,8 +1081,6 @@ namespace KaitaiStream {
10871081
*/
10881082
public constructor(expected: any, actual: any) {
10891083
super("not equal, expected [" + expected + "], but got [" + actual + "]");
1090-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1091-
Object.setPrototypeOf(this, KaitaiStream.ValidationNotEqualError.prototype);
10921084
this.expected = expected;
10931085
this.actual = actual;
10941086
}
@@ -1105,8 +1097,6 @@ namespace KaitaiStream {
11051097
*/
11061098
public constructor(min: any, actual: any) {
11071099
super("not in range, min [" + min + "], but got [" + actual + "]");
1108-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1109-
Object.setPrototypeOf(this, KaitaiStream.ValidationLessThanError.prototype);
11101100
this.min = min;
11111101
this.actual = actual;
11121102
}
@@ -1123,8 +1113,6 @@ namespace KaitaiStream {
11231113
*/
11241114
public constructor(max: any, actual: any) {
11251115
super("not in range, max [" + max + "], but got [" + actual + "]");
1126-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1127-
Object.setPrototypeOf(this, KaitaiStream.ValidationGreaterThanError.prototype);
11281116
this.max = max;
11291117
this.actual = actual;
11301118
}
@@ -1139,8 +1127,6 @@ namespace KaitaiStream {
11391127
*/
11401128
public constructor(actual: any) {
11411129
super("not any of the list, got [" + actual + "]");
1142-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1143-
Object.setPrototypeOf(this, KaitaiStream.ValidationNotAnyOfError.prototype);
11441130
this.actual = actual;
11451131
}
11461132
};
@@ -1154,8 +1140,6 @@ namespace KaitaiStream {
11541140
*/
11551141
public constructor(actual: any) {
11561142
super("not in the enum, got [" + actual + "]");
1157-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1158-
Object.setPrototypeOf(this, KaitaiStream.ValidationNotInEnumError.prototype);
11591143
this.actual = actual;
11601144
}
11611145
};
@@ -1169,8 +1153,6 @@ namespace KaitaiStream {
11691153
*/
11701154
public constructor(actual: any) {
11711155
super("not matching the expression, got [" + actual + "]");
1172-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1173-
Object.setPrototypeOf(this, KaitaiStream.ValidationExprError.prototype);
11741156
this.actual = actual;
11751157
}
11761158
};

0 commit comments

Comments
 (0)