Skip to content
Closed
Changes from 2 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
11 changes: 6 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ export interface BaseOptions<T = any> {
[key: string]: any;
}

export abstract class Base<T = any> extends ReadyEventEmitter {
options: BaseOptions<T>;
export abstract class Base<T = any, O extends BaseOptions<T> = BaseOptions<T>> extends ReadyEventEmitter {
options: O;
#closed = false;
#localStorage: AsyncLocalStorage<T>;

constructor(options?: BaseOptions<T>) {
/* @ts-expect-error just a placeholder, will be implemented in subclass */
protected _close(): Promise<void>;
Comment thread
hzgotb marked this conversation as resolved.
Outdated
constructor(options?: O) {
super();

if (options?.initMethod) {
Expand All @@ -43,7 +44,7 @@ export abstract class Base<T = any> extends ReadyEventEmitter {
});
});
}
this.options = options ?? {};
this.options = options ?? ({} as O);
this.#localStorage = this.options.localStorage ?? getAsyncLocalStorage<T>();
super.on('error', err => {
this._defaultErrorHandler(err);
Expand Down