Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incomplete type for AsyncContext #22

Open
fbruffaert opened this issue Mar 4, 2022 · 1 comment
Open

Incomplete type for AsyncContext #22

fbruffaert opened this issue Mar 4, 2022 · 1 comment

Comments

@fbruffaert
Copy link

Hello,

When I check de type file for AsyncContext, it looks like it:

export declare class AsyncContext implements OnModuleInit, OnModuleDestroy {
    private readonly internalStorage;
    private readonly asyncHookRef;
    private static instance;
    private constructor();
    static getInstance(): AsyncContext;
    onModuleInit(): void;
    onModuleDestroy(): void;
    set<TKey = any, TValue = any>(key: TKey, value: TValue): void;
    get<TKey = any, TReturnValue = any>(key: TKey): TReturnValue;
    register(): void;
    private getAsyncStorage;
    private static initialize;
}

It seems that we have some missing methods listed in the doc:

class AsyncContext {
  // Clear all values from storage
  clear(): void;

  // Delete value by key from storage
  delete(key: K): boolean;

  // Iterate over storage
  forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;

  // Get value from storage by key
  get(key: K): V | undefined;

  // Check if key exists in storage
  has(key: K): boolean;

  // Set value by key in storage
  set(key: K, value: V): this;

  // Get number of keys that stored in storage
  get size: number;

  // Register context, it's better to use this method inside the interceptor
  register(): void

  // Register context for a callback, it's better to use this inside the middleware
  registerCallback<R, TArgs extends any[]>(callback: (...args: TArgs) => R, ...args: TArgs): R

  // Unregister context
  unregister(): void
}

Regards

@techvlad
Copy link
Contributor

techvlad commented Oct 3, 2022

Which methods are you missing during the migration to new version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants