Typescript 如何基于lib.d.ts定义新建Blob
当我试图创建一个Blob时,typescript编译器给出了一个错误Typescript 如何基于lib.d.ts定义新建Blob,typescript,Typescript,当我试图创建一个Blob时,typescript编译器给出了一个错误 var content = '<a id="a"><b id="b">hey!</b></a>'; // the body of the new file... var blob = new Blob([content], { type: "text/xml"}); Using tsc v1.0.1 error TS7005: Variable 'blob' implicitl
var content = '<a id="a"><b id="b">hey!</b></a>'; // the body of the new file...
var blob = new Blob([content], { type: "text/xml"});
Using tsc v1.0.1
error TS7005: Variable 'blob' implicitly has an 'any' type.
error TS2081: Supplied parameters do not match any signature of call target.
error TS2085: Could not select overload for 'new' expression.
如何使用基于此定义的新运算符?
如果是bug,最好的抑制方法是什么
编辑:
它不会在typescript中给出错误。但是,我想我使用的是最新版本
谢谢。那就行了。我的tsc 1.0.1没有错误:
谢谢。我的lib.d.ts实际上指向了一个旧的codeplex git repo。编辑器指向一个较新的,如上图所示。现在很好用。
declare var Blob: {
prototype: Blob;
new (blobParts?: any[], options?: BlobPropertyBag): Blob;
}
interface BlobPropertyBag {
type?: string;
endings?: string;
}