Skip to content
This repository was archived by the owner on Mar 16, 2022. It is now read-only.

Commit

Permalink
feat: Added generic return type
Browse files Browse the repository at this point in the history
  • Loading branch information
edgardmessias committed Apr 21, 2021
1 parent 9a5fe45 commit 30cddef
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class WPPConnectLoader {
* @param condition Function for compare the modules
* @param reverse Search in reverse order
*/
public searchModule(condition: SearchModuleCondition, reverse = false): any {
public searchModule<T>(condition: SearchModuleCondition, reverse = false): T {
const moduleId = this.searchModuleId(condition, reverse);

if (moduleId) {
Expand All @@ -199,12 +199,12 @@ class WPPConnectLoader {
* Return the webpack module from a search function, checking new loaded scripts
* @param condition Function for compare the modules
*/
async waitForModule(
async waitForModule<T>(
condition: SearchModuleCondition,
reverse = false,
timeout: number | false = false
): Promise<any> {
const module = await this.searchModule(condition, reverse);
): Promise<T> {
const module = await this.searchModule<T>(condition, reverse);

if (module) {
return module;
Expand All @@ -217,7 +217,7 @@ class WPPConnectLoader {
if (!refreshed) {
return;
}
const module = await this.searchModule(condition, reverse);
const module = await this.searchModule<T>(condition, reverse);

if (module) {
this.off('refresh', check);
Expand All @@ -239,7 +239,7 @@ class WPPConnectLoader {
* Return the webpack module from ID
* @param moduleId Webpack module ID
*/
public get(moduleId: string): any {
public get<T>(moduleId: string): T {
return this._modules.get(moduleId + '');
}

Expand Down

0 comments on commit 30cddef

Please sign in to comment.