Skip to content
Permalink
Browse files

fix(TS): Error impls now properly type `this` (#4978)

Fixes an issue with TypeScript compilation in more strict environments.
  • Loading branch information...
benlesh committed Aug 26, 2019
1 parent b0fe286 commit 7606dc700155d69c77c4b63c2586c723f2137a0a
@@ -6,7 +6,7 @@ export interface ArgumentOutOfRangeErrorCtor {
}

const ArgumentOutOfRangeErrorImpl = (() => {
function ArgumentOutOfRangeErrorImpl(this: any) {
function ArgumentOutOfRangeErrorImpl(this: Error) {
Error.call(this);
this.message = 'argument out of range';
this.name = 'ArgumentOutOfRangeError';
@@ -6,7 +6,7 @@ export interface EmptyErrorCtor {
}

const EmptyErrorImpl = (() => {
function EmptyErrorImpl(this: any) {
function EmptyErrorImpl(this: Error) {
Error.call(this);
this.message = 'no elements in sequence';
this.name = 'EmptyError';
@@ -6,7 +6,7 @@ export interface ObjectUnsubscribedErrorCtor {
}

const ObjectUnsubscribedErrorImpl = (() => {
function ObjectUnsubscribedErrorImpl(this: any) {
function ObjectUnsubscribedErrorImpl(this: Error) {
Error.call(this);
this.message = 'object unsubscribed';
this.name = 'ObjectUnsubscribedError';
@@ -6,7 +6,7 @@ export interface TimeoutErrorCtor {
}

const TimeoutErrorImpl = (() => {
function TimeoutErrorImpl(this: any) {
function TimeoutErrorImpl(this: Error) {
Error.call(this);
this.message = 'Timeout has occurred';
this.name = 'TimeoutError';
@@ -7,13 +7,13 @@ export interface UnsubscriptionErrorCtor {
}

const UnsubscriptionErrorImpl = (() => {
function UnsubscriptionErrorImpl(this: any, errors: any[]) {
function UnsubscriptionErrorImpl(this: Error, errors: (Error|string)[]) {
Error.call(this);
this.message = errors ?
`${errors.length} errors occurred during unsubscription:
${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}` : '';
this.name = 'UnsubscriptionError';
this.errors = errors;
(this as any).errors = errors;
return this;
}

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

0 comments on commit 7606dc7

Please sign in to comment.
You can’t perform that action at this time.