<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Conrad Davis Jr. on Medium]]></title>
        <description><![CDATA[Stories by Conrad Davis Jr. on Medium]]></description>
        <link>https://medium.com/@conraddavisjr?source=rss-44fdfb49c749------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*X1ABD5gTJ4vtgdgdPTCw8w.jpeg</url>
            <title>Stories by Conrad Davis Jr. on Medium</title>
            <link>https://medium.com/@conraddavisjr?source=rss-44fdfb49c749------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 08:47:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@conraddavisjr/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Poor Performer? You Might Just Have Them in the Wrong Role]]></title>
            <link>https://medium.com/@conraddavisjr/poor-performer-you-might-just-have-them-in-the-wrong-role-ac0d9cf58225?source=rss-44fdfb49c749------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac0d9cf58225</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[future]]></category>
            <category><![CDATA[leadership]]></category>
            <dc:creator><![CDATA[Conrad Davis Jr.]]></dc:creator>
            <pubDate>Mon, 03 Aug 2026 20:13:33 GMT</pubDate>
            <atom:updated>2026-08-03T20:13:33.898Z</atom:updated>
            <content:encoded><![CDATA[<h3>Before concluding that someone is a poor performer, ask whether you’ve placed their strengths in the wrong role</h3><p>I once managed a junior engineer who was struggling in a conventional software-development position.</p><p>The feedback from other engineers wasn’t encouraging; her technical output wasn’t consistently meeting the expectations of the role, and I had reached the point where I had to consider letting her go.</p><p>But the feedback didn’t tell the whole story:</p><p>She was diligent, reliable, driven, exceptionally detail-oriented, collaborative, and genuinely curious. Those are often the qualities of a star performer and there was a chance that I had not yet positioned her towards her “superpowers”.</p><p>So we had an honest conversation, and together, we designed a hybrid quality-engineering role around a major bottleneck in our SDLC: peer review and quality validation.</p><p>I showed her a roadmap tailored specifically to her career.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NvoyMKQSQZfXH7HNxf1-kg.png" /></figure><p>She would review pull requests across multiple teams, gaining exposure to different architectures and development approaches — strengthening her engineering judgment by studying the work of more experienced engineers.</p><p>She would also develop the AI skills she cared about, like using agents to assist with reviews, automating repeatable checks, and building tools that would allow her to provide quality coverage at greater scale.</p><p>Then she took that opportunity and absolutely thrived 🏆 .</p><ul><li>In her first quarter, she prevented more than 87 potential regressions from advancing through our delivery process.</li><li>Her work became a primary contributor to a measured increase of more than 12% in delivery throughput across three engineering teams, tracked through our GitHub and Jira workflow data.</li></ul><p>She also regularly caught consequential issues in changes produced by some of our most senior engineers — And they weren’t careless… they were reviewing whether the code correctly implemented the architecture and intended design.</p><p>However, she was asking a different question: <br><strong>What if the intended design itself is wrong?</strong></p><p>That distinction matters more than ever as AI agents become increasingly capable of writing, reviewing, and testing software:</p><ol><li>Agents can verify that a solution was implemented correctly.</li><li>Engineers can deeply review and understand its architecture — then make adjustments as needed.</li><li>Automation can confirm that the expected cases pass.</li></ol><p>…and regressions can still happen.</p><p>Some of the most damaging flaws are <em>perfectly executed contradictions</em> in our requirements, assumptions, workflows, biases, or product design.</p><p>That is where thoughtful human quality assurance remains invaluable. Great QA professionals don’t merely test whether the software works as designed… They challenge whether what we designed should work that way at all. You can do this earlier in the requirements phase… but details no one considered are often surfaced afterwards, when the full picture comes together.</p><p>Her strengths didn’t <em>suddenly</em> <em>appear</em> when her title changed. We finally placed them where they could create disproportionate value, and gave her a future she could help shape.</p><p>It’s important to note that repositioning <em>will not solve every performance problem</em>. Sometimes separation is still the <em>right</em> decision. But before making that decision, leaders should ask:</p><ol><li>Is this truly a capability problem, or a role-alignment problem?</li><li>What’s the strength of their character, and have they demonstrated qualities that often succeed here?</li><li>What are they genuinely exceptional at? Can that translate to an opportunity?</li><li>Is there an organizational need that matches this person’s strengths?</li><li>Can we offer a new path with dignity, clarity, and real opportunity?</li></ol><p>Great leadership isn’t just about managing performance. Sometimes, it is simply having the imagination to position talent where it can become extraordinary.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac0d9cf58225" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Cheat sheet for Python and Typescript static typing]]></title>
            <link>https://medium.com/@conraddavisjr/a-cheat-sheet-for-python-and-typescript-static-typing-3de56c23e5b0?source=rss-44fdfb49c749------2</link>
            <guid isPermaLink="false">https://medium.com/p/3de56c23e5b0</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Conrad Davis Jr.]]></dc:creator>
            <pubDate>Tue, 11 Jul 2023 13:08:26 GMT</pubDate>
            <atom:updated>2023-07-11T13:08:26.255Z</atom:updated>
            <content:encoded><![CDATA[<h4>A side-by-side comparison of static typing in each language</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o38jrCFAAts7D6urHQ2AQw.jpeg" /></figure><p>I recently needed to do a lot of work in Python, and coming from a Typescript world, static typing was a habit. Fortunately, Python supports this, but I didn’t know how to convert my TS types to Python… so I created a cheatsheet that I could quickly reference when jumping into Python. I hope that this list is useful for you as well!</p><p>This article is for anyone who’s moving from Typescript to Python static typing (or the reverse), and would like to see how each language would solve the same issue using types.</p><h4><strong>1. Working with functions — set a type for a function argument</strong></h4><p><em>Typescript</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc16282915625af728598bb223f16923/href">https://medium.com/media/dc16282915625af728598bb223f16923/href</a></iframe><p><em>Python</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fab40a75d9158b0e427121e68c806764/href">https://medium.com/media/fab40a75d9158b0e427121e68c806764/href</a></iframe><h4>2. Working with Arrays/Lists — simple inline array</h4><p><em>Typescript</em></p><pre>type Numbers = number[];<br><br>const numbers: Numbers = [1, 2, 3, 4, 5];<br>const sum = numbers.reduce((total, num) =&gt; total + num, 0);</pre><p><em>Python</em></p><pre>from typing import List<br><br>Numbers = List[int]<br>numbers: Numbers = [1, 2, 3, 4, 5]<br>sum = sum(numbers)</pre><h4>3. Working with Arrays/Lists — Array Generics</h4><p><em>Typescript</em></p><pre>// Define an interface to represent a user<br>interface User {<br>  name: string;<br>  age: number;<br>}<br><br>// Declare an array of User objects<br>const users: Array&lt;User&gt; = [<br>  { name: &#39;John&#39;, age: 25 },<br>  { name: &#39;Jane&#39;, age: 30 },<br>  { name: &#39;Bob&#39;, age: 40 }<br>];</pre><p><em>Python</em></p><pre>from typing import TypedDict, List<br><br># Define a TypedDict to represent a user<br>class User(TypedDict):<br>    name: str<br>    age: int<br><br># Declare a list of User dictionaries<br>users: List[User] = [<br>    {&#39;name&#39;: &#39;John&#39;, &#39;age&#39;: 25},<br>    {&#39;name&#39;: &#39;Jane&#39;, &#39;age&#39;: 30},<br>    {&#39;name&#39;: &#39;Bob&#39;, &#39;age&#39;: 40}<br>]</pre><h4>4. A function that doesn’t return a value (void/None)</h4><p><em>Typescript</em></p><pre>function sayHello(name: string): void {<br>  console.log(`Hello, my name is ${name}`);<br>}<br><br>sayHello(&#39;Conrad&#39;);</pre><p><em>Python</em></p><pre>def say_hello(name: str) -&gt; None:<br>  print(f&quot;Hello, my name is {name}&quot;)<br><br>say_hello(&#39;Conrad&#39;)</pre><h4>5. Working with Generics —<em> Make a function that accepts a generic type, and returns that generic type</em></h4><p><em>Typescript</em></p><pre>function Identity&lt;T&gt;(arg: T): T {<br>  return arg;<br>}<br><br>const result = Identity&lt;string&gt;(&#39;hello&#39;);</pre><p><em>Python</em></p><pre>def Identity(arg: T) -&gt; T:<br>    return arg<br><br>result: str = Identity[str](&#39;hello&#39;)</pre><h4>6. Working with unions — Multiple scalar values</h4><p><em>Typescript</em></p><pre>function logValue(value: string | number): void {<br>  console.log(`The value is ${value}`);<br>}<br><br>logValue(&#39;hello&#39;); // no error<br>logValue(42); // no error<br>logValue(false) // TS error</pre><p><em>Python</em></p><pre>def log_value(value: Union[str, int]) -&gt; None:<br>  print(f&quot;The value is {value}&quot;)<br><br>log_value(&#39;hello&#39;) # no error<br>log_value(42) # no error<br>log_value(false) # static error</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3de56c23e5b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Conquering a complex error in Typescript]]></title>
            <link>https://medium.com/@conraddavisjr/conquering-a-complex-error-in-typescript-6d3f6bac359e?source=rss-44fdfb49c749------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d3f6bac359e</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Conrad Davis Jr.]]></dc:creator>
            <pubDate>Tue, 18 Apr 2023 15:26:50 GMT</pubDate>
            <atom:updated>2023-04-18T15:26:50.608Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to read and understand the Object Literal error</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WwTQ9Ti6PL0VIReOws2b6A.jpeg" /><figcaption>Image credit: House — macrovector. Bonfire and rocks — Conrad Davis Jr.</figcaption></figure><h4>The Object literal error</h4><p>Type ‘{ poundPrice: null; quantityType: “item”; storeName: string; selectedVariation: string; redeemLocationId: string; redeemDate: string; redeemType: “pickup”; quantity: number; inventory: { maxUnitsAllowed: number; units: number; }; … 4 more …; KneadedDough: { …; }; }’ is not assignable to type ‘ExtendedCartItem’.<br>Object literal may only specify known properties, and ‘Spagetti’ does not exist in type ‘ExtendedCartItem’.ts(2322)</p><p>This is an error that I received in an application I worked on. If you’ve coded with TS for at least a few months, you’ve most likely encountered this style of error. There’s a lot to process here…</p><p>Feeling overwhelmed by an error like this is NOT uncommon. Troubleshooting in Typescript can be complex and intimidating.</p><p>The aim for this article is to provide a human approach to understanding and solving these types of issues. This is <a href="https://medium.com/@conraddavisjr/list/the-typescript-guide-i-wish-i-had-a981847f52f0">part of an ongoing series</a> which will eventually cover the full range of Typescript. If you find this article useful, feel free to follow for upcoming content!</p><h4>There’s a pattern</h4><p>At the core of every TS error is a template, and it’s exceptionally redundant (for good reason). We will discuss ways to recognize these patterns and use them to navigate the “Object Literal” error.</p><figure><img alt="An object literal error in Typescript, divided into three sections, The Data, The Mismatch, and The reason. These sections are used help identify the key sections of the error, and make it easier to troubleshoot." src="https://cdn-images-1.medium.com/max/874/1*KkyX8lRxYx2ZMT5Ohc_9CA.jpeg" /><figcaption>The object literal error, divided into three sections. Visual by Conrad Davis Jr.</figcaption></figure><p>I divided the error above into three sections; The Data, The Mismatch, and the Reason. We’ll start with an overview of each section, then we’ll discuss them in detail with examples.</p><p><strong>The Data </strong>- In the first section of this template (in orange), Typescript is telling us it found an issue with one or more of the properties inside of an object we’re trying to use. This section is usually the most intimidating because it’s so verbose, but fortunately, it’s often the least important in solving the error, so we can usually skip it and only need to revisit it if we need more details about the object’s properties.</p><blockquote>P.S the … 4 more …; in the object means there are four other properties that are hidden from the error message because there are too many to list in the view. This is typically done for performance reasons.</blockquote><p><strong>The Mismatch - </strong><em>The Mismatch</em> section shows us what TS was comparing our object to before it threw an error. The is not assignable to type {NameOfType} phrase means the properties in our object are not matching the properties in the type it’s being compared to. This part of the error message is useful for seeing which type is in conflict. Oftentimes, I can look up the type by its name, and compare its details with my object to see what’s wrong. However, the section below is often much more helpful…</p><p><strong>The Reason </strong>-<strong> </strong>The last section, uses the phrase Object literal may only specify known properties and {property} does not exist in type {NameOfType}. Don’t get hung up on the first part of this error message. It’s just a rule, saying we’re only allowed to use properties that exist within the Types of our application. The other half is the “gold”, because it tells us the <em>name</em> of the property that’s causing the issue. In most cases, we can use this info to solve the issue by either adding the missing property to the type, or simply choose to not use the property, and remove it from the object (code examples coming up). Of course, there are more ways to resolve these issues, and we’ll cover some later in the article.</p><h4>Deep Dive</h4><p>Since the first part of the error message in <em>The Reason </em>is quite cryptic, let’s break it into two parts, and describe it in detail, to gain a deeper understanding of the error:</p><ol><li>object literal</li><li>may only specify known properties</li></ol><h4>1. Object literal</h4><p>This term refers to the properties of an object, for example:</p><pre>// This is an object literal. In this example, the<br>// values are strings. However, they could be boolean, number, etc.<br>{<br>  color: &#39;blue&#39;,<br>  size: &#39;large&#39;,<br>  brand: &#39;Typescript&#39;<br>}<br><br>// In Typescript, this object is seen (inferred) like so:<br>{<br>  color: string;<br>  size: string;<br>  brand: string;<br>}</pre><p>The properties of an object literal can be used to describe something… it could be a t-shirt, a phone case, a desk; you name it… literally! That’s where Typescript comes in! We use it to determine what something is by describing its properties. Let’s identify the object literal above, as a TShirt. In Typescript, we can do it like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ae82e9eefbbbff9a1a41becbb85cafc2/href">https://medium.com/media/ae82e9eefbbbff9a1a41becbb85cafc2/href</a></iframe><h4>2. May only specify known properties</h4><p>This means we can only use properties that are expected. Types and interfaces tell us what properties to expect. When we deviate from this rule, we get errors, for example:</p><pre>const largeBlueTShirt: TShirt = {<br>  color: &quot;blue&quot;,<br>  size: &quot;large&quot;,<br>  brand: &quot;Typescript&quot;,<br>  fabric: &quot;linen&quot; // &lt;--- this would throw an error<br>}</pre><p>Remember that the TShirt type we created only has the properties color, size, and brand; <strong>NOT</strong> fabric. Therefore, using the property fabric would cause an error.</p><p><em>The Result </em>part of the error would look like this:</p><p>type TShirt may only specify known properties. Notice that the error says type TShirt instead of type object literal. This is because the variable largeBlueTShirt has the type TShirt assigned to it. If we didn’t assign a type to the largeBlueTShirt variable, the term would default to “object literal”.</p><blockquote>Note: assigning your objects to a type could help to make your errors more readable.</blockquote><h4>Ways to resolve this error</h4><p>Add a fabric property to the TShirt type like so:</p><pre>type TShirt = {<br>  color: string;<br>  size: &#39;small&#39; | &#39;medium&#39; | &#39;large&#39;;<br>  brand: string;<br>  fabric: string; // &lt;--- add the missing property here<br>};</pre><p>or omit the fabric property from the object assignment:</p><pre>const largeBlueTShirt: TShirt = {<br>  color: &quot;blue&quot;,<br>  size: &quot;large&quot;,<br>  brand: &quot;Typescript&quot;,<br>  fabric: &quot;linen&quot;, // &lt;-- delete this line<br>}<br>// no errors! :)</pre><p>There are many more ways to resolve this issue, you can chain the fabric property to the type like so: TShirt &amp; { fabric: string}. Or, create a new interface that extends the TShirt type and adds the props that you need. interface TShirtExtras extends TShirt { fabric: string; ...}. I plan to cover techniques like this in detail for future articles. If you’d like more insight on this, feel free to follow for updates!</p><p>Back to the fabric: &quot;linen&quot; error. Let’s take a look at the full error TS would present to us, and break it down.</p><p>Type ‘{ color: string; size: “large”; brand: string; fabric: string; }’ is not assignable to type ‘TShirt’. Object literal may only specify known properties, and ‘fabric’ does not exist in type ‘TShirt’.(2322)</p><p><strong>Break it into the three sections we discussed:</strong></p><ol><li>Type ‘{ color: string; size: “large”; brand: string; fabric: string; }’ — this is a snapshot of “<strong>Our Data</strong>”, it’s the object we are assigning to the largeBlueTShirt variable.</li><li>is not assignable to type ‘TShirt’. — TS is telling us there’s a property in our object that is <strong>not</strong> in the TShirt type.</li><li>Object literal may only specify known properties, and ‘fabric’ does not exist in type ‘TShirt’.(2322) —The fabric property does <strong>not </strong>exist inside the TShirt type, and we’re not allowed to use this property unless it’s listed within the TShirt type.</li></ol><h4>Strategy</h4><p>When you encounter an object literal error, <strong>start at the bottom</strong>. Go straight to the “gold”, where TS lists the ‘name’ of the property that doesn’t exist in the type. In the case above, I’d scan for the phrase Object literal may only specify… just so I can detect the last section (The reason). When I’m there, I skim to the right of this phrase, in search of the name of the missing property in single-quotes (‘fabric’ in this case ). Once I know which property doesn’t exist, I take a look at details of the {typeName} being referenced (does not exist in type ‘{typeName}’). From there, I usually decide one of three things:</p><ol><li>Add the missing property to the type.</li><li>Remove the property incase I made a mistake and it doesn’t actually belong there.</li><li>I realize that there’s a need for a refactor in my types. Maybe it’s tiny, and as easy as creating a new interface, or concatenating a property to the type (TypeName &amp; {myProp: “val”}). Perhaps it’s more involved, and I may need to reorganize the relationships between the types in my application. Fortunately, this is often not the case. If you are experiencing this issue repeatedly, and would like an article covering strategies on handling complex issues like this, please let me know.</li></ol><p>You’re welcome to try your hand on this small application I created to demo the object literal error. Since errors come in many shapes and sizes, I decided to write some code that’s different from what’s written in this article. Variety is the spice here! Use the template framework and strategies that we covered to navigate the errors in the app below!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Ftsguide-part1-e6gsw9%3Fembed%3D1%26file%3Dindex.ts&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Ftsguide-part1-e6gsw9%3Ffile%3Dindex.ts&amp;image=https%3A%2F%2Fsocial-img.staticblitz.com%2Fprojects%2Ftsguide-part1-e6gsw9%2F5839684ea752ceec7b90214c926f13db&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7833ddda360cd64183300149abdb81d/href">https://medium.com/media/d7833ddda360cd64183300149abdb81d/href</a></iframe><p>I really hope this content was useful. <a href="https://medium.com/@conraddavisjr/list/the-typescript-guide-i-wish-i-had-a981847f52f0">This article is part of a series</a> on a journey to cover Typescript from zero all the way to 100! If you found this to be helpful, please follow for more content!</p><p>Thanks, until next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d3f6bac359e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Read Errors in TypeScript]]></title>
            <link>https://medium.com/better-programming/the-typescript-guide-i-wish-i-had-reading-errors-part-1-68a1c82d9303?source=rss-44fdfb49c749------2</link>
            <guid isPermaLink="false">https://medium.com/p/68a1c82d9303</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Conrad Davis Jr.]]></dc:creator>
            <pubDate>Wed, 28 Sep 2022 16:21:40 GMT</pubDate>
            <atom:updated>2022-12-01T19:05:56.273Z</atom:updated>
            <content:encoded><![CDATA[<h3>Reading Simple Errors in TypeScript</h3><h4>With visual guides and simple language</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*5XjgqlV781SdKII_yDFkOQ.jpeg" /><figcaption>image by author</figcaption></figure><p>TypeScript can be riddled with errors and warnings, for seemingly every little thing. Take this function for example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1fc90861ec5be9abdc99a84d20c52876/href">https://medium.com/media/1fc90861ec5be9abdc99a84d20c52876/href</a></iframe><p>(If you’re not sure what :number might mean inside of the function arguments, I cover that, and more in an <a href="https://medium.com/@conraddavisjr/the-typescript-guide-i-wish-i-had-185087d66dd1">earlier chapter of this guide</a>. But no worries, we’ll revisit it lightly in this article as well.)</p><p>In strict mode, with a TS eslint setting, TypeScript will actually shout warnings at you for this perfectly working function that even uses TypeScript! The error would look like this: Missing return type on function.</p><p>Rummaging through errors can be a headache, so in this article, we’re going to cover a list of errors and how to understand and resolve them, in depth. Since there are a ton of different errors in TypeScript, this chapter will be broken into many parts in an effort to cover a wide range of errors. Feel free to bookmark this and revisit it in case you run into any of these pesky errors in the future. Let’s begin!</p><h4>1. “Missing return type on function”</h4><p>Reason:</p><p>We didn’t tell TypeScript what we expect to be returned from the function. A lot of times, TypeScript can assume this, but in strict mode, it will expect you to declare this.</p><p>Solution:</p><p>Place a colon after the closing param of your function argument, and write the type(s) that you expect the function to return, like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*Esqxr45NoOGzAEDD550hEQ.jpeg" /><figcaption>a simple function, addTwoNumbers, which sums the first and second number provided. The function is assigned a number type as a return value</figcaption></figure><p><strong>Tip</strong>: If you’re not sure which type(s) can be returned from your function, you can hover over the function name in your text editor, and TypeScript will show you a return type that can be used. This will work 99% of the time!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*P-ZD5zGoV2zHjGQlaVzPWA.gif" /><figcaption>A GIF, showing how typescript interprets function return types</figcaption></figure><p>Why returning a type is important:</p><p>Functions can potentially return a lot of different results. Even something simple like addTwoNumbers could return number,NaN,null, void, or even a string depending on how you design it. Thus, TS wants you to be clear on listing all of the possible return values it should expect.</p><p>This is especially useful if you’re building an API that other people will work with. Helping them reliably know what data type(s) to expect can distinguish your API from others that don’t.</p><p>The cool part of returning a type is that as you refactor or update a function, if you accidentally (or unknowingly) forget to return an important, expected property, TS will let you know. Additionally, it can auto-complete a list of available properties for you to help you discover more about the data you’re working on within the code. We’ll cover all of this shortly.</p><p>We’re going to use this small application I made for this article to see several other errors (and benefits) in action. Feel free to poke around in there… we’ll cover it in detail.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Ftsguide-part1-zgmiiy%3Fembed%3D1%26file%3Dindex.ts&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Ftsguide-part1-zgmiiy%3Ffile%3Dindex.ts&amp;image=https%3A%2F%2Fsocial-img.staticblitz.com%2Fprojects%2Ftsguide-part1-zgmiiy%2F3068ade3b340aa366e356396e670079c&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/c47c33c616e2894597e91d18c39d6d2b/href">https://medium.com/media/c47c33c616e2894597e91d18c39d6d2b/href</a></iframe><p>Let’s unpack the application above. On line 25, we’re using a getUserByRole function to return some user data based on their role. In this application, the user can either be an admin, or a guest.</p><p>Using an interface, we can describe what an AdminUser and a GuestUser look like and communicate that to our function by putting :AdminUser | GuestUser after its argument body. This is how I like to visualize it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*PprmE7X3MDmt6DPqSNWcJA.jpeg" /><figcaption>A graph showing how interfaces are assigned to a method</figcaption></figure><p>Since we defined what an AdminUser and a GuestUser looks like, TypeScript can do a lot of cool things for us. Take this code for example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/008a9090660810d59494a25a90914862/href">https://medium.com/media/008a9090660810d59494a25a90914862/href</a></iframe><p>Just by writing if (role === &#39;admin&#39;), TypeScript can <em>tell</em> that we’re talking about the AdminUser and prepare to expect their specific shape of data to be returned. This is called Type Narrowing. It’s when you narrow down a list of types (officially called a union, it looks like this → type1 | type2) to a smaller, more specific list such as AdminUser | GuestUser to just AdminUser. TypeScript can figure this out by evaluating the properties belonging to the types that we provided.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*-qT-egbnM548dXM-uW35rg.jpeg" /></figure><p>TypeScript helps to provide a list of properties available for the AdminUser. This can give us useful insight into the object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*hI-Dgf1IdjcQgkXlg55uHg.gif" /></figure><p>Try it for yourself! In the application below, comment lines 33–35. Then, while your cursor is inside the object&#39;s body, press ctrl + I or cmd + I (for Mac) to get a full list of the properties that belong to the AdminUser!</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Ftsguide-part1-zgmiiy%3Fembed%3D1%26file%3Dindex.ts&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Ftsguide-part1-zgmiiy%3Ffile%3Dindex.ts&amp;image=https%3A%2F%2Fsocial-img.staticblitz.com%2Fprojects%2Ftsguide-part1-zgmiiy%2F3068ade3b340aa366e356396e670079c&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/c47c33c616e2894597e91d18c39d6d2b/href">https://medium.com/media/c47c33c616e2894597e91d18c39d6d2b/href</a></iframe><p><strong>Note</strong>: The properties list will only show the object properties that aren’t currently listed. So, if you’re already returning all of its properties, that command won’t show any more available properties.</p><p>What if we tried to check for a user with a role that doesn’t exist, like “writer”? Such as if (role === ‘writer’). That would lead us to our next error.</p><h4>2. This condition will always return ‘false’ since the types ‘UserRoles’ and ‘“writer”’ have no overlap.</h4><p>Reason:</p><p>One (or more) of the values we tried to compare don’t align with what TypeScript was told. In the application example above, this is because we only have two roles, “admin” and “guest.” A “writer” role doesn’t exist in our definition. Here’s how I like to visualize it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*0VwPou2G6K4g4CZCXCaurA.jpeg" /></figure><blockquote>This condition will always return ‘false’ since the types ‘UserRoles’ and ‘“writer”’ have no overlap</blockquote><p>Let’s break the error down word for word.</p><p>This condition — The conditional evaluation. That’s the if block, or it could be a ternary , etc. Anything that compares values and results in true or false.</p><p>will always return ‘false’ — It’s never going to run that body of code! It won’t step inside of the conditional, because it&#39;s always false… basically this: if(false) {/* will never run */}.</p><p>since the types ‘UserRoles’ — In this case, ‘UserRoles’ is the value that TypeScript is referencing as its source of truth. Please note that UserRoles is the name that I chose, it could be anything you want. In your application, this will match whichever type was provided to TS.</p><p>and ‘“writer”’ — This is the value you’re trying to use, which caused the error.</p><p>have no overlap — The value you’re trying to use does not exist within the source of truth (UserRoles) that TypeScript is referencing. You can either add it to the list that was provided to TS or stick with using one of the values in the union (UserRoles).</p><p>Solution:</p><p>One of the following will work:</p><p>A. Update the type UserRoles (in this example) to include “writer”, like so: type UserRoles = ‘admin’ | ‘guest’ | ‘writer’.</p><p>Or</p><p>B. Fallback to using a value provided in UserRoles (in this case, ‘admin’ or ‘guest’) so we get “overlap” in the values used.</p><p>For the next error (one of the most common in TS), hop into the text editor below and change any string value to a different data type, like a number. For example, on line 40, change guest123 to a number, like 2.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fstackblitz.com%2Fedit%2Ftsguide-part1-zgmiiy%3Fembed%3D1%26file%3Dindex.ts&amp;display_name=StackBlitz&amp;url=https%3A%2F%2Fstackblitz.com%2Fedit%2Ftsguide-part1-zgmiiy%3Ffile%3Dindex.ts&amp;image=https%3A%2F%2Fsocial-img.staticblitz.com%2Fprojects%2Ftsguide-part1-zgmiiy%2F3068ade3b340aa366e356396e670079c&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=stackblitz" width="745" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/c47c33c616e2894597e91d18c39d6d2b/href">https://medium.com/media/c47c33c616e2894597e91d18c39d6d2b/href</a></iframe><h4>3. Type ‘number’ is not assignable to type ‘string’</h4><p>Or Type ‘[TYPE_1]’ is not assignable to type ‘[TYPE_2]’</p><p>Reason:</p><p>We’re attempting to use a type that doesn’t match what TypeScript is expecting. The first type, TYPE_1, is what we are attempting to use. The other type, TYPE_2, is the one that TypeScript expected. Here’s how I like to visualize this error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*zc75r_g1yPIc3-v2q6y3sg.jpeg" /></figure><p>We told TypeScript that the role could only be “guest,” then we turned around and tried to set a number, 78, as the value for role. This happens often, especially with complex data and APIs that we didn’t build.</p><p>Solution:</p><p>Make your type match what is expected, or update the expectations. In the example above, one solution could be to change the number 78 to &quot;guest&quot; or, if we wanted to allow the number 78 specifically. We could update the GuestUser interface to allow 78 or any generic number value. Here’s an example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc9b7c95278407e7c5f3f4281c023017/href">https://medium.com/media/dc9b7c95278407e7c5f3f4281c023017/href</a></iframe><p>Thanks for reading. Stay tuned for more.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68a1c82d9303" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/the-typescript-guide-i-wish-i-had-reading-errors-part-1-68a1c82d9303">How To Read Errors in TypeScript</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The TypeScript Guide I Wish I Had]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/better-programming/the-typescript-guide-i-wish-i-had-185087d66dd1?source=rss-44fdfb49c749------2"><img src="https://cdn-images-1.medium.com/max/1051/1*nLfKiZrsKWLzcyQOlOuYXg.jpeg" width="1051"></a></p><p class="medium-feed-snippet">Learn TypeScript with visual guides and simple&#xA0;language</p><p class="medium-feed-link"><a href="https://medium.com/better-programming/the-typescript-guide-i-wish-i-had-185087d66dd1?source=rss-44fdfb49c749------2">Continue reading on Better Programming »</a></p></div>]]></description>
            <link>https://medium.com/better-programming/the-typescript-guide-i-wish-i-had-185087d66dd1?source=rss-44fdfb49c749------2</link>
            <guid isPermaLink="false">https://medium.com/p/185087d66dd1</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Conrad Davis Jr.]]></dc:creator>
            <pubDate>Thu, 18 Aug 2022 15:15:40 GMT</pubDate>
            <atom:updated>2022-09-07T16:51:09.896Z</atom:updated>
        </item>
    </channel>
</rss>