14

I am trying to write a file downloader in TypeScript using the FileSystem API.

When I'm trying to create a new Blob object:

var blob: Blob = new Blob(xhr.response, JSON.stringify(mime));

I'm getting the error:

Supplied parameters do not match any signature of call target

It's possible to create a Blob without any parameters:

var blob: Blob = new Blob();

But that doesn't help.

The (deprecated) fall back for Blob is the BlobBuilder object but TypeScript (VS 2012 Plugin) only offers the MSBlobBuilder object.

What am I doing wrong? Or does TypeScript not know about the Blob constructor?

1 Answer 1

10

The definition for Blob in the lib.d.ts library only includes an empty constructor:

declare var Blob: {
    prototype: Blob;
    new (): Blob;
}

If this is incorrect, you could submit back the corrected version, or override it in your code. Here is a rough guess at what the original declaration should look like.

declare var Blob: {
    prototype: Blob;
    new (): Blob;
    new (request: any, mime: string): Blob;
}

I haven't specified the type for the first parameter and the names may be wrong - but as you know what Blob is up to, you can adjust these as required.

Sign up to request clarification or add additional context in comments.

1 Comment

I forgot to mention, lib.d.ts can be found in C:\Program Files (x86)\Microsoft SDKs\TypeScript\0.8.0.0 on 64 bit machines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.