Skip to content

Commit de803c9

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 19b6c16 commit de803c9

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
@@ -1040,8 +1040,6 @@ namespace KaitaiStream {
10401040
*/
10411041
public constructor(bytesReq: number, bytesAvail: number) {
10421042
super("requested " + bytesReq + " bytes, but only " + bytesAvail + " bytes available");
1043-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1044-
Object.setPrototypeOf(this, KaitaiStream.EOFError.prototype);
10451043
this.bytesReq = bytesReq;
10461044
this.bytesAvail = bytesAvail;
10471045
}
@@ -1061,8 +1059,6 @@ namespace KaitaiStream {
10611059
*/
10621060
public constructor(expected: any, actual: any) {
10631061
super("expected [" + expected + "], but got [" + actual + "]");
1064-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1065-
Object.setPrototypeOf(this, KaitaiStream.UnexpectedDataError.prototype);
10661062
this.expected = expected;
10671063
this.actual = actual;
10681064
}
@@ -1073,8 +1069,6 @@ namespace KaitaiStream {
10731069

10741070
public constructor() {
10751071
super();
1076-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1077-
Object.setPrototypeOf(this, KaitaiStream.UndecidedEndiannessError.prototype);
10781072
}
10791073
};
10801074

@@ -1089,8 +1083,6 @@ namespace KaitaiStream {
10891083
*/
10901084
public constructor(expected: any, actual: any) {
10911085
super("not equal, expected [" + expected + "], but got [" + actual + "]");
1092-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1093-
Object.setPrototypeOf(this, KaitaiStream.ValidationNotEqualError.prototype);
10941086
this.expected = expected;
10951087
this.actual = actual;
10961088
}
@@ -1107,8 +1099,6 @@ namespace KaitaiStream {
11071099
*/
11081100
public constructor(min: any, actual: any) {
11091101
super("not in range, min [" + min + "], but got [" + actual + "]");
1110-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1111-
Object.setPrototypeOf(this, KaitaiStream.ValidationLessThanError.prototype);
11121102
this.min = min;
11131103
this.actual = actual;
11141104
}
@@ -1125,8 +1115,6 @@ namespace KaitaiStream {
11251115
*/
11261116
public constructor(max: any, actual: any) {
11271117
super("not in range, max [" + max + "], but got [" + actual + "]");
1128-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1129-
Object.setPrototypeOf(this, KaitaiStream.ValidationGreaterThanError.prototype);
11301118
this.max = max;
11311119
this.actual = actual;
11321120
}
@@ -1141,8 +1129,6 @@ namespace KaitaiStream {
11411129
*/
11421130
public constructor(actual: any) {
11431131
super("not any of the list, got [" + actual + "]");
1144-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1145-
Object.setPrototypeOf(this, KaitaiStream.ValidationNotAnyOfError.prototype);
11461132
this.actual = actual;
11471133
}
11481134
};
@@ -1156,8 +1142,6 @@ namespace KaitaiStream {
11561142
*/
11571143
public constructor(actual: any) {
11581144
super("not in the enum, got [" + actual + "]");
1159-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1160-
Object.setPrototypeOf(this, KaitaiStream.ValidationNotInEnumError.prototype);
11611145
this.actual = actual;
11621146
}
11631147
};
@@ -1171,8 +1155,6 @@ namespace KaitaiStream {
11711155
*/
11721156
public constructor(actual: any) {
11731157
super("not matching the expression, got [" + actual + "]");
1174-
// Workaround https://www.typescriptlang.org/docs/handbook/2/classes.html#inheriting-built-in-types
1175-
Object.setPrototypeOf(this, KaitaiStream.ValidationExprError.prototype);
11761158
this.actual = actual;
11771159
}
11781160
};

0 commit comments

Comments
 (0)