Skip to content

In JS, extra circular reference errors when referring to a missing property on module #26268

Closed as not planned

Description

I think this error is wrong, a result of #26236 combined with (probably) #25732. Here's a repro based on lodash:

var freeModule = module.nodeType;
var Buffer = module.nodeType ? root.Buffer : undefined;

/**
 * Creates a clone of  `buffer`.
 *
 * @private
 * @param {Buffer} buffer The buffer to clone.
 * @param {boolean} [isDeep] Specify a deep clone.
 * @returns {Buffer} Returns the cloned buffer.
 */
function cloneBuffer(buffer, isDeep) {
}

module.exports = cloneBuffer;

Expected behavior:
No error on either type reference to Buffer in a param tag.

Actual behavior:
Error on both, and both say they have a circular reference error.

Activity

  1. sandersn commented on Aug 9, 2018

    @sandersn
    MemberAuthor
    1. Check var freeModule = module.nodeType
    2. Check module.nodeType
    3. Report non-existent property 'nodeType' on 'module'.
    4. Convert the type of module to a string.
    5. Convert the type of the file's module to a string.
    6. Convert the type of cloneBuffer to a string.
    7. Get the type of the parameter buffer.
    8. Get the type of 'Buffer'.
    9. Check the initializer.
    10. Check module.nodeType. Instead of going to (2) forever, issue an error that we have gone circular.

    This error is technically correct, but it is confusing because the real error is that module.nodeType isn't found. This error is also logged, so this is just an extra error that should be removed if possible.

  2. changed the title [-]In JS, a possibly bogus circular reference error on param tag types[/-] [+]In JS, extra circular reference errors when referring to a missing property on `module`[/+] on Aug 9, 2018
  3. sandersn commented on Mar 13, 2019

    @sandersn
    MemberAuthor

    Note that currently, only @returns {Buffer} now gives an error.

  4. RyanCavanaugh commented on Jul 23, 2025

    @RyanCavanaugh
    Member

    Doesn't seem like a problem in practice

  5. locked as resolved and limited conversation to collaborators on Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions