Skip to content

Commit 3581b74

Browse files
fiberthroneyarastqt
authored andcommitted
chore(core): fix withBemMod typings error
1 parent b6349dc commit 3581b74

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

packages/core/core.ts

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -64,30 +64,6 @@ export function withBemMod<T, U extends IClassNameProps = {}>(
6464
let entityClassName: string
6565
let modNames: string[]
6666

67-
// These typings should work properly for class components as well as for forwardRef chains
68-
// See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/35834#issuecomment-497605842
69-
interface IWithBemMod {
70-
<K extends IClassNameProps, Q extends React.ComponentClass<T & K>>(
71-
WrappedComponent: Q,
72-
): React.ForwardRefExoticComponent<
73-
React.ComponentPropsWithoutRef<Q> & { ref?: React.Ref<InstanceType<Q>> }
74-
>
75-
76-
<K extends IClassNameProps>(
77-
WrappedComponent: React.ForwardRefExoticComponent<T & K & { ref?: React.Ref<any> }>,
78-
): React.ForwardRefExoticComponent<T & K & { ref?: React.Ref<any> }>
79-
80-
<K extends IClassNameProps>(
81-
Component: React.FunctionComponent<T & K>,
82-
): React.ForwardRefExoticComponent<T & K>
83-
84-
__isSimple: boolean
85-
__blockName?: string
86-
__mod?: string
87-
__value?: string | number | boolean
88-
__passToProps?: boolean
89-
}
90-
9167
function WithBemMod<K extends IClassNameProps = {}>(WrappedComponent: ComponentType<T & K>) {
9268
// Use cache to prevent create new component when props are changed.
9369
let ModifiedComponent: ComponentType<any>
@@ -154,7 +130,29 @@ export function withBemMod<T, U extends IClassNameProps = {}>(
154130
return BemMod
155131
}
156132

157-
const withMod = WithBemMod as IWithBemMod
133+
// These typings should work properly for class components as well as for forwardRef chains
134+
// See: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/35834#issuecomment-497605842
135+
const withMod = WithBemMod as {
136+
<K extends IClassNameProps, Q extends React.ComponentClass<T & K>>(
137+
WrappedComponent: Q,
138+
): React.ForwardRefExoticComponent<
139+
React.ComponentPropsWithoutRef<Q> & { ref?: React.Ref<InstanceType<Q>> }
140+
>
141+
142+
<K extends IClassNameProps>(
143+
WrappedComponent: React.ForwardRefExoticComponent<T & K & { ref?: React.Ref<any> }>,
144+
): React.ForwardRefExoticComponent<T & K & { ref?: React.Ref<any> }>
145+
146+
<K extends IClassNameProps>(
147+
Component: React.FunctionComponent<T & K>,
148+
): React.ForwardRefExoticComponent<T & K>
149+
150+
__isSimple: boolean
151+
__blockName?: string
152+
__mod?: string
153+
__value?: string | number | boolean
154+
__passToProps?: boolean
155+
}
158156

159157
const { __passToProps = true, __simple = false } = (enhance as withBemModOptions) || {}
160158

0 commit comments

Comments
 (0)