[英]Typescript compilation error: <x> is not assignable to type <y>
When I am trying to assign 当我尝试分配
let blob:Blob = {blobParts: [content]};
where content is a json. 内容是json。
where Blob
is declared in lib.d.ts
as 在
lib.d.ts
中将Blob
声明为
interface Blob {
readonly size: number;
readonly type: string;
msClose(): void;
msDetachStream(): any;
slice(start?: number, end?: number, contentType?: string): Blob;
}
declare var Blob: {
prototype: Blob;
new (blobParts?: any[], options?: BlobPropertyBag): Blob;
};
it is giving me the following error: 它给我以下错误:
Type '{ blobParts: any[]; }' is not assignable to type 'Blob'. Object literal may only specify known properties, and 'blobParts' does not exist in type 'Blob'.
I have verified the spelling of blobParts a number of times 我已经多次验证了blobParts的拼写
您应该使用new
关键字构造Blob ...
let blob: Blob = new Blob([content]);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.