bafolts / tplant

Typescript to plantuml
https://segmentationfaults.com/tplant/default.html
GNU General Public License v3.0
267 stars 34 forks source link

Add support for 'types' #47

Open RamzesTheSecond opened 4 years ago

RamzesTheSecond commented 4 years ago

As a Dev I need a support for 'types'

e.g.

type ExampleType = string | Function;

bafolts commented 4 years ago

Can you provide a sample input typescript and the corresponding plantuml?

hkong commented 2 years ago

For simple purposes, a type can behave in UML just like an interface. For example,

type SetupType = {
  active?: boolean
  comment?: string | string[]
  params?: any
}

can map to

@startuml
interface SetupType {
    +active?: boolean | undefined
    +comment?: string | string[] | undefined
    +params?: any
}
@enduml

but instead of interface it should be type with (mabye) the resulting I turned to T. This would be useful to parse existing code that are already using type and its syntax, instead of having to change them all to interface.

For the OP's original request, I'm guessing this would suffice

@startuml
interface ExampleType {
}
@enduml

again, replacing the interface syntax with the type syntax.

pierscowburn commented 2 years ago

+1, this would be great to have

pierscowburn commented 2 years ago

For reference, the latest TypeScript documentation effectively says that Interfaces and Type aliases are interchangable: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#differences-between-type-aliases-and-interfaces. Which one the user uses is largely down to personal preference.

bafolts commented 2 years ago

Sending out type as interface should be straight forward enough.