-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add number support for identifiers and LayoutOptions values #260
base: master
Are you sure you want to change the base?
Add number support for identifiers and LayoutOptions values #260
Conversation
This change fixes a few issues with `elk-api.d.ts.`: 1. Identifiers in ELK JSON can be a string or an integer [according to the documentation](https://eclipse.dev/elk/documentation/tooldevelopers/graphdatastructure/jsonformat.html#nodes-ports-labels-edges-and-edge-sections). > The id can be a string or an integer. Because of this, a new `type ElkIdentifier` was added and used where necessary. 2. Missing semicolons in the definitions of the interfaces. Although there is no up-to-date specification for typescript, the majority of examples shown in the official documentation have semicolons. There is also inconsistent use of semicolons in this file so this fixes that as well.
Update LayoutOptions so that values such as: ``` 'layered.spacing.nodeNodeBetweenLayers': 40 ``` is supported.
This looks good. I just need to find time to check whether this effects the conversion between json and other formats (which might take a while since I am quite busy at the moment). |
Thanks @soerendomroes ! Concerning the effects on conversion, does this really need to be checked? The reason I ask is because there is no conversion API in I did a quick check on the hosted version of however, the conversion page is indeed having issues: Despite the conversion error, this should not block this PR for the following reasons:
Additionally, I just added a new file to test that numeric identifiers and layout option values work. Can you trigger the tests please? |
Would love for this to be merged! Using elkjs with Typescript as well and am now also running into point 2 as described above (using numeric values for layout options). So this would be nice to prevent erroneous typing errors |
Were you able to find time @soerendomroes? Did you read my arguments as to why I don't think it's necessary to test conversion for this PR? |
@Daniel-Khodabakhsh Not yet, since we would like to be compatible with ELK. |
This update introduces 3 changes to
elk-api.d.ts.
:1. Support integer identifiers
Identifiers in ELK JSON can be a string or an integer according to the documentation.
This is further backed up by org.eclipse.elk.graph.json.JsonAdapter.asId supporting both string and integer JSON types.
With this PR, a new
type ElkIdentifier
was added which allows you to assign integers as identifiers in typescript without errors:2. Allow
number
values forLayoutOptions
Layout options can be a number type such as an integer or double. For example,
org.eclipse.elk.layered.spacing.nodeNodeBetweenLayers
uses double values as mentioned in the documentation.With the change in this PR, we can now assign numbers without typescript throwing an error:
3. Missing semicolons in the definitions of the interfaces
Although there is no up-to-date specification for typescript, the majority of examples shown in the official documentation have semicolons. There is also inconsistent use of semicolons in this file so this fixes that as well.