Reputation: 17530
According to https://developer.mozilla.org/en-US/docs/Web/API/FileReader
interface FileReader extends MSBaseReader {
error: DOMError;
readAsArrayBuffer(blob: Blob): void;
readAsDataURL(blob: Blob): void;
readAsText(blob: Blob, encoding?: string): void;
}
declare var FileReader: {
prototype: FileReader;
new (): FileReader;
}
this from lib.d.ts should also have DONE,LOADING,EMPTY on the variable. How can I extend this, and do lib.d.ts has a public place where such changes can be committed to?
Upvotes: 1
Views: 1319
Reputation: 250862
To get access to new properties before they are added to lib.d.ts you can extend the declarations. This can be done because interfaces in TypeScript are open.
So add a TypeScript file called something like libextensions.ts and add the following:
interface FileReader {
EMPTY: number;
LOADING: number;
DONE: number;
}
You only need to put the missing bits here - they will be added to the lib.d.ts interface.
You can use this technique to stay up to date with working drafts and the compiler will tell you when lib.d.ts has been updated by issuing a duplicate declaration error.
If you have an instance of a FileReader, you don't need to access the constant via FileReader.prototype.DONE
you can use the constant on the instance - example:
var fileReader = new FileReader();
var example = fileReader.DONE;
Upvotes: 4
Reputation: 276269
You should open a bug report here : http://typescript.codeplex.com/workitem/list/basic The typescript team manages lib.d.ts
Upvotes: 0