@docusaurus/module-type-aliases 2.0.0-beta.13 → 2.0.0-beta.15

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 -3
  2. package/src/index.d.ts +29 -14
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/module-type-aliases",
3
- "version": "2.0.0-beta.13",
3
+ "version": "2.0.0-beta.15",
4
4
  "description": "Docusaurus module type aliases.",
5
5
  "types": "./src/index.d.ts",
6
6
  "publishConfig": {
@@ -12,12 +12,12 @@
12
12
  "directory": "packages/docusaurus-module-type-aliases"
13
13
  },
14
14
  "dependencies": {
15
- "@docusaurus/types": "2.0.0-beta.13",
15
+ "@docusaurus/types": "2.0.0-beta.15",
16
16
  "@types/react": "*",
17
17
  "@types/react-helmet": "*",
18
18
  "@types/react-router-config": "*",
19
19
  "@types/react-router-dom": "*"
20
20
  },
21
21
  "license": "MIT",
22
- "gitHead": "b6ca12aedf10a10c2375f4f8b7e7380cfd7c7202"
22
+ "gitHead": "32ec84ef3c0a238436e913b2026ab809e5750fa8"
23
23
  }
package/src/index.d.ts CHANGED
@@ -64,7 +64,14 @@ declare module '@generated/i18n' {
64
64
  defaultLocale: string;
65
65
  locales: [string, ...string[]];
66
66
  currentLocale: string;
67
- localeConfigs: Record<string, {label: string; direction: string}>;
67
+ localeConfigs: Record<
68
+ string,
69
+ {
70
+ label: string;
71
+ direction: string;
72
+ htmlLang: string;
73
+ }
74
+ >;
68
75
  };
69
76
  export = i18n;
70
77
  }
@@ -88,7 +95,7 @@ declare module '@theme/Layout' {
88
95
  import type {ReactNode} from 'react';
89
96
 
90
97
  export interface Props {
91
- readonly children: ReactNode;
98
+ readonly children?: ReactNode;
92
99
  readonly title?: string;
93
100
  readonly description?: string;
94
101
  }
@@ -120,7 +127,7 @@ declare module '@docusaurus/constants' {
120
127
 
121
128
  declare module '@docusaurus/ErrorBoundary' {
122
129
  import type {ReactNode} from 'react';
123
- import ErrorComponent from '@theme/Error';
130
+ import type ErrorComponent from '@theme/Error';
124
131
 
125
132
  export interface Props {
126
133
  readonly fallback?: typeof ErrorComponent;
@@ -162,10 +169,10 @@ declare module '@docusaurus/Link' {
162
169
  declare module '@docusaurus/Interpolate' {
163
170
  import type {ReactNode} from 'react';
164
171
 
165
- // TODO use TS template literal feature to make values typesafe!
166
- // (requires upgrading TS first)
167
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
168
- export type ExtractInterpolatePlaceholders<Str extends string> = string;
172
+ export type ExtractInterpolatePlaceholders<Str extends string> =
173
+ Str extends `${string}{${infer Key}}${infer Rest}`
174
+ ? Key | ExtractInterpolatePlaceholders<Rest>
175
+ : never;
169
176
 
170
177
  export type InterpolateValues<
171
178
  Str extends string,
@@ -200,13 +207,18 @@ declare module '@docusaurus/Translate' {
200
207
 
201
208
  // TS type to ensure that at least one of id or message is always provided
202
209
  // (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'> & {
210
+ type IdOrMessage<
211
+ MessageKey extends 'children' | 'message',
212
+ Str extends string,
213
+ > =
214
+ | ({[key in MessageKey]: Str} & {id?: string})
215
+ | ({[key in MessageKey]?: Str} & {id: string});
216
+
217
+ export type TranslateParam<Str extends string> = IdOrMessage<
218
+ 'message',
219
+ Str
220
+ > & {
208
221
  description?: string;
209
- values?: InterpolateValues<Str, string | number>;
210
222
  };
211
223
 
212
224
  export function translate<Str extends string>(
@@ -214,7 +226,10 @@ declare module '@docusaurus/Translate' {
214
226
  values?: InterpolateValues<Str, string | number>,
215
227
  ): string;
216
228
 
217
- export type TranslateProps<Str extends string> = IdOrMessage<'children'> & {
229
+ export type TranslateProps<Str extends string> = IdOrMessage<
230
+ 'children',
231
+ Str
232
+ > & {
218
233
  description?: string;
219
234
  values?: InterpolateValues<Str, ReactNode>;
220
235
  };