Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/CreateDestroy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Status, Class } from './types.js';
import type { Status, Class, AnyFn } from './types.js';
import { Evented } from '@matrixai/events';
import { RWLockWriter } from '@matrixai/async-locks';
import {
Expand Down Expand Up @@ -118,7 +118,7 @@ function ready(
} else if (descriptor.set != null) {
kind = 'set';
}
const f: Function = descriptor[kind]; // eslint-disable-line @typescript-eslint/ban-types
const f = descriptor[kind] as AnyFn;
if (typeof f !== 'function') {
throw new TypeError(`${key} is not a function`);
}
Expand Down
4 changes: 2 additions & 2 deletions src/CreateDestroyStartStop.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Status, Class } from './types.js';
import type { Status, Class, AnyFn } from './types.js';
import { Evented } from '@matrixai/events';
import { RWLockWriter } from '@matrixai/async-locks';
import {
Expand Down Expand Up @@ -238,7 +238,7 @@ function ready(
} else if (descriptor.set != null) {
kind = 'set';
}
const f: Function = descriptor[kind]; // eslint-disable-line @typescript-eslint/ban-types
const f = descriptor[kind] as AnyFn;
if (typeof f !== 'function') {
throw new TypeError(`${key} is not a function`);
}
Expand Down
3 changes: 2 additions & 1 deletion src/StartStop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ function ready(
} else if (descriptor.set != null) {
kind = 'set';
}
const f: Function = descriptor[kind]; // eslint-disable-line @typescript-eslint/ban-types
type AnyFn = (...args: Array<unknown>) => unknown;
const f = descriptor[kind] as AnyFn;
if (typeof f !== 'function') {
throw new TypeError(`${key} is not a function`);
}
Expand Down
4 changes: 3 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ type Status = 'destroying' | 'starting' | 'stopping' | null;

type Class<T> = new (...args: any[]) => T;

export type { PromiseDeconstructed, Status, Class };
type AnyFn = (...args: Array<unknown>) => unknown;

export type { PromiseDeconstructed, Status, Class, AnyFn };
5 changes: 2 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PromiseDeconstructed } from './types.js';
import type { AnyFn, PromiseDeconstructed } from './types.js';

/**
* Symbols prevents name clashes with decorated classes
Expand Down Expand Up @@ -42,8 +42,7 @@ function promise<T = void>(): PromiseDeconstructed<T> {
* This function rewrites the stack trace according to where the wrapped
* function is called, giving a more useful stack trace
*/
// eslint-disable-next-line @typescript-eslint/ban-types
function resetStackTrace(error: Error, decorated?: Function): void {
function resetStackTrace(error: Error, decorated?: AnyFn): void {
if (error.stack != null) {
const stackTitle = error.stack.slice(0, error.stack.indexOf('\n') + 1);
if (hasCaptureStackTrace) {
Expand Down
2 changes: 1 addition & 1 deletion tests/CreateDestroy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ describe('CreateDestroy', () => {
(async () => {
const x = new X();
const destroy = x.destroy();
x.a;
void x.a;
await destroy;
})(),
).resolves.toBeUndefined();
Expand Down
4 changes: 2 additions & 2 deletions tests/CreateDestroyStartStop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ describe('CreateDestroyStartStop', () => {
await expect(
(async () => {
const start = x.start();
x.a;
void x.a;
await start;
})(),
).rejects.toThrow(ErrorAsyncInitNotRunning);
Expand All @@ -614,7 +614,7 @@ describe('CreateDestroyStartStop', () => {
await expect(
(async () => {
const stop = x.stop();
x.a;
void x.a;
await stop;
})(),
).resolves.toBeUndefined();
Expand Down
4 changes: 2 additions & 2 deletions tests/StartStop.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ describe('StartStop', () => {
await expect(
(async () => {
const start = x.start();
x.a;
void x.a;
await start;
})(),
).rejects.toThrow(ErrorAsyncInitNotRunning);
Expand All @@ -329,7 +329,7 @@ describe('StartStop', () => {
await expect(
(async () => {
const stop = x.stop();
x.a;
void x.a;
await stop;
})(),
).resolves.toBeUndefined();
Expand Down