bem-react icon indicating copy to clipboard operation
bem-react copied to clipboard

@bem-react/classname Proposal generic type for component in generator

Open belozer opened this issue 6 years ago • 0 comments

More info: https://github.com/bem/bem-react/issues/446#issuecomment-510539095, https://github.com/bem/bem-react/issues/446#issuecomment-517455707 and https://github.com/bem/bem-react/issues/446#issuecomment-517469359

Example:

import { cnTheme, Theme as ThemeBase } from '../components/Theme/Theme';
import { withColorDefault } from '../components/Theme/_color/Theme_color_default';

const Theme = compose(
  withColorDefault
)(ThemeBase);

<div className={cnTheme<typeof Theme>({ color: 'default' })} />
// ok

<div className={cnTheme<typeof Theme>({ color: 'def' })} />
// TS Error

<div className={cnTheme<typeof Theme>({ color: 'default', size: 'default' })} />
// TS Error

belozer avatar Aug 01 '19 22:08 belozer