demike / TsUML2

Generates UML diagrams from TypeScript source code
MIT License
250 stars 33 forks source link

Does not work with export default class #20

Closed stared closed 1 year ago

stared commented 1 year ago

First, thank you @demike for developing this nice and useful project! :)

However, it does not work well with export default class. That is:

I prepared a minimal example, https://github.com/stared/tsuml2-default-export-error-example (commit 7e2a479 for the version resulting in an error):

import Person from './person'
import { Vector, Color } from './structures'

export default class MainClass {
  constructor(public color: Color, public v: Vector, public person: Person) {}
}
export default class Person {
  constructor(public name: string, public surname: string) {}
}
export interface Vector {
  x: number
  y: number
}

export interface Color {
  r: number
  g: number
  b: number
}

I run tsuml2 --glob "./src/**/*.ts" -m and get:

Screenshot 2023-02-15 at 12 55 28

Changing to non-default export makes it work (https://github.com/stared/tsuml2-default-export-error-example/commit/c9d15ec0fb16ce2dbd0f3f4e419c1b54ed905952):

Screenshot 2023-02-15 at 12 59 56

My project has plenty of default exports. To create a diagram I need to manually change them not non-default exports (and consequently, non-default imports).

Is there a way to make it work?

demike commented 1 year ago

Thanks for the great explanation. Will take a look at it.

demike commented 1 year ago

@stared can you give the new version (0.9) a try. Tested default exports of interfaces and classes + inheritance , but maybe I missed some cases.

stared commented 1 year ago

Thanks @demike!

It works, but almost. Nodes are fine, named, and unique. But person is of the type default instead of Person.

Screenshot 2023-02-16 at 14 42 40
demike commented 1 year ago

Ahhh forgot the members ... Will do that

demike commented 1 year ago

@stared the new version 0.10.0 should support members of "default export type"

stared commented 1 year ago

Works like a charm - thank you!

Screenshot 2023-02-16 at 16 35 36