Skip to content

Commit 7606dc7

Browse files
authored
fix(TS): Error impls now properly type this (#4978)
Fixes an issue with TypeScript compilation in more strict environments.
1 parent b0fe286 commit 7606dc7

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

src/internal/util/ArgumentOutOfRangeError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface ArgumentOutOfRangeErrorCtor {
66
}
77

88
const ArgumentOutOfRangeErrorImpl = (() => {
9-
function ArgumentOutOfRangeErrorImpl(this: any) {
9+
function ArgumentOutOfRangeErrorImpl(this: Error) {
1010
Error.call(this);
1111
this.message = 'argument out of range';
1212
this.name = 'ArgumentOutOfRangeError';

src/internal/util/EmptyError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface EmptyErrorCtor {
66
}
77

88
const EmptyErrorImpl = (() => {
9-
function EmptyErrorImpl(this: any) {
9+
function EmptyErrorImpl(this: Error) {
1010
Error.call(this);
1111
this.message = 'no elements in sequence';
1212
this.name = 'EmptyError';

src/internal/util/ObjectUnsubscribedError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface ObjectUnsubscribedErrorCtor {
66
}
77

88
const ObjectUnsubscribedErrorImpl = (() => {
9-
function ObjectUnsubscribedErrorImpl(this: any) {
9+
function ObjectUnsubscribedErrorImpl(this: Error) {
1010
Error.call(this);
1111
this.message = 'object unsubscribed';
1212
this.name = 'ObjectUnsubscribedError';

src/internal/util/TimeoutError.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export interface TimeoutErrorCtor {
66
}
77

88
const TimeoutErrorImpl = (() => {
9-
function TimeoutErrorImpl(this: any) {
9+
function TimeoutErrorImpl(this: Error) {
1010
Error.call(this);
1111
this.message = 'Timeout has occurred';
1212
this.name = 'TimeoutError';

src/internal/util/UnsubscriptionError.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ export interface UnsubscriptionErrorCtor {
77
}
88

99
const UnsubscriptionErrorImpl = (() => {
10-
function UnsubscriptionErrorImpl(this: any, errors: any[]) {
10+
function UnsubscriptionErrorImpl(this: Error, errors: (Error|string)[]) {
1111
Error.call(this);
1212
this.message = errors ?
1313
`${errors.length} errors occurred during unsubscription:
1414
${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}` : '';
1515
this.name = 'UnsubscriptionError';
16-
this.errors = errors;
16+
(this as any).errors = errors;
1717
return this;
1818
}
1919

@@ -26,4 +26,4 @@ ${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}` : '';
2626
* An error thrown when one or more errors have occurred during the
2727
* `unsubscribe` of a {@link Subscription}.
2828
*/
29-
export const UnsubscriptionError: UnsubscriptionErrorCtor = UnsubscriptionErrorImpl as any;
29+
export const UnsubscriptionError: UnsubscriptionErrorCtor = UnsubscriptionErrorImpl as any;

0 commit comments

Comments
 (0)