From f51bbc8e67cbc8d85c7368688741602609dbc78f Mon Sep 17 00:00:00 2001 From: Igor Octaviano Date: Mon, 6 Jul 2026 14:13:58 -0300 Subject: [PATCH] Configure Slim logger at startup and fix icon type issues. Apply window.config.logger through Slim's logger at boot, simplify Button icon prop typing, and add React DOMAttributes augmentation for @ant-design/icons pointer-capture handlers. --- src/components/Button.tsx | 5 +---- src/index.tsx | 15 +++++++++++++++ src/utils/logger.ts | 3 ++- types/react-antd-icons.d.ts | 13 +++++++++++++ 4 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 types/react-antd-icons.d.ts diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 1c4c738f..9fdb9d34 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -3,10 +3,7 @@ import React from 'react' import type { IconType } from 'react-icons' interface ButtonProps { - icon: - | IconType - | React.ComponentType> - | React.ForwardRefExoticComponent + icon: IconType | React.ComponentType> tooltip?: string label?: string onClick?: (options: React.SyntheticEvent) => void diff --git a/src/index.tsx b/src/index.tsx index 0179ef4e..85302049 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -7,6 +7,7 @@ import './index.css' import packageInfo from '../package.json' import type AppConfig from './AppConfig' import CustomErrorBoundary from './components/CustomErrorBoundary' +import { logger } from './utils/logger' declare global { interface Window { @@ -19,6 +20,20 @@ if (config === undefined) { throw Error('No application configuration was provided.') } +if (config.logger != null) { + logger.configure({ + ...(config.logger.level != null + ? { level: logger.parseLogLevel(config.logger.level) } + : {}), + ...(config.logger.enableInProduction != null + ? { enableInProduction: config.logger.enableInProduction } + : {}), + ...(config.logger.enableInDevelopment != null + ? { enableInDevelopment: config.logger.enableInDevelopment } + : {}), + }) +} + type AppProps = { config: AppConfig version: string diff --git a/src/utils/logger.ts b/src/utils/logger.ts index 5727ce5a..ef0d5190 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -1,5 +1,6 @@ /** - * Logger utility that wraps console logging and can be configured for different environments + * Logger utility that wraps console logging and can be configured for different environments. + * Configured from `window.config.logger` at application startup. */ export enum LogLevel { diff --git a/types/react-antd-icons.d.ts b/types/react-antd-icons.d.ts new file mode 100644 index 00000000..d65f0896 --- /dev/null +++ b/types/react-antd-icons.d.ts @@ -0,0 +1,13 @@ +/** + * @ant-design/icons@4 types Pick pointer-capture handlers that are absent from + * @types/react's ts5.0 DOMAttributes. Without these, icon props are inferred as + * required and break JSX usage across the app. + */ +import 'react' + +declare module 'react' { + interface DOMAttributes { + onPointerEnterCapture?: React.PointerEventHandler | undefined + onPointerLeaveCapture?: React.PointerEventHandler | undefined + } +}