This commit is contained in:
Nuckyz 2024-06-12 17:45:54 -03:00
parent 337850c33a
commit 002a1cfc16
No known key found for this signature in database
GPG key ID: 440BF8296E1C4AD9
2 changed files with 6 additions and 6 deletions

View file

@ -6,7 +6,7 @@
import { makeLazy } from "./lazy";
export type LazyComponentType<T extends object = {}> = React.ComponentType<T> & Record<PropertyKey, any>;
export type LazyComponentType<T extends object = any> = React.ComponentType<T> & Record<PropertyKey, any>;
export const SYM_LAZY_COMPONENT_INNER = Symbol.for("vencord.lazyComponent.inner");
@ -17,7 +17,7 @@ export const SYM_LAZY_COMPONENT_INNER = Symbol.for("vencord.lazyComponent.inner"
* @param attempts How many times to try to get the component before giving up
* @returns Result of factory function
*/
export function LazyComponent<T extends object = {}>(factory: () => LazyComponentType<T>, attempts = 5) {
export function LazyComponent<T extends object = any>(factory: () => LazyComponentType<T>, attempts = 5) {
const get = makeLazy(factory, attempts, { isIndirect: true });
let InnerComponent = null as LazyComponentType<T> | null;

View file

@ -196,7 +196,7 @@ export function find<T = AnyObject>(filter: FilterFn, callback: (mod: any) => an
* @param parse A function that takes the found component as its first argument and returns a component. Useful if you want to wrap the found component in something. Defaults to the original component
* @returns The component if found, or a noop component
*/
export function findComponent<T extends object = {}>(filter: FilterFn, parse: (component: any) => LazyComponentType<T> = m => m, { isIndirect = false }: { isIndirect?: boolean; } = {}) {
export function findComponent<T extends object = any>(filter: FilterFn, parse: (component: any) => LazyComponentType<T> = m => m, { isIndirect = false }: { isIndirect?: boolean; } = {}) {
if (typeof filter !== "function")
throw new Error("Invalid filter. Expected a function got " + typeof filter);
if (typeof parse !== "function")
@ -241,7 +241,7 @@ export function findComponent<T extends object = {}>(filter: FilterFn, parse: (c
* @param parse A function that takes the found component as its first argument and returns a component. Useful if you want to wrap the found component in something. Defaults to the original component
* @returns The component if found, or a noop component
*/
export function findExportedComponent<T extends object = {}>(...props: string[] | [...string[], (component: any) => LazyComponentType<T>]) {
export function findExportedComponent<T extends object = any>(...props: string[] | [...string[], (component: any) => LazyComponentType<T>]) {
const parse = (typeof props.at(-1) === "function" ? props.pop() : m => m) as (component: any) => LazyComponentType<T>;
const newProps = props as string[];
@ -286,7 +286,7 @@ export function findExportedComponent<T extends object = {}>(...props: string[]
* @param parse A function that takes the found component as its first argument and returns a component. Useful if you want to wrap the found component in something. Defaults to the original component
* @returns The component if found, or a noop component
*/
export function findComponentByCode<T extends object = {}>(...code: string[] | [...string[], (component: any) => LazyComponentType<T>]) {
export function findComponentByCode<T extends object = any>(...code: string[] | [...string[], (component: any) => LazyComponentType<T>]) {
const parse = (typeof code.at(-1) === "function" ? code.pop() : m => m) as (component: any) => LazyComponentType<T>;
const newCode = code as string[];
@ -516,7 +516,7 @@ export function webpackDependantLazy<T = AnyObject>(factory: () => T, attempts?:
* @param attempts How many times to try to get the component before giving up
* @returns Result of factory function
*/
export function webpackDependantLazyComponent<T extends object = {}>(factory: () => any, attempts?: number) {
export function webpackDependantLazyComponent<T extends object = any>(factory: () => any, attempts?: number) {
if (IS_REPORTER) webpackSearchHistory.push(["webpackDependantLazyComponent", [factory]]);
return LazyComponent<T>(factory, attempts);