elkjs icon indicating copy to clipboard operation
elkjs copied to clipboard

Added more specific typing and description LayoutOptions

Open Jona898 opened this issue 2 years ago • 8 comments

I used the knownLayoutOptions() to generate more specific typings and description for LayoutOptions. I tried to parse as much as possible but for example the enums aren't typed.

I don't know, if i placed the file i used to generate the typing at the right place. Feel free to change it. I also have the file in typescript, if that is wanted, but the code base is java-script, so i removed the type annotations.

Jona898 avatar Oct 24 '22 18:10 Jona898

I don't know, if there is a possability, that the interface has extra properties. I left a "[key:string]: any" if the interface isn't complete. It it isn't needed you can remove them as well. Even with this line the code autocompletion is way better

Jona898 avatar Oct 24 '22 18:10 Jona898

I tried the typings and some need to have the elk. at the beginning. I don't know, if all need them or if it hurts, if it is appended to all of them. But it seems to work for the properties I tested

Jona898 avatar Oct 24 '22 19:10 Jona898

Sorry for the continuus changes. I now used https://www.eclipse.org/elk/reference.html to add the Enum Types as Union Strings. I added a few ToDo comments. If you could check these passages i think it should be finished.

Jona898 avatar Oct 28 '22 14:10 Jona898

I added al Variants of the EnumSet<...> as String Union Representation. This adds quite a lot of combinations. It it wanted, that the options can be in any order? If a fixed Order of options is acceptable that would shrink the options for the Set greatly. To see what I mean look at the changes in last commit.

@uruuru @soerendomroes Any Preferences from you guys?

Jona898 avatar Oct 29 '22 23:10 Jona898

How do your changes integrate with the current elkjs build? Can generating the typings be part of npm run build?

soerendomroes avatar Nov 01 '22 09:11 soerendomroes

The Problem with generating the types in the continuous integrating is that elk.knownLayoutOptions() returns not the enum type, but only the value is of type enum. So it will be hard to map these Types together. grafik As base of the types I used the current elk-api.d.ts.

Because not all types are string anymore, but "real" numbers or booleans Typescript will mark those as errors in deployment see action run on my repository.

Jona898 avatar Nov 01 '22 13:11 Jona898

Sorry for the delay. These option might change a lot in ELK. If this would require manual effort, I would rather create an "any" type for enums than write 1000 lines of enums by hand, or do you generate them too?

soerendomroes avatar Nov 17 '22 14:11 soerendomroes

The first thing I did when I decided elkjs was a great solution is I started manually adding the typings I was using.

I think this PR would be a huge help towards improving developer experience! I hope it or one like it can get merged.

joryphillips avatar Feb 16 '23 16:02 joryphillips