apigee-127 / sway

A library that simplifies OpenAPI (fka Swagger) integrations/tooling.
MIT License
190 stars 92 forks source link

reexported modules #208

Closed 73rhodes closed 5 years ago

73rhodes commented 5 years ago

I apologize if this has already been covered or has an obvious fix, but I haven't been able to find a solution. I'm using tsd-jsdoc to generate a types.d.ts file for a node library / npm module. There's a top-level module that's the main entry point and it rexports things that are defined in sub modules. Here's a contrived example:

/** @module mytest */
import * as utils from "./lib/utils";
exports.utils = utils;

Running jsdoc with the tsd-jsdoc template generate something like this:

/**
 * @module utils
 */
declare module "utils" {
  // misc.
}

/**
 * @module mytest
 */
declare module "mytest" { }

Not surprisingly this leads to a package that when included as a dependency in a typescript project (eg. import * as mytest from "mytest") gives you a mytest variable that has no properties defined on it.

My expectation for module re-exports was that mytest.utils would be defined, as well as things documented within the submodule itself, like mytest.utils.foo and mytest.utils.bar. I've tried a number of things such as explicitly importing the utility functions by name and re-exporting them under a new export property, but their original JSDoc documantion is not attached to these renamed exports. I've not been able to propagate type definitions from a submodule through the parent module when re-exporting these things. I could make things work by lumping code into one big file, but I'd prefer to keep the modular code organization of separate files. Any recommendations or comments as to whether or not this is, or can be, supported would be appreciated.

Thanks!

73rhodes commented 5 years ago

Sorry, this was posted under the wrong repo. My bad.