我有以下代码来处理用户的文件上传:
17 const onFileDrop =
18 (files: File[]) => {
19 files.forEach(file => file.text().then(content => console.log(content)));
20 },
21 );
VS Code 没有显示任何错误,我可以正确访问File
包含text()
函数的界面。
但是,在运行时,npm start
我看到以下错误:
[tsl] ERROR in {omitted}/RawCommandOutputs.tsx(19,34)
TS2339: Property 'text' does not exist on type 'File'.
[tsl] ERROR in {omitted}/RawCommandOutputs.tsx(19,46)
TS7006: Parameter 'content' implicitly has an 'any' type.