diff --git a/.changelog/5973-fix-react-19-prop-types-typings.md b/.changelog/5973-fix-react-19-prop-types-typings.md new file mode 100644 index 0000000000..2e3d1f9e4e --- /dev/null +++ b/.changelog/5973-fix-react-19-prop-types-typings.md @@ -0,0 +1,3 @@ +### Removed + +- 💥 Function components: removed `ReactWebChat.propTypes` and `Composer.propTypes`, fixing type errors with `@types/react@19`, related to [#5552](https://github.com/microsoft/BotFramework-WebChat/issues/5552), in PR [#5973](https://github.com/microsoft/BotFramework-WebChat/pull/5973), by [@OEvgeny](https://github.com/OEvgeny) diff --git a/packages/api/src/hooks/Composer.tsx b/packages/api/src/hooks/Composer.tsx index c3a8ef9927..11678f3d22 100644 --- a/packages/api/src/hooks/Composer.tsx +++ b/packages/api/src/hooks/Composer.tsx @@ -857,13 +857,6 @@ const Composer = ({ internalRenderErrorBox, onTelemetry, ponyfill, styleOptions, ); }; -Composer.propTypes = { - ...ComposerWithStore.propTypes, - internalRenderErrorBox: PropTypes.any, - onTelemetry: PropTypes.func, - ponyfill: PropTypes.any -}; - export default Composer; export type { ComposerProps }; diff --git a/packages/bundle/src/FullComposer.tsx b/packages/bundle/src/FullComposer.tsx index 385ebdbaa6..eb74cf6501 100644 --- a/packages/bundle/src/FullComposer.tsx +++ b/packages/bundle/src/FullComposer.tsx @@ -1,5 +1,4 @@ import { Components, type ComposerProps } from 'botframework-webchat-component'; -import PropTypes from 'prop-types'; import React from 'react'; import AddFullBundle, { type AddFullBundleProps, type AddFullBundleChildren } from './AddFullBundle'; @@ -13,7 +12,7 @@ type ComposerPropsChildren = ComposerProps['children']; * The union type of ComposerProps and AddFullBundleProps was not resolving correctly, so manually constructing the type here. */ type FullComposerProps = Omit & { - children?: ComposerPropsChildren | AddFullBundleChildren; + readonly children?: ComposerPropsChildren | AddFullBundleChildren | undefined; }; const FullComposer = (props: FullComposerProps) => ( @@ -28,13 +27,6 @@ const FullComposer = (props: FullComposerProps) => ( ); -FullComposer.propTypes = { - ...Composer.propTypes, - adaptiveCardsHostConfig: PropTypes.any, - adaptiveCardsPackage: PropTypes.any, - children: PropTypes.any -}; - export default FullComposer; export type { FullComposerProps }; diff --git a/packages/component/src/Composer.tsx b/packages/component/src/Composer.tsx index 9e82278c4c..789ae10e19 100644 --- a/packages/component/src/Composer.tsx +++ b/packages/component/src/Composer.tsx @@ -517,11 +517,5 @@ const Composer = ({ ); }; -Composer.propTypes = { - ...APIComposer.propTypes, - ...ComposerCore.propTypes, - children: PropTypes.any -}; - export default Composer; export type { ComposerProps }; diff --git a/packages/component/src/ReactWebChat.tsx b/packages/component/src/ReactWebChat.tsx index 93a359e329..b31be76794 100644 --- a/packages/component/src/ReactWebChat.tsx +++ b/packages/component/src/ReactWebChat.tsx @@ -1,4 +1,3 @@ -import PropTypes from 'prop-types'; import React from 'react'; import BasicWebChat from './BasicWebChat'; @@ -25,18 +24,6 @@ const ReactWebChat = ({ className, role, ...composerProps }: ReactWebChatProps) ); -const { - // Excluding "children" from ComposerProps. - children: _, - ...composerPropTypesWithoutChildren -} = Composer.propTypes; - -ReactWebChat.propTypes = { - className: PropTypes.string, - role: PropTypes.string, - ...composerPropTypesWithoutChildren -}; - export default ReactWebChat; export type { ReactWebChatProps };