Skip to content

Commit df3752c

Browse files
Josh-Cenaslorber
andauthored
fix: fix a few TS errors (facebook#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>
1 parent 74f060d commit df3752c

File tree

12 files changed

+31
-36
lines changed

12 files changed

+31
-36
lines changed

.github/workflows/v2-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ jobs:
2828
install-command: yarn
2929
- name: Test
3030
run: yarn test
31+
- name: TypeCheck website
32+
run: yarn workspace website tsc

packages/docusaurus-init/templates/classic-typescript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
"devDependencies": {
3030
"@docusaurus/module-type-aliases": "2.0.0-beta.5",
31-
"@tsconfig/docusaurus": "^1.0.3",
31+
"@tsconfig/docusaurus": "^1.0.4",
3232
"@types/react": "^17.0.14",
3333
"@types/react-helmet": "^6.1.2",
3434
"@types/react-router-dom": "^5.1.8",

packages/docusaurus-init/templates/classic-typescript/tsconfig.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// This file is not used in compilation. It is here just for a nice editor experience.
33
"extends": "@tsconfig/docusaurus/tsconfig.json",
44
"compilerOptions": {
5-
"paths": {
6-
"@site/*": ["./*"]
7-
}
8-
},
9-
"include": ["src/"]
5+
"baseUrl": "."
6+
}
107
}

packages/docusaurus-mdx-loader/src/types.d.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
*/
77

88
declare module '@docusaurus/mdx-loader' {
9+
type RemarkOrRehypePlugin =
10+
// eslint-disable-next-line @typescript-eslint/ban-types
11+
[Function, Record<string, unknown>] | Function;
912
export interface RemarkAndRehypePluginOptions {
1013
remarkPlugins: RemarkOrRehypePlugin[];
1114
rehypePlugins: string[];
@@ -18,7 +21,7 @@ declare module '@docusaurus/mdx-loader' {
1821
declare module '@mdx-js/mdx' {
1922
import type {Plugin, Processor} from 'unified';
2023

21-
export namespace mdx {
24+
namespace mdx {
2225
interface Options {
2326
filepath?: string;
2427
skipExport?: boolean;
@@ -31,8 +34,7 @@ declare module '@mdx-js/mdx' {
3134
function createMdxAstCompiler(options?: Options): Processor;
3235
function createCompiler(options?: Options): Processor;
3336
}
34-
export default function mdx(
35-
content: string,
36-
options?: mdx.Options,
37-
): Promise<string>;
37+
function mdx(content: string, options?: mdx.Options): Promise<string>;
38+
39+
export default mdx;
3840
}

packages/docusaurus-plugin-content-blog/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ declare module '@theme/BlogSidebar' {
2222

2323
declare module '@theme/BlogPostPage' {
2424
import type {BlogSidebar} from '@theme/BlogSidebar';
25+
import type {TOCItem} from '@docusaurus/types';
2526

2627
export type FrontMatter = import('./src/blogFrontMatter').BlogPostFrontMatter;
2728
export type Assets = import('./src/types').Assets;

packages/docusaurus-plugin-content-docs/src/client/docsClientUtils.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,11 @@ export type ActivePlugin = {
2020
pluginData: GlobalPluginData;
2121
};
2222

23-
export type GetActivePluginOptions = {failfast?: boolean};
23+
export type GetActivePluginOptions = {failfast?: boolean}; // use fail-fast option if you know for sure one plugin instance is active
2424

2525
// get the data of the plugin that is currently "active"
2626
// ie the docs of that plugin are currently browsed
2727
// it is useful to support multiple docs plugin instances
28-
export function getActivePlugin(
29-
allPluginDatas: Record<string, GlobalPluginData>,
30-
pathname: string,
31-
options: {failfast: true}, // use fail-fast option if you know for sure one plugin instance is active
32-
): ActivePlugin;
33-
export function getActivePlugin(
34-
allPluginDatas: Record<string, GlobalPluginData>,
35-
pathname: string,
36-
options?: GetActivePluginOptions,
37-
): ActivePlugin | undefined;
38-
3928
export function getActivePlugin(
4029
allPluginDatas: Record<string, GlobalPluginData>,
4130
pathname: string,

packages/docusaurus-plugin-content-docs/src/plugin-content-docs.d.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ declare module '@theme/DocPage' {
166166
}
167167

168168
declare module '@theme/Seo' {
169+
import type {ReactNode} from 'react';
170+
169171
export type Props = {
170172
readonly title?: string;
171173
readonly description?: string;
@@ -184,15 +186,16 @@ declare module '@theme/hooks/useDocs' {
184186
type ActivePlugin = import('./client/docsClientUtils').ActivePlugin;
185187
type ActiveDocContext = import('./client/docsClientUtils').ActiveDocContext;
186188
type DocVersionSuggestions = import('./client/docsClientUtils').DocVersionSuggestions;
189+
type GetActivePluginOptions = import('./client/docsClientUtils').GetActivePluginOptions;
187190

188191
export type {GlobalPluginData, GlobalVersion};
189192
export const useAllDocsData: () => Record<string, GlobalPluginData>;
190193
export const useDocsData: (pluginId?: string) => GlobalPluginData;
191194
export const useActivePlugin: (
192-
options: GetActivePluginOptions = {},
195+
options?: GetActivePluginOptions,
193196
) => ActivePlugin | undefined;
194197
export const useActivePluginAndVersion: (
195-
options: GetActivePluginOptions = {},
198+
options?: GetActivePluginOptions,
196199
) =>
197200
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
198201
| undefined;

packages/docusaurus-theme-classic/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@
5151
},
5252
"devDependencies": {
5353
"@docusaurus/module-type-aliases": "2.0.0-beta.5",
54-
"@types/parse-numeric-range": "^0.0.1"
54+
"@types/parse-numeric-range": "^0.0.1",
55+
"utility-types": "^3.10.0"
5556
},
5657
"peerDependencies": {
5758
"react": "^16.8.4 || ^17.0.0",

packages/docusaurus-theme-classic/src/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,7 @@ declare module '@theme/TagsListInline' {
743743

744744
declare module '@theme/Tag' {
745745
import type {TagsListItem} from '@theme/TagsListByLetter';
746+
import type {Optional} from 'utility-types';
746747

747748
export type Props = Optional<TagsListItem, 'count'>;
748749

website/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"netlify:crowdin:downloadTranslations": "yarn netlify:crowdin:wait && yarn --cwd .. crowdin:download:website",
2626
"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)')",
2727
"netlify:crowdin:uploadSources": "yarn --cwd .. crowdin:upload:website",
28-
"netlify:test": "yarn netlify:build:deployPreview && yarn netlify dev --debug"
28+
"netlify:test": "yarn netlify:build:deployPreview && yarn netlify dev --debug",
29+
"typecheck": "tsc"
2930
},
3031
"dependencies": {
3132
"@crowdin/cli": "^3.5.2",
@@ -63,7 +64,7 @@
6364
]
6465
},
6566
"devDependencies": {
66-
"@tsconfig/docusaurus": "^1.0.3",
67+
"@tsconfig/docusaurus": "^1.0.4",
6768
"cross-env": "^7.0.3",
6869
"raw-loader": "^4.0.2"
6970
}

0 commit comments

Comments
 (0)