diff --git a/packages/react-element/src/wrapBrick.tsx b/packages/react-element/src/wrapBrick.tsx index bf337ab5f4..a9dca597e4 100644 --- a/packages/react-element/src/wrapBrick.tsx +++ b/packages/react-element/src/wrapBrick.tsx @@ -25,19 +25,26 @@ type MapEvents = { [key in keyof M]?: M[key] extends keyof E ? (e: E[M[key]]) => void : never; }; -export function wrapLocalBrick( +export function wrapLocalBrick< + T extends Partial, + P, + E, + M extends object, +>( brick: Constructable | string, eventsMapping: M ): WrappedBrickWithEventsMap; -export function wrapLocalBrick( +export function wrapLocalBrick, P>( brick: Constructable | string ): WrappedBrick; -export function wrapLocalBrick( - brick: Constructable | string, - eventsMapping?: M -) { +export function wrapLocalBrick< + T extends Partial, + P, + _E, + M extends object, +>(brick: Constructable | string, eventsMapping?: M) { // istanbul ignore next if (process.env.NODE_ENV === "development") { if (typeof brick === "string" && !customElements.get(brick)) { @@ -62,19 +69,23 @@ export function wrapLocalBrick( ); } -export function wrapBrick( - BrickName: string, - eventsMapping: M -): WrappedBrickWithEventsMap; +export function wrapBrick< + T extends Partial, + P, + E, + M extends object, +>(BrickName: string, eventsMapping: M): WrappedBrickWithEventsMap; -export function wrapBrick( +export function wrapBrick, P>( BrickName: string ): WrappedBrick; -export function wrapBrick( - BrickName: string, - eventsMapping?: M -) { +export function wrapBrick< + T extends Partial, + P, + _E, + M extends object, +>(BrickName: string, eventsMapping?: M) { return forwardRef & PropsWithChildren

>( function BrickReactWrapper({ children, ...props }, ref: Ref) { const properties = getMappedProperties(