-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Add support for an @export
tag
#22126
Comments
Note, this is different from the |
Does this comment turn the file into a module without an |
i suppose so. |
Currently // bar.js
/**
* @typedef {object} Point
* @property {number} x
* @property {number} y
*
*/
export {} // foo.js
/**
* @type {import("./bar.js").Point}
*/
const x = { x: 10, y: 20 } // Type is imported correctly What would this |
The docs of One use case I'm coming across would be for class-producing factories. AFAICT, there is no good JSDoc-only-based way with TS to specify that for something like the following that a private class (in this case export default () => {
return Parser => {
// Read static properties from `Parser`
const tokTypes = /** @type {EnhancedTokTypes} */ (Object.assign({}, Parser.acorn.tokTypes));
return class EspreeParser extends Parser {
// Use the static properties like `tokTypes` within instance methods of the class
};
} The only terribly hackish way I could do this with our project goal of seeking to keep the definitions inline within the file (and not in a declaration file) was to export a separate export class EspreeParser extends acorn.Parser {
/**
* Constructor for EspreeParser
* @param {ParserOptions} options The parser options
* @param {string} input The input text
* @param {number} [startPos] The starting position
*/
constructor(options, input, startPos) {
super(/** @type {acorn.Options} */ (options), input, startPos);
}
// Other bare-bones methods here...
} Using So if there were an While JSDoc with An alternative would be allowing one to define a |
The text was updated successfully, but these errors were encountered: