mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-29 22:47:52 +02:00
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:
parent
f041a37622
commit
5e73c72f26
39 changed files with 146 additions and 71 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue