<?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 MING WU on Medium]]></title>
        <description><![CDATA[Stories by MING WU on Medium]]></description>
        <link>https://medium.com/@crazyming?source=rss-ab809d53e8db------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*0OPu2kxtn4MVOFt-.</url>
            <title>Stories by MING WU on Medium</title>
            <link>https://medium.com/@crazyming?source=rss-ab809d53e8db------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 22:42:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@crazyming/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[React’s Secret Weapon: useSyncExternalStore for Seamless State Management]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/reacts-secret-weapon-usesyncexternalstore-for-seamless-state-management-7acb1c838a3c?source=rss-ab809d53e8db------2"><img src="https://cdn-images-1.medium.com/max/998/1*EVg8PVjrUHrtRlZN7CNppQ@2x.png" width="998"></a></p><p class="medium-feed-snippet">React&#x2019;s useSyncExternalStore hook provides a powerful and elegant way to integrate external data sources into your React components. This&#x2026;</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/reacts-secret-weapon-usesyncexternalstore-for-seamless-state-management-7acb1c838a3c?source=rss-ab809d53e8db------2">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/reacts-secret-weapon-usesyncexternalstore-for-seamless-state-management-7acb1c838a3c?source=rss-ab809d53e8db------2</link>
            <guid isPermaLink="false">https://medium.com/p/7acb1c838a3c</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[react-hook]]></category>
            <category><![CDATA[state-management]]></category>
            <dc:creator><![CDATA[MING WU]]></dc:creator>
            <pubDate>Sun, 31 Mar 2024 06:57:06 GMT</pubDate>
            <atom:updated>2024-04-01T03:04:31.018Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Calling APIs Concurrently with Fetch: A Comparison of p-map and RxJS mergeMap]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/calling-apis-concurrently-with-fetch-a-comparison-of-p-map-and-rxjs-mergemap-7089177cc366?source=rss-ab809d53e8db------2"><img src="https://cdn-images-1.medium.com/max/2414/1*pF-NVtRDYqpruhYVPppbzQ@2x.png" width="2414"></a></p><p class="medium-feed-snippet">In modern web development, fetching data from APIs is a common task. Often, applications need to fetch data from multiple sources&#x2026;</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/calling-apis-concurrently-with-fetch-a-comparison-of-p-map-and-rxjs-mergemap-7089177cc366?source=rss-ab809d53e8db------2">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/calling-apis-concurrently-with-fetch-a-comparison-of-p-map-and-rxjs-mergemap-7089177cc366?source=rss-ab809d53e8db------2</link>
            <guid isPermaLink="false">https://medium.com/p/7089177cc366</guid>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[promises]]></category>
            <category><![CDATA[concurrent]]></category>
            <dc:creator><![CDATA[MING WU]]></dc:creator>
            <pubDate>Sat, 30 Mar 2024 02:02:50 GMT</pubDate>
            <atom:updated>2024-04-01T02:02:07.590Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Mastering TypeScript Decorators: A Comprehensive Guide to Enhancing Your Code]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://javascript.plainenglish.io/mastering-typescript-decorators-a-comprehensive-guide-to-enhancing-your-code-31bd856d8248?source=rss-ab809d53e8db------2"><img src="https://cdn-images-1.medium.com/max/1078/1*b3RGZ79WZZvgDbAgSfHK1w.png" width="1078"></a></p><p class="medium-feed-snippet">Why do we need a decorator?</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/mastering-typescript-decorators-a-comprehensive-guide-to-enhancing-your-code-31bd856d8248?source=rss-ab809d53e8db------2">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/mastering-typescript-decorators-a-comprehensive-guide-to-enhancing-your-code-31bd856d8248?source=rss-ab809d53e8db------2</link>
            <guid isPermaLink="false">https://medium.com/p/31bd856d8248</guid>
            <category><![CDATA[typescript-with-react]]></category>
            <category><![CDATA[decorators]]></category>
            <category><![CDATA[decorator-functions]]></category>
            <dc:creator><![CDATA[MING WU]]></dc:creator>
            <pubDate>Mon, 10 Apr 2023 06:58:18 GMT</pubDate>
            <atom:updated>2024-04-06T12:00:09.166Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Learn rxjs in an easy way]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://blog.devgenius.io/learn-rxjs-in-an-easy-way-8008f291ef8f?source=rss-ab809d53e8db------2"><img src="https://cdn-images-1.medium.com/max/2600/1*06aLTGrv3O1f7oRDY-qYbg.png" width="2950"></a></p><p class="medium-feed-snippet">Unlike Object-oriented programming (where states and behaviors are coupled together into an object), Reactive programming is a different&#x2026;</p><p class="medium-feed-link"><a href="https://blog.devgenius.io/learn-rxjs-in-an-easy-way-8008f291ef8f?source=rss-ab809d53e8db------2">Continue reading on Dev Genius »</a></p></div>]]></description>
            <link>https://blog.devgenius.io/learn-rxjs-in-an-easy-way-8008f291ef8f?source=rss-ab809d53e8db------2</link>
            <guid isPermaLink="false">https://medium.com/p/8008f291ef8f</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[rxjs]]></category>
            <dc:creator><![CDATA[MING WU]]></dc:creator>
            <pubDate>Fri, 21 Oct 2022 13:53:52 GMT</pubDate>
            <atom:updated>2023-05-13T05:12:56.407Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[A quick guide about Dependency Injection (in Angular/React)]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://blog.devgenius.io/a-quick-guide-about-dependency-injection-in-angular-react-2ff26fe57bd0?source=rss-ab809d53e8db------2"><img src="https://cdn-images-1.medium.com/max/2048/1*_wGhvy2izfibCt3fZeQR7g.png" width="2048"></a></p><p class="medium-feed-snippet">In fact, DI (Dependency Injection) is a super simple concept that is widely used in software development. It basically means that when a&#x2026;</p><p class="medium-feed-link"><a href="https://blog.devgenius.io/a-quick-guide-about-dependency-injection-in-angular-react-2ff26fe57bd0?source=rss-ab809d53e8db------2">Continue reading on Dev Genius »</a></p></div>]]></description>
            <link>https://blog.devgenius.io/a-quick-guide-about-dependency-injection-in-angular-react-2ff26fe57bd0?source=rss-ab809d53e8db------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ff26fe57bd0</guid>
            <category><![CDATA[angula]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <dc:creator><![CDATA[MING WU]]></dc:creator>
            <pubDate>Fri, 13 May 2022 03:05:18 GMT</pubDate>
            <atom:updated>2022-05-14T07:52:51.824Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[The Difference Between jest.spyOn and jest.mock]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">When I first started to write unit tests for react applications, I found that it is confusing whether I should use jest.spyOn or jest.mock.</p><p class="medium-feed-link"><a href="https://javascript.plainenglish.io/the-difference-between-jest-spyon-and-jest-mock-98c9cff23c8f?source=rss-ab809d53e8db------2">Continue reading on JavaScript in Plain English »</a></p></div>]]></description>
            <link>https://javascript.plainenglish.io/the-difference-between-jest-spyon-and-jest-mock-98c9cff23c8f?source=rss-ab809d53e8db------2</link>
            <guid isPermaLink="false">https://medium.com/p/98c9cff23c8f</guid>
            <category><![CDATA[react-testing]]></category>
            <category><![CDATA[jest]]></category>
            <dc:creator><![CDATA[MING WU]]></dc:creator>
            <pubDate>Wed, 11 May 2022 13:48:42 GMT</pubDate>
            <atom:updated>2024-09-16T12:54:19.630Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Some thoughts about unit test in React]]></title>
            <link>https://crazyming.medium.com/some-thoughts-about-unit-test-in-react-360932b6776b?source=rss-ab809d53e8db------2</link>
            <guid isPermaLink="false">https://medium.com/p/360932b6776b</guid>
            <category><![CDATA[react-testing-library]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[unit-testing]]></category>
            <dc:creator><![CDATA[MING WU]]></dc:creator>
            <pubDate>Sun, 12 Sep 2021 07:11:30 GMT</pubDate>
            <atom:updated>2021-09-12T07:11:30.160Z</atom:updated>
            <content:encoded><![CDATA[<ol><li><strong>Do not wrap fireEvent in “act” or “await waitFor”</strong></li></ol><p>If we are testing with fireEvent in react-testing library but found this error in the console</p><pre>Warning: An update to Example inside a test was not wrapped in act(...)</pre><p>It means that we did not wait for react to flush the new state to the dom. The app’s state is updated but we did not test it. There is a potential scenario we need to consider/test (that is the DOM is now changed as the state is changed, do you expect it to change?).</p><p>Here is an example that replicates this issue:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ky8SOlnkEmt90F_KH76Hw.png" /></figure><p>In this example, we fired a click event and immediately did the assertion. But the state will only be updated after 2s later. Even if the test is pass, we got the “not wrapped in act” warning in the console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QF4dIjXZAn8lIHsuBKRERw.png" /><figcaption>A wrong test that does not wait for react to update the state</figcaption></figure><p><strong>The assertion is wrong.</strong> We are supposed to wait for react to flush the state and after the state is updated, then we do the assertion.</p><p>So in this example, ‘await waitFor’ is the rescue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l81Z7eEECBTG9upJml9YGw.png" /><figcaption>when to use wait waitFor</figcaption></figure><p>This time it passed without any warnings. <strong>Whenever we fired an event, ask ourselves will it trigger any react state updates. If the answer is YES, then always use “await waitFor” to wait for the state to update.</strong></p><p>In this example, it is not best practice to really wait for 2s, which is too slow. We could manipulate the time by using jest.useFakeTimers and jest.advanceTimersByTime(2000).</p><p><strong>2. fire event with userEvent instead of fireEvent</strong></p><p>fireEvent cannot simulate users’ real behaviors. When you fire a click event with fireEvent.click(targetButton), it simply clicks that element, but the button is not focused. However, when the user clicks a button, the button should also be focused.</p><p>This example replicates this issue:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6xloofZhY05t78jWBqXOXw.png" /><figcaption>fireEvent.click vs userEvent.click</figcaption></figure><p>fireEvent.click only fires click event but the focus event is not fired, which is not correct in production environment. userEvent.click fixes this problem. It is just a wrapper of fireEvent but can better simulate users’ behaviors.</p><p>This focus issue is discussed here:</p><p><a href="https://github.com/testing-library/user-event/issues/350">fireEvent.focus should be discouraged · Issue #350 · testing-library/user-event (github.com)</a></p><p><a href="https://testing-library.com/docs/guide-events/">Considerations for fireEvent | Testing Library (testing-library.com)</a></p><p><strong>Recommended to read:</strong></p><p><a href="https://kentcdodds.com/blog/common-mistakes-with-react-testing-library#wrapping-things-in-act-unnecessarily">Common mistakes with React Testing Library (kentcdodds.com)</a></p><p>Here is the example code from codesandbox:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodesandbox.io%2Fembed%2F97uf3&amp;display_name=CodeSandbox&amp;url=https%3A%2F%2Fcodesandbox.io%2Fs%2F97uf3&amp;image=https%3A%2F%2Fcodesandbox.io%2Fapi%2Fv1%2Fsandboxes%2F97uf3%2Fscreenshot.png&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=codesandbox" width="1000" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/e18c9fcd1bdbd238d4d6ec753437a6f9/href">https://medium.com/media/e18c9fcd1bdbd238d4d6ec753437a6f9/href</a></iframe><h3>Other things about unit testing:</h3><p><strong>1. Passing functions as parameters are better than call them directly in another function.</strong></p><p>If you are familiar with dependency injection in angular or c#, you already know that the biggest benefit of Di is that it makes your code easier to test.</p><p>Let use check out this example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WYTq6GzsqbkPdOWUQOVPYA.png" /><figcaption>example of passing function as dependencies</figcaption></figure><p>In this example, we have a ‘displayValueInCapital’ function that returns a capital value, a ‘findName’ function that returns the target object, and a ‘renderName’ function that accepts a list, target string, the findName function and displayValueInCapital function.</p><p>We pass findNameFunc and displayValueFunc as dependencies and call them in ‘renderName’. It is much better than directly call them inside of renderName and makes these three functions less coupled.</p><p>If we already have tests for ‘displayValueInCapital’ and ‘findName’, then it is unnecessary to test them again in renderName. So in renderName, we can just mock these two functions like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QwKyfNFaEBuNsZ66Wi5uLQ.png" /><figcaption>mock function dependencies</figcaption></figure><p>The first two tests already tested <strong>displayValueInCapital</strong> and findName functions. In the last test, we can easily mock the dependencies and only test the core logic that is related to <strong>renderName.</strong></p><p>However, if we just call them directly in renderName like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V6XRqEtWFpUlo-iDq1HPXA.png" /><figcaption>a bad example of renderName</figcaption></figure><p>it makes the renderName2 too coupled with findName and displayValueInCapital and not that easy to mock these two functions.</p><p>2. <strong>Do not use Optional chaining(?.) all the time</strong></p><p>By using optional chaining (?.), it means there are more branches to test. One branch is that the value exists, and other branch is that the value does not exist. Additionally, errors or issues could be hidden and hard to find.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=360932b6776b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learn Git in a scenario-based way]]></title>
            <link>https://crazyming.medium.com/learn-git-in-a-scenario-based-way-2e99c4a3df12?source=rss-ab809d53e8db------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e99c4a3df12</guid>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[MING WU]]></dc:creator>
            <pubDate>Sat, 21 Aug 2021 13:36:01 GMT</pubDate>
            <atom:updated>2021-09-03T06:23:26.210Z</atom:updated>
            <content:encoded><![CDATA[<p>The git commands you will learn:</p><ol><li>git stash</li><li>git reset</li><li>git cherry-pick</li><li>git blame</li><li>git reflog</li><li>git rebase</li></ol><p>These are all very important and easy-to-understand git commands in daily dev workflow.</p><blockquote>git stash</blockquote><h4>1. I am currently in ticket001 branch adding a new feature. I just finished 50% of the work but I have not committed anything. I am assigned an emergent bug fix ticket. I need to do the bug fix ticket right now. What should I do with my uncommited work?</h4><p>Steps in English:</p><p>For instance, here is my git status:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5GMjZ6OAcyeny0i2" /></figure><p>I have two uncommitted files. The below git command is used to save the new changes into a local temp zone.</p><pre>git stash save &quot;WIP: change new files&quot;</pre><p>After doing it, the new changes are saved, and will disappear so that I am able to check out to a new branch to fix the bug.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VsAUhUpwo0kgbtsQ" /></figure><pre>git stash list</pre><p>This will list all the saved stashes locally like the below screenshot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/0*gE_L4RBK2G3vOX8m" /></figure><p>stash{0} is like a reference to the first stash. We can use it to re-apply the changes on any branch using git stash apply</p><pre>git stash apply &#39;stash{0}&#39;</pre><p>After doing it, the previously saved changes will reapply. We are then able to continue to work on it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r6OCcAtSgOmXWzGt" /></figure><blockquote><em>git reset: with --soft HEAD, --mixed HEAD, --hard HEAD</em></blockquote><h4>2.1 I did a lot of changes but I want to delete all of them. What should I do?</h4><pre>git reset --hard HEAD</pre><p>This will delete all new changes locally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*lxwNGKCWcZ3s3s5w" /></figure><h4>2.2 I am working on a ticket but I made 3 commit messages. How could I squash them into one?</h4><p><strong>Option 1:</strong></p><pre>git reset --soft HEAD~3</pre><p>This command will remove the previous commit messages and leaves us in a state where “Changes need to be commit”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/0*tZbjkpo_oBDo4t5C" /></figure><p>We can just use git commit -m &quot;commit message name&quot;</p><p><strong>Option 2:</strong></p><pre>git reset --mix HEAD~2</pre><p>This is very similar to “soft”. It will leave us in a state where we have staged these changes like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/0*LohRv57wseuBsun4" /></figure><p>We just need to manually git add and git commit -m</p><blockquote>git cherry-pick</blockquote><h4>3. I made a commit in master branch but I should make it in feature branch. How can I move the git commit to feature branch?</h4><p>Step 1: Find the git commit hash by git log</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/0*u1iywCAHLKoDDhf6" /></figure><p>This is the hash for this git commit.</p><p>Step 2: Go to feature branch and do this:</p><pre>git cherry-pick d7ecb81fd5d5789d729240dfbb7fcc6b4022c404</pre><p>This commit is copied from the one in master to the one in feature.</p><blockquote>git blame</blockquote><h4>3. Someone introduced a bug and I need to know who changed this file?</h4><pre>git blame &#39;name of the file&#39;</pre><p>It tells us who made what changes to which file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/0*Se7dV-hn3Nkblhgi" /></figure><p>I prefer to use git blame function in webstorm. It is easier to visualize the change.</p><h4>4. I accidently used git reset --hard HEAD^1 to permanently deleted the last commit. How can I recover it?</h4><p>If I deleted the first commit with sha of ‘87489b7’ and I am in this state:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/0*X0SLacc1J2KsjckE" /></figure><p>The deleted git commit is gone.</p><p>git reflog will show me everything I did previously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/0*0CjFyUmaEDiEJRXW" /></figure><p>Find the commit sha, and do this:</p><pre>git reset --hard 87489b7</pre><h4>5. If you are working on feature branch (checked out from master 5 days ago). but master is updated to the newest from server. You hope that the new commit in feature branch is on top of the newest commit in master. It will look like your feature branch just checked out from master. How do you do it?</h4><p>Your base was the master branch. Now you need to change your base to the new master branch (the one with new commits).</p><p>Step 1: Make sure master branch is already up to date with server. Now Go to feature branch by git checkout feature</p><p>Step 2:</p><p>do the rebase command in feature branch.</p><pre>git rebase master</pre><p>After doing these, your old base will be changed to the new master branch. It looks like you just checked out from master (instead of checking it out from master 5 days ago). But if you merge master, you commit will be behind the new commits in master.</p><p><strong>Remember: git rebase is another kind of git merge for different purposes. git rebase changed the history. git merge keeps what the history is. When you made a commit on a branch, ask yourself whether you want your commit to be on the top of new coming commits or behind the new coming commits. If you want your commit on the top, then use git rebase otherwise use git merge.</strong></p><p>References:</p><p><a href="https://codewithming.hashnode.dev/Link">https://github.blog/2015-06-08-how-to-undo-almost-anything-with-git/</a></p><p><em>Originally published at </em><a href="https://codewithming.hashnode.dev/learn-git-in-a-scenario-based-way"><em>https://codewithming.hashnode.dev</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e99c4a3df12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Things You Need to Know About TypeScript]]></title>
            <link>https://crazyming.medium.com/things-you-need-to-know-about-typescript-441e74e650a5?source=rss-ab809d53e8db------2</link>
            <guid isPermaLink="false">https://medium.com/p/441e74e650a5</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[MING WU]]></dc:creator>
            <pubDate>Tue, 13 Aug 2019 23:58:52 GMT</pubDate>
            <atom:updated>2019-08-14T00:00:09.242Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/816/1*TpbxEQy4ckB-g31PwUQPlg.png" /></figure><p>This passage is not finished and is still in progress…</p><ol><li>Numbers:</li></ol><pre>const bigNumber:number=1_100_200_3000 //much easier to read;</pre><p>what this compiles to javascript is</p><pre>const bigNumber=11002003000;</pre><p>In typescript, using underscore makes your code easier to read.</p><p>2. Add “!” to tell ts to ignore it</p><p>3. keyof</p><pre>interface IPet{<br>  name:string,<br>  age:number,<br>  favouritePark?:string<br>}<br>type ReadonlyPet{<br>  +readonly [K in keyof IPet]-?:IPet[K]<br>}</pre><p>“+” clearly indicates that we are adding a “readonly” modifier and the “-” clearly indicates that we are deleting “optional” modifier.</p><p>4. types and interface</p><p>They are similar to some extent</p><pre>type Eat=(food:string)=&gt;void;</pre><pre>interface Eat{<br>  (food:string):void<br> }</pre><p>Another example:</p><pre>type Cat = IPet &amp; IFeiline;<br>interface ICat extends IPet,IFeline{<br>}</pre><pre>//definition<br>interface IPet{<br>  pose():void;<br>}<br>interface IFeline{<br>  nightvision:boolean<br>}</pre><p>Differences:</p><pre>type PetType=IDog|ICat;</pre><pre>interface IPet extends PetType{<br> //this is not allowed<br>}</pre><p>interface can merge but types cannot merge</p><pre>interface foo{<br>  a:string<br>}<br>interface foo{<br>  b:string<br>}<br>let foo:Foo //type does not support</pre><p>5. unknown or any</p><pre>unknown is very strict and does not allow you to do any unless you specify its types.<br>any is the least strict type. You can do anything.</pre><p>6. conditional types</p><pre>interface Book{<br> id:string<br>}</pre><pre>interface TV{<br> id:number,<br> diagonal:number<br>}<br>interface IItemService{<br> getItem&lt;T extends string | number&gt;(id:T):T extends string?Book:TV<br>}<br>let itemService:IItemService;<br>const book=itemService.getItem(&#39;10&#39;);<br>const tv=itemService.getItem(10);</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=441e74e650a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>