mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
chore(website): cleanup ts-errors
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { Analytics } from '@vercel/analytics/react';
|
||||
import type { Metadata } from 'next/types';
|
||||
import type { Metadata } from 'next';
|
||||
import type { PropsWithChildren } from 'react';
|
||||
import { Providers } from './providers';
|
||||
import { DESCRIPTION } from '~/util/constants';
|
||||
|
||||
@@ -10,10 +10,6 @@ export default withBundleAnalyzer({
|
||||
eslint: {
|
||||
ignoreDuringBuilds: true,
|
||||
},
|
||||
// Until Next.js fixes their type issues
|
||||
typescript: {
|
||||
ignoreBuildErrors: true,
|
||||
},
|
||||
outputFileTracing: true,
|
||||
experimental: {
|
||||
appDir: true,
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { get } from '@vercel/edge-config';
|
||||
import { NextResponse } from 'next/server';
|
||||
import type { ServerRuntime } from 'next/types';
|
||||
|
||||
export const runtime: ServerRuntime = 'edge';
|
||||
export const runtime = 'edge';
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
|
||||
@@ -3,9 +3,8 @@
|
||||
import type { ApiItemKind } from '@microsoft/api-extractor-model';
|
||||
import { ImageResponse } from '@vercel/og';
|
||||
import type { NextRequest } from 'next/server';
|
||||
import type { ServerRuntime } from 'next/types';
|
||||
|
||||
export const runtime: ServerRuntime = 'edge';
|
||||
export const runtime = 'edge';
|
||||
|
||||
const fonts = Promise.all([
|
||||
fetch(new URL('../../../assets/fonts/Inter-Regular.ttf', import.meta.url)).then(async (res) => res.arrayBuffer()),
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
/* eslint-disable react/no-unknown-property */
|
||||
|
||||
import { ImageResponse } from '@vercel/og';
|
||||
import type { ServerRuntime } from 'next/types';
|
||||
|
||||
export const runtime: ServerRuntime = 'edge';
|
||||
export const runtime = 'edge';
|
||||
|
||||
const fonts = fetch(new URL('../../../assets/fonts/Inter-Black.ttf', import.meta.url)).then(async (res) =>
|
||||
res.arrayBuffer(),
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
import { generatePath } from '@discordjs/api-extractor-utils';
|
||||
import { tryResolveSummaryText } from '@discordjs/scripts';
|
||||
import type { ApiClass, ApiDeclaredItem, ApiItemContainerMixin } from '@microsoft/api-extractor-model';
|
||||
import { ApiItemKind, ExcerptTokenKind } from '@microsoft/api-extractor-model';
|
||||
import type { NextRequest } from 'next/server';
|
||||
import { NextResponse } from 'next/server';
|
||||
import { memberPredicate } from '~/components/documentation/util';
|
||||
import { fetchMember } from '~/util/fetchMember';
|
||||
import { resolveMembers } from '~/util/members';
|
||||
|
||||
export const revalidate = 3_600;
|
||||
|
||||
export async function GET(_: NextRequest, { params }: { params: { item: string; package: string; version: string } }) {
|
||||
const member = await fetchMember({
|
||||
package: params.package,
|
||||
version: params.version,
|
||||
item: params.item,
|
||||
});
|
||||
|
||||
if (!member) {
|
||||
return new Response(null, { status: 404 });
|
||||
}
|
||||
|
||||
const model = member.getAssociatedModel();
|
||||
const excerpt = (member as ApiClass).extendsType?.excerpt;
|
||||
|
||||
return NextResponse.json({
|
||||
name: member.displayName,
|
||||
kind: member.kind,
|
||||
extendsFrom:
|
||||
excerpt?.spannedTokens
|
||||
.map((token) => {
|
||||
if (token.kind === ExcerptTokenKind.Reference) {
|
||||
const referenceItem = member
|
||||
.getAssociatedModel()
|
||||
?.resolveDeclarationReference(token.canonicalReference!, model).resolvedApiItem;
|
||||
|
||||
if (referenceItem) {
|
||||
return {
|
||||
name: referenceItem.displayName,
|
||||
kind: referenceItem.kind,
|
||||
summary: tryResolveSummaryText(referenceItem as unknown as ApiDeclaredItem) ?? '',
|
||||
path: generatePath(referenceItem.getHierarchy(), params.version),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
})
|
||||
.filter(Boolean) ?? null,
|
||||
summary: tryResolveSummaryText(member as ApiDeclaredItem) ?? '',
|
||||
path: generatePath(member.getHierarchy(), params.version),
|
||||
members:
|
||||
member.kind === ApiItemKind.Class || member.kind === ApiItemKind.Interface
|
||||
? resolveMembers(member as ApiItemContainerMixin, memberPredicate).map((member) => {
|
||||
const isDeprecated = Boolean(member.item.tsdocComment?.deprecatedBlock);
|
||||
|
||||
return {
|
||||
inheritedFrom: member.inherited
|
||||
? {
|
||||
name: member.inherited.displayName,
|
||||
kind: member.inherited.kind,
|
||||
summary: tryResolveSummaryText(member.inherited as unknown as ApiDeclaredItem) ?? '',
|
||||
path: generatePath(member.inherited.getHierarchy(), params.version),
|
||||
}
|
||||
: null,
|
||||
name: member.item.displayName,
|
||||
kind: member.item.kind,
|
||||
deprecated: isDeprecated,
|
||||
// @ts-expect-error: Typings
|
||||
readonly: member.item.isReadonly ?? false,
|
||||
optional: member.item.isOptional,
|
||||
// @ts-expect-error: Typings
|
||||
static: member.item.isStatic ?? false,
|
||||
// @ts-expect-error: Typings
|
||||
protected: member.item.isProtected ?? false,
|
||||
summary: tryResolveSummaryText(member.item as ApiDeclaredItem) ?? '',
|
||||
path: generatePath(member.item.getHierarchy(), params.version),
|
||||
};
|
||||
})
|
||||
: null,
|
||||
});
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { connect } from '@planetscale/database';
|
||||
|
||||
const sql = connect({
|
||||
async fetch(input, init) {
|
||||
// @ts-expect-error: Deleting cache or setting as undefined, same thing
|
||||
return fetch(input, { ...init, cache: undefined, next: { revalidate: 3_600 } });
|
||||
},
|
||||
url: process.env.DATABASE_URL!,
|
||||
|
||||
@@ -15,8 +15,8 @@ import type {
|
||||
ApiFunction,
|
||||
} from '@microsoft/api-extractor-model';
|
||||
import { ApiItemKind, ApiModel } from '@microsoft/api-extractor-model';
|
||||
import type { Metadata } from 'next';
|
||||
import { notFound } from 'next/navigation';
|
||||
import type { Metadata } from 'next/types';
|
||||
import { fetchModelJSON } from '~/app/docAPI';
|
||||
import { Class } from '~/components/model/Class';
|
||||
import { Interface } from '~/components/model/Interface';
|
||||
@@ -42,11 +42,11 @@ async function fetchHeadMember({ package: packageName, version, item }: ItemRout
|
||||
return findMember(model, packageName, memberName);
|
||||
}
|
||||
|
||||
function resolveMemberSearchParams(packageName: string, member: ApiItem) {
|
||||
function resolveMemberSearchParams(packageName: string, member?: ApiItem) {
|
||||
const params = new URLSearchParams({
|
||||
pkg: packageName,
|
||||
kind: member?.kind,
|
||||
name: member?.displayName,
|
||||
kind: member?.kind ?? '',
|
||||
name: member?.displayName ?? '',
|
||||
});
|
||||
|
||||
switch (member?.kind) {
|
||||
|
||||
@@ -3,10 +3,9 @@ import { VscArrowRight } from '@react-icons/all-files/vsc/VscArrowRight';
|
||||
import { VscVersions } from '@react-icons/all-files/vsc/VscVersions';
|
||||
import Link from 'next/link';
|
||||
import { notFound } from 'next/navigation';
|
||||
import type { ServerRuntime } from 'next/types';
|
||||
import { PACKAGES } from '~/util/constants';
|
||||
|
||||
export const runtime: ServerRuntime = 'edge';
|
||||
export const runtime = 'edge';
|
||||
|
||||
async function getData(pkg: string) {
|
||||
if (!PACKAGES.includes(pkg)) {
|
||||
|
||||
@@ -3,10 +3,9 @@ import { VscArrowLeft } from '@react-icons/all-files/vsc/VscArrowLeft';
|
||||
import { VscArrowRight } from '@react-icons/all-files/vsc/VscArrowRight';
|
||||
import { VscPackage } from '@react-icons/all-files/vsc/VscPackage';
|
||||
import Link from 'next/link';
|
||||
import type { ServerRuntime } from 'next/types';
|
||||
import { PACKAGES } from '~/util/constants';
|
||||
|
||||
export const runtime: ServerRuntime = 'edge';
|
||||
export const runtime = 'edge';
|
||||
|
||||
export default function Page() {
|
||||
return (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Analytics } from '@vercel/analytics/react';
|
||||
import type { Metadata } from 'next/types';
|
||||
import type { Metadata } from 'next';
|
||||
import type { PropsWithChildren } from 'react';
|
||||
import { Providers } from './providers';
|
||||
import { DESCRIPTION } from '~/util/constants';
|
||||
@@ -44,7 +44,7 @@ export const metadata: Metadata = {
|
||||
|
||||
themeColor: [
|
||||
{ media: '(prefers-color-scheme: light)', color: '#f1f3f5' },
|
||||
{ media: '(prefers-color-scheme: dark)', color: '#181818' },
|
||||
{ media: '(prefers-color-scheme: dark)', color: '#1c1c1e' },
|
||||
],
|
||||
colorScheme: 'light dark',
|
||||
|
||||
@@ -68,7 +68,7 @@ export const metadata: Metadata = {
|
||||
},
|
||||
|
||||
other: {
|
||||
'msapplication-TileColor': '#090a16',
|
||||
'msapplication-TileColor': '#1c1c1e',
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ export default function NotFound() {
|
||||
<h2 className="text-[2rem] md:text-[3rem]">Not found.</h2>
|
||||
<Link
|
||||
className="h-11 flex flex-row transform-gpu cursor-pointer select-none appearance-none place-items-center border-0 rounded bg-blurple px-6 text-base font-semibold leading-none text-white no-underline outline-0 active:translate-y-px focus:ring focus:ring-width-2 focus:ring-white"
|
||||
href="/docs/packages"
|
||||
href="/docs"
|
||||
>
|
||||
Take me back
|
||||
</Link>
|
||||
|
||||
@@ -74,6 +74,7 @@ export function TSDoc({ item, tsdoc }: { item: ApiItem; tsdoc: DocNode }): JSX.E
|
||||
|
||||
case DocNodeKind.FencedCode: {
|
||||
const { language, code } = tsdoc as DocFencedCode;
|
||||
// @ts-expect-error async component
|
||||
return <SyntaxHighlighter code={code.trim()} key={idx} lang={language ?? 'typescript'} />;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { ApiEntryPoint, ApiItem, ApiModel } from '@microsoft/api-extractor-model';
|
||||
import type { ApiEntryPoint, ApiModel } from '@microsoft/api-extractor-model';
|
||||
|
||||
export function findMemberByKey(model: ApiModel, packageName: string, containerKey: string) {
|
||||
const pkg = model.tryGetPackageByName(`@discordjs/${packageName}`)!;
|
||||
|
||||
Reference in New Issue
Block a user