Skip to content

Commit b1a536d

Browse files
committed
PR feedback
1 parent 57ed4d2 commit b1a536d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packages/core/src/integration.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,12 @@ export function makeIntegrationFn<
174174
// eslint-disable-next-line @typescript-eslint/no-explicit-any
175175
Fn extends (...rest: any[]) => Partial<IntegrationFnResult>,
176176
>(name: string, fn: Fn): ((...rest: Parameters<Fn>) => ReturnType<Fn> & { name: string }) & { id: string } {
177-
const patchedFn = addNameToIntegrationFnResult(name, fn);
177+
const patchedFn = addNameToIntegrationFnResult(name, fn) as ((
178+
...rest: Parameters<Fn>
179+
) => ReturnType<Fn> & { name: string }) & { id: string };
178180

179-
return Object.assign(patchedFn, { id: name });
181+
patchedFn.id = name;
182+
return patchedFn;
180183
}
181184

182185
/**
@@ -192,14 +195,12 @@ export function convertIntegrationFnToClass<
192195
return Object.assign(
193196
// eslint-disable-next-line @typescript-eslint/no-explicit-any
194197
function ConvertedIntegration(...rest: any[]) {
195-
const res = {
198+
return {
196199
// eslint-disable-next-line @typescript-eslint/no-empty-function
197200
setupOnce: () => {},
198201
...fn(...rest),
199202
name: fn.id,
200203
};
201-
202-
return res;
203204
},
204205
{ id: fn.id },
205206
) as unknown as IntegrationClass<Integration>;
@@ -210,7 +211,9 @@ function addNameToIntegrationFnResult<
210211
Fn extends (...rest: any[]) => Partial<IntegrationFnResult>,
211212
>(name: string, fn: Fn): (...rest: Parameters<Fn>) => ReturnType<Fn> & { name: string } {
212213
const patchedFn = (...rest: Parameters<Fn>): ReturnType<Fn> & { name: string } => {
213-
return { ...fn(...rest), name } as ReturnType<Fn> & { name: string };
214+
const result = fn(...rest);
215+
result.name = name;
216+
return result as ReturnType<Fn> & { name: string };
214217
};
215218

216219
return patchedFn;

0 commit comments

Comments
 (0)