tplant icon indicating copy to clipboard operation
tplant copied to clipboard

Add support for 'types'

Open RamzesTheSecond opened this issue 5 years ago • 5 comments

As a Dev I need a support for 'types'

e.g.

type ExampleType = string | Function;

RamzesTheSecond avatar Feb 05 '20 20:02 RamzesTheSecond

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

bafolts avatar Feb 06 '20 01:02 bafolts

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.

hkong avatar Oct 08 '21 00:10 hkong

+1, this would be great to have

pierscowburn avatar Nov 23 '21 13:11 pierscowburn

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.

pierscowburn avatar Nov 23 '21 13:11 pierscowburn

Sending out type as interface should be straight forward enough.

bafolts avatar Nov 29 '21 17:11 bafolts