Skip to content

Commit

Permalink
fix(TS): Error impls now properly type this (#4978)
Browse files Browse the repository at this point in the history
Fixes an issue with TypeScript compilation in more strict environments.
  • Loading branch information
benlesh committed Aug 26, 2019
1 parent b0fe286 commit 7606dc7
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/internal/util/ArgumentOutOfRangeError.ts
Expand Up @@ -6,7 +6,7 @@ export interface ArgumentOutOfRangeErrorCtor {
} }


const ArgumentOutOfRangeErrorImpl = (() => { const ArgumentOutOfRangeErrorImpl = (() => {
function ArgumentOutOfRangeErrorImpl(this: any) { function ArgumentOutOfRangeErrorImpl(this: Error) {
Error.call(this); Error.call(this);
this.message = 'argument out of range'; this.message = 'argument out of range';
this.name = 'ArgumentOutOfRangeError'; this.name = 'ArgumentOutOfRangeError';
Expand Down
2 changes: 1 addition & 1 deletion src/internal/util/EmptyError.ts
Expand Up @@ -6,7 +6,7 @@ export interface EmptyErrorCtor {
} }


const EmptyErrorImpl = (() => { const EmptyErrorImpl = (() => {
function EmptyErrorImpl(this: any) { function EmptyErrorImpl(this: Error) {
Error.call(this); Error.call(this);
this.message = 'no elements in sequence'; this.message = 'no elements in sequence';
this.name = 'EmptyError'; this.name = 'EmptyError';
Expand Down
2 changes: 1 addition & 1 deletion src/internal/util/ObjectUnsubscribedError.ts
Expand Up @@ -6,7 +6,7 @@ export interface ObjectUnsubscribedErrorCtor {
} }


const ObjectUnsubscribedErrorImpl = (() => { const ObjectUnsubscribedErrorImpl = (() => {
function ObjectUnsubscribedErrorImpl(this: any) { function ObjectUnsubscribedErrorImpl(this: Error) {
Error.call(this); Error.call(this);
this.message = 'object unsubscribed'; this.message = 'object unsubscribed';
this.name = 'ObjectUnsubscribedError'; this.name = 'ObjectUnsubscribedError';
Expand Down
2 changes: 1 addition & 1 deletion src/internal/util/TimeoutError.ts
Expand Up @@ -6,7 +6,7 @@ export interface TimeoutErrorCtor {
} }


const TimeoutErrorImpl = (() => { const TimeoutErrorImpl = (() => {
function TimeoutErrorImpl(this: any) { function TimeoutErrorImpl(this: Error) {
Error.call(this); Error.call(this);
this.message = 'Timeout has occurred'; this.message = 'Timeout has occurred';
this.name = 'TimeoutError'; this.name = 'TimeoutError';
Expand Down
6 changes: 3 additions & 3 deletions src/internal/util/UnsubscriptionError.ts
Expand Up @@ -7,13 +7,13 @@ export interface UnsubscriptionErrorCtor {
} }


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


Expand All @@ -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 * An error thrown when one or more errors have occurred during the
* `unsubscribe` of a {@link Subscription}. * `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.