Skip to content

Commit 9edd012

Browse files
committed
update docusaurus
1 parent a68387c commit 9edd012

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

website/src/pages/index.mdx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,6 @@ const removeFirstUser = (users: ReadonlyArray<User>) => {
135135
};
136136
```
137137

138-
### Return Types
139-
140-
Including return type annotations is highly encouraged, although not required ([eslint rule](https://typescript-eslint.io/rules/explicit-function-return-type/)).
141-
142-
Consider benefits when explicitly typing the return value of a function:
143-
144-
- Return values makes it clear and easy to understand to any calling code what type is returned.
145-
- In the case where there is no return value, the calling code doesn't try to use the undefined value when it shouldn't.
146-
- Surface potential type errors faster in the future if there are code changes that change the return type of the function.
147-
- Easier to refactor, since it ensures that the return value is assigned to a variable of the correct type.
148-
- Similar to writing tests before implementation (TDD), defining function arguments and return type, gives you the opportunity to discuss the feature functionality and its interface ahead of implementation.
149-
- Although type inference is very convenient, adding return types can save TypeScript compiler a lot of work.
150-
151138
### Discriminated union
152139

153140
If there's only one TypeScript feature to choose from, embrace discriminated unions.
@@ -186,6 +173,19 @@ Discriminated unions advantages:
186173
- Discriminated unions make refactoring and maintenance easier by providing a centralized definition of related types. When adding or modifying types within the union, the compiler reports any inconsistencies throughout the codebase.
187174
- IDEs can leverage discriminated unions to provide better autocompletion and type inference.
188175

176+
### Return Types
177+
178+
Including return type annotations is highly encouraged, although not required ([eslint rule](https://typescript-eslint.io/rules/explicit-function-return-type/)).
179+
180+
Consider benefits when explicitly typing the return value of a function:
181+
182+
- Return values makes it clear and easy to understand to any calling code what type is returned.
183+
- In the case where there is no return value, the calling code doesn't try to use the undefined value when it shouldn't.
184+
- Surface potential type errors faster in the future if there are code changes that change the return type of the function.
185+
- Easier to refactor, since it ensures that the return value is assigned to a variable of the correct type.
186+
- Similar to writing tests before implementation (TDD), defining function arguments and return type, gives you the opportunity to discuss the feature functionality and its interface ahead of implementation.
187+
- Although type inference is very convenient, adding return types can save TypeScript compiler a lot of work.
188+
189189
### Template Literal Types
190190

191191
Embrace using template literal types, instead of just (wide) `string` type.

0 commit comments

Comments
 (0)