Skip to content
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

Cannot use "require" within @example in TypeScript files #1269

Open
rdmurphy opened this issue Jul 31, 2019 · 2 comments
Open

Cannot use "require" within @example in TypeScript files #1269

rdmurphy opened this issue Jul 31, 2019 · 2 comments

Comments

@rdmurphy
Copy link

rdmurphy commented Jul 31, 2019

If you're reporting a bug, please include input code, output documentation,
a description of what you expected to happen, and what happened instead.

  • What version of documentation.js are you using?: 12.0.3
  • How are you running documentation.js (on the CLI, Node.js API, Grunt, other?): CLI

I've attached a repo that reproduces what I'm seeing. I have a function written in TypeScript that includes an @example call in the JSDoc comment. But the only way I can get it to successfully parse (without throwing an error) is if I use import ... from ..., not require(). I don't believe this is an issue when parsing JavaScript. Maybe the TypeScript parser does not understand require, but I'm wanting to document how to use my library in Node.js (so with require()), not TypeScript-parsed JavaScript. 😬

The example repo: https://github.com/rdmurphy/documentation-typescript-require

Thank you!

@cekvenich
Copy link

--shallow

@tmcw
Copy link
Member

tmcw commented Sep 9, 2019

The root cause is in detective, which only parses modules with acorn if there's a require() detected.

https://github.com/browserify/detective/blob/master/index.js#L44-L47

I think, long-term, documentation would swap out detective for something that's maintained and modern.

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

No branches or pull requests

3 participants