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:
Joshua Chen 2022-03-06 13:09:10 +08:00 committed by GitHub
parent 9f925a42bf
commit 4db0c620de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
71 changed files with 210 additions and 174 deletions

View file

@ -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(
', ',

View file

@ -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]!),
};
}