<?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 Ori Calvo on Medium]]></title>
        <description><![CDATA[Stories by Ori Calvo on Medium]]></description>
        <link>https://medium.com/@oricalvo?source=rss-291618f212bd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_aBo0efIkmtNMLHJ.jpg</url>
            <title>Stories by Ori Calvo on Medium</title>
            <link>https://medium.com/@oricalvo?source=rss-291618f212bd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 18:44:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@oricalvo/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[This simple flag reduces Typescript compilation timing by 50%]]></title>
            <link>https://medium.com/@oricalvo/this-simple-flag-reduces-typescript-compilation-timing-by-50-4afee0edb644?source=rss-291618f212bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/4afee0edb644</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[compilation]]></category>
            <dc:creator><![CDATA[Ori Calvo]]></dc:creator>
            <pubDate>Fri, 30 Aug 2024 16:37:01 GMT</pubDate>
            <atom:updated>2024-08-30T16:37:01.463Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*OcyfJNKp1tum7w9dgoGrNw.png" /></figure><p>I’ve just cloned the Typescript compiler source code. It’s been a while since I took a look at this repo. I am using Typescript a lot but didn’t spend much time looking at the source code of the compiler itself.</p><p>My idea was to investigate a bit the architecture of the compiler. You know, tokenizer, parser, checker and friends.</p><p>The first thing that caught my eyes was <a href="https://github.com/microsoft/TypeScript/blob/main/src/tsconfig.json">tsconfig.json</a>. It is always interesting to see what kind of configuration a complex project is using. Here it is:</p><pre>{<br>    &quot;files&quot;: [],<br>    &quot;include&quot;: [],<br>    &quot;references&quot;: [<br>        { &quot;path&quot;: &quot;./cancellationToken&quot; },<br>        { &quot;path&quot;: &quot;./compiler&quot; },<br>        { &quot;path&quot;: &quot;./deprecatedCompat&quot; },<br>        { &quot;path&quot;: &quot;./harness&quot; },<br>        { &quot;path&quot;: &quot;./jsTyping&quot; },<br>        { &quot;path&quot;: &quot;./server&quot; },<br>        { &quot;path&quot;: &quot;./services&quot; },<br>        { &quot;path&quot;: &quot;./testRunner&quot; },<br>        { &quot;path&quot;: &quot;./tsc&quot; },<br>        { &quot;path&quot;: &quot;./tsserver&quot; },<br>        { &quot;path&quot;: &quot;./typescript&quot; },<br>        { &quot;path&quot;: &quot;./typingsInstaller&quot; },<br>        { &quot;path&quot;: &quot;./typingsInstallerCore&quot; },<br>        { &quot;path&quot;: &quot;./watchGuard&quot; }<br>    ]<br>}</pre><p>Looks clean and simple. Nothing special.</p><p>Next file is <a href="https://github.com/microsoft/TypeScript/blob/main/src/tsconfig-base.json">tsconfig-base.json</a>:</p><pre>{<br>    &quot;compilerOptions&quot;: {<br>        &quot;rootDir&quot;: &quot;.&quot;,<br>        &quot;outDir&quot;: &quot;../built/local&quot;,<br><br>        &quot;pretty&quot;: true,<br>        &quot;lib&quot;: [&quot;es2020&quot;],<br>        &quot;target&quot;: &quot;es2020&quot;,<br>        &quot;module&quot;: &quot;NodeNext&quot;,<br>        &quot;moduleResolution&quot;: &quot;NodeNext&quot;,<br><br>        &quot;declaration&quot;: true,<br>        &quot;declarationMap&quot;: true,<br>        &quot;sourceMap&quot;: true,<br>        &quot;composite&quot;: true,<br>        &quot;emitDeclarationOnly&quot;: true,<br><br>        &quot;strict&quot;: true,<br>        &quot;strictBindCallApply&quot;: false,<br>        &quot;useUnknownInCatchVariables&quot;: false,<br>        &quot;noImplicitOverride&quot;: true,<br><br>        &quot;skipLibCheck&quot;: true,<br><br>        &quot;alwaysStrict&quot;: true,<br>        &quot;preserveConstEnums&quot;: true,<br>        &quot;newLine&quot;: &quot;lf&quot;,<br><br>        &quot;types&quot;: []<br>    }<br>}</pre><p>Hmmm, much more interesting. Did you notice a strange compilation flag?</p><p>skipLibCheck !!!</p><p>According to <a href="https://www.typescriptlang.org/tsconfig/#skipLibCheck">documentation</a>: “This can save time during compilation at the expense of type-system accuracy”</p><p>So I just throw it into my own project and execute a clean build.</p><p>Amazingly, <strong>it reduces compilation time from 104 to 51 seconds</strong>. More than 50% reduction.</p><p>At this point, you are probably wondering what is the “safety” price we are paying for the time reduction.</p><p>Actually, not much. This flag tells the Typescript compiler to NOT check external libraries .d.ts files.</p><p>A .d.ts file is still parsed, and any source code is checked against it. However, the .d.ts file is NOT type checked against other libraries. So as long as you are willing to assume all .d.ts are correct you can safely use the skipLibCheck flag.</p><p>If the Typescript project is OK with the skipLibCheck flag, I guess I am OK with it too.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4afee0edb644" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Type safe CLI parser]]></title>
            <link>https://medium.com/@oricalvo/type-safe-cli-parser-364ddc21aa8b?source=rss-291618f212bd------2</link>
            <guid isPermaLink="false">https://medium.com/p/364ddc21aa8b</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[cli]]></category>
            <dc:creator><![CDATA[Ori Calvo]]></dc:creator>
            <pubDate>Mon, 26 Aug 2024 16:09:47 GMT</pubDate>
            <atom:updated>2024-08-26T16:09:47.854Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/763/1*nkzL1OFzd1071KhkbnGRQw.png" /></figure><p>Later or sooner you will find yourself parsing/reading CLI parameters</p><p>Writing the actual parsing logic is not fun so you probably will be using an NPM package</p><p>The most popular CLI parser these days is <a href="https://www.npmjs.com/package/yargs">yargs</a> with more than 80M weekly downloads</p><p>While being simple and quite flexible, <a href="https://www.npmjs.com/package/yargs">yargs </a>is not type safe</p><p>Another option is using <a href="https://www.npmjs.com/package/oclif">oclif</a> which is a complete framework for writing CLI applications. It supports plugins, classes as commands and more. <br>For me, it is too much</p><p>I am expecting a CLI parser to offer the following simple API which can be used anywhere in my application:</p><pre>const cli = read({<br>    name: Schema.string(),<br>});<br><br>console.log(&quot;Hello &quot; + cli.name);</pre><pre>$ node main.js --name World<br>Hello World</pre><p>A more complex example would support other Schema types like boolean, number, date, enum and arrays:</p><pre>const cli = read({<br>    name: Schema.string(), // Parameter --name is required<br>    id: Schema.number(), // Parameter --id is required (must be a number)<br>    verbose: Schema.boolean(&quot;v&quot;, false), // Parameter --v is optional<br>    emails: Schema.stringArray(&quot;email&quot;) // Parameter --email is a list of strings. For example, &quot;abc cde efg&quot;<br>});<br><br>console.log(&quot;Name: &quot; + cli.name);<br>console.log(&quot;ID: &quot; + cli.id);<br>console.log(&quot;Verbose: &quot; + cli.verbose);<br>console.log(&quot;Emails: &quot; + cli.emails);</pre><pre>$ node main.js --name Roni --id 1 --email &quot;oc1@g.com oc2@g.com&quot;<br>Name: Roni<br>ID: 1<br>Vervose: true<br>Emails: oc1@g.com oc2@g.com</pre><p>Take a look at <a href="https://www.npmjs.com/package/@ocfx/cli">@ocfx/cli</a> which supports exactly that API</p><p>What a strange coincidence …</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=364ddc21aa8b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>