Bug: error when exporting indirect class #166

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

Comments

Projects
None yet
2 participants
@typhonrt
Contributor

typhonrt commented Nov 12, 2015

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

This comment has been minimized.

Show comment
Hide comment
@h13i32maru

h13i32maru Nov 23, 2015

Member

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

Member

h13i32maru commented Nov 23, 2015

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

@h13i32maru

This comment has been minimized.

Show comment
Hide comment
@h13i32maru

h13i32maru Feb 6, 2016

Member

I fixed this issue in v0.4.4

Member

h13i32maru commented Feb 6, 2016

I fixed this issue in v0.4.4

@h13i32maru h13i32maru closed this Feb 6, 2016

@typhonrt

This comment has been minimized.

Show comment
Hide comment
@typhonrt

typhonrt Feb 6, 2016

Contributor

👍

Contributor

typhonrt commented Feb 6, 2016

👍

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