Skip to content

CJS: module.exports object only works with shorthand assignments #49195

@twilson90

Description

@twilson90

Does this issue occur when all extensions are disabled?: Yes

Version: 1.67.2 (user setup)
Commit: c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5
Date: 2022-05-17T18:15:52.058Z
Electron: 17.4.1
Chromium: 98.0.4758.141
Node.js: 16.13.0
V8: 9.8.177.13-electron.0
OS: Windows_NT x64 10.0.19043

Example files:

// utils.js
class Thing  { ... }
class AnotherThing { ... }
module.exports = {
    Thing,
    AnotherThing,
    do_thing() { ... }
}
// main.js
/** @type {import('./utils').Thing} */
var Thing;

In main.js, the variable 'Thing' provides no autocompletion or recognition of the Thing class.
However, if I remove do_thing() { ... } from the utils.js module.exports object, it works as expected.

If this is not a bug, how do I correctly implement?
If it is a bug, is there a convenient workaround?

Metadata

Metadata

Assignees

Labels

Domain: JSDocRelates to JSDoc parsing and type generationFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions