<story><title>Problems with TypeScript</title><url>https://blog.logrocket.com/is-typescript-worth-it/</url></story><parent_chain><item><author>dkdbejwi383</author><text>I&amp;#x27;m interested in the way you describe handling errors here. Do you have any real world examples you can point me to? Thanks</text></item><item><author>valand</author><text>Guaranteed almost 100% type soundness!!! Non TypeScript user will hate this.&lt;p&gt;Config it to maximum strictness!&lt;p&gt;Add in runtime type checks
Parse, don&amp;#x27;t validate &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;lexi-lambda.github.io&amp;#x2F;blog&amp;#x2F;2019&amp;#x2F;11&amp;#x2F;05&amp;#x2F;parse-don-t-validate&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;lexi-lambda.github.io&amp;#x2F;blog&amp;#x2F;2019&amp;#x2F;11&amp;#x2F;05&amp;#x2F;parse-don-t-va...&lt;/a&gt;&lt;p&gt;Bring type to business logic, e.g.&lt;p&gt;RegisteredUser { userId: number, email: string }&lt;p&gt;AnonymousUser { userId: number, email: null }&lt;p&gt;User = RegisteredUser | AnonymousUser&lt;p&gt;Handle errors ala Rust,&lt;p&gt;Return errors&amp;#x2F;errortype rather than throws&lt;p&gt;Utilize structure to determine result, e.g.&lt;p&gt;Failure { error: Error, value: null }&lt;p&gt;Success&amp;lt;T&amp;gt; { error: null, value: T }&lt;p&gt;It is worth it. My experience with TypeScript is a whole lot different.&lt;p&gt;Conspiracy theory inducing facts:&lt;p&gt;- LogRocket&amp;#x27;s main use is monitoring bugs in browser application&lt;p&gt;- Airbnb is LogRocket&amp;#x27;s customer</text></item></parent_chain><comment><author>valand</author><text>I would have gladly shown it to you, but almost all my code is proprietary&lt;p&gt;Here&amp;#x27;s a small example:&lt;p&gt;```&lt;p&gt;function fetchCurrentWeather(){
  return fetch(...)
   .catch(() =&amp;gt; ({ error: new NetworkError(), value: null})
   .then(res =&amp;gt; res.json())
   .then(maybeWeather =&amp;gt; Weather.is(maybeWeather) ? { value: maybeWeather, error: null} : { error: new DecodeError(), value: null})
  .catch(() =&amp;gt; ({ error: new DecodeError(), value: null}))
}&lt;p&gt;&amp;#x2F;&amp;#x2F; And then you use it somewhere in you react app&lt;p&gt;async initialFetch(){
  try {
    if (this.state.isLoading) return;
    this.setState({ isLoading: true, weather: null, error: null });
    this.setState({ 
      weather: await fetchCurrentWeather().then(reault =&amp;gt; {
       if (result.error) throw result.error;
       return result.value;
      })
    });
  } catch (error) {
    this.setState({ error })
  } finally {
    this.setState({ isLoading: false });
  }
}&lt;p&gt;render(){
  return (
    &amp;lt;div&amp;gt;
      {this.state.isLoading &amp;amp;&amp;amp; ...}
      {this.state.weather &amp;amp;&amp;amp; ...}
      {this.state.error &amp;amp;&amp;amp; ...}
    &amp;lt;&amp;#x2F;div&amp;gt;
  )
}&lt;p&gt;```</text></comment>
<story><title>Problems with TypeScript</title><url>https://blog.logrocket.com/is-typescript-worth-it/</url></story><parent_chain><item><author>dkdbejwi383</author><text>I&amp;#x27;m interested in the way you describe handling errors here. Do you have any real world examples you can point me to? Thanks</text></item><item><author>valand</author><text>Guaranteed almost 100% type soundness!!! Non TypeScript user will hate this.&lt;p&gt;Config it to maximum strictness!&lt;p&gt;Add in runtime type checks
Parse, don&amp;#x27;t validate &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;lexi-lambda.github.io&amp;#x2F;blog&amp;#x2F;2019&amp;#x2F;11&amp;#x2F;05&amp;#x2F;parse-don-t-validate&amp;#x2F;&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;lexi-lambda.github.io&amp;#x2F;blog&amp;#x2F;2019&amp;#x2F;11&amp;#x2F;05&amp;#x2F;parse-don-t-va...&lt;/a&gt;&lt;p&gt;Bring type to business logic, e.g.&lt;p&gt;RegisteredUser { userId: number, email: string }&lt;p&gt;AnonymousUser { userId: number, email: null }&lt;p&gt;User = RegisteredUser | AnonymousUser&lt;p&gt;Handle errors ala Rust,&lt;p&gt;Return errors&amp;#x2F;errortype rather than throws&lt;p&gt;Utilize structure to determine result, e.g.&lt;p&gt;Failure { error: Error, value: null }&lt;p&gt;Success&amp;lt;T&amp;gt; { error: null, value: T }&lt;p&gt;It is worth it. My experience with TypeScript is a whole lot different.&lt;p&gt;Conspiracy theory inducing facts:&lt;p&gt;- LogRocket&amp;#x27;s main use is monitoring bugs in browser application&lt;p&gt;- Airbnb is LogRocket&amp;#x27;s customer</text></item></parent_chain><comment><author>aecorredor</author><text>Check out the chapter on handling errors in the book “Programming TypeScript”, it gives a solid pattern for achieving something very close to Rust’s Option.</text></comment>