demike / TsUML2

Generates UML diagrams from TypeScript source code
MIT License
248 stars 32 forks source link

Parse error, expected "label" but got ";" #72

Closed Harrolee closed 7 months ago

Harrolee commented 7 months ago

Can you help me understand this output?

  1. I ran npx tsuml2 --glob "./src/**/!(*.d|*.spec).ts"
  2. The program listed the files that the glob caught
  3. The program output the below, with a real path instead of PATH-REDACTED
render to svg
Error: Parse error at line 172 column 39, expected "label" but got ";" 

ParseError: Parse error at line 172 column 39, expected "label" but got ";"
    at error (/PATH-REDACTED/node_modules/nomnoml/dist/nomnoml.js:902:19)
    at parseAssociation (/PATH-REDACTED/node_modules/nomnoml/dist/nomnoml.js:769:21)
    at parseNodesAndAssocs (/PATH-REDACTED/node_modules/nomnoml/dist/nomnoml.js:743:53)
    at parsePart (/PATH-REDACTED/node_modules/nomnoml/dist/nomnoml.js:715:39)
    at parseNode (/PATH-REDACTED/node_modules/nomnoml/dist/nomnoml.js:804:28)
    at parseNodesAndAssocs (/PATH-REDACTED/node_modules/nomnoml/dist/nomnoml.js:734:24)
    at parsePart (/PATH-REDACTED/node_modules/nomnoml/dist/nomnoml.js:715:39)
    at linearParse (/PATH-REDACTED/node_modules/nomnoml/dist/nomnoml.js:682:22)
    at parse (/PATH-REDACTED/node_modules/nomnoml/dist/nomnoml.js:927:38)
    at parseAndRender (/PATH-REDACTED/node_modules/nomnoml/dist/nomnoml.js:1709:29) {
  expected: '"label"',
  actual: '";"',
  line: 172,
  column: 39
}
demike commented 7 months ago

can you provide a reduced example with additional arguments --outDsl nomnoml.dsl. This parameter outputs the generated nomnoml "code" that is used for generating the svg.

The problematic command should be in this nomnoml.dsl file on line 172 (as stated in the error)

Harrolee commented 7 months ago

Thanks demike!

Here is line 172 of the nomnoml.dsl file: [PaginationQueryDto|+page[size]: number;+page[current]: number|]

Here's the code for PaginationQueryDto: pagination-query.dto.ts

export class PaginationQueryDto {
  'page[size]': number;

  'page[current]': number;
}

I realized that dto files don't add much to the UML diagram. TsUML2 generated an svg successfully when I filtered out .dto files (like this: --glob "./src/**/!(*.d|*.spec|*.dto).ts").

So I'm all good! Thank you :)

demike commented 7 months ago

@Harrolee this problem should be fixed in version 0.14 now!

Thank you for filing and investigating this issue!