From 1e1477e84367fefbcebf55a91df0614e0be7843c Mon Sep 17 00:00:00 2001 From: dengfuping Date: Sat, 27 Jan 2024 15:46:58 +0800 Subject: [PATCH] fix(design): ConfigProvider TS error --- packages/design/src/config-provider/index.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/design/src/config-provider/index.tsx b/packages/design/src/config-provider/index.tsx index f19ed712d..d82d29f48 100644 --- a/packages/design/src/config-provider/index.tsx +++ b/packages/design/src/config-provider/index.tsx @@ -72,7 +72,16 @@ const ExtendedConfigContext = React.createContext({ const { defaultSeed } = themeConfig; -const ConfigProvider = ({ +export type ConfigProviderType = React.FC & { + ExtendedConfigContext: typeof ExtendedConfigContext; +} & { + ConfigContext: React.Context; + SizeContext: typeof AntConfigProvider.SizeContext; + config: typeof AntConfigProvider.config; + useConfig: typeof AntConfigProvider.useConfig; +}; + +const ConfigProvider: ConfigProviderType = ({ children, theme, navigate, @@ -82,7 +91,7 @@ const ConfigProvider = ({ tabs, styleProviderProps, ...restProps -}: ConfigProviderProps) => { +}) => { // inherit from parent ConfigProvider const parentContext = React.useContext(AntConfigProvider.ConfigContext); const parentExtendedContext = @@ -140,8 +149,7 @@ const ConfigProvider = ({ ); }; -ConfigProvider.ConfigContext = - AntConfigProvider.ConfigContext as React.Context; +ConfigProvider.ConfigContext = AntConfigProvider.ConfigContext; ConfigProvider.ExtendedConfigContext = ExtendedConfigContext; ConfigProvider.SizeContext = AntConfigProvider.SizeContext; ConfigProvider.config = AntConfigProvider.config;