mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-19 12:07:00 +02:00
fix: fix a few TS errors (#5437)
* fix errors Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Fix website Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Revert adding lib Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Fix tsconfig Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * Restore previous ordering Signed-off-by: Josh-Cena <sidachen2003@gmail.com> * exclude sw.js from typechecking * Tests: include typechecking of website * cleanup @site/ alias in TS config Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
74f060dde0
commit
df3752cc71
12 changed files with 31 additions and 36 deletions
2
.github/workflows/v2-tests.yml
vendored
2
.github/workflows/v2-tests.yml
vendored
|
@ -28,3 +28,5 @@ jobs:
|
||||||
install-command: yarn
|
install-command: yarn
|
||||||
- name: Test
|
- name: Test
|
||||||
run: yarn test
|
run: yarn test
|
||||||
|
- name: TypeCheck website
|
||||||
|
run: yarn workspace website tsc
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@docusaurus/module-type-aliases": "2.0.0-beta.5",
|
"@docusaurus/module-type-aliases": "2.0.0-beta.5",
|
||||||
"@tsconfig/docusaurus": "^1.0.3",
|
"@tsconfig/docusaurus": "^1.0.4",
|
||||||
"@types/react": "^17.0.14",
|
"@types/react": "^17.0.14",
|
||||||
"@types/react-helmet": "^6.1.2",
|
"@types/react-helmet": "^6.1.2",
|
||||||
"@types/react-router-dom": "^5.1.8",
|
"@types/react-router-dom": "^5.1.8",
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
// This file is not used in compilation. It is here just for a nice editor experience.
|
// This file is not used in compilation. It is here just for a nice editor experience.
|
||||||
"extends": "@tsconfig/docusaurus/tsconfig.json",
|
"extends": "@tsconfig/docusaurus/tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"paths": {
|
"baseUrl": "."
|
||||||
"@site/*": ["./*"]
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"include": ["src/"]
|
|
||||||
}
|
}
|
||||||
|
|
12
packages/docusaurus-mdx-loader/src/types.d.ts
vendored
12
packages/docusaurus-mdx-loader/src/types.d.ts
vendored
|
@ -6,6 +6,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
declare module '@docusaurus/mdx-loader' {
|
declare module '@docusaurus/mdx-loader' {
|
||||||
|
type RemarkOrRehypePlugin =
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
|
[Function, Record<string, unknown>] | Function;
|
||||||
export interface RemarkAndRehypePluginOptions {
|
export interface RemarkAndRehypePluginOptions {
|
||||||
remarkPlugins: RemarkOrRehypePlugin[];
|
remarkPlugins: RemarkOrRehypePlugin[];
|
||||||
rehypePlugins: string[];
|
rehypePlugins: string[];
|
||||||
|
@ -18,7 +21,7 @@ declare module '@docusaurus/mdx-loader' {
|
||||||
declare module '@mdx-js/mdx' {
|
declare module '@mdx-js/mdx' {
|
||||||
import type {Plugin, Processor} from 'unified';
|
import type {Plugin, Processor} from 'unified';
|
||||||
|
|
||||||
export namespace mdx {
|
namespace mdx {
|
||||||
interface Options {
|
interface Options {
|
||||||
filepath?: string;
|
filepath?: string;
|
||||||
skipExport?: boolean;
|
skipExport?: boolean;
|
||||||
|
@ -31,8 +34,7 @@ declare module '@mdx-js/mdx' {
|
||||||
function createMdxAstCompiler(options?: Options): Processor;
|
function createMdxAstCompiler(options?: Options): Processor;
|
||||||
function createCompiler(options?: Options): Processor;
|
function createCompiler(options?: Options): Processor;
|
||||||
}
|
}
|
||||||
export default function mdx(
|
function mdx(content: string, options?: mdx.Options): Promise<string>;
|
||||||
content: string,
|
|
||||||
options?: mdx.Options,
|
export default mdx;
|
||||||
): Promise<string>;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ declare module '@theme/BlogSidebar' {
|
||||||
|
|
||||||
declare module '@theme/BlogPostPage' {
|
declare module '@theme/BlogPostPage' {
|
||||||
import type {BlogSidebar} from '@theme/BlogSidebar';
|
import type {BlogSidebar} from '@theme/BlogSidebar';
|
||||||
|
import type {TOCItem} from '@docusaurus/types';
|
||||||
|
|
||||||
export type FrontMatter = import('./src/blogFrontMatter').BlogPostFrontMatter;
|
export type FrontMatter = import('./src/blogFrontMatter').BlogPostFrontMatter;
|
||||||
export type Assets = import('./src/types').Assets;
|
export type Assets = import('./src/types').Assets;
|
||||||
|
|
|
@ -20,22 +20,11 @@ export type ActivePlugin = {
|
||||||
pluginData: GlobalPluginData;
|
pluginData: GlobalPluginData;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type GetActivePluginOptions = {failfast?: boolean};
|
export type GetActivePluginOptions = {failfast?: boolean}; // use fail-fast option if you know for sure one plugin instance is active
|
||||||
|
|
||||||
// get the data of the plugin that is currently "active"
|
// get the data of the plugin that is currently "active"
|
||||||
// ie the docs of that plugin are currently browsed
|
// ie the docs of that plugin are currently browsed
|
||||||
// it is useful to support multiple docs plugin instances
|
// it is useful to support multiple docs plugin instances
|
||||||
export function getActivePlugin(
|
|
||||||
allPluginDatas: Record<string, GlobalPluginData>,
|
|
||||||
pathname: string,
|
|
||||||
options: {failfast: true}, // use fail-fast option if you know for sure one plugin instance is active
|
|
||||||
): ActivePlugin;
|
|
||||||
export function getActivePlugin(
|
|
||||||
allPluginDatas: Record<string, GlobalPluginData>,
|
|
||||||
pathname: string,
|
|
||||||
options?: GetActivePluginOptions,
|
|
||||||
): ActivePlugin | undefined;
|
|
||||||
|
|
||||||
export function getActivePlugin(
|
export function getActivePlugin(
|
||||||
allPluginDatas: Record<string, GlobalPluginData>,
|
allPluginDatas: Record<string, GlobalPluginData>,
|
||||||
pathname: string,
|
pathname: string,
|
||||||
|
|
|
@ -166,6 +166,8 @@ declare module '@theme/DocPage' {
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module '@theme/Seo' {
|
declare module '@theme/Seo' {
|
||||||
|
import type {ReactNode} from 'react';
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
readonly title?: string;
|
readonly title?: string;
|
||||||
readonly description?: string;
|
readonly description?: string;
|
||||||
|
@ -184,15 +186,16 @@ declare module '@theme/hooks/useDocs' {
|
||||||
type ActivePlugin = import('./client/docsClientUtils').ActivePlugin;
|
type ActivePlugin = import('./client/docsClientUtils').ActivePlugin;
|
||||||
type ActiveDocContext = import('./client/docsClientUtils').ActiveDocContext;
|
type ActiveDocContext = import('./client/docsClientUtils').ActiveDocContext;
|
||||||
type DocVersionSuggestions = import('./client/docsClientUtils').DocVersionSuggestions;
|
type DocVersionSuggestions = import('./client/docsClientUtils').DocVersionSuggestions;
|
||||||
|
type GetActivePluginOptions = import('./client/docsClientUtils').GetActivePluginOptions;
|
||||||
|
|
||||||
export type {GlobalPluginData, GlobalVersion};
|
export type {GlobalPluginData, GlobalVersion};
|
||||||
export const useAllDocsData: () => Record<string, GlobalPluginData>;
|
export const useAllDocsData: () => Record<string, GlobalPluginData>;
|
||||||
export const useDocsData: (pluginId?: string) => GlobalPluginData;
|
export const useDocsData: (pluginId?: string) => GlobalPluginData;
|
||||||
export const useActivePlugin: (
|
export const useActivePlugin: (
|
||||||
options: GetActivePluginOptions = {},
|
options?: GetActivePluginOptions,
|
||||||
) => ActivePlugin | undefined;
|
) => ActivePlugin | undefined;
|
||||||
export const useActivePluginAndVersion: (
|
export const useActivePluginAndVersion: (
|
||||||
options: GetActivePluginOptions = {},
|
options?: GetActivePluginOptions,
|
||||||
) =>
|
) =>
|
||||||
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
|
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
|
||||||
| undefined;
|
| undefined;
|
||||||
|
|
|
@ -51,7 +51,8 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@docusaurus/module-type-aliases": "2.0.0-beta.5",
|
"@docusaurus/module-type-aliases": "2.0.0-beta.5",
|
||||||
"@types/parse-numeric-range": "^0.0.1"
|
"@types/parse-numeric-range": "^0.0.1",
|
||||||
|
"utility-types": "^3.10.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"react": "^16.8.4 || ^17.0.0",
|
"react": "^16.8.4 || ^17.0.0",
|
||||||
|
|
|
@ -743,6 +743,7 @@ declare module '@theme/TagsListInline' {
|
||||||
|
|
||||||
declare module '@theme/Tag' {
|
declare module '@theme/Tag' {
|
||||||
import type {TagsListItem} from '@theme/TagsListByLetter';
|
import type {TagsListItem} from '@theme/TagsListByLetter';
|
||||||
|
import type {Optional} from 'utility-types';
|
||||||
|
|
||||||
export type Props = Optional<TagsListItem, 'count'>;
|
export type Props = Optional<TagsListItem, 'count'>;
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,8 @@
|
||||||
"netlify:crowdin:downloadTranslations": "yarn netlify:crowdin:wait && yarn --cwd .. crowdin:download:website",
|
"netlify:crowdin:downloadTranslations": "yarn netlify:crowdin:wait && yarn --cwd .. crowdin:download:website",
|
||||||
"netlify:crowdin:downloadTranslationsFailSafe": "yarn netlify:crowdin:wait && (yarn --cwd .. crowdin:download:website || echo 'Crowdin translation download failure (only internal PRs have access to the Crowdin env token)')",
|
"netlify:crowdin:downloadTranslationsFailSafe": "yarn netlify:crowdin:wait && (yarn --cwd .. crowdin:download:website || echo 'Crowdin translation download failure (only internal PRs have access to the Crowdin env token)')",
|
||||||
"netlify:crowdin:uploadSources": "yarn --cwd .. crowdin:upload:website",
|
"netlify:crowdin:uploadSources": "yarn --cwd .. crowdin:upload:website",
|
||||||
"netlify:test": "yarn netlify:build:deployPreview && yarn netlify dev --debug"
|
"netlify:test": "yarn netlify:build:deployPreview && yarn netlify dev --debug",
|
||||||
|
"typecheck": "tsc"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@crowdin/cli": "^3.5.2",
|
"@crowdin/cli": "^3.5.2",
|
||||||
|
@ -63,7 +64,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tsconfig/docusaurus": "^1.0.3",
|
"@tsconfig/docusaurus": "^1.0.4",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"raw-loader": "^4.0.2"
|
"raw-loader": "^4.0.2"
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,8 @@
|
||||||
// This file is not used in compilation. It is here just for a nice editor experience.
|
// This file is not used in compilation. It is here just for a nice editor experience.
|
||||||
"extends": "@tsconfig/docusaurus/tsconfig.json",
|
"extends": "@tsconfig/docusaurus/tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"paths": {
|
"baseUrl": ".",
|
||||||
"@site/*": ["./*"]
|
|
||||||
},
|
|
||||||
"resolveJsonModule": true
|
"resolveJsonModule": true
|
||||||
},
|
},
|
||||||
"include": ["src/"]
|
"exclude": ["src/sw.js"]
|
||||||
}
|
}
|
||||||
|
|
|
@ -3849,10 +3849,10 @@
|
||||||
resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.1.1.tgz#3348564048e7a2d7398c935d466c0414ebb6a669"
|
resolved "https://registry.yarnpkg.com/@trysound/sax/-/sax-0.1.1.tgz#3348564048e7a2d7398c935d466c0414ebb6a669"
|
||||||
integrity sha512-Z6DoceYb/1xSg5+e+ZlPZ9v0N16ZvZ+wYMraFue4HYrE4ttONKtsvruIRf6t9TBR0YvSOfi1hUU0fJfBLCDYow==
|
integrity sha512-Z6DoceYb/1xSg5+e+ZlPZ9v0N16ZvZ+wYMraFue4HYrE4ttONKtsvruIRf6t9TBR0YvSOfi1hUU0fJfBLCDYow==
|
||||||
|
|
||||||
"@tsconfig/docusaurus@^1.0.3":
|
"@tsconfig/docusaurus@^1.0.4":
|
||||||
version "1.0.3"
|
version "1.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/@tsconfig/docusaurus/-/docusaurus-1.0.3.tgz#040582bdceb27336d7abf2301fb0f4c909a9ac2f"
|
resolved "https://registry.yarnpkg.com/@tsconfig/docusaurus/-/docusaurus-1.0.4.tgz#fc40f87a672568678d83533dd4031a09d75877ca"
|
||||||
integrity sha512-g4X3HvNXbkowvEdPLu759fZjbXoazPjvi2a/fAAITp2yMOGeSKpHuY6N538ZY+1u6Z91Er3QKPtYGdZQ+tqXUA==
|
integrity sha512-I6sziQAzLrrqj9r6S26c7aOAjfGVXIE7gWdNONPwnpDcHiMRMQut1s1YCi/APem3dOy23tAb2rvHfNtGCaWuUQ==
|
||||||
|
|
||||||
"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.7":
|
"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.7":
|
||||||
version "7.1.14"
|
version "7.1.14"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue