You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if("role"inusr) { // use the `in` operator for typeguards since TS 2.7+
660
662
routeToAdminPage(usr.role);
@@ -663,7 +665,7 @@ function redirect(usr: Admin | User) {
663
665
}
664
666
}
665
667
666
-
// custom type guard, does the same thing in older TS versions or where `in` isnt enough
668
+
//Method 2: custom type guard, does the same thing in older TS versions or where `in` isnt enough
667
669
function isAdmin(usr:Admin|User):usrisAdmin {
668
670
return (<Admin>usr).role !==undefined
669
671
}
@@ -813,7 +815,7 @@ partialStateUpdate({foo: 2}) // this works
813
815
814
816
<details>
815
817
<summary>
816
-
Minor caveats on using <pre>Partial</pre>
818
+
Minor caveats on using <code>Partial</code>
817
819
</summary>
818
820
819
821
Note that there are some TS users who don't agree with using `Partial` as it behaves today. See [subtle pitfalls of the above example here](https://twitter.com/ferdaber/status/1084798596027957248), and check out this long discussion on [why @types/react uses Pick instead of Partial](https://github.com/DefinitelyTyped/DefinitelyTyped/issues/18365).
0 commit comments