mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-19 11:12:36 +02:00
refactor: enable a few TS flags (#6852)
* refactor: enable a few TS flags * refactor * revert to working version * fix * better * change
This commit is contained in:
parent
9f925a42bf
commit
4db0c620de
71 changed files with 210 additions and 174 deletions
|
@ -49,7 +49,7 @@ async function readCategoriesMetadata(contentPath: string) {
|
|||
const categoryToFile = _.groupBy(categoryFiles, path.dirname);
|
||||
return combinePromises(
|
||||
_.mapValues(categoryToFile, async (files, folder) => {
|
||||
const [filePath] = files;
|
||||
const filePath = files[0]!;
|
||||
if (files.length > 1) {
|
||||
logger.warn`There are more than one category metadata files for path=${folder}: ${files.join(
|
||||
', ',
|
||||
|
|
|
@ -201,12 +201,12 @@ export function createSidebarsUtils(sidebars: Sidebars): SidebarsUtils {
|
|||
if (!sidebarName) {
|
||||
return emptySidebarNavigation();
|
||||
}
|
||||
if (!sidebarNameToNavigationItems[sidebarName]) {
|
||||
const navigationItems = sidebarNameToNavigationItems[sidebarName];
|
||||
if (!navigationItems) {
|
||||
throw new Error(
|
||||
`Doc with ID ${docId} wants to display sidebar ${sidebarName} but a sidebar with this name doesn't exist`,
|
||||
);
|
||||
}
|
||||
const navigationItems = sidebarNameToNavigationItems[sidebarName];
|
||||
const currentItemIndex = navigationItems.findIndex((item) => {
|
||||
if (item.type === 'doc') {
|
||||
return item.id === docId;
|
||||
|
@ -263,7 +263,7 @@ export function createSidebarsUtils(sidebars: Sidebars): SidebarsUtils {
|
|||
if (!sidebarName) {
|
||||
return emptySidebarNavigation();
|
||||
}
|
||||
const navigationItems = sidebarNameToNavigationItems[sidebarName];
|
||||
const navigationItems = sidebarNameToNavigationItems[sidebarName]!;
|
||||
const currentItemIndex = navigationItems.findIndex(
|
||||
isCurrentCategoryGeneratedIndexItem,
|
||||
);
|
||||
|
@ -341,7 +341,7 @@ Available document ids are:
|
|||
getCategoryGeneratedIndexList,
|
||||
getCategoryGeneratedIndexNavigation,
|
||||
checkSidebarsDocIds,
|
||||
getFirstLink: (id) => getFirstLink(sidebars[id]),
|
||||
getFirstLink: (id) => getFirstLink(sidebars[id]!),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue