Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can this reexport classes? #146

Open
ThrowsException opened this issue Mar 2, 2021 · 0 comments
Open

Can this reexport classes? #146

ThrowsException opened this issue Mar 2, 2021 · 0 comments

Comments

@ThrowsException
Copy link

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) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant