diff --git a/lib/discord/src/actions.ts b/lib/discord/src/actions.ts index 147c0b7..c50a60a 100644 --- a/lib/discord/src/actions.ts +++ b/lib/discord/src/actions.ts @@ -48,7 +48,7 @@ export let ActionSheetActionCreators: DiscordModules.Actions.ActionSheetActionCr if (module) return (ActionSheetActionCreators = module) }, { - hint: 'object', + hint: {}, }, )! @@ -75,7 +75,7 @@ export let AlertActionCreators: DiscordModules.Actions.AlertActionCreators = if (module) return (AlertActionCreators = module) }, { - hint: 'object', + hint: {}, }, )! diff --git a/lib/discord/src/common/index.ts b/lib/discord/src/common/index.ts index 71c1886..faee380 100644 --- a/lib/discord/src/common/index.ts +++ b/lib/discord/src/common/index.ts @@ -51,5 +51,5 @@ export let Constants: DiscordModules.Constants = proxify( if (module) return (Constants = module) }, - { hint: 'object' }, + { hint: {} }, )! diff --git a/lib/discord/src/design.ts b/lib/discord/src/design.ts index e076694..01757b9 100644 --- a/lib/discord/src/design.ts +++ b/lib/discord/src/design.ts @@ -41,7 +41,7 @@ export let Design: Design = proxify( if (module) return (Design = module) }, { - hint: 'object', + hint: {}, }, )! diff --git a/lib/discord/src/modules/main_tabs_v2.ts b/lib/discord/src/modules/main_tabs_v2.ts index 824bdcb..80eda74 100644 --- a/lib/discord/src/modules/main_tabs_v2.ts +++ b/lib/discord/src/modules/main_tabs_v2.ts @@ -34,6 +34,6 @@ export let RootNavigationRef: RootNavigationRef = proxify( if (module) return (RootNavigationRef = module) }, { - hint: 'object', + hint: {}, }, )! diff --git a/lib/discord/src/modules/settings/renderer.ts b/lib/discord/src/modules/settings/renderer.ts index 26bbcb1..7e77b68 100644 --- a/lib/discord/src/modules/settings/renderer.ts +++ b/lib/discord/src/modules/settings/renderer.ts @@ -42,6 +42,6 @@ export let SettingListRenderer: SettingListRenderer = proxify( if (module) return (SettingListRenderer = module) }, { - hint: 'object', + hint: {}, }, )! diff --git a/lib/externals/src/browserify.ts b/lib/externals/src/browserify.ts index 41f3f6e..adbd48c 100644 --- a/lib/externals/src/browserify.ts +++ b/lib/externals/src/browserify.ts @@ -27,6 +27,6 @@ export let nodeUtil: typeof import('node:util') = proxify( if (module) return (nodeUtil = module) }, { - hint: 'object', + hint: {}, }, )! diff --git a/lib/externals/src/react-native-clipboard.ts b/lib/externals/src/react-native-clipboard.ts index 743b27f..e474687 100644 --- a/lib/externals/src/react-native-clipboard.ts +++ b/lib/externals/src/react-native-clipboard.ts @@ -45,13 +45,13 @@ let ClipboardModule: typeof import('@react-native-clipboard/clipboard') = if (module) return (ClipboardModule = module) }, { - hint: 'object', + hint: {}, }, )! export const { useClipboard } = destructure(ClipboardModule, { - hint: 'function', + hint: () => {}, }) export const { default: Clipboard } = destructure(ClipboardModule, { - hint: 'object', + hint: {}, }) diff --git a/lib/externals/src/react-navigation.ts b/lib/externals/src/react-navigation.ts index d5c96db..c1d295e 100644 --- a/lib/externals/src/react-navigation.ts +++ b/lib/externals/src/react-navigation.ts @@ -36,7 +36,7 @@ export let ReactNavigationNative: typeof import('@react-navigation/native') = if (module) return (ReactNavigationNative = module) }, { - hint: 'object', + hint: {}, }, )! @@ -69,7 +69,7 @@ export let ReactNavigationStack: typeof import('@react-navigation/stack') = if (module) return (ReactNavigationStack = module) }, { - hint: 'object', + hint: {}, }, )! diff --git a/lib/externals/src/shopify.ts b/lib/externals/src/shopify.ts index 400d366..f0e7bf9 100644 --- a/lib/externals/src/shopify.ts +++ b/lib/externals/src/shopify.ts @@ -37,6 +37,6 @@ export let FlashList: typeof import('@shopify/flash-list') = proxify( if (module) return (FlashList = module) }, { - hint: 'object', + hint: {}, }, )! diff --git a/lib/utils/src/proxy.ts b/lib/utils/src/proxy.ts index 1f565e7..c1b9ec4 100644 --- a/lib/utils/src/proxy.ts +++ b/lib/utils/src/proxy.ts @@ -83,9 +83,9 @@ export interface ProxifyOptions { /** * The hint for the proxified value. * - * @default 'function' + * @default function () {} */ - hint?: 'object' | 'function' | object + hint?: object /** * Whether the proxified value should be cached. */ @@ -108,7 +108,7 @@ export interface ProxifyOptions { * * @example Without cache * ```ts - * const proxified = proxify(() => ({ value: Math.random() }), { hint: 'object' }) + * const proxified = proxify(() => ({ value: Math.random() }), { hint: {} }) * console.log(proxified) // { value: 0.123 } * console.log(proxified.value) // 0.456 * console.log(proxified) // { value: 0.789 } @@ -116,28 +116,15 @@ export interface ProxifyOptions { * * @example With cache * ```ts - * const proxified = proxify(() => ({ value: Math.random() }), { hint: 'object', cache: true }) + * const proxified = proxify(() => ({ value: Math.random() }), { hint: {}, cache: true }) * console.log(proxified) // { value: 0.123 } * console.log(proxified.value) // 0.123 * console.log(proxified) // { value: 0.123 } * ``` */ export function proxify(signal: () => T, options?: ProxifyOptions): T { - let hint: any - - switch (options?.hint) { - case undefined: - case 'function': - // biome-ignore lint/complexity/useArrowFunction: We need a function with a constructor - hint = function () {} - break - case 'object': - hint = {} - break - default: - hint = options!.hint - break - } + // biome-ignore lint/complexity/useArrowFunction: We need a function with a constructor + const hint = options?.hint ?? function () {} _metas.set(hint, [ signal, @@ -150,7 +137,7 @@ export function proxify(signal: () => T, options?: ProxifyOptions): T { if (v == null) DEBUG_warnNullishProxifiedValue() } - return new Proxy(hint, _handler) + return new Proxy(hint, _handler) as T } /** @@ -165,7 +152,7 @@ export function proxify(signal: () => T, options?: ProxifyOptions): T { * * @example Without cache * ```ts - * const proxified = proxify(() => ({ value: Math.random() }), { hint: 'object' }) + * const proxified = proxify(() => ({ value: Math.random() }), { hint: {} }) * const x = unproxify(proxified) * console.log(x) // { value: 0.123 } * console.log(x.value) // 0.123 @@ -174,7 +161,7 @@ export function proxify(signal: () => T, options?: ProxifyOptions): T { * * @example With cache * ```ts - * const proxified = proxify(() => ({ value: Math.random() }), { hint: 'object', cache: true }) + * const proxified = proxify(() => ({ value: Math.random() }), { hint: {}, cache: true }) * const x = unproxify(proxified) * console.log(x) // { value: 0.123 } * console.log(x.value) // 0.123 @@ -209,7 +196,7 @@ function unproxifyFromHint(hint: object) { * // cache is not turned on, so each access will call the signal again * const { x, y } = destructure( * proxify(() => ({ x: Math.random(), y: [Math.random()], z: null })), - * { hint: 'object' } + * { hint: {} } * ) * * // Non-nullish primitives are not proxifiable