-
Notifications
You must be signed in to change notification settings - Fork 159
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
feat(types): improve partial-autocomplete and type inference #265
Conversation
Removed union of primitive string and defined string unions
This is a rework of #256 that looks promising. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@M0hammedImran Thanks for your contribution.
I directly committed to the branch to introduce StyleArrayValue
and StyleShapeValue
types, as the ArrayValue
and the ShapeValue
types are for built-in/core values provided by maxGraph according to the JSDoc.
I'm not very happy with the names of the new types, so if you have better names, please suggest them. 😄
@tbouffard, I have noticed an inconsistency in JSDoc and type here types.ts. If I read the JSdoc the allowed type is boolean but the actual type used a ENUM DIRECTION. |
- Use Record utility type where every necessary. - Define EdgeParametersValue.
- Use EdgeParametersValue for insertEdge.
@tbouffard, I have also noticed there are export const DIRECTION = {
NORTH: 'north',
SOUTH: 'south',
EAST: 'east',
WEST: 'west',
} as const; And, type Direction = typeof DIRECTION;
export type DirectionValue = Direction[keyof Direction]; The type would remain the same. Of course, I also realize that there are other files where we might have to make some changes, but I think it's worth it. |
@M0hammedImran thanks for the update. About |
Yes this seems to be a error introduced during the migration from mxGraph to maxGraph. This has probably been introduced in b51504d when the style configuration switched from a string to a dedicated object. In mxGraph, this was a boolean: https://github.com/jgraph/mxgraph/blob/v4.2.2/javascript/src/js/util/mxUtils.js#L2250 |
Yes, I think it would be wise to create a dedicated PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
As discussed in comments, there are other types to improved. This will done later.
Summary
Update types with partial-autocomplete and value type for better type inference.
Description for the changelog
Update types.ts with (string & {}) union.
Other info