Open C-Powers opened 7 years ago
I found this issue (https://github.com/esdoc/esdoc/issues/390), but there was no solution other than stop using the plugin.
I am also seeing this issue now. esdoc: v1.1.0 and the esdoc-typescript-plugin: v1.0.1.
Experiencing this issue when using generic types, e.g. Observable<T>
. Works well when I convert all T
s to any
for example.
I'm getting this error but there are no generic types in the file it fails on. I have some other files with generic types that work fine. Figured out a way to fix my issue and debug it.
The traceback I got was this:
{ SyntaxError: Unexpected token (47:24)
at Parser.pp$5.raise (/Users/maxkaye/src/sv/lib/node_modules/babylon/lib/index.js:4456:13)
at Parser.pp.unexpected (/Users/maxkaye/src/sv/lib/node_modules/babylon/lib/index.js:1761:8)
...snip...
at Parser.pp$3.parseExprAtom (/Users/maxkaye/src/sv/lib/node_modules/babylon/lib/index.js:3709:19) pos: 2032, loc: Position { line: 47, column: 24 } }
/Users/maxkaye/src/sv/lib/node_modules/esdoc/out/src/Factory/DocFactory.js:135
for (const exportNode of this._ast.program.body) {
^
TypeError: Cannot read property 'program' of undefined
at DocFactory._inspectExportDefaultDeclaration (/Users/maxkaye/src/sv/lib/node_modules/esdoc/out/src/Factory/DocFactory.js:135:40)
...snip...
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
The syntax error part didn't stick out originally, but it's the key
The syntax error line reference is meaningless though because the file is preprocessed so it doesn't correspond to the correct line
So I went to node_modules/babylon/lib/index.js:4456:13
and changed pp$5.raise
to
pp$5.raise = function (pos, message) {
console.error(this.input, pos, message)
var loc = getLineInfo(this.input, pos);
console.error(`THE LINE:\n`,this.input.split('\n', 99999)[loc.line-1])
message += " (" + loc.line + ":" + loc.column + ")";
var err = new SyntaxError(message);
err.pos = pos;
err.loc = loc;
throw err;
};
basically dumping everything I wanted.
Was initially thrown off because there's an off by one error with loc.line
(it's correct in the snippet above)
Anyway eventually found my problem.
I had const thing = (<any>window).injectedThing
which is valid typescript AFAIK.
Changed it to const thing = (window as any).injectedThing
and 🎉 it all worked.
I also tried checking for inconsistencies in docstrings and found some (mainly around async functions and promises) but that didn't fix anything.
is there no updates on this?
config:
error:
It works fine without the typescript plugin, but fails when it is added.