@docusaurus/module-type-aliases 2.0.0-beta.138b4c997 → 2.0.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/index.d.ts +122 -46
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/module-type-aliases",
3
- "version": "2.0.0-beta.138b4c997",
3
+ "version": "2.0.0-beta.14",
4
4
  "description": "Docusaurus module type aliases.",
5
5
  "types": "./src/index.d.ts",
6
6
  "publishConfig": {
@@ -11,13 +11,13 @@
11
11
  "url": "https://github.com/facebook/docusaurus.git",
12
12
  "directory": "packages/docusaurus-module-type-aliases"
13
13
  },
14
- "devDependencies": {
14
+ "dependencies": {
15
+ "@docusaurus/types": "2.0.0-beta.14",
15
16
  "@types/react": "*",
16
17
  "@types/react-helmet": "*",
17
- "@types/react-loadable": "*",
18
18
  "@types/react-router-config": "*",
19
19
  "@types/react-router-dom": "*"
20
20
  },
21
21
  "license": "MIT",
22
- "gitHead": "8cc620648710971acc459aabd2c6f505ef757701"
22
+ "gitHead": "c4824a8937d8f1aa0806667749cbc74058e2b294"
23
23
  }
package/src/index.d.ts CHANGED
@@ -6,45 +6,57 @@
6
6
  */
7
7
 
8
8
  declare module '@generated/client-modules' {
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
10
  const clientModules: readonly any[];
10
11
  export default clientModules;
11
12
  }
12
13
 
13
14
  declare module '@generated/docusaurus.config' {
14
- const config: any;
15
+ import type {DocusaurusConfig} from '@docusaurus/types';
16
+
17
+ const config: DocusaurusConfig;
15
18
  export default config;
16
19
  }
17
20
 
18
21
  declare module '@generated/site-metadata' {
19
- const siteMetadata: any;
20
- export default siteMetadata;
22
+ import type {DocusaurusSiteMetadata} from '@docusaurus/types';
23
+
24
+ const siteMetadata: DocusaurusSiteMetadata;
25
+ export = siteMetadata;
21
26
  }
22
27
 
23
28
  declare module '@generated/registry' {
24
29
  const registry: {
30
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
31
  readonly [key: string]: [() => Promise<any>, string, string];
26
32
  };
27
33
  export default registry;
28
34
  }
29
35
 
30
36
  declare module '@generated/routes' {
37
+ import type {RouteConfig} from 'react-router-config';
38
+
31
39
  type Route = {
32
40
  readonly path: string;
33
- readonly component: any;
41
+ readonly component: RouteConfig['component'];
34
42
  readonly exact?: boolean;
43
+ readonly routes?: Route[];
35
44
  };
36
45
  const routes: Route[];
37
46
  export default routes;
38
47
  }
39
48
 
40
49
  declare module '@generated/routesChunkNames' {
41
- const routesChunkNames: Record<string, Record<string, string>>;
42
- export default routesChunkNames;
50
+ import type {RouteChunksTree} from '@docusaurus/types';
51
+
52
+ const routesChunkNames: Record<string, RouteChunksTree>;
53
+ export = routesChunkNames;
43
54
  }
44
55
 
45
56
  declare module '@generated/globalData' {
46
- const globalData: Record<string, unknown>;
47
- export default globalData;
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
+ const globalData: Record<string, any>;
59
+ export = globalData;
48
60
  }
49
61
 
50
62
  declare module '@generated/i18n' {
@@ -54,19 +66,68 @@ declare module '@generated/i18n' {
54
66
  currentLocale: string;
55
67
  localeConfigs: Record<string, {label: string; direction: string}>;
56
68
  };
57
- export default i18n;
69
+ export = i18n;
58
70
  }
59
71
 
60
72
  declare module '@generated/codeTranslations' {
61
73
  const codeTranslations: Record<string, string>;
62
- export default codeTranslations;
74
+ export = codeTranslations;
63
75
  }
64
76
 
65
- declare module '@theme/*';
66
-
67
77
  declare module '@theme-original/*';
68
78
 
69
- declare module '@docusaurus/*';
79
+ declare module '@theme/Error' {
80
+ export interface Props {
81
+ readonly error: Error;
82
+ readonly tryAgain: () => void;
83
+ }
84
+ export default function Error(props: Props): JSX.Element;
85
+ }
86
+
87
+ declare module '@theme/Layout' {
88
+ import type {ReactNode} from 'react';
89
+
90
+ export interface Props {
91
+ readonly children: ReactNode;
92
+ readonly title?: string;
93
+ readonly description?: string;
94
+ }
95
+ export default function Layout(props: Props): JSX.Element;
96
+ }
97
+
98
+ declare module '@theme/Loading' {
99
+ import type {LoadingComponentProps} from 'react-loadable';
100
+
101
+ export default function Loading(props: LoadingComponentProps): JSX.Element;
102
+ }
103
+
104
+ declare module '@theme/NotFound' {
105
+ export default function NotFound(): JSX.Element;
106
+ }
107
+
108
+ declare module '@theme/Root' {
109
+ import type {ReactNode} from 'react';
110
+
111
+ export interface Props {
112
+ readonly children: ReactNode;
113
+ }
114
+ export default function Root({children}: Props): JSX.Element;
115
+ }
116
+
117
+ declare module '@docusaurus/constants' {
118
+ export const DEFAULT_PLUGIN_ID: 'default';
119
+ }
120
+
121
+ declare module '@docusaurus/ErrorBoundary' {
122
+ import type {ReactNode} from 'react';
123
+ import ErrorComponent from '@theme/Error';
124
+
125
+ export interface Props {
126
+ readonly fallback?: typeof ErrorComponent;
127
+ readonly children: ReactNode;
128
+ }
129
+ export default function ErrorBoundary(props: Props): JSX.Element;
130
+ }
70
131
 
71
132
  declare module '@docusaurus/Head' {
72
133
  import type {HelmetProps} from 'react-helmet';
@@ -79,21 +140,21 @@ declare module '@docusaurus/Head' {
79
140
  }
80
141
 
81
142
  declare module '@docusaurus/Link' {
82
- import type {ReactNode} from 'react';
83
-
84
- type RRLinkProps = Partial<import('react-router-dom').LinkProps>;
85
- export type LinkProps = RRLinkProps & {
86
- readonly isNavLink?: boolean;
87
- readonly to?: string;
88
- readonly href?: string;
89
- readonly activeClassName?: string;
90
- readonly children?: ReactNode;
91
- readonly isActive?: (match: any, location: any) => boolean;
92
- readonly autoAddBaseUrl?: boolean;
93
-
94
- // escape hatch in case broken links check is annoying for a specific link
95
- readonly 'data-noBrokenLinkCheck'?: boolean;
96
- };
143
+ import type {CSSProperties, ComponentProps} from 'react';
144
+
145
+ type NavLinkProps = Partial<import('react-router-dom').NavLinkProps>;
146
+ export type LinkProps = NavLinkProps &
147
+ ComponentProps<'a'> & {
148
+ readonly className?: string;
149
+ readonly style?: CSSProperties;
150
+ readonly isNavLink?: boolean;
151
+ readonly to?: string;
152
+ readonly href?: string;
153
+ readonly autoAddBaseUrl?: boolean;
154
+
155
+ // escape hatch in case broken links check is annoying for a specific link
156
+ readonly 'data-noBrokenLinkCheck'?: boolean;
157
+ };
97
158
  const Link: (props: LinkProps) => JSX.Element;
98
159
  export default Link;
99
160
  }
@@ -108,7 +169,7 @@ declare module '@docusaurus/Interpolate' {
108
169
 
109
170
  export type InterpolateValues<
110
171
  Str extends string,
111
- Value extends ReactNode
172
+ Value extends ReactNode,
112
173
  > = Record<ExtractInterpolatePlaceholders<Str>, Value>;
113
174
 
114
175
  // TS function overload: if all the values are plain strings, then interpolate returns a simple string
@@ -134,16 +195,16 @@ declare module '@docusaurus/Interpolate' {
134
195
  }
135
196
 
136
197
  declare module '@docusaurus/Translate' {
137
- import type {
138
- InterpolateProps,
139
- InterpolateValues,
140
- } from '@docusaurus/Interpolate';
141
-
142
- export type TranslateParam<Str extends string> = Partial<
143
- InterpolateProps<Str>
144
- > & {
145
- message: Str;
146
- id?: string;
198
+ import type {ReactNode} from 'react';
199
+ import type {InterpolateValues} from '@docusaurus/Interpolate';
200
+
201
+ // TS type to ensure that at least one of id or message is always provided
202
+ // (Generic permits to handled message provided as React children)
203
+ type IdOrMessage<MessageKey extends 'children' | 'message'> =
204
+ | ({[key in MessageKey]: string} & {id?: string})
205
+ | ({[key in MessageKey]?: string} & {id: string});
206
+
207
+ export type TranslateParam<Str extends string> = IdOrMessage<'message'> & {
147
208
  description?: string;
148
209
  values?: InterpolateValues<Str, string | number>;
149
210
  };
@@ -153,9 +214,9 @@ declare module '@docusaurus/Translate' {
153
214
  values?: InterpolateValues<Str, string | number>,
154
215
  ): string;
155
216
 
156
- export type TranslateProps<Str extends string> = InterpolateProps<Str> & {
157
- id?: string;
217
+ export type TranslateProps<Str extends string> = IdOrMessage<'children'> & {
158
218
  description?: string;
219
+ values?: InterpolateValues<Str, ReactNode>;
159
220
  };
160
221
 
161
222
  export default function Translate<Str extends string>(
@@ -173,7 +234,13 @@ declare module '@docusaurus/history' {
173
234
  }
174
235
 
175
236
  declare module '@docusaurus/useDocusaurusContext' {
176
- export default function (): any;
237
+ import type {DocusaurusContext} from '@docusaurus/types';
238
+
239
+ export default function useDocusaurusContext(): DocusaurusContext;
240
+ }
241
+
242
+ declare module '@docusaurus/useIsBrowser' {
243
+ export default function useIsBrowser(): boolean;
177
244
  }
178
245
 
179
246
  declare module '@docusaurus/useBaseUrl' {
@@ -215,10 +282,10 @@ declare module '@docusaurus/ComponentCreator' {
215
282
  }
216
283
 
217
284
  declare module '@docusaurus/BrowserOnly' {
218
- export type Props = {
219
- children?: () => JSX.Element;
220
- fallback?: JSX.Element;
221
- };
285
+ export interface Props {
286
+ readonly children?: () => JSX.Element;
287
+ readonly fallback?: JSX.Element;
288
+ }
222
289
  const BrowserOnly: (props: Props) => JSX.Element | null;
223
290
  export default BrowserOnly;
224
291
  }
@@ -249,10 +316,19 @@ declare module '@docusaurus/useGlobalData' {
249
316
  pluginId?: string,
250
317
  ): T;
251
318
 
319
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
252
320
  function useGlobalData(): Record<string, any>;
253
321
  export default useGlobalData;
254
322
  }
255
323
 
324
+ declare module '*.svg' {
325
+ import type {ComponentType, SVGProps} from 'react';
326
+
327
+ const ReactComponent: ComponentType<SVGProps<SVGSVGElement>>;
328
+
329
+ export default ReactComponent;
330
+ }
331
+
256
332
  declare module '*.module.css' {
257
333
  const classes: {readonly [key: string]: string};
258
334
  export default classes;