Skip to content

JSDoc @type tag not validating on module.exports #27327

@TheColorRed

Description

@TheColorRed

tsc: 3.0.3
vscode: 1.27.2

I have a library (we will call it my-module). I am including it in my JavaScript app for testing with JavaScript, I am trying to typedoc a module.exports which just exports an object literal. Adding JSDoc to it doesn't validate the object like I was expecting.

I have this TS interface:

export interface AppSettings {
    port: number;
    // other settings
}

This works, it throws an error saying that port is missing.

/** @type {import('my-module').AppSettings} */
let settings = {}
module.exports = settings

So, I tried it on the object, but it doesn't work, port is missing but there is no error.

/** @type {import('my-module').AppSettings} */
module.exports = {}

I have tried multiple doctypes, and none of them work such as:

This one is similar to how it is described on the jsdoc website

/**
 * @namespace 
 * @property {import('my-module').AppSettings} exports 
 */
module.exports = {}
module = {
  /** @type {import('my-module').AppSettings} */
  exports: {}
}

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: JavaScriptThe issue relates to JavaScript specificallyFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions