From 207fbe90b6018fdc6eb986cba5432fabd3413d6c Mon Sep 17 00:00:00 2001 From: mkosir Date: Sat, 16 Mar 2024 21:03:41 +0100 Subject: [PATCH] update docusaurus --- website/src/pages/index.mdx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/website/src/pages/index.mdx b/website/src/pages/index.mdx index 1c1c952d..6597b20e 100644 --- a/website/src/pages/index.mdx +++ b/website/src/pages/index.mdx @@ -76,7 +76,7 @@ When creating types we try to think of how they would best **describe our code** Being expressive and keeping types as **narrow as possible** brings benefits to the codebase: - Increased Type Safety - Catch errors at compile-time, since narrowed types provide more specific information about the shape and behavior of your data. -- Improved Code Clarity - Reduced cognitive load by providing clearer boundaries and constraints on your data which makes your code easier to understand by other developers. +- Improved Code Clarity - Cognitive load is reduced by providing clearer boundaries and constraints on your data which makes your code easier to understand by other developers. - Easier Refactoring - Refactor with confidence, since types are narrow, making changes to your code becomes less risky. - Optimized Performance - In some cases, narrow types can help the TypeScript compiler generate more optimized JavaScript code. @@ -134,21 +134,21 @@ Template literal types have many applicable use cases e.g. API endpoints, routin ```ts // ❌ Avoid -const userEndpoint = '/api/usersss'; // Type 'string' - Since typo, route 'usersss' doesn't exist it will result in runtime error +const userEndpoint = '/api/usersss'; // Type 'string' - Since typo 'usersss', route doesn't exist and results in runtime error // ✅ Use type ApiRoute = 'users' | 'posts' | 'comments'; type ApiEndpoint = `/api/${ApiRoute}`; const userEndpoint: ApiEndpoint = '/api/users'; // ❌ Avoid -const homeTitleTranslation = 'translation.homesss.title'; // Type 'string' - Since typo, translations page 'homesss' doesn't exist it will result in runtime error +const homeTitleTranslation = 'translation.homesss.title'; // Type 'string' - Since typo 'homesss', translation doesn't exist and results in runtime error // ✅ Use type LocaleKeyPages = 'home' | 'about' | 'contact'; type TranslationKey = `translation.${LocaleKeyPages}.${string}`; const homeTitleTranslation: TranslationKey = 'translation.home.title'; // ❌ Avoid -const color = 'blue-450'; // Type 'string' - Since color 'blue-450' doesn't exist it will result in runtime error +const color = 'blue-450'; // Type 'string' - Since color 'blue-450' doesn't exist and results in runtime error // ✅ Use type BaseColor = 'blue' | 'red' | 'yellow' | 'gray'; type Variant = 50 | 100 | 200 | 300 | 400;