chore: use descriptive type parameter names (#9937)

* chore: use descriptive type parameter names

* refactor: requested changes

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Almeida
2023-11-12 17:21:51 +00:00
committed by GitHub
parent 4ff3ea4a1b
commit 975d5f18ae
34 changed files with 1104 additions and 895 deletions

View File

@@ -6,7 +6,7 @@ import { usePathname } from 'next/navigation';
import type { PropsWithChildren } from 'react';
import { useCurrentPathMeta } from '~/hooks/useCurrentPathMeta';
export interface ItemLinkProps<T extends string> extends Omit<LinkProps<T>, 'href'> {
export interface ItemLinkProps<Route extends string> extends Omit<LinkProps<Route>, 'href'> {
readonly className?: string;
/**
* The URI of the api item to link to. (e.g. `/RestManager`)
@@ -29,7 +29,7 @@ export interface ItemLinkProps<T extends string> extends Omit<LinkProps<T>, 'hre
* This component only needs the relative path to the item, and will automatically
* generate the full path to the item client-side.
*/
export function ItemLink<T extends string>(props: PropsWithChildren<ItemLinkProps<T>>) {
export function ItemLink<Route extends string>(props: PropsWithChildren<ItemLinkProps<Route>>) {
const pathname = usePathname();
const { packageName, version } = useCurrentPathMeta();

View File

@@ -6,9 +6,9 @@ import type { ApiItem, ApiItemContainerMixin } from '@discordjs/api-extractor-mo
* @param parent - The parent to resolve the inherited members of.
* @param predicate - A predicate to filter the members by.
*/
export function resolveMembers<T extends ApiItem>(
export function resolveMembers<WantedItem extends ApiItem>(
parent: ApiItemContainerMixin,
predicate: (item: ApiItem) => item is T,
predicate: (item: ApiItem) => item is WantedItem,
) {
const seenItems = new Set<string>();
const inheritedMembers = parent.findMembersWithInheritance().items.reduce((acc, item) => {
@@ -25,14 +25,17 @@ export function resolveMembers<T extends ApiItem>(
}
return acc;
}, new Array<{ inherited?: ApiItemContainerMixin | undefined; item: T }>());
}, new Array<{ inherited?: ApiItemContainerMixin | undefined; item: WantedItem }>());
const mergedMembers = parent
.getMergedSiblings()
.filter((sibling) => sibling.containerKey !== parent.containerKey)
.flatMap((sibling) => (sibling as ApiItemContainerMixin).findMembersWithInheritance().items)
.filter((item) => predicate(item) && !seenItems.has(item.containerKey))
.map((item) => ({ item: item as T, inherited: item.parent ? (item.parent as ApiItemContainerMixin) : undefined }));
.map((item) => ({
item: item as WantedItem,
inherited: item.parent ? (item.parent as ApiItemContainerMixin) : undefined,
}));
return [...inheritedMembers, ...mergedMembers];
}