-
Notifications
You must be signed in to change notification settings - Fork 485
Crashing on a single Typescript file #1359
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
Comments
Please somebody shed some light on this. We need to generate documentation for our software. |
Can you share more of the surrounding code? This small snippet looks fine, and likely isn't the problem. It's most likely something like an unsupported syntax that's in the code before this. |
@tmcw thank you for your reply. The code before that line: constructor(
containerId: string,
mapParams: {
id: number;
options: MapOptionsInterface;
svgFileLastChanged: number;
version: string;
}
) {
const options = mapParams.options;
this.updateOutdatedOptions(options);
this.dirtyFields = [];
this.containerId = containerId;
this.options = <MapOptionsInterface>$.extend(true, {}, DefaultOptions, options);
this.options.source = this.urlToRelativePath(this.options.source);
this.editMode = this.options.editMode;
delete this.options.editMode;
this.id = mapParams.id;
this.svgFileLastChanged = mapParams.svgFileLastChanged;
this.regions = new ArrayIndexed("id");
this.objects = new ArrayIndexed("id");
this.events = new Events(this);
this.highlightedRegions = [];
this.editRegions = { on: false }; // <<<<<< COMPILER CRASHES HERE
``` |
Here's a reduced testcase: The bad line is this.options = <MapOptionsInterface>$.extend(true, {}, DefaultOptions, options); So the issue is, per the TypeScript playground, that this file will not work if JSX is enabled in the TS config. Switching that on and off might be an option if that's a PR to documentation.js, or there may be a different way to express that typing that doesn't trigger JSX. |
@tmcw you saved my life, thank you so much :) I would never find that by myself. I'll try to disable JSX now. |
So how can I disable JSX for documentation.js/TS parser? I've tried adding the following line to tsconfig.js but it didn't help:
Docs: https://www.typescriptlang.org/tsconfig#jsx |
…ntationjs#1359 ts has conflict syntax with casting type. It is valid TS but not valid TSX
documentation.js version: 12.3.0
command:
Result:
SyntaxError: Unexpected token, expected "}" (305:30) at _class.raise (/usr/local/lib/node_modules/documentation/node_modules/@babel/parser/lib/index.js:3939:15) at _class.unexpected (/usr/local/lib/node_modules/documentation/node_modules/@babel/parser/lib/index.js:5248:16) at _class.expect (/usr/local/lib/node_modules/documentation/node_modules/@babel/parser/lib/index.js:5236:28) at _class.jsxParseExpressionContainer (/usr/local/lib/node_modules/documentation/node_modules/@babel/parser/lib/index.js:3497:12) at _class.jsxParseElementAt (/usr/local/lib/node_modules/documentation/node_modules/@babel/parser/lib/index.js:3584:36) at _class.jsxParseElement (/usr/local/lib/node_modules/documentation/node_modules/@babel/parser/lib/index.js:3626:19) at _class.parseExprAtom (/usr/local/lib/node_modules/documentation/node_modules/@babel/parser/lib/index.js:3633:21) at _class.parseExprSubscripts (/usr/local/lib/node_modules/documentation/node_modules/@babel/parser/lib/index.js:5924:21) at _class.parseMaybeUnary (/usr/local/lib/node_modules/documentation/node_modules/@babel/parser/lib/index.js:5903:21) at _class.parseMaybeUnary (/usr/local/lib/node_modules/documentation/node_modules/@babel/parser/lib/index.js:10244:54)
The code at line 305 in Map.ts:
The error points to column number 30 which is the letter "o" after "{". Somehow babel doesn't like the
on:false
content and wants to see an empty object instead:{}
. Why?The
editRegions
property is defined above in the same file as:The text was updated successfully, but these errors were encountered: