Closed archiewx closed 6 years ago
import { ComponentType } from 'react' import { getDisplayName } from '../utils/getDisplayName' export const withDefaultProps = <P extends object, DP extends Partial<P> = Partial<P>>( defaultProps: DP, Cmp: ComponentType<P>, ) => { type RequiredProps = Omit<P, keyof DP> type Props = Partial<DP> & Required<RequiredProps> Cmp.defaultProps = defaultProps return (Cmp as ComponentType<any>) as ComponentType<Props> }
就不用英文了
更新到0.5.1,修正结果如下,如果我对您这段代码语义理解不对 导致颜色分配有误,可以继续指出。
谢谢。持续关注中