Skip to content

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

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

Open
sandersn opened this issue Aug 7, 2018 · 2 comments
Labels
Bug A bug in TypeScript
Milestone

Comments

@sandersn
Copy link
Member

sandersn commented Aug 7, 2018

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.

@sandersn
Copy link
Member Author

sandersn commented Aug 9, 2018

  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.

@sandersn sandersn 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 Aug 9, 2018
@sandersn
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
Development

No branches or pull requests

3 participants