diff --git a/packages/docusaurus-module-type-aliases/src/index.d.ts b/packages/docusaurus-module-type-aliases/src/index.d.ts index 9714e56873..d61de8b4da 100644 --- a/packages/docusaurus-module-type-aliases/src/index.d.ts +++ b/packages/docusaurus-module-type-aliases/src/index.d.ts @@ -69,11 +69,41 @@ declare module '@generated/codeTranslations' { export default codeTranslations; } -declare module '@theme/*'; - declare module '@theme-original/*'; -declare module '@docusaurus/*'; +declare module '@theme/Layout' { + import type {ReactNode} from 'react'; + + export interface Props { + readonly children: ReactNode; + readonly title?: string; + readonly description?: string; + } + export default function Layout(props: Props): JSX.Element; +} + +declare module '@theme/Loading' { + import type {LoadingComponentProps} from 'react-loadable'; + + export default function Loading(props: LoadingComponentProps): JSX.Element; +} + +declare module '@theme/NotFound' { + export default function NotFound(props: any): JSX.Element; +} + +declare module '@theme/Root' { + import type {ReactNode} from 'react'; + + export interface Props { + readonly children: ReactNode; + } + export default function Root({children}: Props): JSX.Element; +} + +declare module '@docusaurus/constants' { + export const DEFAULT_PLUGIN_ID: 'default'; +} declare module '@docusaurus/Head' { import type {HelmetProps} from 'react-helmet'; diff --git a/packages/docusaurus-plugin-ideal-image/.npmignore b/packages/docusaurus-plugin-ideal-image/.npmignore index 4978437c5d..c59f11ebb5 100644 --- a/packages/docusaurus-plugin-ideal-image/.npmignore +++ b/packages/docusaurus-plugin-ideal-image/.npmignore @@ -1,2 +1 @@ -src -copyUntypedFiles.js \ No newline at end of file +copyUntypedFiles.js diff --git a/packages/docusaurus-plugin-ideal-image/package.json b/packages/docusaurus-plugin-ideal-image/package.json index d682f2f4b6..37e3dbba8f 100644 --- a/packages/docusaurus-plugin-ideal-image/package.json +++ b/packages/docusaurus-plugin-ideal-image/package.json @@ -3,6 +3,7 @@ "version": "2.0.0-beta.7", "description": "Docusaurus Plugin to generate an almost ideal image (responsive, lazy-loading, and low quality placeholder).", "main": "lib/index.js", + "types": "src/plugin-ideal-image.d.ts", "scripts": { "build": "tsc && node copyUntypedFiles.js", "watch": "node copyUntypedFiles.js && tsc --watch" diff --git a/packages/docusaurus-plugin-ideal-image/src/index.ts b/packages/docusaurus-plugin-ideal-image/src/index.ts index 70d3a6631e..d62ddcb9e8 100644 --- a/packages/docusaurus-plugin-ideal-image/src/index.ts +++ b/packages/docusaurus-plugin-ideal-image/src/index.ts @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ import {LoadContext, Plugin} from '@docusaurus/types'; -import {PluginOptions} from './types'; +import type {PluginOptions} from '@docusaurus/plugin-ideal-image'; import {Configuration} from 'webpack'; import path from 'path'; diff --git a/packages/docusaurus-plugin-ideal-image/src/plugin-ideal-image.d.ts b/packages/docusaurus-plugin-ideal-image/src/plugin-ideal-image.d.ts new file mode 100644 index 0000000000..6e2a3eff21 --- /dev/null +++ b/packages/docusaurus-plugin-ideal-image/src/plugin-ideal-image.d.ts @@ -0,0 +1,50 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +declare module '@docusaurus/plugin-ideal-image' { + export type PluginOptions = { + /** + * Filename template for output files. + */ + name?: string; + /** + * Specify all widths you want to use; if a specified size exceeds the original image's width, the latter will be used (i.e. images won't be scaled up). You may also declare a default sizes array in the loader options in your webpack.config.js. + */ + sizes?: number[]; + /** + * Specify one width you want to use; if the specified size exceeds the original image's width, the latter will be used (i.e. images won't be scaled up) + */ + size?: number; + /** + * As an alternative to manually specifying sizes, you can specify min, max and steps, and the sizes will be generated for you. + */ + min?: number; + /** + * See min above + */ + max?: number; + /** + * Configure the number of images generated between min and max (inclusive) + */ + steps?: number; + /** + * JPEG compression quality + */ + quality?: number; + }; +} + +declare module '@theme/IdealImage' { + import type {ComponentProps} from 'react'; + + export interface Props extends ComponentProps<'img'> { + img: any; + } + export default function IdealImage(props: Props): JSX.Element; +} + +declare module '@endiliey/react-ideal-image'; diff --git a/packages/docusaurus-plugin-ideal-image/src/types.ts b/packages/docusaurus-plugin-ideal-image/src/types.ts deleted file mode 100644 index 2f034e2129..0000000000 --- a/packages/docusaurus-plugin-ideal-image/src/types.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -export interface PluginOptions { - /** - * Filename template for output files. - */ - name?: string; - /** - * Specify all widths you want to use; if a specified size exceeds the original image's width, the latter will be used (i.e. images won't be scaled up). You may also declare a default sizes array in the loader options in your webpack.config.js. - */ - sizes?: number[]; - /** - * Specify one width you want to use; if the specified size exceeds the original image's width, the latter will be used (i.e. images won't be scaled up) - */ - size?: number; - /** - * As an alternative to manually specifying sizes, you can specify min, max and steps, and the sizes will be generated for you. - */ - min?: number; - /** - * See min above - */ - max?: number; - /** - * Configure the number of images generated between min and max (inclusive) - */ - steps?: number; - /** - * JPEG compression quality - */ - quality?: number; -} diff --git a/packages/docusaurus-theme-classic/src/types.d.ts b/packages/docusaurus-theme-classic/src/types.d.ts index d2c8d415c8..cabd03ed3e 100644 --- a/packages/docusaurus-theme-classic/src/types.d.ts +++ b/packages/docusaurus-theme-classic/src/types.d.ts @@ -19,6 +19,10 @@ declare module '@theme/AnnouncementBar' { export default AnnouncementBar; } +declare module '@theme/BackToTopButton' { + export default function BackToTopButton(): JSX.Element; +} + declare module '@theme/BlogListPaginator' { import type {Metadata} from '@theme/BlogListPage'; @@ -505,6 +509,10 @@ declare module '@theme/NavbarItem' { export default NavbarItem; } +declare module '@theme/SearchBar' { + export default function SearchBar(): JSX.Element; +} + declare module '@theme/TabItem' { import type {ReactNode} from 'react'; diff --git a/packages/docusaurus/src/client/exports/constants.ts b/packages/docusaurus/src/client/exports/constants.ts index 48fa05bd69..e7e5a1dcc2 100644 --- a/packages/docusaurus/src/client/exports/constants.ts +++ b/packages/docusaurus/src/client/exports/constants.ts @@ -5,16 +5,5 @@ * LICENSE file in the root directory of this source tree. */ -/* -// eslint-disable-next-line no-restricted-imports -export { - // constants were only available on node - // this makes some useful constants available to frontend/themes too - // import {DEFAULT_PLUGIN_ID} '@docusaurus/constants' - DEFAULT_PLUGIN_ID, -} from '../../constants'; - */ - -// Not duplicating the constants seems to produce -// weird TS compilation side-effects +// Constants used on the client-side: duplicated from server-side code export const DEFAULT_PLUGIN_ID = 'default'; diff --git a/packages/docusaurus/src/client/exports/useGlobalData.ts b/packages/docusaurus/src/client/exports/useGlobalData.ts index 15c9034acc..155ee22e6f 100644 --- a/packages/docusaurus/src/client/exports/useGlobalData.ts +++ b/packages/docusaurus/src/client/exports/useGlobalData.ts @@ -6,12 +6,7 @@ */ import useDocusaurusContext from './useDocusaurusContext'; - -// TODO annoying constant duplication -// if we import something from outside the /client folder, -// the tsc directory structure is affected -// import {DEFAULT_PLUGIN_ID} from '../../constants'; -const DEFAULT_PLUGIN_ID = 'default'; +import {DEFAULT_PLUGIN_ID} from './constants'; export default function useGlobalData(): Record { const {globalData} = useDocusaurusContext(); diff --git a/website/src/types.d.ts b/website/src/types.d.ts new file mode 100644 index 0000000000..75278b9bdd --- /dev/null +++ b/website/src/types.d.ts @@ -0,0 +1 @@ +///