englercj / tsd-jsdoc

Compiles JSDoc annotated JavaScript into a Typescript Definition file (.d.ts)
MIT License
316 stars 42 forks source link

Can this reexport classes? #146

Open ThrowsException opened 3 years ago

ThrowsException commented 3 years ago

I have a file that imports a bunch of classes and Id like to reexport them from there as properties something like

/** Class representing a point. */
class Point {
  /**
   * Create a point.
   * @param {number} x - The x value.
   * @param {number} y - The y value.
   */
  constructor(x, y) {
      // ...
  }

  /**
   * Get the x value.
   * @return {number} The x value.
   */
  getX() {
      // ...
  }
}
/**
 * App Module
 * @module app 
 */

/** @type Point */
exports.Point = require('./Point');

but my types.d.ts makes the Point export a var and I get the complaint that it can't be new since its not a function or constrcutor

/**
 * Create a point.
 * @param x - The x value.
 * @param y - The y value.
 */
declare class Point {
    constructor(x: number, y: number);
    /**
     * Get the x value.
     * @returns The x value.
     */
    getX(): number;
}

/**
 * App Module
 */
declare module "app" {
    var Point: Point;
}

is it possible to add Point as an export to app so I can call new app.Point(x,y) ?