mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 08:49:51 +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
|
@ -67,7 +67,7 @@ ${
|
|||
type MigrationContext = {
|
||||
siteDir: string;
|
||||
newDir: string;
|
||||
deps: Record<string, string>;
|
||||
deps: {[key: string]: string};
|
||||
shouldMigrateMdFiles: boolean;
|
||||
shouldMigratePages: boolean;
|
||||
v1Config: VersionOneConfig;
|
||||
|
@ -83,7 +83,7 @@ export async function migrateDocusaurusProject(
|
|||
async function createMigrationContext(): Promise<MigrationContext> {
|
||||
const v1Config = importFresh(`${siteDir}/siteConfig`) as VersionOneConfig;
|
||||
logger.info('Starting migration from v1 to v2...');
|
||||
const deps: Record<string, string> = {
|
||||
const deps = {
|
||||
'@docusaurus/core': DOCUSAURUS_VERSION,
|
||||
'@docusaurus/preset-classic': DOCUSAURUS_VERSION,
|
||||
clsx: '^1.1.1',
|
||||
|
@ -206,7 +206,7 @@ export function createConfigFile({
|
|||
'v1Config' | 'siteDir' | 'newDir'
|
||||
>): VersionTwoConfig {
|
||||
const siteConfig = v1Config;
|
||||
const customConfigFields: Record<string, unknown> = {};
|
||||
const customConfigFields: {[key: string]: unknown} = {};
|
||||
// add fields that are unknown to v2 to customConfigFields
|
||||
Object.keys(siteConfig).forEach((key) => {
|
||||
const knownFields = [
|
||||
|
@ -564,7 +564,7 @@ async function migrateVersionedSidebar(
|
|||
};
|
||||
});
|
||||
return acc;
|
||||
}, {} as Record<string, Array<string | Record<string, unknown>>>);
|
||||
}, {} as {[key: string]: Array<string | {[key: string]: unknown}>});
|
||||
return topLevel;
|
||||
},
|
||||
{},
|
||||
|
@ -702,9 +702,9 @@ async function migrateLatestDocs(context: MigrationContext) {
|
|||
async function migratePackageFile(context: MigrationContext): Promise<void> {
|
||||
const {deps, siteDir, newDir} = context;
|
||||
const packageFile = importFresh(`${siteDir}/package.json`) as {
|
||||
scripts?: Record<string, string>;
|
||||
dependencies?: Record<string, string>;
|
||||
devDependencies?: Record<string, string>;
|
||||
scripts?: {[key: string]: string};
|
||||
dependencies?: {[key: string]: string};
|
||||
devDependencies?: {[key: string]: string};
|
||||
[otherKey: string]: unknown;
|
||||
};
|
||||
packageFile.scripts = {
|
||||
|
|
|
@ -33,8 +33,8 @@ export type SidebarEntry =
|
|||
|
||||
export type SidebarEntries = {
|
||||
[key: string]:
|
||||
| Record<string, unknown>
|
||||
| Array<Record<string, unknown> | string>;
|
||||
| {[key: string]: unknown}
|
||||
| Array<{[key: string]: unknown} | string>;
|
||||
};
|
||||
|
||||
export interface VersionTwoConfig {
|
||||
|
@ -58,7 +58,7 @@ export interface VersionTwoConfig {
|
|||
logo?: {
|
||||
src?: string;
|
||||
};
|
||||
items: Array<Record<string, unknown> | null>;
|
||||
items: Array<{[key: string]: unknown} | null>;
|
||||
};
|
||||
image?: string;
|
||||
footer: {
|
||||
|
@ -74,7 +74,7 @@ export interface VersionTwoConfig {
|
|||
src?: string;
|
||||
};
|
||||
};
|
||||
algolia?: Record<string, unknown>;
|
||||
algolia?: {[key: string]: unknown};
|
||||
};
|
||||
customFields: {
|
||||
[key: string]: unknown;
|
||||
|
@ -111,16 +111,16 @@ export type VersionOneConfig = {
|
|||
copyright?: string;
|
||||
editUrl?: string;
|
||||
customDocsPath?: string;
|
||||
users?: Array<Record<string, unknown>>;
|
||||
users?: Array<{[key: string]: unknown}>;
|
||||
disableHeaderTitle?: string;
|
||||
disableTitleTagline?: string;
|
||||
separateCss?: Array<Record<string, unknown>>;
|
||||
separateCss?: Array<{[key: string]: unknown}>;
|
||||
footerIcon?: string;
|
||||
translationRecruitingLink?: string;
|
||||
algolia?: Record<string, unknown>;
|
||||
algolia?: {[key: string]: unknown};
|
||||
gaTrackingId?: string;
|
||||
gaGtag?: boolean;
|
||||
highlight?: Record<string, unknown>;
|
||||
highlight?: {[key: string]: unknown};
|
||||
markdownPlugins?: Array<() => void>;
|
||||
scripts?: Array<{src: string; [key: string]: unknown} | string>;
|
||||
stylesheets?: Array<{href: string; [key: string]: unknown} | string>;
|
||||
|
@ -133,5 +133,5 @@ export type VersionOneConfig = {
|
|||
ogImage?: string;
|
||||
cleanUrl?: boolean;
|
||||
scrollToTop?: boolean;
|
||||
scrollToTopOptions?: Record<string, unknown>;
|
||||
scrollToTopOptions?: {[key: string]: unknown};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue