chore(v2): Fix linter warnings (#4442)

* chore(v2): Fix linter warnings

223 warnings to 145 warnings

* Remove explicit type annotations

* Do not prefetch when targetLink == null
This commit is contained in:
Sam Zhou 2021-03-17 12:28:42 -04:00 committed by GitHub
parent f041a37622
commit 5e73c72f26
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 146 additions and 71 deletions

View file

@ -76,7 +76,7 @@ function normalizeCategoryShorthand(
* Check that item contains only allowed keys.
*/
function assertItem<K extends string>(
item: any,
item: Record<string, unknown>,
keys: K[],
): asserts item is Record<K, any> {
const unknownKeys = Object.keys(item).filter(
@ -94,7 +94,7 @@ function assertItem<K extends string>(
}
function assertIsCategory(
item: unknown,
item: Record<string, unknown>,
): asserts item is SidebarItemCategoryJSON {
assertItem(item, ['items', 'label', 'collapsed', 'customProps']);
if (typeof item.label !== 'string') {
@ -115,7 +115,9 @@ function assertIsCategory(
}
}
function assertIsDoc(item: unknown): asserts item is SidebarItemDoc {
function assertIsDoc(
item: Record<string, unknown>,
): asserts item is SidebarItemDoc {
assertItem(item, ['id', 'customProps']);
if (typeof item.id !== 'string') {
throw new Error(
@ -124,7 +126,9 @@ function assertIsDoc(item: unknown): asserts item is SidebarItemDoc {
}
}
function assertIsLink(item: unknown): asserts item is SidebarItemLink {
function assertIsLink(
item: Record<string, unknown>,
): asserts item is SidebarItemLink {
assertItem(item, ['href', 'label', 'customProps']);
if (typeof item.href !== 'string') {
throw new Error(