busi488energy/next-shim.d.ts

110 lines
4.0 KiB
TypeScript

/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-empty-object-type */
/* eslint-disable import/no-default-export */
// shim any nextjs modules that don't behave well with nodenext in here
// see: file://./node_modules/next/dynamic.d.ts
declare module 'next/dynamic' {
import React from 'react';
type ComponentModule<P = {}> = {
default: React.ComponentType<P>;
};
export declare type LoaderComponent<P = {}> = Promise<React.ComponentType<P> | ComponentModule<P>>;
export declare type Loader<P = {}> = (() => LoaderComponent<P>) | LoaderComponent<P>;
export type LoaderMap = {
[module: string]: () => Loader<any>;
};
export type LoadableGeneratedOptions = {
webpack?(): any;
modules?(): LoaderMap;
};
export type DynamicOptionsLoadingProps = {
error?: Error | null;
isLoading?: boolean;
pastDelay?: boolean;
retry?: () => void;
timedOut?: boolean;
};
export type DynamicOptions<P = {}> = LoadableGeneratedOptions & {
loading?: (loadingProps: DynamicOptionsLoadingProps) => React.ReactNode;
loader?: Loader<P> | LoaderMap;
loadableGenerated?: LoadableGeneratedOptions;
ssr?: boolean;
};
export type LoadableOptions<P = {}> = DynamicOptions<P>;
export type LoadableFn<P = {}> = (opts: LoadableOptions<P>) => React.ComponentType<P>;
export type LoadableComponent<P = {}> = React.ComponentType<P>;
export declare function noSSR<P = {}>(
LoadableInitializer: LoadableFn<P>,
loadableOptions: DynamicOptions<P>,
): React.ComponentType<P>;
/**
* This function lets you dynamically import a component.
* It uses [React.lazy()](https://react.dev/reference/react/lazy) with [Suspense](https://react.dev/reference/react/Suspense) under the hood.
*
* Read more: [Next.js Docs: `next/dynamic`](https://nextjs.org/docs/app/building-your-application/optimizing/lazy-loading#nextdynamic)
*/
export default function dynamic<P = {}>(
dynamicOptions: DynamicOptions<P> | Loader<P>,
options?: DynamicOptions<P>,
): React.ComponentType<P>;
export {};
}
// see: file://./node_modules/next/link.d.ts
declare module 'next/link' {
import React from 'react';
import type { UrlObject } from 'url';
type Url = string | UrlObject;
type OnNavigateEventHandler = (event: { preventDefault: () => void }) => void;
type InternalLinkProps = {
href: Url;
as?: Url;
replace?: boolean;
scroll?: boolean;
shallow?: boolean;
passHref?: boolean;
prefetch?: boolean | 'auto' | null;
locale?: string | false;
legacyBehavior?: boolean;
onMouseEnter?: React.MouseEventHandler<HTMLAnchorElement>;
onTouchStart?: React.TouchEventHandler<HTMLAnchorElement>;
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
onNavigate?: OnNavigateEventHandler;
};
export interface LinkProps<RouteInferType = any> extends InternalLinkProps {}
declare const Link: React.ForwardRefExoticComponent<
Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof LinkProps<any>> &
LinkProps<any> & {
children?: React.ReactNode | undefined;
} & React.RefAttributes<HTMLAnchorElement>
>;
export declare const useLinkStatus: () => { pending: boolean };
export default Link;
}
// see: file://./node_modules/next/error.d.ts
declare module 'next/error' {
import React from 'react';
import type { NextPageContext } from '../shared/lib/utils';
export type ErrorProps = {
statusCode: number;
hostname?: string;
title?: string;
withDarkMode?: boolean;
};
declare function _getInitialProps({ req, res, err }: NextPageContext): Promise<ErrorProps> | ErrorProps;
/**
* `Error` component used for handling errors.
*/
export default class Error<P = {}> extends React.Component<P & ErrorProps> {
static displayName: string;
static getInitialProps: typeof _getInitialProps;
static origGetInitialProps: typeof _getInitialProps;
render(): import('react/jsx-runtime').JSX.Element;
}
export {};
}