"declare module" may need quotes
See original GitHub issueThank you for all the work put into that great project, @englercj!
I currently develop jsdoc-tsd-webpack-plugin
which generates tsd-jsdoc
output and better-docs
output through Webpack compilation.
array-to-object-keys
is an example project from me. This is the important part:
/** @module array-to-object-keys */
// Removed for simplicity
/**
* Converts an array to an object with static keys and customizable values
* @example
* arrayToObjectKeys(["a", "b"])
* // {a: null, b: null}
* @example
* arrayToObjectKeys(["a", "b"], "value")
* // {a: "value", b: "value"}
* @example
* arrayToObjectKeys(["a", "b"], (key, index) => `value for ${key} #${index + 1}`)
* // {a: "value for a #1", b: "value for b #2"}
* @param {string[]} array Keys for the generated object
* @param {valueGenerator|*} [valueGenerator=null] Optional function that sets the object values based on key and index
* @returns {Object<string, *>} A generated object based on the array input
*/
export default (array, valueGenerator = null) => {
// Removed for simplicity
}
tsd-jsdoc
generates:
/** @module array-to-object-keys
*/
declare module array-to-object-keys {
/**
* Converts an array to an object with static keys and customizable values
* @example
* arrayToObjectKeys(["a", "b"])
* // {a: null, b: null}
* @example
* arrayToObjectKeys(["a", "b"], "value")
* // {a: "value", b: "value"}
* @example
* arrayToObjectKeys(["a", "b"], (key, index) => `value for ${key} #${index + 1}`)
* // {a: "value for a #1", b: "value for b #2"}
* @param {string[]} array Keys for the generated object
* @param {valueGenerator|*} [valueGenerator=null] Optional function that sets the object values based on key and index
* @returns {Object<string, *>} A generated object based on the array input
*/
function default(array: string[], valueGenerator?: valueGenerator | any): {
[key: string]: any;
};
}
This looks fine, but the syntax highlighting in my VSCode looked suspicious.
The module name is not parsed correctly with those dashes. Semi-official sources like this one told me that module names need to be quoted.
Okay, I can fix this as long as JSDoc doesn’t mind!
- /** @module array-to-object-keys */
+ /** @module "array-to-object-keys" */
It worked, the TSD output looks legit now, but… what is this abomination?
The underscores in the file name were one of many impacts that told me that the @module
annotation is the wrong place to hack in a fix for that.
So what do you recommend? Is this a case that should be included in tsd-jsoc
?
Like:
moduleName = moduleName.includes("-") ? `"${moduleName}"` : moduleName
Or did I understand something wrong on my side?
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Hopefully that fixes it up, got some other work I want to do and will do a release at some point.
Turns out unquoted modules are actually just namespaces, so I need to quote them all. Will fix.