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

ES6 module-syntax export default errors #73

Closed
davidtheclark opened this issue May 15, 2015 · 5 comments
Closed

ES6 module-syntax export default errors #73

davidtheclark opened this issue May 15, 2015 · 5 comments
Milestone

Comments

@davidtheclark
Copy link

When I try a file with ES6 syntax export default function() { .. } I get the following error:

assert.js:86
  throw new assert.AssertionError({
        ^
AssertionError: did not recognize object of type "ExportDefaultDeclaration"
    at Object.getFieldNames (/home/dclark/dev/documentation/node_modules/ast-types/lib/types.js:595:16)
    at visitChildren (/home/dclark/dev/documentation/node_modules/ast-types/lib/path-visitor.js:203:32)
    at Visitor.PVp.visitWithoutReset (/home/dclark/dev/documentation/node_modules/ast-types/lib/path-visitor.js:188:16)
    at NodePath.each (/home/dclark/dev/documentation/node_modules/ast-types/lib/path.js:96:22)
    at visitChildren (/home/dclark/dev/documentation/node_modules/ast-types/lib/path-visitor.js:199:14)
    at Visitor.PVp.visitWithoutReset (/home/dclark/dev/documentation/node_modules/ast-types/lib/path-visitor.js:188:16)
    at visitChildren (/home/dclark/dev/documentation/node_modules/ast-types/lib/path-visitor.js:226:21)
    at Context.traverse (/home/dclark/dev/documentation/node_modules/ast-types/lib/path-visitor.js:343:12)
    at Context.types.visit.visitNode (/home/dclark/dev/documentation/streams/parse.js:130:14)
    at Context.invokeVisitorMethod (/home/dclark/dev/documentation/node_modules/ast-types/lib/path-visitor.js:306:43)

Because Espree-powered ESLint supports this syntax I thought documentation would ... What do you think?

I could try submitting a PR with a failing test if you'd like that.

@tmcw
Copy link
Member

tmcw commented May 22, 2015

This is likely a lack in ast-types rather than espree: benjamn/ast-types#111

@davidtheclark
Copy link
Author

Seems like you found the culprit.

@tmcw tmcw added this to the 3.0.0 milestone Jul 4, 2015
@tmcw tmcw closed this as completed in 9919f49 Oct 1, 2015
@gajus
Copy link

gajus commented Oct 13, 2015

benjamn/ast-types#111 issue has been closed, but this remains an issue.

/**
 * Extracts date from a string using provided format.
 * 
 * The supplied format must include 
 * 
 * @param {string} subject
 * @param {string} format
 * @param {string} locale
 * @returns {string} YYYY-MM-DD
 */
export default (subject, format, explicitLocale) => {

};

produces:

curiosity:src gajus$ documentation ./extractDate.js

assert.js:89
  throw new assert.AssertionError({
  ^
AssertionError: did not recognize object of type "ExportDefaultDeclaration"
    at Object.getFieldNames (/Users/gajus/.nvm/versions/node/v4.2.0/lib/node_modules/documentation/node_modules/ast-types/lib/types.js:602:16)
    at visitChildren (/Users/gajus/.nvm/versions/node/v4.2.0/lib/node_modules/documentation/node_modules/ast-types/lib/path-visitor.js:203:32)
    at Visitor.PVp.visitWithoutReset (/Users/gajus/.nvm/versions/node/v4.2.0/lib/node_modules/documentation/node_modules/ast-types/lib/path-visitor.js:188:16)
    at NodePath.each (/Users/gajus/.nvm/versions/node/v4.2.0/lib/node_modules/documentation/node_modules/ast-types/lib/path.js:96:22)
    at visitChildren (/Users/gajus/.nvm/versions/node/v4.2.0/lib/node_modules/documentation/node_modules/ast-types/lib/path-visitor.js:199:14)
    at Visitor.PVp.visitWithoutReset (/Users/gajus/.nvm/versions/node/v4.2.0/lib/node_modules/documentation/node_modules/ast-types/lib/path-visitor.js:188:16)
    at visitChildren (/Users/gajus/.nvm/versions/node/v4.2.0/lib/node_modules/documentation/node_modules/ast-types/lib/path-visitor.js:226:21)
    at Context.traverse (/Users/gajus/.nvm/versions/node/v4.2.0/lib/node_modules/documentation/node_modules/ast-types/lib/path-visitor.js:343:12)
    at Context.types.visit.visitNode (/Users/gajus/.nvm/versions/node/v4.2.0/lib/node_modules/documentation/streams/parse.js:155:14)
    at Context.invokeVisitorMethod (/Users/gajus/.nvm/versions/node/v4.2.0/lib/node_modules/documentation/node_modules/ast-types/lib/path-visitor.js:306:43)

@gajus
Copy link

gajus commented Oct 13, 2015

This issue is not present in the master, though.

@kulakowka
Copy link

I have the same error.

» documentation

assert.js:89
  throw new assert.AssertionError({
  ^
AssertionError: did not recognize object of type "ExportDefaultDeclaration"
    at Object.getFieldNames (/usr/local/lib/node_modules/documentation/node_modules/ast-types/lib/types.js:602:16)
    at visitChildren (/usr/local/lib/node_modules/documentation/node_modules/ast-types/lib/path-visitor.js:203:32)
    at Visitor.PVp.visitWithoutReset (/usr/local/lib/node_modules/documentation/node_modules/ast-types/lib/path-visitor.js:188:16)
    at NodePath.each (/usr/local/lib/node_modules/documentation/node_modules/ast-types/lib/path.js:96:22)
    at visitChildren (/usr/local/lib/node_modules/documentation/node_modules/ast-types/lib/path-visitor.js:199:14)
    at Visitor.PVp.visitWithoutReset (/usr/local/lib/node_modules/documentation/node_modules/ast-types/lib/path-visitor.js:188:16)
    at visitChildren (/usr/local/lib/node_modules/documentation/node_modules/ast-types/lib/path-visitor.js:226:21)
    at Context.traverse (/usr/local/lib/node_modules/documentation/node_modules/ast-types/lib/path-visitor.js:343:12)
    at Context.types.visit.visitNode (/usr/local/lib/node_modules/documentation/streams/parse.js:155:14)
    at Context.invokeVisitorMethod (/usr/local/lib/node_modules/documentation/node_modules/ast-types/lib/path-visitor.js:306:43)

I suspect that it is because such structures

export default (req, res, next) => {
  res.render('homepage/index')
}

Who knows how to solve this problem?

rhendric pushed a commit to rhendric/documentation that referenced this issue Sep 15, 2022
It is unlikely that I will pull in the latest changes any time soon, so I'm officially calling it stale.
If I ever get the urge to deal with it again, I will probably redo it from scratch with CoreFN or, if it'll be available, the imperative core.
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

4 participants