mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 17:00:08 +00:00
fix: optionalize recursive type works with nested objects and arrays (#2115)
* fix: get rid of type errors for now * fix: only 6 type errors left
This commit is contained in:
1
plugins/cache/src/setupCacheRemovals.ts
vendored
1
plugins/cache/src/setupCacheRemovals.ts
vendored
@@ -67,7 +67,6 @@ export function setupCacheRemovals<B extends Bot>(bot: BotWithCache<B>) {
|
||||
|
||||
bot.handlers.GUILD_EMOJIS_UPDATE = function (_, data, shardId) {
|
||||
const payload = data.d as DiscordGuildEmojisUpdate;
|
||||
|
||||
const guild = bot.guilds.get(bot.transformers.snowflake(payload.guild_id));
|
||||
|
||||
if (guild) {
|
||||
|
||||
@@ -1242,7 +1242,7 @@ export type Camelize<T> = {
|
||||
: never;
|
||||
};
|
||||
|
||||
// export type Optionalize<T> = T extends object ?
|
||||
// export type Optionalize<T> = T extends object ?
|
||||
// & {
|
||||
// [K in KeysWithUndefined<T>]?: Optionalize<T[K]>;
|
||||
// }
|
||||
@@ -1252,17 +1252,19 @@ export type Camelize<T> = {
|
||||
// : T;
|
||||
|
||||
export type KeysWithUndefined<T> = {
|
||||
[K in keyof T]-?: (undefined | null) extends T[K] ? K : never;
|
||||
[K in keyof T]-?: undefined extends T[K]
|
||||
? K
|
||||
: null extends T[K]
|
||||
? K
|
||||
: never;
|
||||
}[keyof T];
|
||||
|
||||
export type Optionalize<T> = (
|
||||
& {
|
||||
[K in KeysWithUndefined<T>]?: Optionalize<T[K]>;
|
||||
&{
|
||||
[K in KeysWithUndefined<T>]?: T[K]
|
||||
} & {
|
||||
[K in Exclude<keyof T, KeysWithUndefined<T>>]: T[K] extends object
|
||||
? Object extends Pick<T[K], keyof T[K]> ? T[K] : Optionalize<T[K]>
|
||||
: T[K];
|
||||
}
|
||||
& {
|
||||
[K in Exclude<keyof T, KeysWithUndefined<T>>]: (
|
||||
// deno-lint-ignore ban-types
|
||||
T[K] extends object ? Object extends Pick<T[K], keyof T[K]> ? T[K] : Optionalize<T[K]> : T[K]
|
||||
);
|
||||
}
|
||||
);
|
||||
);
|
||||
Reference in New Issue
Block a user