我正在尝试自定义antd,但是当我通过 构建项目时npm run build
,生成的代码与生成的代码不同npm install antd
(显然,当我尝试导入所需的类时,我生成的代码不起作用)。
更具体地说,我在谈论.d.ts
文件,下面是一个示例。
Upload.d.ts
file 是我要自定义和使用的类。
有效的代码(npm install antd
):
import * as React from 'react';
import Dragger from './Dragger';
import { RcFile, UploadProps, UploadState, UploadFile, UploadLocale, UploadChangeParam, UploadType, UploadListType } from './interface';
import { T } from './utils';
import { ConfigConsumerProps } from '../config-provider';
export { UploadProps };
declare class Upload extends React.Component<UploadProps, UploadState> {
static Dragger: typeof Dragger;
static defaultProps: {
type: UploadType;
multiple: boolean;
action: string;
data: {};
accept: string;
beforeUpload: typeof T;
showUploadList: boolean;
listType: UploadListType;
className: string;
disabled: boolean;
supportServerRender: boolean;
};
static getDerivedStateFromProps(nextProps: UploadProps): {
fileList: UploadFile<any>[];
} | null;
recentUploadStatus: boolean | PromiseLike<any>;
progressTimer: any;
upload: any;
constructor(props: UploadProps);
componentWillUnmount(): void;
saveUpload: (node: any) => void;
onStart: (file: RcFile) => void;
onSuccess: (response: any, file: UploadFile<any>, xhr: any) => void;
onProgress: (e: {
percent: number;
}, file: UploadFile<any>) => void;
onError: (error: Error, response: any, file: UploadFile<any>) => void;
handleRemove: (file: UploadFile<any>) => void;
onChange: (info: UploadChangeParam<UploadFile<any>>) => void;
onFileDrop: (e: React.DragEvent<HTMLDivElement>) => void;
beforeUpload: (file: RcFile, fileList: RcFile[]) => boolean | PromiseLike<void>;
clearProgressTimer(): void;
autoUpdateProgress(_: any, file: UploadFile): void;
renderUploadList: (locale: UploadLocale) => JSX.Element;
renderUpload: ({ getPrefixCls }: ConfigConsumerProps) => JSX.Element;
render(): JSX.Element;
}
export default Upload;
我生成的代码:
import * as React from 'react';
import Dragger from './Dragger';
import { UploadProps } from './interface';
export { UploadProps };
interface CompoundedComponent extends React.ForwardRefExoticComponent<React.PropsWithChildren<UploadProps> & React.RefAttributes<any>> {
Dragger: typeof Dragger;
LIST_IGNORE: string;
}
declare const Upload: CompoundedComponent;
export default Upload;
我在命令中遗漏了什么吗?