bafolts / tplant

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

undefined and null types aren't transformed properly #26

Open marcosvrs opened 5 years ago

marcosvrs commented 5 years ago

Code example:

interface ComplexTypesInterface {
    type: Dict<{ stringType: string; numberType: number; }> | undefined;
}

Current transformation:

@startuml
interface ComplexTypesInterface {
    type: Dict<{ stringType: string; numberType: number; }>
}
@enduml

Expected transformation:

@startuml
interface ComplexTypesInterface {
    type: Dict<{ stringType: string; numberType: number; }> | undefined
}
@enduml
bafolts commented 5 years ago

I can't reproduce this issue if I define Dict.

interface Dict<T> {
    public keys: T[];
}

interface ComplexTypesInterface {
    type: Dict<{ stringType: string; numberType: number; }> | undefined;
}

Generates

@startuml
interface Dict<T> {
    +keys: T[]
}
interface ComplexTypesInterface {
    +type: Dict<{ stringType: string; numberType: number; }> | undefined
}
@enduml

If I don't define Dict I get any as the type. @marcosvrs was this posted prior to merging the re-factor? I can't seem to recreate the issue.

marcosvrs commented 5 years ago

Interesting behavior. But actually my Dict interface looks like that:

interface Dict<T> {
    [index: string]: T;
}

You can also take a look in my last commit here where I could also reproduce it.