fix(bot): Use an object to present desired properties errors (#4208)

* Use DesiredPropertiesError instead of strings

Using an object allows typescript to error in more cases as with strings
if the original propriety was a string it would not error for stuff like
`.endsWith(...)`

We use a symbol to make sure the type doesn't actually become a generic
object, but instead is a specific type that can be checked against.

* Update docs
This commit is contained in:
Fleny
2025-06-01 08:20:16 +02:00
committed by GitHub
parent 5b97b217a7
commit ef5cf54c66
2 changed files with 14 additions and 4 deletions
+7 -2
View File
@@ -152,10 +152,15 @@ The caveats of this behavior are the following:
#### `ChangeType`
All the "undesired" properties will be typed with a string that will explain why the property is disabled, this may also include the dependencies for said property if those are present.
All the "undesired" properties will be typed with a string wrapped in a type that will explain why the property is disabled, this may also include the dependencies for said property if those are present.
The caveats of this behavior are the following:
- Typescript may not always error on the usage of undesired properties, as in some cases, strings can be a valid option (e.g. channel.name is always a string so typescript won't error)
- Typescript may not always error on the usage of undesired properties, as in some cases, the object without any property can be a valid thing to use (e.g. `message.poll` is an object, so if you only check if `message.poll` exists Typescript won't error)
The types for undesired properties will be like the following:
```js
(property) content: DesiredPropertiesError<"This property is not set as desired in desiredProperties option in createBot(), so you can't use it. More info here: https://discordeno.js.org/desired-props">
```
### Removing TypeScript Clutter