Skip to content

Commit

Permalink
Update safe-cast-to.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus authored Aug 23, 2024
1 parent 3e7b1d7 commit 0596285
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions source/safe-cast-to.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/**
Cast a value to the given type safely.
This is useful since the `as` keyword allows you to convert between two unrelated types, which is type-unsafe. For example, converting a number to a string type.
However, this function only allows you to cast a given value to a type that is compatible with it, avoiding the potential risk of using "as" and not breaking the type safety of your code.
The `as` keyword allows unsafe conversions between unrelated types, like converting a number to a string. This function restricts casting to compatible types, preserving type safety.
@example
```
Expand Down

0 comments on commit 0596285

Please sign in to comment.