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

Bug: error when exporting indirect class #166

Closed
typhonrt opened this issue Nov 12, 2015 · 3 comments
Closed

Bug: error when exporting indirect class #166

typhonrt opened this issue Nov 12, 2015 · 3 comments

Comments

@typhonrt
Copy link
Contributor

ESDoc does not support export of indirect class instances. The following gives a simple test case.

'use strict';

class Test2 {}

class Test
{
   constructor()
   {
      this.Test2 = Test2;
   }
}
const test = new Test();

export default new test.Test2();

This will work, but is an undesirable workaround:

'use strict';

class Test2 {}

class Test
{
   constructor()
   {
      this.Test2 = Test2;
   }
}
const test = new Test();

const test2 = new test.Test2();

export default test2;

In my day to day usage of ESDoc this pops up when I try to export a Backbone.Events instance. Like the test example above Backbone is a composed class at runtime. IE this fails like the test case above:

'use strict';

import Backbone   from 'backbone';

export default new Backbone.Events();

Here is the stack trace. Note that I am using typhonjs-core-gulptasks which uses gulp-esdoc which embeds esdoc. I shortened the paths so ignore <FILEPATH>. The ESDoc version being used is 0.4.3.

<FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/node_modules/esdoc/out/src/ESDoc.js:409
            throw _iteratorError5;
                  ^
TypeError: Cannot read property 'replace' of undefined
    at DocFactory._inspectExportDefaultDeclaration (<FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/node_modules/esdoc/out/src/Factory/DocFactory.js:170:51)
    at new DocFactory (<FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/node_modules/esdoc/out/src/Factory/DocFactory.js:101:10)
    at Function._traverse (<FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/node_modules/esdoc/out/src/ESDoc.js:439:21)
    at <FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/node_modules/esdoc/out/src/ESDoc.js:187:26
    at Function._walk (<FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/node_modules/esdoc/out/src/ESDoc.js:394:13)
    at Function._walk (<FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/node_modules/esdoc/out/src/ESDoc.js:396:18)
    at Function._walk (<FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/node_modules/esdoc/out/src/ESDoc.js:396:18)
    at Function.generate (<FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/node_modules/esdoc/out/src/ESDoc.js:127:12)
    at DestroyableTransform.flush [as _flush] (<FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/index.js:31:11)
    at DestroyableTransform.<anonymous> (<FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:123:12)
    at DestroyableTransform.g (events.js:199:16)
    at DestroyableTransform.emit (events.js:104:17)
    at prefinish (<FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:499:12)
    at finishMaybe (<FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:507:7)
    at endWritable (<FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:519:3)
    at DestroyableTransform.Writable.end (<FILEPATH>/node_modules/typhonjs-core-gulptasks/node_modules/gulp-esdoc/node_modules/through2/node_modules/readable-stream/lib/_stream_writable.js:484:5)
@h13i32maru
Copy link
Member

@typhonrt I will fix this in future version. thanks.

@h13i32maru
Copy link
Member

I fixed this issue in v0.4.4

@typhonrt
Copy link
Contributor Author

typhonrt commented Feb 6, 2016

👍

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

No branches or pull requests

2 participants