Conditionally Adding an Effect to a Pipe in Typescript

How do I conditionally add an effect to a pipe?

let currentSpanContext = trace.getSpan(context.active())?.spanContext();
const span = makeExternalSpan(currentSpanContext);
await Effect.runPromise(Effect.succeed("some effect").pipe(span ? Effect.withParentSpan(span) : ???, ...))

I want to pipe withParentSpan if there is one, but I want to do nothing when there is none
Was this page helpful?