0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

effect-tsで型情報の欠落?

0
Posted at

前回のチェックでcatch系の確認を実施したが、動作や型は同じようにしても
それを構成したprogram関数の型が変化する場合があるため、さらに場合分けして状況調査する

前回や参考

前回の時点で分かったこと

  • catchAllDefect
  • catchSomeDefect
    ではエラーキャッチできない
関数名 エラーの動作 OKの動作 NG-dieの動作 NG-failの動作
catch
catchAll
catchAllCause
catchAllDefect
catchIf
catchSome
catchSomeCause
catchSomeDefect
catchTag
catchTags

program関数の型

基本は以下の型

const program: Effect.Effect<void, never, never>

以下になる場合がある

const program: Effect.Effect<void, never, unknown>

これを場合分けする

⭕と✖

関数名 型  
catch
catchAll
catchAllCause
catchIf
catchSome
catchSomeCause
catchTag
catchTags

つまるところ、以下の2つは同じではない

catchTag

const defect_result = yield* tryEffect.pipe(
    Effect.catchTag("UnknownException", Effect.cause)
  )
---
const defect_result: Effect.Effect<never, FailMessage, never> | Effect.Effect<number, never, never> | Cause.Cause<Cause.UnknownException>
const defect_result = yield* tryEffect.pipe(
    Effect.catchTags({
      UnknownException: Effect.cause
    })
  )
---
const defect_result: Effect.Effect<never, FailMessage, never> | Effect.Effect<number, never, never> | Cause.Cause<unknown>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?