Skip to content

Commit

Permalink
fix typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Jun 9, 2022
1 parent 0acdf95 commit de067c9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 207 deletions.
16 changes: 6 additions & 10 deletions packages/docusaurus-plugin-content-docs/src/client/index.ts
Expand Up @@ -85,7 +85,7 @@ export const useAllDocsData = (): {[pluginId: string]: GlobalPluginData} =>
}
| undefined) ?? StableEmptyObject;

export const useDocsData = (pluginId: string | undefined): GlobalPluginData =>
export const useDocsData = (pluginId?: string): GlobalPluginData =>
usePluginData('docusaurus-plugin-content-docs', pluginId, {
failfast: true,
}) as GlobalPluginData;
Expand Down Expand Up @@ -117,12 +117,12 @@ export function useActivePluginAndVersion(
}

/** Versions are returned ordered (most recent first). */
export function useVersions(pluginId: string | undefined): GlobalVersion[] {
export function useVersions(pluginId?: string): GlobalVersion[] {
const data = useDocsData(pluginId);
return data.versions;
}

export function useLatestVersion(pluginId: string | undefined): GlobalVersion {
export function useLatestVersion(pluginId?: string): GlobalVersion {
const data = useDocsData(pluginId);
return getLatestVersion(data);
}
Expand All @@ -131,17 +131,13 @@ export function useLatestVersion(pluginId: string | undefined): GlobalVersion {
* Returns `undefined` on doc-unrelated pages, because there's no version
* currently considered as active.
*/
export function useActiveVersion(
pluginId: string | undefined,
): GlobalVersion | undefined {
export function useActiveVersion(pluginId?: string): GlobalVersion | undefined {
const data = useDocsData(pluginId);
const {pathname} = useLocation();
return getActiveVersion(data, pathname);
}

export function useActiveDocContext(
pluginId: string | undefined,
): ActiveDocContext {
export function useActiveDocContext(pluginId?: string): ActiveDocContext {
const data = useDocsData(pluginId);
const {pathname} = useLocation();
return getActiveDocContext(data, pathname);
Expand All @@ -150,7 +146,7 @@ export function useActiveDocContext(
* Useful to say "hey, you are not on the latest docs version, please switch"
*/
export function useDocVersionSuggestions(
pluginId: string | undefined,
pluginId?: string,
): DocVersionSuggestions {
const data = useDocsData(pluginId);
const {pathname} = useLocation();
Expand Down
5 changes: 4 additions & 1 deletion website/docusaurus.config.js
Expand Up @@ -8,6 +8,9 @@

const path = require('path');
const math = require('remark-math');
// TODO cannot use v6 until https://github.com/vfile/vfile/pull/78
// Maybe we should hold off until MDX v2 migration?
const katex = require('rehype-katex');
const npm2yarn = require('@docusaurus/remark-plugin-npm2yarn');
const versions = require('./versions.json');
const VersionsArchived = require('./versionsArchived.json');
Expand Down Expand Up @@ -607,7 +610,7 @@ async function createConfig() {
const configTabs = (await import('./src/remark/configTabs.mjs')).default;
const lightTheme = (await import('./src/utils/prismLight.mjs')).default;
const darkTheme = (await import('./src/utils/prismDark.mjs')).default;
const katex = (await import('rehype-katex')).default;
// const katex = (await import('rehype-katex')).default;
config.plugins?.push(FeatureRequestsPlugin);
// @ts-expect-error: we know it exists, right
config.presets[0][1].docs.remarkPlugins.push(configTabs);
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Expand Up @@ -59,7 +59,7 @@
"react-lite-youtube-embed": "^2.2.2",
"react-medium-image-zoom": "^4.4.3",
"react-popper": "^2.3.0",
"rehype-katex": "^6.0.2",
"rehype-katex": "^4.0.0",
"remark-math": "^3.0.1",
"swc-loader": "^0.2.1",
"unist-util-visit": "^2.0.3",
Expand Down
2 changes: 2 additions & 0 deletions website/tsconfig.json
Expand Up @@ -28,6 +28,8 @@
"noUnusedParameters": false,
"importsNotUsedAsValues": "remove",

"moduleResolution": "NodeNext",

// This is important. We run `yarn tsc` in website so we can catch issues
// with our declaration files (mostly names that are forgotten to be
// imported, invalid semantics...). Because we don't have end-to-end type
Expand Down

0 comments on commit de067c9

Please sign in to comment.