mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-05 20:32:42 +02:00
refactor: properly type docs version (#5284)
* Type docs version Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Move non-null assertions Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Test again
This commit is contained in:
parent
bc6c67720a
commit
0a668366c2
9 changed files with 66 additions and 29 deletions
|
@ -15,7 +15,7 @@ import React, {
|
|||
import {useThemeConfig, DocsVersionPersistence} from '../useThemeConfig';
|
||||
import {isDocsPluginEnabled} from '../docsUtils';
|
||||
|
||||
import {useAllDocsData} from '@theme/hooks/useDocs';
|
||||
import {useAllDocsData, GlobalPluginData} from '@theme/hooks/useDocs';
|
||||
|
||||
import DocsPreferredVersionStorage from './DocsPreferredVersionStorage';
|
||||
|
||||
|
@ -54,7 +54,7 @@ function readStorageState({
|
|||
}: {
|
||||
pluginIds: string[];
|
||||
versionPersistence: DocsVersionPersistence;
|
||||
allDocsData: any; // TODO find a way to type it :(
|
||||
allDocsData: Record<string, GlobalPluginData>;
|
||||
}): DocsPreferredVersionState {
|
||||
// The storage value we read might be stale,
|
||||
// and belong to a version that does not exist in the site anymore
|
||||
|
@ -68,7 +68,7 @@ function readStorageState({
|
|||
);
|
||||
const pluginData = allDocsData[pluginId];
|
||||
const versionExists = pluginData.versions.some(
|
||||
(version: any) => version.name === preferredVersionNameUnsafe,
|
||||
(version) => version.name === preferredVersionNameUnsafe,
|
||||
);
|
||||
if (versionExists) {
|
||||
return {preferredVersionName: preferredVersionNameUnsafe};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue