node_modules / antd / lib / upload / interface.d.ts:47:42-错误TS2304:找不到名称

时间:2019-09-22 14:34:20

标签: reactjs typescript npm antd

使用npm run build时,出现与ant design相关的错误node_modules/antd/lib/upload/interface.d.ts:47:42 - error TS2304: Cannot find name xxxx。根据文档,您不再需要为antd安装类型。这是完整的错误:

node_modules/antd/lib/affix/index.d.ts:3:39 - error TS2304: Cannot find name 'Window'.

3 declare function getDefaultTarget(): (Window & typeof globalThis) | null;
                                        ~~~~~~

node_modules/antd/lib/affix/index.d.ts:16:20 - error TS2304: Cannot find name 'Window'.

16     target?: () => Window | HTMLElement | null;
                      ~~~~~~

node_modules/antd/lib/affix/index.d.ts:29:17 - error TS2304: Cannot find name 'Window'.

29     prevTarget: Window | HTMLElement | null;
                   ~~~~~~

node_modules/antd/lib/anchor/Anchor.d.ts:5:41 - error TS2304: Cannot find name 'Window'.

5 declare function getDefaultContainer(): Window & typeof globalThis;
                                          ~~~~~~

node_modules/antd/lib/anchor/Anchor.d.ts:6:53 - error TS2304: Cannot find name 'Window'.

6 export declare type AnchorContainer = HTMLElement | Window;
                                                      ~~~~~~

node_modules/antd/lib/back-top/index.d.ts:6:34 - error TS2304: Cannot find name 'Window'.

6     target?: () => HTMLElement | Window;
                                   ~~~~~~

node_modules/antd/lib/upload/interface.d.ts:6:33 - error TS2304: Cannot find name 'File'.

6 export interface RcFile extends File {
                                  ~~~~

node_modules/antd/lib/upload/interface.d.ts:22:21 - error TS2304: Cannot find name 'File'.

22     originFileObj?: File | Blob;
                       ~~~~

node_modules/antd/lib/upload/interface.d.ts:22:28 - error TS2304: Cannot find name 'Blob'.

22     originFileObj?: File | Blob;
                              ~~~~

node_modules/antd/lib/upload/interface.d.ts:47:42 - error TS2304: Cannot find name 'File'.

47 declare type PreviewFileHandler = (file: File | Blob) => PromiseLike<string>;
                                            ~~~~

node_modules/antd/lib/upload/interface.d.ts:47:49 - error TS2304: Cannot find name 'Blob'.

47 declare type PreviewFileHandler = (file: File | Blob) => PromiseLike<string>;
                                                   ~~~~

node_modules/antd/lib/upload/interface.d.ts:48:64 - error TS2304: Cannot find name 'Blob'.

48 declare type TransformFileHandler = (file: RcFile) => string | Blob | File | PromiseLike<string | Blob | File>;
                                                                  ~~~~

node_modules/antd/lib/upload/interface.d.ts:48:71 - error TS2304: Cannot find name 'File'.

48 declare type TransformFileHandler = (file: RcFile) => string | Blob | File | PromiseLike<string | Blob | File>;
                                                                         ~~~~

node_modules/antd/lib/upload/interface.d.ts:48:99 - error TS2304: Cannot find name 'Blob'.

48 declare type TransformFileHandler = (file: RcFile) => string | Blob | File | PromiseLike<string | Blob | File>;
                                                                                                     ~~~~

node_modules/antd/lib/upload/interface.d.ts:48:106 - error TS2304: Cannot find name 'File'.

48 declare type TransformFileHandler = (file: RcFile) => string | Blob | File | PromiseLike<string | Blob | File>;
                                                                                                            ~~~~

node_modules/antd/lib/upload/utils.d.ts:12:44 - error TS2304: Cannot find name 'File'.

12 export declare function previewImage(file: File | Blob): Promise<string>;
                                              ~~~~

node_modules/antd/lib/upload/utils.d.ts:12:51 - error TS2304: Cannot find name 'Blob'.

12 export declare function previewImage(file: File | Blob): Promise<string>;
                                                     ~~~~

这是我的package.json:

{
  "name": "x",
  "version": "0.1.0",
  "description": "",
  "main": "lib/index.js",
  "types": "lib",
  "scripts": {
    "build": "tsc -p ."
  },
  "keywords": [],
  "author": "x",
  "license": "ISC",
  "peerDependencies": {
    "react": ">=16.0.0"
  },
  "devDependencies": {
    "@types/node": "12.7.5",
    "@types/react": "^16.9.2",
    "@types/react-dom": "^16.9.0",
    "antd": "^3.23.4",
    "babel-plugin-import": "^1.12.1",
    "react": "^16.9.0",
    "react-dom": "^16.9.0",
    "typerscript": "^0.2.3",
    "typescript": "^3.6.3",
    "typestyle": "^2.0.4"
  }
}

我不知道如何安装它说缺少的文件,感谢任何帮助!

0 个答案:

没有答案