From 62e338c7757cdba9b318bfb1a7ac50561209b61e Mon Sep 17 00:00:00 2001 From: afc163 Date: Sun, 17 Sep 2023 21:52:01 +0800 Subject: [PATCH] type: enable type prompt for .dumirc.ts (#44886) * type: fix .dumi missing types * Update tsconfig.json Signed-off-by: lijianan <574980606@qq.com> * Update tsconfig.json Signed-off-by: lijianan <574980606@qq.com> * Update tsconfig.json Signed-off-by: lijianan <574980606@qq.com> * chore: clear tsconfig.json * chore: update dumi version declaration * type: correct unified plugin types --------- Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: lijianan <574980606@qq.com> Co-authored-by: PeachScript --- .dumi/rehypeAntd.ts | 4 ++-- .dumi/remarkAntd.ts | 8 +++++--- .dumi/tsconfig.json | 14 +++----------- package.json | 2 +- tsconfig.json | 2 ++ 5 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.dumi/rehypeAntd.ts b/.dumi/rehypeAntd.ts index 56c5b1acf3..8f10bf4d84 100644 --- a/.dumi/rehypeAntd.ts +++ b/.dumi/rehypeAntd.ts @@ -62,12 +62,12 @@ function rehypeAntd(): UnifiedTransformer { (node.properties.className as string[]).push('component-api-table'); } else if (node.type === 'element' && (node.tagName === 'Link' || node.tagName === 'a')) { const { tagName } = node; - node.properties.sourceType = tagName; + node.properties!.sourceType = tagName; node.tagName = 'LocaleLink'; } else if (node.type === 'element' && node.tagName === 'video') { node.tagName = 'VideoPlayer'; } else if (node.tagName === 'SourceCode') { - const { lang } = node.properties; + const { lang } = node.properties!; if (typeof lang === 'string' && lang.startsWith('sandpack')) { const code = (node.children[0] as any).value as string; diff --git a/.dumi/remarkAntd.ts b/.dumi/remarkAntd.ts index 85970e2c01..61fdb859c5 100644 --- a/.dumi/remarkAntd.ts +++ b/.dumi/remarkAntd.ts @@ -1,12 +1,14 @@ -import { unistUtilVisit } from 'dumi'; +import { unistUtilVisit, type UnifiedTransformer } from 'dumi'; -export default function remarkMeta() { +function remarkMeta(): UnifiedTransformer { return (tree, vFile) => { // read frontmatter unistUtilVisit.visit(tree, 'yaml', (node) => { if (!/(^|[\n\r])description:/.test(node.value)) { - vFile.data.frontmatter.__autoDescription = true; + (vFile.data.frontmatter as any).__autoDescription = true; } }); }; } + +export default remarkMeta; diff --git a/.dumi/tsconfig.json b/.dumi/tsconfig.json index f0b63fb243..74eb1d4439 100644 --- a/.dumi/tsconfig.json +++ b/.dumi/tsconfig.json @@ -1,15 +1,7 @@ { + "extends": "../tsconfig.json", "compilerOptions": { - "jsx": "react-jsx", - "esModuleInterop": true, - "resolveJsonModule": true, - "baseUrl": "../", - "paths": { - "@@/*": [".dumi/tmp/*"], - "antd": ["components/index.tsx"], - "antd/es/*": ["components/*"], - "dumi/theme/*": [".dumi/theme/*"] - } + "resolveJsonModule": true }, - "include": ["./**/*", "../site/theme/template/Content"] + "include": ["**/*"] } diff --git a/package.json b/package.json index 835ed48377..48479775c2 100644 --- a/package.json +++ b/package.json @@ -216,7 +216,7 @@ "cross-fetch": "^4.0.0", "crypto": "^1.0.1", "dekko": "^0.2.1", - "dumi": "^2.1.23", + "dumi": "^2.2.10", "duplicate-package-checker-webpack-plugin": "^3.0.0", "esbuild-loader": "^4.0.0", "eslint": "^8.40.0", diff --git a/tsconfig.json b/tsconfig.json index aadc26e8e4..d04de09c99 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,6 +2,7 @@ "compilerOptions": { "baseUrl": "./", "paths": { + "@@/*": [".dumi/tmp/*"], "antd": ["components/index.ts"], "antd/es/*": ["components/*"], "antd/lib/*": ["components/*"], @@ -23,5 +24,6 @@ "skipLibCheck": true, "stripInternal": true }, + "include": [".dumirc.ts", "**/*"], "exclude": ["node_modules", "lib", "es"] }