Skip to content

Commit 14699e9

Browse files
authored
fix minor formatting issues
1 parent 1bc63e0 commit 14699e9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ class CssThemeProvider extends React.PureComponent<Props> {
555555
`forwardRef`:
556556

557557
```tsx
558-
type Props = { children: React.ReactNode; type: 'submit | 'button' }
558+
type Props = { children: React.ReactNode; type: 'submit' | 'button' }
559559
export type Ref = HTMLButtonElement
560560
export const FancyButton = React.forwardRef<Ref, Props>((props, ref) => (
561561
<button ref={ref} className="MyClassName" type={props.type}>
@@ -655,6 +655,8 @@ interface Admin {
655655
interface User {
656656
email: string;
657657
}
658+
659+
// Method 1: use `in` keyword
658660
function redirect(usr: Admin | User) {
659661
if("role" in usr) { // use the `in` operator for typeguards since TS 2.7+
660662
routeToAdminPage(usr.role);
@@ -663,7 +665,7 @@ function redirect(usr: Admin | User) {
663665
}
664666
}
665667

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
667669
function isAdmin(usr: Admin | User): usr is Admin {
668670
return (<Admin>usr).role !==undefined
669671
}
@@ -813,7 +815,7 @@ partialStateUpdate({foo: 2}) // this works
813815

814816
<details>
815817
<summary>
816-
Minor caveats on using <pre>Partial</pre>
818+
Minor caveats on using <code>Partial</code>
817819
</summary>
818820

819821
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

Comments
 (0)