@docusaurus/module-type-aliases 2.0.0-beta.8bda3b2db → 2.0.0-beta.9

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 +3 -4
  2. package/src/index.d.ts +87 -40
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/module-type-aliases",
3
- "version": "2.0.0-beta.8bda3b2db",
3
+ "version": "2.0.0-beta.9",
4
4
  "description": "Docusaurus module type aliases.",
5
5
  "types": "./src/index.d.ts",
6
6
  "publishConfig": {
@@ -11,13 +11,12 @@
11
11
  "url": "https://github.com/facebook/docusaurus.git",
12
12
  "directory": "packages/docusaurus-module-type-aliases"
13
13
  },
14
- "devDependencies": {
14
+ "dependencies": {
15
15
  "@types/react": "*",
16
16
  "@types/react-helmet": "*",
17
- "@types/react-loadable": "*",
18
17
  "@types/react-router-config": "*",
19
18
  "@types/react-router-dom": "*"
20
19
  },
21
20
  "license": "MIT",
22
- "gitHead": "11a61b194f840ae0d554849a71c0d9447ef770af"
21
+ "gitHead": "8a491fc29ad002f90e97f5b5fe4178ac8fa0c4d7"
23
22
  }
package/src/index.d.ts CHANGED
@@ -6,32 +6,41 @@
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;
22
+ import type {DocusaurusSiteMetadata} from '@docusaurus/types';
23
+
24
+ const siteMetadata: DocusaurusSiteMetadata;
20
25
  export default 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;
@@ -43,7 +52,8 @@ declare module '@generated/routesChunkNames' {
43
52
  }
44
53
 
45
54
  declare module '@generated/globalData' {
46
- const globalData: Record<string, unknown>;
55
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
56
+ const globalData: Record<string, any>;
47
57
  export default globalData;
48
58
  }
49
59
 
@@ -62,11 +72,41 @@ declare module '@generated/codeTranslations' {
62
72
  export default codeTranslations;
63
73
  }
64
74
 
65
- declare module '@theme/*';
66
-
67
75
  declare module '@theme-original/*';
68
76
 
69
- declare module '@docusaurus/*';
77
+ declare module '@theme/Layout' {
78
+ import type {ReactNode} from 'react';
79
+
80
+ export interface Props {
81
+ readonly children: ReactNode;
82
+ readonly title?: string;
83
+ readonly description?: string;
84
+ }
85
+ export default function Layout(props: Props): JSX.Element;
86
+ }
87
+
88
+ declare module '@theme/Loading' {
89
+ import type {LoadingComponentProps} from 'react-loadable';
90
+
91
+ export default function Loading(props: LoadingComponentProps): JSX.Element;
92
+ }
93
+
94
+ declare module '@theme/NotFound' {
95
+ export default function NotFound(): JSX.Element;
96
+ }
97
+
98
+ declare module '@theme/Root' {
99
+ import type {ReactNode} from 'react';
100
+
101
+ export interface Props {
102
+ readonly children: ReactNode;
103
+ }
104
+ export default function Root({children}: Props): JSX.Element;
105
+ }
106
+
107
+ declare module '@docusaurus/constants' {
108
+ export const DEFAULT_PLUGIN_ID: 'default';
109
+ }
70
110
 
71
111
  declare module '@docusaurus/Head' {
72
112
  import type {HelmetProps} from 'react-helmet';
@@ -79,21 +119,21 @@ declare module '@docusaurus/Head' {
79
119
  }
80
120
 
81
121
  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
- };
122
+ import type {CSSProperties, ComponentProps} from 'react';
123
+
124
+ type NavLinkProps = Partial<import('react-router-dom').NavLinkProps>;
125
+ export type LinkProps = NavLinkProps &
126
+ ComponentProps<'a'> & {
127
+ readonly className?: string;
128
+ readonly style?: CSSProperties;
129
+ readonly isNavLink?: boolean;
130
+ readonly to?: string;
131
+ readonly href?: string;
132
+ readonly autoAddBaseUrl?: boolean;
133
+
134
+ // escape hatch in case broken links check is annoying for a specific link
135
+ readonly 'data-noBrokenLinkCheck'?: boolean;
136
+ };
97
137
  const Link: (props: LinkProps) => JSX.Element;
98
138
  export default Link;
99
139
  }
@@ -108,7 +148,7 @@ declare module '@docusaurus/Interpolate' {
108
148
 
109
149
  export type InterpolateValues<
110
150
  Str extends string,
111
- Value extends ReactNode
151
+ Value extends ReactNode,
112
152
  > = Record<ExtractInterpolatePlaceholders<Str>, Value>;
113
153
 
114
154
  // TS function overload: if all the values are plain strings, then interpolate returns a simple string
@@ -134,16 +174,16 @@ declare module '@docusaurus/Interpolate' {
134
174
  }
135
175
 
136
176
  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;
177
+ import type {ReactNode} from 'react';
178
+ import type {InterpolateValues} from '@docusaurus/Interpolate';
179
+
180
+ // TS type to ensure that at least one of id or message is always provided
181
+ // (Generic permits to handled message provided as React children)
182
+ type IdOrMessage<MessageKey extends 'children' | 'message'> =
183
+ | ({[key in MessageKey]: string} & {id?: string})
184
+ | ({[key in MessageKey]?: string} & {id: string});
185
+
186
+ export type TranslateParam<Str extends string> = IdOrMessage<'message'> & {
147
187
  description?: string;
148
188
  values?: InterpolateValues<Str, string | number>;
149
189
  };
@@ -153,9 +193,9 @@ declare module '@docusaurus/Translate' {
153
193
  values?: InterpolateValues<Str, string | number>,
154
194
  ): string;
155
195
 
156
- export type TranslateProps<Str extends string> = InterpolateProps<Str> & {
157
- id?: string;
196
+ export type TranslateProps<Str extends string> = IdOrMessage<'children'> & {
158
197
  description?: string;
198
+ values?: InterpolateValues<Str, ReactNode>;
159
199
  };
160
200
 
161
201
  export default function Translate<Str extends string>(
@@ -173,7 +213,13 @@ declare module '@docusaurus/history' {
173
213
  }
174
214
 
175
215
  declare module '@docusaurus/useDocusaurusContext' {
176
- export default function (): any;
216
+ import type {DocusaurusContext} from '@docusaurus/types';
217
+
218
+ export default function useDocusaurusContext(): DocusaurusContext;
219
+ }
220
+
221
+ declare module '@docusaurus/useIsBrowser' {
222
+ export default function useIsBrowser(): boolean;
177
223
  }
178
224
 
179
225
  declare module '@docusaurus/useBaseUrl' {
@@ -215,10 +261,10 @@ declare module '@docusaurus/ComponentCreator' {
215
261
  }
216
262
 
217
263
  declare module '@docusaurus/BrowserOnly' {
218
- export type Props = {
219
- children?: () => JSX.Element;
220
- fallback?: JSX.Element;
221
- };
264
+ export interface Props {
265
+ readonly children?: () => JSX.Element;
266
+ readonly fallback?: JSX.Element;
267
+ }
222
268
  const BrowserOnly: (props: Props) => JSX.Element | null;
223
269
  export default BrowserOnly;
224
270
  }
@@ -249,6 +295,7 @@ declare module '@docusaurus/useGlobalData' {
249
295
  pluginId?: string,
250
296
  ): T;
251
297
 
298
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
252
299
  function useGlobalData(): Record<string, any>;
253
300
  export default useGlobalData;
254
301
  }