【发布时间】:2018-11-13 15:05:35
【问题描述】:
我在 Stackoverflow 和网络上进行了搜索,我找到了这个线程 https://github.com/Microsoft/TypeScript/issues/14813,但它并没有解决我的问题。我在使用ng serve --watch 编译代码时遇到了这个错误。
错误 TS2339:“FormData”类型上不存在属性“条目”。
带有fd.entries() 的这部分会触发错误...知道这里发生了什么吗?
onFileSelected(event) {
const fd = new FormData;
for (const file of event.target.files) {
fd.append('thumbnail', file, file.name);
const entries = fd.entries();
// some other methods are called here e. g. upload the images
for (const pair of entries) {
fd.delete(pair[0]);
}
}
}
我看到 (https://github.com/Microsoft/TypeScript/blob/master/src/lib/dom.iterable.d.ts) 有一些 entries 的接口,但不知何故这对我不起作用。
编辑
我的tsconfig.json 看起来像这样
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
【问题讨论】:
-
你能显示你的
tsconfig.json的lib数组吗? -
我在这个问题上添加了我的
tsconfig.json。
标签: angular typescript tslint