1. ts
      // Type definitions for [~THE LIBRARY NAME~] [~OPTIONAL VERSION NUMBER~]
    2. // Project: [~THE PROJECT NAME~]
    3. // Definitions by: [~YOUR NAME~] <[~A URL FOR YOU~]>
    4. /*~ This template shows how to write a global plugin. */
    5. /*~ Write a declaration for the original type and add new members.
    6. *~ For example, this adds a 'toBinaryString' method with overloads to
    7. *~ the built-in number type.
    8. */
    9. interface Number {
    10. toBinaryString(opts?: MyLibrary.BinaryFormatOptions): string;
    11. toBinaryString(
    12. callback: MyLibrary.BinaryFormatCallback,
    13. opts?: MyLibrary.BinaryFormatOptions
    14. ): string;
    15. }
    16. /*~ If you need to declare several types, place them inside a namespace
    17. *~ to avoid adding too many things to the global namespace.
    18. */
    19. declare namespace MyLibrary {
    20. type BinaryFormatCallback = (n: number) => string;
    21. interface BinaryFormatOptions {
    22. prefix?: string;
    23. padding: number;
    24. }
    25. }