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 is the module template file for class modules.
    5. *~ You should rename it to index.d.ts and place it in a folder with the same name as the module.
    6. *~ For example, if you were writing a file for "super-greeter", this
    7. *~ file should be 'super-greeter/index.d.ts'
    8. */
    9. // Note that ES6 modules cannot directly export class objects.
    10. // This file should be imported using the CommonJS-style:
    11. // import x = require('[~THE MODULE~]');
    12. //
    13. // Alternatively, if --allowSyntheticDefaultImports or
    14. // --esModuleInterop is turned on, this file can also be
    15. // imported as a default import:
    16. // import x from '[~THE MODULE~]';
    17. //
    18. // Refer to the TypeScript documentation at
    19. // https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require
    20. // to understand common workarounds for this limitation of ES6 modules.
    21. /*~ If this module is a UMD module that exposes a global variable 'myClassLib' when
    22. *~ loaded outside a module loader environment, declare that global here.
    23. *~ Otherwise, delete this declaration.
    24. */
    25. export as namespace myClassLib;
    26. /*~ This declaration specifies that the class constructor function
    27. *~ is the exported object from the file
    28. */
    29. export = MyClass;
    30. /*~ Write your module's methods and properties in this class */
    31. declare class MyClass {
    32. constructor(someParam?: string);
    33. someProperty: string[];
    34. myMethod(opts: MyClass.MyClassMethodOptions): number;
    35. }
    36. /*~ If you want to expose types from your module as well, you can
    37. *~ place them in this block.
    38. *~
    39. *~ Note that if you decide to include this namespace, the module can be
    40. *~ incorrectly imported as a namespace object, unless
    41. *~ --esModuleInterop is turned on:
    42. *~ import * as x from '[~THE MODULE~]'; // WRONG! DO NOT DO THIS!
    43. */
    44. declare namespace MyClass {
    45. export interface MyClassMethodOptions {
    46. width?: number;
    47. height?: number;
    48. }
    49. }