Skip to content

Commit d01eb24

Browse files
author
swyx
committed
format
1 parent 1de149a commit d01eb24

File tree

7 files changed

+20
-19
lines changed

7 files changed

+20
-19
lines changed

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
<!-- markdownlint-enable -->
2222
<!-- prettier-ignore-end -->
23+
2324
<!-- ALL-CONTRIBUTORS-LIST:END -->
2425

2526
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

docs/advanced/misc-concerns.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,11 @@ Any other tips? Please contribute on this topic! [We have an ongoing issue here
185185

186186
</details>
187187

188-
189188
## Compilation Speed
190189

191190
Compiling large TS projects can get slow. Here are some tips:
192191

193192
- use [TS 3.0 Project references](https://react-typescript-cheatsheet.netlify.app/docs/advanced/patterns_by_version#typescript-30)
194193
- Webpack ([see CRA diff](https://gist.github.com/jaredpalmer/d3016701589f14df8a3572df91a5754b)):
195194
- set `output.pathinfo = false`
196-
- set `optimization.splitChunks`, `optimization.removeAvailableModules`, `optimization.removeEmptyChunks` to `false`
195+
- set `optimization.splitChunks`, `optimization.removeAvailableModules`, `optimization.removeEmptyChunks` to `false`

docs/advanced/patterns_by_usecase.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ You might also see this with React Router:
158158

159159
```tsx
160160
const PrivateRoute = ({ component: Component, ...rest }: PrivateRouteProps) => {
161-
const { isLoggedIn } = useAuth();
161+
const { isLoggedIn } = useAuth();
162162

163-
return isLoggedIn ? <Component {...rest} /> : <Redirect to="/" />;
163+
return isLoggedIn ? <Component {...rest} /> : <Redirect to="/" />;
164164
};
165165
```
166166

docs/advanced/utility-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ We will assume knowledge of utility types covered in the sister project [`typesc
88

99
If you intend to maintain a large TS codebase/a nontrivial React+TS library, **we strongly recommend exploring these utilities** so that you don't reinvent the wheel and/or lose sanity trying to do so. Studying their code can also teach you a lot of advanced TS that is not covered here.
1010

11-
I also recommend have a good working knowledge of how to construct the inbuilt utility types from scratch. See [Dr. Rasuchmeyer's guide](https://2ality.com/2020/06/computing-with-types.html) for a concise introduction.
11+
I also recommend have a good working knowledge of how to construct the inbuilt utility types from scratch. See [Dr. Rasuchmeyer's guide](https://2ality.com/2020/06/computing-with-types.html) for a concise introduction.
1212

1313
A level of comfort with **generic types** is therefore required. Here are some helpful resources:
1414

docs/basic/getting-started/hooks.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,18 @@ setUser(newUser);
2929
You can use [Discriminated Unions](https://www.typescriptlang.org/docs/handbook/advanced-types.html#discriminated-unions) for reducer actions. Don't forget to define the return type of reducer, otherwise TypeScript will infer it.
3030

3131
```tsx
32-
const initialState = {count: 0};
33-
34-
type ACTIONTYPE =
35-
| { type: 'increment', payload: number}
36-
| { type: 'decrement', payload: string}
32+
const initialState = { count: 0 };
3733

34+
type ACTIONTYPE =
35+
| { type: "increment"; payload: number }
36+
| { type: "decrement"; payload: string };
3837

3938
function reducer(state: typeof initialState, action: ACTIONTYPE) {
4039
switch (action.type) {
41-
case 'increment':
42-
return {count: state.count + action.payload};
43-
case 'decrement':
44-
return {count: state.count - Number(action.payload)};
40+
case "increment":
41+
return { count: state.count + action.payload };
42+
case "decrement":
43+
return { count: state.count - Number(action.payload) };
4544
default:
4645
throw new Error();
4746
}
@@ -52,8 +51,12 @@ function Counter() {
5251
return (
5352
<>
5453
Count: {state.count}
55-
<button onClick={() => dispatch({type: 'decrement', payload: '5'})}>-</button>
56-
<button onClick={() => dispatch({type: 'increment', payload: 5})}>+</button>
54+
<button onClick={() => dispatch({ type: "decrement", payload: "5" })}>
55+
-
56+
</button>
57+
<button onClick={() => dispatch({ type: "increment", payload: 5 })}>
58+
+
59+
</button>
5760
</>
5861
);
5962
}

docs/basic/troubleshooting/ts-config.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ You can find [all the Compiler options in the TypeScript docs](https://www.types
3838
}
3939
```
4040

41-
You can find more [recommended TS config here](https://github.com/tsconfig/bases).
41+
You can find more [recommended TS config here](https://github.com/tsconfig/bases).
4242

4343
Please open an issue and discuss if there are better recommended choices for React.
4444

docs/migration/from-flow.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,4 @@ title: From Flow
1111
- [Ecobee's brief experience](https://mobile.twitter.com/alanhietala/status/1104450494754377728)
1212
- [Migrating a 50K SLOC Flow + React Native app to TypeScript](https://blog.usejournal.com/migrating-a-flow-react-native-app-to-typescript-c74c7bceae7d)
1313

14-
15-
1614
[entria]: https://medium.com/entria/incremental-migration-to-typescript-on-a-flowtype-codebase-515f6490d92d "Incremental Migration to TypeScript on a Flowtype codebase"

0 commit comments

Comments
 (0)