<?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 Samuel Briole on Medium]]></title>
        <description><![CDATA[Stories by Samuel Briole on Medium]]></description>
        <link>https://medium.com/@samuelbriole?source=rss-9a535aec5037------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nlgzDb8fMLlRZaECKP5y4w.jpeg</url>
            <title>Stories by Samuel Briole on Medium</title>
            <link>https://medium.com/@samuelbriole?source=rss-9a535aec5037------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 10 May 2026 15:27:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@samuelbriole/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[Migrating from Flow to Typescript: Why ? How ? Worth it ?]]></title>
            <link>https://medium.com/inato/migrating-from-flow-to-typescript-why-how-worth-it-5b7703d12089?source=rss-9a535aec5037------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b7703d12089</guid>
            <category><![CDATA[flow]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[developer-tools]]></category>
            <dc:creator><![CDATA[Samuel Briole]]></dc:creator>
            <pubDate>Fri, 12 Apr 2019 12:32:25 GMT</pubDate>
            <atom:updated>2019-06-20T08:27:24.175Z</atom:updated>
            <content:encoded><![CDATA[<h3>Migrating from Flow to Typescript: Why? How? Worth it?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-AZ2Nc_PY0N0nXNfmgVkRQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/photos/WPmPsdX2ySw?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Gary Bendig</a> on <a href="https://unsplash.com/search/photos/birds-migrating?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>When I arrived at Inato, the codebase was written in ES6. Then, we added some robustness with Flow. It helped us perform major refactors and lower our bug count. We were happy… until problems showed up.</p><h3>Problems we had with Flow</h3><ul><li>Flow takes a lot of RAM and computing resources (we witnessed &gt; 10 Go of RAM).</li><li>The integration with text editors is not state-of-the-art. We could not find a way to make auto-completion and auto-imports work in VSCode.</li><li>There is no official support for exporting type definitions from a module (this is painful when we split our code into different modules)</li><li>For some npm packages, either typings are missing in flow-typed, or typings are incomplete / out of date. For instance formik and styled-components have poor flow definitions. This makes the code less safe.</li></ul><h3>Project-specific problems we had with Flow</h3><ul><li>React typings are bound to Flow’s version. After we upgraded React to 16.8.4 in order to use hooks, we wrote some unsatisfying $FlowFixMe</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*nmjBogbAQSCVGA6q_vILlg.png" /></figure><ul><li>In thereact-relay library, the typing of createFragmentContainer is wrong, and breaks the type safety for numerous components. (<a href="https://github.com/facebook/relay/issues/2316">see the GitHub issue</a>)</li></ul><h3>Exploring alternatives to Flow</h3><p>What are the other typed languages that compile to Javascript? Typescript and ReasonML seem to be the best candidates.</p><ul><li>ReasonML produces very safely typed code. The syntax is quite different from ES6 though, and the ecosystem looks young.</li><li>Typescript is a great typed language with a large community. The ecosystem is mature and the syntax is similar to ES6. This is obviously the best choice for us.</li></ul><h3>How to migrate to Typescript</h3><ul><li>If you use Flow, you probably use Babel. Upgrade to babel 7 to use the Typescript preset.</li><li>Install typescript (yarn install typescript)</li><li>Add a tsconfig.json file at the project root. Use&quot;strict&quot;: false in the compiler options.</li><li>Change the file extensions from .js to .ts (or .tsx if your project uses JSX). You can run this command to rename all files at once in the .ts extension:</li></ul><pre>find src -name &quot;*.js&quot; -exec sh -c &#39;mv &quot;$0&quot; &quot;${0%.js}.ts&quot;&#39; {} \;</pre><ul><li>Monitor the errors: yarn tsc --noEmit --watch. You will see a lot of syntax errors. You can fix most of them with a couple of regexes:</li></ul><pre>Search and replace:</pre><pre>{| ⇒ {<br>|} ⇒ }<br>import type ⇒ import<br>$ReadonlyArray ⇒ ReadonlyArray<br>$NonMaybeType ⇒ NonNullable</pre><pre>Regexes:</pre><pre>\+(\w+) ⇒ readonly $1<br>: \?(\w+&lt;?\w*&gt;?) ⇒ : $1 | null | undefined<br>&lt;\?(\w+)&gt; ⇒ &lt;$1 | null | undefined&gt;<br>\$PropertyType&lt;(\w+), (&#39;?\w+&#39;?)&gt; ⇒ $1[$2]</pre><ul><li>After your syntax errors count has gone to 0, you will see a lot of new errors. These are type errors ! There is no generic way to fix them, handle them one by one (this is the longer part of the process).</li><li>Update your babel config. It should look like this:</li></ul><pre>{<br>  &quot;presets&quot;: [&quot;@babel/env&quot;, &quot;@babel/typescript&quot;],<br>  &quot;plugins&quot;: [<br>    &quot;@babel/proposal-class-properties&quot;,<br>    &quot;@babel/proposal-object-rest-spread&quot;<br>  ]<br>}</pre><ul><li>Update your linter. If you’re using ESLint, use <a href="https://github.com/typescript-eslint/typescript-eslint">@typescript-eslint</a></li><li>Update your test suite. If you’re using Jest, use ts-jest</li></ul><h3>Is it worth it?</h3><p>YES! Definitely!<br>We’ve eliminated almost all problems we had with Flow. We’re still having small issues with composite projects, but overall it’s a great improvement.</p><ul><li>The Typescript integration in VSCode is impressive: auto-imports and auto-complete work.</li><li>We have no more inconvenient RAM usage.</li><li><a href="https://github.com/DefinitelyTyped/DefinitelyTyped">DefinitelyTyped</a> contains a lot of typings and the quality of these typings is great overall. No more problems with react and react-relay typings.</li><li>It’s easy to export type definitions =&gt; it encourages developers to split their code into smaller packages (which I think is a good practice)</li></ul><p>It’s too soon to witness the impact on our productivity, so I measured the impact on the “Developper Happiness” among team members. I’m assuming that happy coding is correlated with less problems and higher productivity. Here are the results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hD2UNei2GF1ZgXfURK64-Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2I6lBivz90-MmCYMhAw9iA.png" /></figure><h3>Conclusion</h3><p>Flow is a great tool a lot of people are happy with. But it has some limitations when the codebase becomes big. If you’re experiencing the same problems as we did, I strongly recommend to migrate.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b7703d12089" width="1" height="1" alt=""><hr><p><a href="https://medium.com/inato/migrating-from-flow-to-typescript-why-how-worth-it-5b7703d12089">Migrating from Flow to Typescript: Why ? How ? Worth it ?</a> was originally published in <a href="https://medium.com/inato">inato</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to use flow in a mono-repo]]></title>
            <link>https://medium.com/inato/how-to-use-flow-in-a-mono-repo-8947d43d50fb?source=rss-9a535aec5037------2</link>
            <guid isPermaLink="false">https://medium.com/p/8947d43d50fb</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[monorepo]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[flow]]></category>
            <category><![CDATA[yarn]]></category>
            <dc:creator><![CDATA[Samuel Briole]]></dc:creator>
            <pubDate>Thu, 27 Dec 2018 15:21:02 GMT</pubDate>
            <atom:updated>2018-12-27T15:21:02.557Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YXjjzGzK-PrZbudwq2Ilpg.png" /></figure><p>At Inato, we organize our codebase by building several modules inside a “mono-repo” with yarn workspaces. Also, we always work on improving our developer experience, because we think that it leverages our team’s productivity.</p><p><em>In a </em><a href="https://medium.com/inato/how-to-write-your-own-components-library-with-hot-reloading-using-yarn-workspaces-and-webpack-70934e845f51"><em>previous article</em></a><em>, I explained how to achieve cross-library hot-reloading for a front-end application.</em></p><p>Flow is one of the tools we use to maintain high code quality, and we rely on it to ship our code with confidence. However, flow does not support yarn workspaces yet, it’s designed to work with just a standard project (there’s an open issue <a href="https://github.com/flow-typed/flow-typed/issues/1391">here</a>).</p><h4>Here are the 2 main issues that we identified:</h4><ul><li>1: The type definitions of your dependencies are not detected by flow.</li><li>2: The type definitions are not detected when you import something from one module into another.</li></ul><p>As frustrating as it could be, our temporary fix was to stub all these libraries with flow-typed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*UA0ZiO1-wHkRLkEBKCLOCw.png" /></figure><p>It was obviously a big hole in our <a href="https://en.wikipedia.org/wiki/Swiss_cheese_model">swiss cheese model</a>, so we looked for solutions.</p><h3>Why are dependencies’ type definitions not detected?</h3><p>Flow doesn’t detect the type definitions of your dependencies when using yarn workspaces, because the packages are hoisted in the root package.</p><p>Basically, with this file architecture:</p><pre>.<br>├── package.json<br>├── packages<br>│   └── app<br>│       ├── node_modules<br>│       └── src<br>│           └── index.js<br>│   <br>│       <br>└── node_modules</pre><p>In the app module, flow will look for type definitions of the dependencies inside ./packages/app/node_modules but the packages are actually in ./node_modules .</p><h3>How to use dependencies’ type definitions</h3><p>The solution is to use a tool called <a href="https://immoweltgroup.gitbooks.io/flow-mono-cli/">flow-mono-cli</a>.<br>It will fix the problem above by creating symlinks from ./packages/app/node_modules to ./node_modules.</p><p>To do so, just follow the documentation. Roughly:</p><ul><li>install flow-mono-cli at the top level</li><li>run flow-mono create-symlinks</li></ul><p>We fixed the first issue, let’s tackle the second one now !</p><h3>Why are type definitions not detected when we import something from one module into another?</h3><p>When a module is used by another module, we expose only the lib folder which contains the source code transformed by babel. Unfortunately, babel strips out all the type definitions, so the lib folder does not contain them.</p><pre>.<br>├── package.json<br>└── packages<br>    ├── app<br>    │   ├── package.json<br>    │   └── src<br>    │       └── index.js<br>    └── ui<br>        ├── lib<br>        │   └── component.js // does not contains type definitions<br>        └── src<br>            └── component.js // contains type definitions</pre><p>For instance, if we consider the above architecture, when you write import { Component } from &#39;ui/lib/component&#39; in the app module,Component will not be correctly typed.</p><p>The solution to this problem is to export the type definitions in the lib folder, along with code transformed by babel.</p><h3>How to export flow definitions</h3><p>Exporting flow definitions in the lib folder is surprisingly easy!</p><p>What you need to do is copy your source files containing the flow definitions next to the transformed files in the lib folder, and rename them with a .flow extension.</p><pre>.<br>├── package.json<br>└── packages<br>    ├── app<br>    │   ├── package.json<br>    │   └── src<br>    │       └── index.js<br>    └── ui<br>        ├── lib<br>        │   ├── component.js <br>        │   └── component.js.flow // copy of src/component.js<br>        └── src<br>            └── component.js // contains type definitions</pre><p>Now, when you write import { Component } from &#39;ui/lib/component&#39;, Component will be correctly typed.</p><p>In order to automate this copying process, I suggest that you use <a href="https://github.com/Macil/flow-copy-source#readme">flow-copy-source</a>. You can run flow-copy-source src/ lib/ or flow-copy-source src/ lib/ -w with the convenient watch option!</p><h4>One last step: include your dependencies in your .flowconfig</h4><p>When you change something in the ui module and babel/ flow-copy-source write new content in the lib folder, flow in the app folder may not understand that something changed at once.</p><p>In order to have a seamless experience, include your dependencies in the .flowconfig file of the app module:</p><pre>[include]<br>../ui/lib/**/*.js.flow</pre><h3>Conclusion</h3><p>We’ve put some effort at Inato to improve our developer experience with flow, and I hope that our learnings will help you as well :)</p><p>Taking a step back, I feel like flow is a great type-checker, but it lacks tooling and we have to use non-official tools like flow-mono-cli and flow-copy-source to get basic things done. <br>Also flow is quite slow sometimes, and we have to use small hacks like [include] in the .flowconfig to have a decent experience.</p><p>Considering typescript‘s bigger ecosystem, we currently wonder if migrating to typescript would be a rewarding investment. If you have experienced similar problems with typescript, please let me know!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8947d43d50fb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/inato/how-to-use-flow-in-a-mono-repo-8947d43d50fb">How to use flow in a mono-repo</a> was originally published in <a href="https://medium.com/inato">inato</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to write your own components library with hot-reloading, using yarn-workspaces and webpack]]></title>
            <link>https://medium.com/inato/how-to-write-your-own-components-library-with-hot-reloading-using-yarn-workspaces-and-webpack-70934e845f51?source=rss-9a535aec5037------2</link>
            <guid isPermaLink="false">https://medium.com/p/70934e845f51</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[yarn]]></category>
            <category><![CDATA[hot-reloading]]></category>
            <category><![CDATA[yarn-workspace]]></category>
            <category><![CDATA[webpack]]></category>
            <dc:creator><![CDATA[Samuel Briole]]></dc:creator>
            <pubDate>Thu, 18 Oct 2018 15:44:13 GMT</pubDate>
            <atom:updated>2018-12-14T10:10:20.928Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to write your own components library with hot-reloading, using yarn-workspaces and babel</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*xTzZRXZym6Um7zQCInmzBA.jpeg" /></figure><h3>Introduction</h3><p>At Inato, we are creating a product that includes several front-end applications. All these apps are located in a single mono-repo which we manage with yarn-workspaces, where each app is a javascript module.</p><p>For example, let’s imagine that we have 2 front-end modules, app and back-office. The file structure would look like this:</p><pre>.<br>├── package.json<br>├── packages<br>│   ├── app<br>│   │   ├── package.json<br>│   │   └── src<br>│   │       └── index.js<br>│   │<br>│   └── back-office<br>│       ├── package.json<br>│       └── src<br>│           └── index.js<br>│       <br>└── yarn.lock</pre><p>For each of these front-end app, we have a nice developer experience with hot-reloading, so we have a quick feedback when we design new components, especially when we write styles.</p><p>At some point, we discovered that some UI components were duplicated across different apps. So, we decided to refactor all these components into a new UI-dedicated module, enforcing code unicity and UI integrity:</p><pre>.<br>├── package.json<br>├── packages<br>│   ├── app<br>│   │   ├── package.json<br>│   │   └── src<br>│   │       └── index.js<br>│   │   <br>│   ├── back-office<br>│   │   ├── package.json<br>│   │   └── src<br>│   │       └── index.js<br>│   │   <br>│   └── ui<br>│       ├── package.json<br>│       └── src<br>└── yarn.lock</pre><p>In this article, I will explain how you can build the ui module while keeping a great hot-reloading experience.</p><h3>How to build the module with hot-reloading</h3><p>The standard way is to process and copy the source files into a lib folder. Using babel, a command like babel src --out-dir lib will do the trick.</p><p>Then,you can import your components in your app and back-office front-end modules with: import { SomeComponent } from &#39;ui/lib/SomeComponent&#39;.</p><p>In order to build the files each time they are edited, you can add a “watch” option in the babel command :</p><p>babel src --out-dir lib -w</p><p>Now, when you change something in ui, the processed files are updated in lib, and hot-reloading is triggered in app and back-office!</p><h3>The end</h3><p>I hope you enjoyed this short article. If you have any question, just drop a comment below.</p><p>In my next article, I will explain how to export flow definitions from a javascript module.</p><p>Also, if you are curious about Inato activities, we are currently hiring software engineers! Check out the open positions: <a href="https://angel.co/inato/jobs">https://angel.co/inato/jobs</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70934e845f51" width="1" height="1" alt=""><hr><p><a href="https://medium.com/inato/how-to-write-your-own-components-library-with-hot-reloading-using-yarn-workspaces-and-webpack-70934e845f51">How to write your own components library with hot-reloading, using yarn-workspaces and webpack</a> was originally published in <a href="https://medium.com/inato">inato</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>