mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-19 20:17:06 +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
|
||||
- name: Test
|
||||
run: yarn test
|
||||
- name: TypeCheck website
|
||||
run: yarn workspace website tsc
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@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-helmet": "^6.1.2",
|
||||
"@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.
|
||||
"extends": "@tsconfig/docusaurus/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"@site/*": ["./*"]
|
||||
}
|
||||
},
|
||||
"include": ["src/"]
|
||||
"baseUrl": "."
|
||||
}
|
||||
}
|
||||
|
|
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' {
|
||||
type RemarkOrRehypePlugin =
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
[Function, Record<string, unknown>] | Function;
|
||||
export interface RemarkAndRehypePluginOptions {
|
||||
remarkPlugins: RemarkOrRehypePlugin[];
|
||||
rehypePlugins: string[];
|
||||
|
@ -18,7 +21,7 @@ declare module '@docusaurus/mdx-loader' {
|
|||
declare module '@mdx-js/mdx' {
|
||||
import type {Plugin, Processor} from 'unified';
|
||||
|
||||
export namespace mdx {
|
||||
namespace mdx {
|
||||
interface Options {
|
||||
filepath?: string;
|
||||
skipExport?: boolean;
|
||||
|
@ -31,8 +34,7 @@ declare module '@mdx-js/mdx' {
|
|||
function createMdxAstCompiler(options?: Options): Processor;
|
||||
function createCompiler(options?: Options): Processor;
|
||||
}
|
||||
export default function mdx(
|
||||
content: string,
|
||||
options?: mdx.Options,
|
||||
): Promise<string>;
|
||||
function mdx(content: string, options?: mdx.Options): Promise<string>;
|
||||
|
||||
export default mdx;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ declare module '@theme/BlogSidebar' {
|
|||
|
||||
declare module '@theme/BlogPostPage' {
|
||||
import type {BlogSidebar} from '@theme/BlogSidebar';
|
||||
import type {TOCItem} from '@docusaurus/types';
|
||||
|
||||
export type FrontMatter = import('./src/blogFrontMatter').BlogPostFrontMatter;
|
||||
export type Assets = import('./src/types').Assets;
|
||||
|
|
|
@ -20,22 +20,11 @@ export type ActivePlugin = {
|
|||
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"
|
||||
// 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>,
|
||||
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(
|
||||
allPluginDatas: Record<string, GlobalPluginData>,
|
||||
pathname: string,
|
||||
|
|
|
@ -166,6 +166,8 @@ declare module '@theme/DocPage' {
|
|||
}
|
||||
|
||||
declare module '@theme/Seo' {
|
||||
import type {ReactNode} from 'react';
|
||||
|
||||
export type Props = {
|
||||
readonly title?: string;
|
||||
readonly description?: string;
|
||||
|
@ -184,15 +186,16 @@ declare module '@theme/hooks/useDocs' {
|
|||
type ActivePlugin = import('./client/docsClientUtils').ActivePlugin;
|
||||
type ActiveDocContext = import('./client/docsClientUtils').ActiveDocContext;
|
||||
type DocVersionSuggestions = import('./client/docsClientUtils').DocVersionSuggestions;
|
||||
type GetActivePluginOptions = import('./client/docsClientUtils').GetActivePluginOptions;
|
||||
|
||||
export type {GlobalPluginData, GlobalVersion};
|
||||
export const useAllDocsData: () => Record<string, GlobalPluginData>;
|
||||
export const useDocsData: (pluginId?: string) => GlobalPluginData;
|
||||
export const useActivePlugin: (
|
||||
options: GetActivePluginOptions = {},
|
||||
options?: GetActivePluginOptions,
|
||||
) => ActivePlugin | undefined;
|
||||
export const useActivePluginAndVersion: (
|
||||
options: GetActivePluginOptions = {},
|
||||
options?: GetActivePluginOptions,
|
||||
) =>
|
||||
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
|
||||
| undefined;
|
||||
|
|
|
@ -51,7 +51,8 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@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": {
|
||||
"react": "^16.8.4 || ^17.0.0",
|
||||
|
|
|
@ -743,6 +743,7 @@ declare module '@theme/TagsListInline' {
|
|||
|
||||
declare module '@theme/Tag' {
|
||||
import type {TagsListItem} from '@theme/TagsListByLetter';
|
||||
import type {Optional} from 'utility-types';
|
||||
|
||||
export type Props = Optional<TagsListItem, 'count'>;
|
||||
|
||||
|
|
|
@ -25,7 +25,8 @@
|
|||
"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: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": {
|
||||
"@crowdin/cli": "^3.5.2",
|
||||
|
@ -63,7 +64,7 @@
|
|||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tsconfig/docusaurus": "^1.0.3",
|
||||
"@tsconfig/docusaurus": "^1.0.4",
|
||||
"cross-env": "^7.0.3",
|
||||
"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.
|
||||
"extends": "@tsconfig/docusaurus/tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"paths": {
|
||||
"@site/*": ["./*"]
|
||||
},
|
||||
"baseUrl": ".",
|
||||
"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"
|
||||
integrity sha512-Z6DoceYb/1xSg5+e+ZlPZ9v0N16ZvZ+wYMraFue4HYrE4ttONKtsvruIRf6t9TBR0YvSOfi1hUU0fJfBLCDYow==
|
||||
|
||||
"@tsconfig/docusaurus@^1.0.3":
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/@tsconfig/docusaurus/-/docusaurus-1.0.3.tgz#040582bdceb27336d7abf2301fb0f4c909a9ac2f"
|
||||
integrity sha512-g4X3HvNXbkowvEdPLu759fZjbXoazPjvi2a/fAAITp2yMOGeSKpHuY6N538ZY+1u6Z91Er3QKPtYGdZQ+tqXUA==
|
||||
"@tsconfig/docusaurus@^1.0.4":
|
||||
version "1.0.4"
|
||||
resolved "https://registry.yarnpkg.com/@tsconfig/docusaurus/-/docusaurus-1.0.4.tgz#fc40f87a672568678d83533dd4031a09d75877ca"
|
||||
integrity sha512-I6sziQAzLrrqj9r6S26c7aOAjfGVXIE7gWdNONPwnpDcHiMRMQut1s1YCi/APem3dOy23tAb2rvHfNtGCaWuUQ==
|
||||
|
||||
"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.7":
|
||||
version "7.1.14"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue