-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot have Generic of Generics in Class diagram #3287
Comments
Also related, these types of class diagrams with overloads of generic parameters do not render correctly either.
Renders like: classDiagram
class A~T~ {
+T value
}
class A~T,N~ {
}
class A~int~ {
}
A~int~ <|.. A~T~
|
You can have classDiagram
class A {
List~Something~T~~ ids
}
So the issue is only with Class having generic types at the top. It might be a bug with the grammar. |
The nested generics is good but this doesn't yet seem to support lists of generics as commonly used for things like Map<K,V>. Example: class MyDemo<T> {
private demoFns: Map<string, (s: T) => void>
}
classDiagram
class MyDemo~T~ {
#demoFns: Map~string, (s: T) => void~
}
|
caused by mermaid-js/mermaid#3287 (comment) wait mermaid fix this
So you mean specifically when you use a => statement, since the parser trips on the bracket after the equals? |
Apologies, I was thinking it was for the lack of generic list support but in testing with a fresh look it seems to handle the list of generics just fine. Test: class MyDemo<X,Y> {
private xVector: X
private yVector: Y
} classDiagram
class MyDemo~X,Y~ {
#xVector: X
#yVector: Y
}
Seems to also work with default type specifications: class MyDemo<X=Vector,Y=Vector> {
private xVector: X
private yVector: Y
} classDiagram
class MyDemo~X=Vector,Y=Vector~ {
#xVector: X
#yVector: Y
}
However, in coming up with an example that avoids the js shorthand (thanks for pointing that out) I'm still seeing tilde's instead of brackets in what's generated. class MyDemo<X,Y> {
tests: Map<string,(X,Y): void>
} classDiagram
class MyDemo~X,Y~ {
tests: Map~string,(X,Y): void~
}
If I simplify the class members to mappings with a simple generic list I get a class MyDemo<X=any,Y=any> {
xTests: Map<string,X>
yTests: Map<string,Y>
} classDiagram
class MyDemo~X,Y~ {
xTests: Map~string,X~
yTests: Map~string,Y~
}
Furthermore, if I try to express an anonymous object type mapping I get a class MyDemo<X,Y> {
tests: Map<string,{X,Y}>
} classDiagram
class MyDemo~X,Y~ {
tests: Map~string,{X,Y}~
}
|
The parser is choking on two aspects of this.
This is going to take a little more time to find the best way to address this |
Describe the bug
In the class diagram we can use ~ to achieve generic types, for instance:
But we cannot have Generic of generic <T>, for instnace:
and the result is:
Related to #1120 and #1063
The text was updated successfully, but these errors were encountered: