【发布时间】:2019-01-07 06:54:23
【问题描述】:
使用,
import { XMLHttpRequest } from 'xmlhttprequest';
在 Node 上使用 tsc 编译时出现以下错误
index.ts|4 col 32 错误| 7016[QF 可用]:找不到模块“
xmlhttprequest”的声明文件。 '<project>/node_modules/xmlhttprequest/lib/XMLHttpRequest.js' 隐含了一个 'any' 类型。尝试npm install @types/xmlhttprequest(如果存在)或添加包含declare module 'xmlhttprequest';的新声明(.d.ts)文件
但是,那个包好像不存在,
npm install @types/xmlhttprequest
npm ERR! code E404
npm ERR! 404 Not Found: @types/xmlhttprequest@latest
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ecarroll/.npm/_logs/2018-07-31T00_19_20_299Z-debug.log
有没有办法封装这种类型?
【问题讨论】:
标签: node.js typescript xmlhttprequest