Handling Type Inference for Nullable Values in TypeScript Effects

Is there a way to avoid this problem other than just casting the final value as string | null?

const getFoo = Effect.gen(function*() {
  let foo: string | null = null

  yield* Effect.sync(function() {
    foo = "Hello!"
  })

  return foo
})


The problem is that getFoo's type is Effect.Effect<null>, not Effect.Effect<string|null>.
Was this page helpful?