<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Teshane Crawford</title>
    <description>The latest articles on DEV Community by Teshane Crawford (@teshanecrawford).</description>
    <link>https://dev.to/teshanecrawford</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F638982%2Fcf6ffbcb-46b6-4d0a-b435-e6a92d27cf7f.jpg</url>
      <title>DEV Community: Teshane Crawford</title>
      <link>https://dev.to/teshanecrawford</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/teshanecrawford"/>
    <language>en</language>
    <item>
      <title>Dealing with the '--downlevelIteration' Error in TypeScript</title>
      <dc:creator>Teshane Crawford</dc:creator>
      <pubDate>Fri, 25 Aug 2023 20:15:52 +0000</pubDate>
      <link>https://dev.to/teshanecrawford/dealing-with-the-downleveliteration-error-in-typescript-4c9i</link>
      <guid>https://dev.to/teshanecrawford/dealing-with-the-downleveliteration-error-in-typescript-4c9i</guid>
      <description>&lt;p&gt;In the world of TypeScript development, encountering errors is a common occurrence. One such error that developers might encounter is the &lt;code&gt;Type 'string' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher error&lt;/code&gt; message. This error often arises when you're working with string iterations in a certain configuration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Error
&lt;/h2&gt;

&lt;p&gt;The error message is quite clear, suggesting that when you're dealing with string iteration, you need to enable the &lt;code&gt;'--downlevelIteration'&lt;/code&gt; flag or set the &lt;code&gt;'--target'&lt;/code&gt; compiler option to 'es2015' or a higher version. This error typically shows up when using a for...of loop to iterate over a string.&lt;/p&gt;

&lt;h2&gt;
  
  
  Resolving the Error
&lt;/h2&gt;

&lt;p&gt;Let's look at the solutions to resolve this error:&lt;/p&gt;

&lt;h2&gt;
  
  
  Using '--downlevelIteration' Flag
&lt;/h2&gt;

&lt;p&gt;To address the error, you can make use of the '--downlevelIteration' flag during compilation. This flag enables downlevel iteration for iterating over strings using a for...of loop. Here's how you can use it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;tsc &lt;span class="nt"&gt;--downlevelIteration&lt;/span&gt; your-file.ts

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Adjusting the '--target' Compiler Option
&lt;/h2&gt;

&lt;p&gt;Another way to resolve the error is by adjusting the '--target' compiler option to 'es2015' or a higher version in your TypeScript configuration (tsconfig.json):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"compilerOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"target"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"es2015"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;other&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;options&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will allow you to use for...of loops with strings without encountering the error.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution with 'importHelpers'
&lt;/h2&gt;

&lt;p&gt;This option, 'importHelpers', is handy for dealing with common helper functions, like iterating strings. When enabled, TypeScript emits import statements for helper functions. To utilize this::&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"compilerOptions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"importHelpers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;...&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;other&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;options&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using Array.from()
&lt;/h2&gt;

&lt;p&gt;It's crucial to remember that TypeScript's compiler options provide flexibility. If '--downlevelIteration' and 'importHelpers' don't fit your project's context, alternative solutions, like using Array.from(), exist.:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;myString&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Hello, world!&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;charArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;myString&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;char&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;charArray&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;char&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;TypeScript errors might seem daunting at first, but with a bit of understanding and the right adjustments, they can be easily resolved. In the case of the &lt;code&gt;Type 'string' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher&lt;/code&gt; error, you can either enable the '--downlevelIteration' flag, adjust the '--target' compiler option, or use Array.from() to successfully iterate over strings without any hassle. Keep experimenting and referring to TypeScript's official documentation for the best outcomes. &lt;strong&gt;Happy coding!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>react</category>
    </item>
    <item>
      <title>Demystifying Namespace Naming in C# and .NET</title>
      <dc:creator>Teshane Crawford</dc:creator>
      <pubDate>Fri, 25 Aug 2023 18:09:21 +0000</pubDate>
      <link>https://dev.to/teshanecrawford/demystifying-namespace-naming-in-c-and-net-2d2n</link>
      <guid>https://dev.to/teshanecrawford/demystifying-namespace-naming-in-c-and-net-2d2n</guid>
      <description>&lt;p&gt;Namespaces play a crucial role in organizing code within software projects, providing a structured hierarchy that helps developers manage complexity and avoid naming conflicts. Properly naming namespaces is essential for creating clear and maintainable codebases. In this article, we will explore the best practices for naming namespaces based on established guidelines.&lt;/p&gt;

&lt;h2&gt;
  
  
  Namespace Naming Template
&lt;/h2&gt;

&lt;p&gt;When naming namespaces, the primary goal is to ensure that the namespace's purpose is immediately apparent to developers using the framework. To achieve this, Microsoft's Framework Design Guidelines offer a naming template:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Company&amp;gt;.(&amp;lt;Product&amp;gt;|&amp;lt;Technology&amp;gt;)[.&amp;lt;Feature&amp;gt;][.&amp;lt;Subnamespace&amp;gt;]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's a breakdown of the components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;&amp;lt;Company&amp;gt;&lt;/code&gt;: Prefix the namespace name with the company's name. This helps prevent clashes between namespaces from different organizations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;(&amp;lt;Product&amp;gt;|&amp;lt;Technology&amp;gt;)&lt;/code&gt;: At the second level, use a stable and version-independent product or technology name. This provides context about the domain of the namespace.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;[.&amp;lt;Feature&amp;gt;]&lt;/code&gt;: Optionally, include a feature name to further clarify the purpose of the namespace.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;[.&amp;lt;Subnamespace&amp;gt;]&lt;/code&gt;: For additional organization, use subnamespaces to group related functionalities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use PascalCasing for namespace names&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For instance, consider the following examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Fabrikam.Math
Litware.Security

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Dos and Don'ts
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Do&lt;/strong&gt; prefix namespace names with a company name to avoid conflicts between namespaces from different companies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Do&lt;/strong&gt; use a stable, version-independent product or technology name at the second level of the namespace.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Don't&lt;/strong&gt; base namespace names on organizational hierarchies, as they tend to change frequently. Instead, organize namespaces around related technologies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**Do **use PascalCasing and separate namespace components with periods (e.g., Microsoft.Office.PowerPoint).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Consider&lt;/strong&gt; using plural namespace names where appropriate, except for brand names and acronyms. For example, prefer &lt;code&gt;System.Collections&lt;/code&gt; over &lt;code&gt;System.Collection.&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Don't&lt;/strong&gt; use the same name for a namespace and a type within that namespace to avoid conflicts.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Don't&lt;/strong&gt; introduce generic type names like Element, Node, Log, and Message. Qualify generic type names to avoid conflicts (e.g., FormElement, XmlNode).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Namespace and Type Name Conflicts
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Don't&lt;/strong&gt; use the same name for types in namespaces within a single application model. This ensures clarity and avoids confusion.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Don't&lt;/strong&gt; give types names that conflict with Core namespaces (e.g., &lt;code&gt;Stream&lt;/code&gt; conflicting with &lt;code&gt;System.IO.Stream&lt;/code&gt;).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Don't&lt;/strong&gt; introduce type name conflicts within a single technology namespace group.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Avoid&lt;/strong&gt; conflicts between types in technology namespaces and application model namespaces unless intended.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Choosing appropriate names for namespaces is a critical aspect of maintaining a well-organized and easily understandable codebase. By adhering to these best practices, you can enhance code clarity, prevent conflicts, and make the development process smoother. Following these guidelines will lead to a more efficient and maintainable codebase in the long run.&lt;/p&gt;

&lt;p&gt;I hope this blog post has been helpful. If you have any questions, please feel free to leave a comment below.&lt;/p&gt;

&lt;p&gt;(Portions of this article are from "&lt;em&gt;Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries, 2nd Edition" by Krzysztof Cwalina and Brad Abrams, published Oct 22, 2008, by Addison-Wesley Professional&lt;/em&gt;.)&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
      <category>productivity</category>
    </item>
    <item>
      <title>JS Skills Sharpen</title>
      <dc:creator>Teshane Crawford</dc:creator>
      <pubDate>Sat, 26 Jun 2021 23:28:28 +0000</pubDate>
      <link>https://dev.to/teshanecrawford/js-skills-sharpen-491c</link>
      <guid>https://dev.to/teshanecrawford/js-skills-sharpen-491c</guid>
      <description>&lt;p&gt;Starting today I'll be sharpening my JS skill&lt;/p&gt;

</description>
      <category>100daysofcode</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
    <item>
      <title>100 Days Of Coding</title>
      <dc:creator>Teshane Crawford</dc:creator>
      <pubDate>Thu, 27 May 2021 21:25:34 +0000</pubDate>
      <link>https://dev.to/teshanecrawford/100-days-of-coding-5g0d</link>
      <guid>https://dev.to/teshanecrawford/100-days-of-coding-5g0d</guid>
      <description>&lt;p&gt;Today I take up the challenge of 100daysofcode&lt;/p&gt;

</description>
      <category>100daysofcode</category>
    </item>
  </channel>
</rss>
