TypeScript - How to override declaration in lib.d.ts?

The problem is this:

I need to create an instance Fileusing a constructor that takes 2 arguments (byteArray, fileName), and I need to create TypeScript for it.

The definition Filein lib.d.ts is as follows (line 11479):

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

Correct me if I am wrong, but:

  • I cannot define constructors inside interfaces (which I can extend)
  • I cannot extend declarations (on which I can create the required constructor)

Since modifying lib.d.ts is not a good idea, you guys suggest that I create an instance of the file without TS error.

Thanks in advance

+4
1
  • ( )

, - , , . , , abstract class, TypeScript ().

  • ( )

. , /, File.

0

All Articles