refactor: ensure all types are using index signature instead of Record (#6995)

* refactor: ensure all types are using index signature instead of Record

* kick CI
This commit is contained in:
Joshua Chen 2022-03-25 18:06:30 +08:00 committed by GitHub
parent e8800b9d49
commit 87592bca03
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
99 changed files with 339 additions and 307 deletions

View file

@ -21,7 +21,7 @@ import _ from 'lodash';
describe('docsClientUtils', () => {
it('getActivePlugin', () => {
const data: Record<string, GlobalPluginData> = {
const data: {[key: string]: GlobalPluginData} = {
pluginIosId: {
path: '/ios',
versions: [],

View file

@ -23,11 +23,11 @@ import type {
// ie the docs of that plugin are currently browsed
// it is useful to support multiple docs plugin instances
export function getActivePlugin(
allPluginDatas: Record<string, GlobalPluginData>,
allPluginData: {[pluginId: string]: GlobalPluginData},
pathname: string,
options: GetActivePluginOptions = {},
): ActivePlugin | undefined {
const activeEntry = Object.entries(allPluginDatas)
const activeEntry = Object.entries(allPluginData)
// Route sorting: '/android/foo' should match '/android' instead of '/'
.sort((a, b) => b[1].path.localeCompare(a[1].path))
.find(
@ -46,7 +46,7 @@ export function getActivePlugin(
if (!activePlugin && options.failfast) {
throw new Error(
`Can't find active docs plugin for "${pathname}" pathname, while it was expected to be found. Maybe you tried to use a docs feature that can only be used on a docs-related page? Existing docs plugin paths are: ${Object.values(
allPluginDatas,
allPluginData,
)
.map((plugin) => plugin.path)
.join(', ')}`,

View file

@ -31,7 +31,7 @@ const StableEmptyObject = {};
// Not using useAllPluginInstancesData() because in blog-only mode, docs hooks
// are still used by the theme. We need a fail-safe fallback when the docs
// plugin is not in use
export const useAllDocsData = (): Record<string, GlobalPluginData> =>
export const useAllDocsData = (): {[pluginId: string]: GlobalPluginData} =>
useGlobalData()['docusaurus-plugin-content-docs'] ?? StableEmptyObject;
export const useDocsData = (pluginId: string | undefined): GlobalPluginData =>