<?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 Lorenzo on Medium]]></title>
        <description><![CDATA[Stories by Lorenzo on Medium]]></description>
        <link>https://medium.com/@LRNZ09?source=rss-156198c2ef8a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AxQ2ywgRG3nnoXxnWK32mA@2x.jpeg</url>
            <title>Stories by Lorenzo on Medium</title>
            <link>https://medium.com/@LRNZ09?source=rss-156198c2ef8a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 09:27:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@LRNZ09/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[TypeScript Path Aliases: Why Your Prefix Choice Matters More Than You Think]]></title>
            <link>https://medium.com/@LRNZ09/typescript-path-aliases-why-your-prefix-choice-matters-more-than-you-think-787963f27429?source=rss-156198c2ef8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/787963f27429</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Lorenzo]]></dc:creator>
            <pubDate>Wed, 06 Aug 2025 21:26:56 GMT</pubDate>
            <atom:updated>2025-08-06T21:26:56.313Z</atom:updated>
            <content:encoded><![CDATA[<p>A deep dive into the hidden conflicts of popular path alias conventions and better alternatives.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wqNH1hAZAJRCAZkK" /><figcaption>Photo by <a href="https://unsplash.com/@mikeenerio?utm_source=medium&amp;utm_medium=referral">Mike Enerio</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you’ve been working with TypeScript for a while, you’ve probably discovered the magic of path aliases. They transform ugly relative imports like ../../../components/radio-group into clean, readable ones like @/components/radio-group. But have you ever stopped to consider why everyone uses @ as a prefix? And more importantly, is it the best choice?</p><blockquote>Spoiler alert: it’s not.</blockquote><h3>The Problem Everyone Ignores</h3><p>Walk into any TypeScript project today, and you’ll likely see a tsconfig.json that looks like this:</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;baseUrl&quot;: &quot;.&quot;,<br>    &quot;paths&quot;: {<br>      &quot;@/*&quot;: [&quot;./src/*&quot;],<br>      &quot;@components/*&quot;: [&quot;./src/components/*&quot;],<br>      &quot;@types/*&quot;: [&quot;./src/types/*&quot;],<br>      &quot;@utils/*&quot;: [&quot;./src/utils/*&quot;]<br>    }<br>  }<br>}</pre><p>It’s everywhere. Next.js uses it, Vue CLI uses it, and numerous tutorials recommend it. But most developers overlook a fundamental issue: <strong>the </strong><strong>@ symbol is already claimed by npm-scoped packages</strong>.</p><h3>The Scoped Package Conflict</h3><p>When you write import { debounce } from &#39;@lodash/debounce&#39;, you&#39;re importing from a scoped npm package. The @ symbol has a specific meaning in the Node.js ecosystem, denoting package organizational namespaces.</p><p>Now, when you also use @ for your local path aliases, you create potential conflicts and confusion. Consider these problematic patterns:</p><pre>import type { Buffer } from &#39;@types/node&#39;              // npm package<br>import { RadioGroup } from &#39;@/components/radio-group&#39;  // Your local file  <br>import type { User } from &#39;@types/user&#39;;               // Wait, is this local or npm?<br>import { debounce } from &#39;@lodash/debounce&#39;;           // npm package</pre><p>The @types/user import is especially confusing — is this a type definition from npm&#39;s @types organization, or is it from your local types folder? This ambiguity makes the code harder to read and understand.</p><h3>Other Problematic Alternatives</h3><p>“Okay,” you might think, “I’ll just use ~ instead.” Many Vue.js projects do exactly this:</p><pre>{<br>  &quot;paths&quot;: {<br>    &quot;~/*&quot;: [&quot;./src/*&quot;]<br>  }<br>}</pre><p>But ~ is also taken. On Unix-like systems (macOS, Linux), the tilde is a filesystem alias for the user&#39;s home directory. While this doesn&#39;t cause technical conflicts in most cases, it adds cognitive overhead.</p><p>Similarly, other symbols have their issues. The dollar sign ($) might seem like a clean alternative. Still, it’s heavily used in regex patterns. It can cause problems with tools; for example, GitHub’s search interprets $/components as a regex pattern and throws the error “Searching for this literally, slashes must surround regular expressions.”</p><h3>The Better Alternative: The Hash Symbol</h3><p>So what should you use instead? The answer is elegantly simple: the hash symbol (#).</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;baseUrl&quot;: &quot;.&quot;,<br>    &quot;paths&quot;: {<br>      &quot;#/*&quot;: [&quot;./src/*&quot;]<br>    }<br>  }<br>}</pre><p>The hash symbol is perfect for this use case for several reasons:</p><ol><li><strong>No conflicts</strong>: It doesn’t clash with npm-scoped packages, filesystem conventions, or other established patterns.</li><li><strong>Visual distinction</strong>: It marks path aliases while remaining visually similar to @.</li><li><strong>Keyboard intuition</strong>: On some keyboard layouts (like the US one), # sits next to @, making the mental connection between scoped packages and local aliases natural.</li><li><strong>Growing adoption</strong>: Modern projects are increasingly adopting this convention.</li><li><strong>IDE support</strong>: Most editors provide excellent autocomplete and navigation for # prefixed imports.</li></ol><p>Your imports become clean and unambiguous:</p><pre>import { debounce } from &#39;@lodash/debounce&#39;;            // npm package - no confusion<br>import type { Buffer } from &#39;@types/node&#39;;              // npm package - clearly external<br>import { RadioGroup } from &#39;#/components/radio-group&#39;;  // Local file - clear and clean<br>import type { User } from &#39;#/types/user&#39;;               // Another local file</pre><p>The hash symbol serves as a simple shortcut to your source directory, nothing more. It doesn’t try to rename or alias your actual folder structure — it just provides a clean path to reach it.</p><p>The keyboard proximity is particularly elegant. When you’re typing imports, @ and # are neighbors on your keyboard, creating an intuitive pairing: @ for external packages, # for internal modules.</p><h3>Why This Matters</h3><p>You might be thinking, “This is a minor issue. TypeScript resolves everything correctly anyway.” And you’d be partially right. But consider these factors:</p><ol><li><strong>Code clarity</strong>: New developers should be able to distinguish between local and external imports immediately.</li><li><strong>Tooling reliability</strong>: Some tools and IDEs handle ambiguous prefixes less gracefully.</li><li><strong>Future-proofing</strong>: As your project grows and adds more dependencies, conflicts become more likely.</li><li><strong>Best practices</strong>: Following established conventions prevents confusion.</li></ol><h3>Making the Switch</h3><p>If starting a new project, use #/* from the beginning. If you&#39;re working with an existing codebase that uses @/*, the migration is usually straightforward with find-and-replace. However, you’ll want to be careful not to change the actual scope of package imports.</p><p>Most bundlers and tools (Webpack, Vite, etc.) will need similar configuration updates to match your tsconfig paths. Modern build tools like Vite and Next.js typically respect tsconfig path mappings automatically, making the transition smoother.</p><h3>The Bottom Line</h3><p>The @/* convention became popular because major frameworks adopted it early, but that doesn&#39;t make it the best choice. The hash symbol (#) provides all the benefits of clean path aliases while avoiding namespace conflicts and maintaining intuitive keyboard ergonomics.</p><p>Choosing #/* for your path aliases creates a cleaner, more maintainable codebase with a clear visual distinction between local and external imports.</p><p><em>What path alias prefix do you prefer? Have you encountered any conflicts with conventional approaches? Share your experiences in the comments below.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=787963f27429" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Property-based Testing: An Introduction with TypeScript]]></title>
            <link>https://medium.com/welld-tech/property-based-testing-a-hands-on-introduction-with-typescript-c4d0703a5772?source=rss-156198c2ef8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4d0703a5772</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Lorenzo]]></dc:creator>
            <pubDate>Thu, 15 Feb 2024 07:31:29 GMT</pubDate>
            <atom:updated>2025-08-06T21:20:49.355Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Property-based Testing: An Introduction With TypeScript</h3><p>Property-based testing has gained popularity in the programming community as an alternative approach to software testing. It covers the same scope as example-based testing, from unit to integration tests. What are the reasons that make it so best-selling?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9RjK7T2T2DuZiqR3" /><figcaption>Photo by <a href="https://unsplash.com/@maximalfocus?utm_source=medium&amp;utm_medium=referral">Maximalfocus</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This article will introduce property-based testing using fast-check, a JavaScript framework; you can find more about the library here: <a href="https://github.com/dubzzz/fast-check">https://github.com/dubzzz/fast-check</a>. However, the examples can also be adapted to other languages and testing frameworks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*t0FowzclzmQRCJKCbZJ91A.png" /><figcaption>fast-check logo</figcaption></figure><h3>Is it worth it?</h3><p>Let’s first look at the various automated testing techniques available that we apply to verify the accuracy of our code, mapped out on two axes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*XNsgVsAU1cnyhbNgWFzC0w.png" /><figcaption>Automated testing techniques available</figcaption></figure><p>— Feature compliance (the X axis), whether the code correctly executes the desired feature</p><p>— Input scope coverage (the Y axis), the extent to which all possible inputs are accounted for</p><p>When writing tests, we often emphasize the importance of examples, particularly when adopting approaches such as <em>“Specification by examples”</em>. Samples are incredibly beneficial when comprehending requirements, as they clearly and concisely explain what needs to be accomplished.</p><p><em>1. Given this input<br>2. I invoke something<br>3. And I expect that output</em></p><blockquote>This approach&#39;s limitation is that we will only focus on the input scope we identified, and there may still be instances where these methods are insufficient.</blockquote><p>Imagine an approach as powerful as example-based testing for feature compliance checking that also covers a much more critical number of inputs.</p><p>This is where property-based testing can be helpful.</p><h3>What is “property-based testing”?</h3><p>Property-based testing is a powerful technique that doesn’t require specific examples of inputs and expected outputs. Instead, it utilizes a generative engine to create randomized inputs that <strong>ensure correct feature requirements</strong>.</p><p>The secret to property-based testing is all about properties! These tests are designed to verify that a property remains true under various inputs, significantly reducing the number of tests required with different examples instead. These properties don’t necessarily have to provide detailed output information, but they must check for specific characteristics needed for the output.</p><p>A property looks like:</p><p><em>for any (x, y, …)<br>such that precondition(x, y, …) holds<br>predicate(x, y, …) is true</em></p><p>Something similar is commonly found in functional programming, where we prioritize the creation of pure functions. These functions consistently produce the same output given the same input and have no side effects, i.e., they don’t modify any state outside their scope, making them predictable and manageable to test.</p><h4>👣 Going further</h4><p>Suppose we have a crop function that takes a string and the maximal length we accept.</p><pre>const crop = (input: string, maxLength: number): string =&gt;<br>  input.substring(0, maxLength)</pre><p>We could write the following property:</p><pre>fc.property(<br>  fc<br>    .record({<br>      input: fc.string(),<br>      maxLength: fc.nat(),<br>    })<br>    .filter(({ input, maxLength }) =&gt; input.length &lt;= maxLength),<br>  ({ input, maxLength }) =&gt; {<br>    return crop(input, maxLength) === input<br>  },<br>)</pre><p>It states that when the crop function receives an input shorter than or as long as the maximum length, the output will be identical to the input.</p><p>It also relies on fc.filter to filter out invalid entries (input strings longer than the generated maxLength number). Be aware that many values could be rejected when the filtering is too strict, with only a few kept. Consequently, it’s recommended to rely on options directly provided by the arbitraries rather than filtering them whenever feasible. For instance, if you want to generate strings having at least two characters, you should prefer fc.string({ minLength: 2 }) over fc.string().filter(s =&gt; s.length &gt;= 2).</p><h3>Property, arbitrary, and predicate</h3><p>Let’s deep dive into what a property describes:</p><ol><li>How to generate the inputs of the predicate — <em>via arbitraries</em></li><li>What the user wants to assess — <em>via a predicate</em></li></ol><pre>fc.property(<br>  ...arbitraries // how to generate the values received as inputs of the predicate<br>  predicate // how to check if the code worked<br>)</pre><p>An arbitrary function is responsible for generating random values in a seeded way and shrinking them if requested. In the example above, we only used fc.record, fc.nat, and fc.string. But there are many other built-in ones, and you can produce an infinite number just by combining existing ones.</p><p>On the other hand, the predicate is a function that takes the values produced by the declared arbitraries as inputs and returns either a boolean value or directly asserts. For instance, our first property could also have leveraged assertions by using the following predicate:</p><pre>({ input, maxLength }) =&gt; {<br>  expect(crop(input, maxLength)).toBe(input)<br>  // return crop(input, maxLength) === input // &lt;-- the boolean version<br>}</pre><p>If you are wondering what the generated inputs are for our predicate, we can wrap our property with fc.sample and log its result. Inputs may be generated, such as the following:</p><pre>[<br>  // ...<br>  [{ input: &quot;A eQX*&amp;[&quot;, maxLength: 4 }],<br>  [{ input: &quot;I%*lfmdgs}&quot;, maxLength: 8 }],<br>  [{ input: &quot;valueOf&quot;, maxLength: 2 }],<br>  [{ input: &quot;ga *Jk(k0&quot;, maxLength: 4 }],<br>  [{ input: &quot;key&quot;, maxLength: 2 }],<br>  [{ input: &quot;$ookupGett&quot;, maxLength: 2 }],<br>  [{ input: &quot;isProtot&quot;, maxLength: 0 }],<br>  [{ input: &quot;qyi8x5o`&quot;, maxLength: 0 }],<br>  [{ input: &quot;-:$FLkc@/&quot;, maxLength: 8 }],<br>  [{ input: &quot;Ncallerapp&quot;, maxLength: 9 }],<br>  [{ input: &quot;arguments&quot;, maxLength: 6 }],<br>  [{ input: &quot;__lookupSe&quot;, maxLength: 4 }],<br>  [{ input: &quot;\&quot;#ySP#&amp;S\&quot;&quot;, maxLength: 6 }],<br>  [{ input: &quot;.r]o-; s\\\&quot;&quot;, maxLength: 7 }],<br>  [{ input: &quot;toString&quot;, maxLength: 2 }],<br>  [{ input: &quot;~[?!Zl&gt;i&quot;, maxLength: 6 }],<br>  [{ input: &quot;pI&lt;-*)79r&quot;, maxLength: 1 }],<br>  [{ input: &quot;:&quot;, maxLength: 0 }],<br>  // ...<br>]</pre><h4>🐛 Designed for bugs</h4><p>The goal of property-based testing is not to generate random data, but instead to find bugs. Property-based testing frameworks are designed to <strong>detect common problems with a higher probability</strong>.</p><p>For instance, it is almost impossible to generate an array with duplicated 32-bit integer values randomly. However, property-based testing can create such an array and other common values that trigger issues, such as -1, 0, or even dangerous strings like __proto__ in JavaScript. As you can see, some generated strings are entirely random, while others refer to common keywords we can find in a JavaScript/TypeScript environment, such as valueOf, arguments, toString, etc.</p><h3>Runners and assertions</h3><p>fast-check has several runners. Runners are responsible for interpreting and possibly executing the properties, or at least part of them. The most common runner is fc.assert, which takes a property and runs it multiple times.</p><h4>🚦 Designed for users</h4><p>Property-based testing involves randomizing inputs to find bugs and helping users find and fix the errors. Property-based testing frameworks have what we refer to as <strong>shrinking capabilities</strong>.</p><p>If a test fails for some input, instead of stopping immediately, fc.assert will attempt to report another input that is simpler to understand and investigate, which caused the error. In general, long inputs containing many complex characters or values tend to guide the developer down the wrong track. With shrinker, this useless noise will be dropped, and the failure being reported will only focus on the minimal input to make the predicate fail.</p><p>Here’s how a test for our crop function defined above that uses the related property and fc.assert might look like:</p><pre>const lessThanOrEqualArbitrary = fc.nat().chain((maxLength) =&gt;<br> fc.record({<br>  input: fc.string({ maxLength }),<br>  maxLength: fc.constant(maxLength),<br> }),<br>)<br><br>// Add a max cap to improve the test duration<br>const moreThanArbitrary = fc.nat({ max: 10000 }).chain((length) =&gt;<br> fc.record({<br>  expectedOutput: fc.string({ minLength: length, maxLength: length }),<br>  partialInput: fc.string({ minLength: 1 }),<br>  maxLength: fc.constant(length),<br> }),<br>)<br><br>describe(&#39;crop&#39;, () =&gt; {<br> test(&#39;the input is shorter than or as long as the maximum length&#39;, () =&gt; {<br>  fc.assert(<br>   fc.property(lessThanOrEqualArbitrary, ({ input, maxLength }) =&gt; {<br>    expect(crop(input, maxLength)).toBe(input)<br>   }),<br>  )<br> })<br><br> test(&#39;the input is longer than the maximum length&#39;, () =&gt; {<br>  fc.assert(<br>   fc.property(<br>    moreThanArbitrary,<br>    ({ partialInput, maxLength, expectedOutput }) =&gt; {<br>     const input = `${expectedOutput}${partialInput}`<br>     const output = crop(input, maxLength)<br><br>     expect(output).toBe(expectedOutput)<br>    },<br>   ),<br>  )<br> })<br>})</pre><p>Since we previously recommended preferring arbitrary options rather than fc.filter when possible, in this example, fc.chain is involved instead, which acts as a flat-map of an existing arbitrary.</p><p>Moreover, all tests are launched with a precise seed, so you will get the same set of values every time, making it easy to reproduce errors.</p><h4>🧩 Document the code</h4><p>Property-based testing can help to document the <strong>code’s behavior at a high level</strong>. When testing a sorting algorithm, for example, property-based tests could specify anticipated invariants, like ensuring the resulting array maintains identical values as the source array and is sorted in ascending order.</p><blockquote>By writing property-based tests, you capture the essence of what the code should do.</blockquote><h3>Conclusion</h3><p>There’s no doubt about the efficiency of bug-detection capabilities provided by fast-check. It has successfully identified bugs in key open-source projects within the JavaScript/TypeScript ecosystem, including <a href="https://github.com/facebook/react/issues/18661">react</a>, <a href="https://github.com/gcanti/io-ts/issues/214">io-ts</a> and <a href="https://github.com/jestjs/jest/issues/7941">jest</a>.</p><p>Finally, fast-check provides official integrations with popular test runners such as the aforementioned jest, plus ava and vitest. Beyond offering enhanced versions of test and it functions, these integrations seamlessly synchronize timeouts, eliminating the need for separate timeout configurations and ensuring a hassle-free experience out-of-the-box.</p><p>Some more code examples can be found at <a href="https://github.com/dubzzz/fast-check/tree/main/examples">https://github.com/dubzzz/fast-check/tree/main/examples</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4d0703a5772" width="1" height="1" alt=""><hr><p><a href="https://medium.com/welld-tech/property-based-testing-a-hands-on-introduction-with-typescript-c4d0703a5772">Understanding Property-based Testing: An Introduction with TypeScript</a> was originally published in <a href="https://medium.com/welld-tech">WellD Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>