You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I imported plantuml-parser in my Next.js app, and I need some of type guards.
Now I just written a piece of type guards(only for what I need), and they are in my app project.
eg. When I render UML in browser,
classify between interface and class to show some icon
classify between methods and member variable to separate div tag
Describe the solution you'd like
As far as I have been able to find in the repository, it does not appear that type guards are provided.
If I am mistaken and type guards already exists in the project, please let me know.
May I create a pull request to add the type guard I coded?
It might help other users. (although it may not be necessary)
Currently I have only created type guards for a few classes I need, but
I consider that I can create type guards for all types defined in types.d.ts.
Here is an example of what I have created;
constisMethod=(maybeMethod: Object): maybeMethod is Method=>{return(hasPrimitive(maybeMethod,'name','string')&&hasPrimitive(maybeMethod,'isStatic','boolean')&&hasStringLiteral(maybeMethod,'accessor',isAccessor)&&hasPrimitive(maybeMethod,'returnType','string')&&hasPrimitive(maybeMethod,'_arguments','string'));};constisMemberVariable=(maybeMemberVariable: Object): maybeMemberVariable is MemberVariable=>{return(hasPrimitive(maybeMemberVariable,'name','string')&&hasPrimitive(maybeMemberVariable,'isStatic','boolean')&&hasStringLiteral(maybeMemberVariable,'accessor',isAccessor)&&hasPrimitive(maybeMemberVariable,'type','string'));};constisMember=(maybeMember: Object): maybeMember is Member=>{returnisMethod(maybeMember)||isMemberVariable(maybeMember);};// how to useconstrenderClass=(c: Class)=>{constvariables=c.members.filter(member=>isMemberVariable(member));constmethods=c.members.filter(member=>isMethod(member));return<divclassName="container"><h1>{c.title}</h1>{variables.length>0&&<divclassName="properties"><h2>properties</h2><ul>{variables.map(v=><li>{v.name}</li>)}</ul></div>}{methods.length>0&&<divclassName="methods"><h2>methods</h2><ul>{methods.map(m=><li>{m.name}</li>)}</ul></div>}</div>}
The text was updated successfully, but these errors were encountered:
Hello @hache9669 , and thank you for this issue.
You are right. There are no such type guards provided for any types in this project.
If you have a set of helpful typeguards and are willing to extend those to cover all types in this project. I am more than happy to review and merge a pull request for this 👍 . I think the only point to discuss would be how we can easily integrate testing for those guards.
Is your feature request related to a problem? Please describe.
I imported plantuml-parser in my Next.js app, and I need some of type guards.
Now I just written a piece of type guards(only for what I need), and they are in my app project.
eg. When I render UML in browser,
Describe the solution you'd like
As far as I have been able to find in the repository, it does not appear that type guards are provided.
If I am mistaken and type guards already exists in the project, please let me know.
May I create a pull request to add the type guard I coded?
It might help other users. (although it may not be necessary)
Currently I have only created type guards for a few classes I need, but
I consider that I can create type guards for all types defined in types.d.ts.
Here is an example of what I have created;
The text was updated successfully, but these errors were encountered: