Ver Fonte

Merge pull request #1464 from thinkasany/main

fix: optimized type
代强 há 2 anos atrás
pai
commit
9e03a31194

+ 3 - 3
packages/semi-ui/_base/base.ts

@@ -29,8 +29,8 @@ export interface MotionChildrenProps {
         animationFillMode?: string
     };
     animateEvents?: {
-        onAnimationIteration?: React.AnimationEventHandler<any> | undefined;
-        onAnimationStart?: React.AnimationEventHandler<any> | undefined;
-        onAnimationEnd?: React.AnimationEventHandler<any> | undefined
+        onAnimationIteration?: React.AnimationEventHandler<any>;
+        onAnimationStart?: React.AnimationEventHandler<any>;
+        onAnimationEnd?: React.AnimationEventHandler<any>
     }
 }

+ 1 - 1
packages/semi-ui/anchor/index.tsx

@@ -19,7 +19,7 @@ export type { LinkProps } from './link';
 export interface AnchorProps {
     autoCollapse?: boolean;
     className?: string;
-    children?: ReactNode | undefined;
+    children?: ReactNode;
     defaultAnchor?: string;
     getContainer?: () => HTMLElement | Window;
     maxHeight?: string | number;

+ 1 - 1
packages/semi-ui/autoComplete/index.tsx

@@ -48,7 +48,7 @@ export interface AutoCompleteProps<T extends AutoCompleteItems> {
     autoFocus?: boolean;
     className?: string;
     clearIcon?: ReactNode;
-    children?: ReactNode | undefined;
+    children?: ReactNode;
     data?: T[];
     disabled?: boolean;
     defaultOpen?: boolean;

+ 1 - 1
packages/semi-ui/button/Button.tsx

@@ -19,7 +19,7 @@ export interface ButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonE
     id?: string;
     block?: boolean;
     circle?: boolean;
-    children?: ReactNode | undefined;
+    children?: ReactNode;
     disabled?: boolean;
     className?: string;
     icon?: React.ReactNode;

+ 1 - 1
packages/semi-ui/checkbox/checkbox.tsx

@@ -26,7 +26,7 @@ export interface CheckboxProps extends BaseCheckboxProps {
     'aria-invalid'?: React.AriaAttributes['aria-invalid'];
     'aria-labelledby'?: React.AriaAttributes['aria-labelledby'];
     'aria-required'?: React.AriaAttributes['aria-required'];
-    children?: React.ReactNode | undefined;
+    children?: React.ReactNode;
     onChange?: (e: CheckboxEvent) => any;
     // TODO, docs
     style?: React.CSSProperties;

+ 1 - 1
packages/semi-ui/checkbox/checkboxGroup.tsx

@@ -24,7 +24,7 @@ export type CheckboxGroupProps = {
     options?: any[];
     value?: any[];
     onChange?: (value: any[]) => void;
-    children?: React.ReactNode | undefined;
+    children?: React.ReactNode;
     prefixCls?: string;
     direction?: CheckboxDirection;
     style?: React.CSSProperties;

+ 1 - 1
packages/semi-ui/descriptions/index.tsx

@@ -20,7 +20,7 @@ export interface DescriptionsProps {
     size?: DescriptionsSize;
     style?: React.CSSProperties;
     className?: string;
-    children?: React.ReactNode | undefined;
+    children?: React.ReactNode;
     data?: Data[]
 }
 

+ 1 - 1
packages/semi-ui/layout/index.tsx

@@ -60,7 +60,7 @@ export interface BasicLayoutProps {
     prefixCls?: string;
     style?: CSSProperties;
     className?: string;
-    children?: React.ReactNode | undefined;
+    children?: React.ReactNode;
     hasSider?: boolean;
     tagName?: keyof HTMLElementTagNameMap
 }

+ 3 - 3
packages/semi-ui/progress/index.tsx

@@ -10,9 +10,9 @@ import { generateColor, StrokeArr } from '@douyinfe/semi-foundation/progress/gen
 const prefixCls = cssClasses.PREFIX;
 
 export interface ProgressProps {
-    'aria-label'?: string | undefined;
-    'aria-labelledby'?: string | undefined;
-    'aria-valuetext'?: string | undefined;
+    'aria-label'?: string;
+    'aria-labelledby'?: string;
+    'aria-valuetext'?: string;
     className?: string;
     direction?: 'horizontal' | 'vertical';
     format?: (percent: number) => React.ReactNode;

+ 1 - 1
packages/semi-ui/radio/radio.tsx

@@ -24,7 +24,7 @@ export type RadioType =
 export type RadioProps = {
     autoFocus?: boolean;
     checked?: boolean;
-    children?: React.ReactNode | undefined;
+    children?: React.ReactNode;
     defaultChecked?: boolean;
     value?: string | number;
     disabled?: boolean;

+ 1 - 1
packages/semi-ui/tabs/interface.ts

@@ -60,7 +60,7 @@ export interface TabBarProps {
 
 export interface TabPaneProps {
     className?: string;
-    children?: React.ReactNode | undefined;
+    children?: React.ReactNode;
     disabled?: boolean;
     icon?: ReactNode;
     itemKey?: string;

+ 1 - 1
packages/semi-ui/tagInput/index.tsx

@@ -79,7 +79,7 @@ export interface TagInputProps {
     style?: React.CSSProperties;
     suffix?: React.ReactNode;
     validateStatus?: ValidateStatus;
-    value?: string[] | undefined;
+    value?: string[];
     autoFocus?: boolean;
     'aria-label'?: string;
     preventScroll?: boolean

+ 2 - 2
src/components/ImageBox/index.tsx

@@ -5,11 +5,11 @@ import './index.scss';
 interface ImageBoxProps {
     url: string;
     darkUrl?: string;
-    alt: string;
+    alt: string
 }
 
 function ImageBox(props: ImageBoxProps): React.ReactElement {
-    const { url, alt, darkUrl, darkAlt } = props;
+    const { url, alt, darkUrl } = props;
 
     return (
         <Empty

+ 2 - 2
src/components/JumpToToken/index.tsx

@@ -1,6 +1,6 @@
 import React, { useEffect } from 'react';
 
-const JumpToToken = (): React.ReactElement => {
+const JumpToToken = (): React.ReactNode => {
     useEffect(() => {
         const job = (): void => {
             const token = (new URLSearchParams(window.location.search)).get('token');
@@ -9,7 +9,7 @@ const JumpToToken = (): React.ReactElement => {
             }
             const timer = setInterval(() => {
                 try {
-                    const targetDom: HTMLElement = document.querySelector(`[data-token=${token}]`);
+                    const targetDom: HTMLElement | null = document.querySelector(`[data-token=${token}]`);
                     if (targetDom) {
                         targetDom.scrollIntoView({
                             block: 'center'