mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-22 05:27:00 +02:00
refactor: ensure all types are using index signature instead of Record (#6995)
* refactor: ensure all types are using index signature instead of Record * kick CI
This commit is contained in:
parent
e8800b9d49
commit
87592bca03
99 changed files with 339 additions and 307 deletions
|
@ -15,11 +15,11 @@ function testField(params: {
|
|||
fieldName: keyof BlogPostFrontMatter;
|
||||
validFrontMatters: BlogPostFrontMatter[];
|
||||
convertibleFrontMatter?: [
|
||||
ConvertibleFrontMatter: Record<string, unknown>,
|
||||
ConvertibleFrontMatter: {[key: string]: unknown},
|
||||
ConvertedFrontMatter: BlogPostFrontMatter,
|
||||
][];
|
||||
invalidFrontMatters?: [
|
||||
InvalidFrontMatter: Record<string, unknown>,
|
||||
InvalidFrontMatter: {[key: string]: unknown},
|
||||
ErrorMessage: string,
|
||||
][];
|
||||
}) {
|
||||
|
|
|
@ -15,7 +15,7 @@ import type {
|
|||
BlogPostFrontMatterAuthors,
|
||||
} from '@docusaurus/plugin-content-blog';
|
||||
|
||||
export type AuthorsMap = Record<string, Author>;
|
||||
export type AuthorsMap = {[authorKey: string]: Author};
|
||||
|
||||
const AuthorsMapSchema = Joi.object<AuthorsMap>()
|
||||
.pattern(
|
||||
|
|
|
@ -43,9 +43,9 @@ export function truncate(fileString: string, truncateMarker: RegExp): string {
|
|||
return fileString.split(truncateMarker, 1).shift()!;
|
||||
}
|
||||
|
||||
export function getSourceToPermalink(
|
||||
blogPosts: BlogPost[],
|
||||
): Record<string, string> {
|
||||
export function getSourceToPermalink(blogPosts: BlogPost[]): {
|
||||
[aliasedPath: string]: string;
|
||||
} {
|
||||
return Object.fromEntries(
|
||||
blogPosts.map(({metadata: {source, permalink}}) => [source, permalink]),
|
||||
);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
declare module 'remark-admonitions' {
|
||||
type Options = Record<string, unknown>;
|
||||
type Options = {[key: string]: unknown};
|
||||
|
||||
const plugin: (options?: Options) => void;
|
||||
export = plugin;
|
||||
|
|
|
@ -74,8 +74,8 @@ const BlogFrontMatterSchema = Joi.object<BlogPostFrontMatter>({
|
|||
'{#label} blog frontMatter field is deprecated. Please use {#alternative} instead.',
|
||||
});
|
||||
|
||||
export function validateBlogPostFrontMatter(
|
||||
frontMatter: Record<string, unknown>,
|
||||
): BlogPostFrontMatter {
|
||||
export function validateBlogPostFrontMatter(frontMatter: {
|
||||
[key: string]: unknown;
|
||||
}): BlogPostFrontMatter {
|
||||
return validateFrontMatter(frontMatter, BlogFrontMatterSchema);
|
||||
}
|
||||
|
|
|
@ -205,7 +205,7 @@ export default async function pluginContentBlog(
|
|||
blogTagsListPath,
|
||||
} = blogContents;
|
||||
|
||||
const blogItemsToMetadata: Record<string, BlogPostMetadata> = {};
|
||||
const blogItemsToMetadata: {[postId: string]: BlogPostMetadata} = {};
|
||||
|
||||
const sidebarBlogPosts =
|
||||
options.blogSidebarCount === 'ALL'
|
||||
|
@ -316,7 +316,7 @@ export default async function pluginContentBlog(
|
|||
return;
|
||||
}
|
||||
|
||||
const tagsModule: Record<string, TagModule> = Object.fromEntries(
|
||||
const tagsModule: {[tagName: string]: TagModule} = Object.fromEntries(
|
||||
Object.entries(blogTags).map(([, tag]) => {
|
||||
const tagModule: TagModule = {
|
||||
allTagsPath: blogTagsListPath,
|
||||
|
|
|
@ -232,7 +232,7 @@ declare module '@docusaurus/plugin-content-blog' {
|
|||
/**
|
||||
* Front matter, as-is.
|
||||
*/
|
||||
readonly frontMatter: BlogPostFrontMatter & Record<string, unknown>;
|
||||
readonly frontMatter: BlogPostFrontMatter & {[key: string]: unknown};
|
||||
/**
|
||||
* Tags, normalized.
|
||||
*/
|
||||
|
@ -301,7 +301,7 @@ declare module '@docusaurus/plugin-content-blog' {
|
|||
/** Markdown content. */
|
||||
content: string;
|
||||
/** Front matter. */
|
||||
frontMatter?: BlogPostFrontMatter & Record<string, unknown>;
|
||||
frontMatter?: BlogPostFrontMatter & {[key: string]: unknown};
|
||||
/** Options accepted by ngryman/reading-time. */
|
||||
options?: ReadingTimeOptions;
|
||||
}) => number;
|
||||
|
@ -402,7 +402,7 @@ declare module '@docusaurus/plugin-content-blog' {
|
|||
* unlocalized file. Ignored when `editUrl` is a function.
|
||||
*/
|
||||
editLocalizedFiles?: boolean;
|
||||
admonitions: Record<string, unknown>;
|
||||
admonitions: {[key: string]: unknown};
|
||||
/** Path to the authors map file, relative to the blog content directory. */
|
||||
authorsMapPath: string;
|
||||
/** A callback to customize the reading time number displayed. */
|
||||
|
@ -545,7 +545,7 @@ declare module '@theme/BlogTagsListPage' {
|
|||
/** Blog sidebar. */
|
||||
readonly sidebar: BlogSidebar;
|
||||
/** A map from tag names to the full tag module. */
|
||||
readonly tags: Readonly<Record<string, TagModule>>;
|
||||
readonly tags: Readonly<{[tagName: string]: TagModule}>;
|
||||
}
|
||||
|
||||
export default function BlogTagsListPage(props: Props): JSX.Element;
|
||||
|
|
|
@ -50,6 +50,6 @@ export type BlogMarkdownLoaderOptions = {
|
|||
siteDir: string;
|
||||
contentPaths: BlogContentPaths;
|
||||
truncateMarker: RegExp;
|
||||
sourceToPermalink: Record<string, string>;
|
||||
sourceToPermalink: {[aliasedPath: string]: string};
|
||||
onBrokenMarkdownLink: (brokenMarkdownLink: BlogBrokenMarkdownLink) => void;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue