登録して招待リンクを共有すると、動画再生報酬と紹介報酬を獲得できます。

mizchi
@mizchi
辻 Frontend Ops の傭兵。触るもの全てのパフォーマンスを倍にする。お仕事の依頼は DM または mizchi.work@gmail.com まで。 趣味はオーバーエンジニアリングです。
参加 April 2008
4.3K フォロー中    42.8K ファン
明確なアンチパターン。JSのError インスタンスはリフレクション的な性質があり、new Error で生成された時点で stacktrace が固定される。 これを引き回して別の場所で再 throw するなどすると、本来のスタックトレースを失うことになる。
もっと見る
PLEASE stop modeling "errors as values" in TypeScript after the "Result" enum from Rust. It is unnecessarily verbose and you're paying for an object instantiation for every value you return, everywhere, even if the error path never happens in the entire lifetime of your application. Instead, use unions: Simply return T | Error, and TypeScript automatically narrows the type for you once you check (x instanceof Error). instanceof checks are trivial, and if you never return errors at runtime, V8's JIT will optimize out the error case entirely and performance will be identical to if you didn't handle errors at all. You'll only pay for the deopt when you do hit the error case, but that's fine.
もっと見る