Skip to content

Commit ad901f1

Browse files
committed
small TS sugar
1 parent 0af568b commit ad901f1

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

src/diagnostics.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,21 +367,28 @@ export function shouldTrace<TContext = unknown>(
367367
/* c8 ignore stop */
368368
}
369369

370+
interface TraceLifecycleContext {
371+
error?: unknown;
372+
result?: unknown;
373+
}
374+
375+
type TraceStartContext<TContext extends TraceLifecycleContext> = Omit<
376+
TContext,
377+
'error' | 'result'
378+
>;
379+
370380
/**
371381
* Publish a mixed sync-or-promise operation through `channel`. Caller has
372382
* already verified that a subscriber is attached.
373383
*
374384
* @internal
375385
*/
376-
export function traceMixed<TResult, TContext = unknown>(
386+
export function traceMixed<TResult, TContext extends TraceLifecycleContext>(
377387
channel: MinimalTracingChannel<TContext>,
378-
contextInput: TContext extends object ? TContext : object,
388+
contextInput: TraceStartContext<TContext>,
379389
fn: () => TResult,
380390
): TResult {
381-
const context = contextInput as TContext & {
382-
error?: unknown;
383-
result?: unknown;
384-
};
391+
const context = contextInput as TContext;
385392

386393
return channel.start.runStores(context, () => {
387394
let result: TResult;

0 commit comments

Comments
 (0)