• global-plugin.d.ts

    global-plugin.d.ts

    1. // 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 to overloads to
    7. *~ the built-in number type.
    8. */
    9. interface Number {
    10. toBinaryString(opts?: MyLibrary.BinaryFormatOptions): string;
    11. toBinaryString(callback: MyLibrary.BinaryFormatCallback, opts?: MyLibrary.BinaryFormatOptions): string;
    12. }
    13. /*~ If you need to declare several types, place them inside a namespace
    14. *~ to avoid adding too many things to the global namespace.
    15. */
    16. declare namespace MyLibrary {
    17. type BinaryFormatCallback = (n: number) => string;
    18. interface BinaryFormatOptions {
    19. prefix?: string;
    20. padding: number;
    21. }
    22. }