From 13033b1d9662f66b27ad0a06630d8839ee63871f Mon Sep 17 00:00:00 2001 From: dengfuping Date: Tue, 17 Oct 2023 21:40:16 +0800 Subject: [PATCH] fix(ts): should export original theme object --- packages/design/src/index.ts | 6 ++---- packages/design/src/theme/index.ts | 15 +++++++-------- tsconfig.json | 4 +++- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/packages/design/src/index.ts b/packages/design/src/index.ts index 7bc546559..780e5dabc 100644 --- a/packages/design/src/index.ts +++ b/packages/design/src/index.ts @@ -1,5 +1,3 @@ -import { theme } from 'antd'; - // 引入 antd/dist/reset.css,以重置基本样式,保证原生元素遵从 antd 规范样式 // ref: https://ant.design/docs/react/migration-v5-cn#%E6%8A%80%E6%9C%AF%E8%B0%83%E6%95%B4 import 'antd/dist/reset.css'; @@ -25,9 +23,9 @@ export { default as Breadcrumb } from './breadcrumb'; export { default as Spin } from './spin'; export { default as Badge } from './badge'; -const { useToken } = theme; +import theme from './theme'; -// 直接导出 useToken,方便上层使用 +const { useToken } = theme; export { useToken }; export type { PresetStatusColorType } from 'antd/es/_util/colors'; diff --git a/packages/design/src/theme/index.ts b/packages/design/src/theme/index.ts index 5714cf822..4cd32d9bd 100644 --- a/packages/design/src/theme/index.ts +++ b/packages/design/src/theme/index.ts @@ -22,13 +22,12 @@ const defaultSeed = { const defaultConfig = theme.defaultConfig; defaultConfig.token = defaultSeed; -export default { - ...theme, - defaultSeed, - defaultConfig, - components: { - InputNumber: { - handleVisible: true as true, - }, +theme.defaultSeed = defaultSeed; +theme.defaultConfig = defaultConfig; +(theme as any).components = { + InputNumber: { + handleVisible: true as true, }, }; + +export default theme; diff --git a/tsconfig.json b/tsconfig.json index 464d8a8c9..6fc3213bb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,13 +6,15 @@ "jsx": "react-jsx", "jsxImportSource": "@emotion/react", "esModuleInterop": true, - "types": ["jest", "node", "@ant-design/cssinjs"], + "types": ["jest", "node"], "declaration": true, // TS 编译时跳过对 node_modules 依赖的检查 "skipLibCheck": true, "resolveJsonModule": true, "baseUrl": "./", "paths": { + // ref: https://github.com/microsoft/TypeScript/issues/29808#issuecomment-540292885 + "@ant-design/cssinjs": ["node_modules/@ant-design/cssinjs"], "@@/*": [".dumi/tmp/*"], "@oceanbase/design": ["packages/design/src/index.ts"], "@oceanbase/design/es/*": ["packages/design/src/*"],