Просмотр исходного кода

fix: fix typescript type error

fix #5578
chenshuai2144 6 лет назад
Родитель
Сommit
4c36a09fce
1 измененных файлов с 5 добавлено и 5 удалено
  1. 5 5
      src/pages/user/login/components/Login/index.tsx

+ 5 - 5
src/pages/user/login/components/Login/index.tsx

@@ -18,7 +18,7 @@ export interface LoginProps {
   className?: string;
   form: FormComponentProps['form'];
   onCreate?: (form?: FormComponentProps['form']) => void;
-  children: React.ReactElement<LoginTab>[];
+  children: React.ReactElement<typeof LoginTab>[];
 }
 
 interface LoginState {
@@ -125,16 +125,16 @@ class Login extends Component<LoginProps, LoginState> {
   render() {
     const { className, children } = this.props;
     const { type, tabs = [] } = this.state;
-    const TabChildren: React.ReactComponentElement<LoginTab>[] = [];
+    const TabChildren: React.ReactComponentElement<typeof LoginTab>[] = [];
     const otherChildren: React.ReactElement<unknown>[] = [];
     React.Children.forEach(
       children,
-      (child: React.ReactComponentElement<LoginTab> | React.ReactElement<unknown>) => {
+      (child: React.ReactComponentElement<typeof LoginTab> | React.ReactElement<unknown>) => {
         if (!child) {
           return;
         }
-        if (child.type.typeName === 'LoginTab') {
-          TabChildren.push(child as React.ReactComponentElement<LoginTab>);
+        if ((child.type as { typeName: string }).typeName === 'LoginTab') {
+          TabChildren.push(child as React.ReactComponentElement<typeof LoginTab>);
         } else {
           otherChildren.push(child);
         }