[英]Typescript HTML5 API Typings
Anyone know if there exists type definitions for the HTML5 File API?有人知道 HTML5 文件 API 是否存在类型定义吗? Specifically:具体来说:
Also in Angular there is a document.defaultView
object that represents the window, but it does not the full Window interface with respect to the Html5 File API, so it would be necessary to cast document.defaultView
to an instance that has the Window
interface for the file API.同样在 Angular 中有一个document.defaultView
对象代表窗口,但它没有关于 Html5 File API 的完整 Window 接口,因此有必要将document.defaultView
转换为具有Window
接口的实例文件 API。
I cannot tell you why File
and FileReader
are not included on the Window
object already.我不能告诉你为什么File
和FileReader
没有包含在Window
对象中。 You can certainly open an issue with typescript
to see if they plan on adding them.你当然可以用typescript
打开一个问题,看看他们是否打算添加它们。 In the meantime, the easiest way to "patch" this oversight would be to use declaration merging.同时,“修补”这种疏忽的最简单方法是使用声明合并。
Window.d.ts窗口.d.ts
interface Window {
File?:File;
FileReader?:FileReader;
}
Now File
and FileReader
will be available on the Window
object anywhere in your project.现在File
和FileReader
将在项目中任何位置的Window
对象上可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.