Skip to content

Commit

Permalink
fix types...
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Dec 19, 2023
1 parent d51f0be commit 785d712
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions packages/core/src/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ function findIndex<T>(arr: T[], callback: (item: T) => boolean): number {
return -1;
}

// We want to ensure that any Integration Class generated by `convertIntegrationFnToClass`
// can be called with or without setupOnce arguments.
interface IntegrationWithoutSetupOnce extends Integration {
setupOnce: (addGlobalEventProcessor?: (callback: EventProcessor) => void, getCurrentHub?: () => Hub) => void;
}

/**
* Convert a new integration function to the legacy class syntax.
* In v8, we can remove this and instead export the integration functions directly.
Expand All @@ -181,7 +175,11 @@ interface IntegrationWithoutSetupOnce extends Integration {
export function convertIntegrationFnToClass<Fn extends IntegrationFn>(
name: string,
fn: Fn,
): IntegrationClass<IntegrationWithoutSetupOnce> {
): IntegrationClass<
Integration & {
setupOnce: (addGlobalEventProcessor?: (callback: EventProcessor) => void, getCurrentHub?: () => Hub) => void;
}
> {
return Object.assign(
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function ConvertedIntegration(...rest: any[]) {
Expand All @@ -192,5 +190,9 @@ export function convertIntegrationFnToClass<Fn extends IntegrationFn>(
};
},
{ id: name },
) as unknown as IntegrationClass<IntegrationWithoutSetupOnce>;
) as unknown as IntegrationClass<
Integration & {
setupOnce: (addGlobalEventProcessor?: (callback: EventProcessor) => void, getCurrentHub?: () => Hub) => void;
}
>;
}

0 comments on commit 785d712

Please sign in to comment.