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
- 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.
240
240
- IDEs can leverage discriminated unions to provide better autocompletion and type inference.
241
241
242
-
### Type-Safe Constants with satisfies
242
+
### Type-Safe Constants With Satisfies
243
243
244
244
The `as const satisfies` syntax is a powerful TypeScript feature that combines strict type-checking and immutability for constants. It is particularly useful when defining constants that need to conform to a specific type.
245
245
@@ -888,7 +888,7 @@ While it's often hard to find the best name, aim to optimize code for consistenc
888
888
} asconst;
889
889
```
890
890
891
-
If type exist use `satisfies` operator in conjunction with const assertion, to conform object matches its type.
891
+
If type exist use [Type-Safe Constants With Satisfies](#type-safe-constants-with-satisfies).
892
892
893
893
```ts
894
894
// OrderStatus is predefined (e.g. generated from database schema, API)
0 commit comments