-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Update nodes.ts to allow strong NodeType #4665
base: main
Are you sure you want to change the base?
Conversation
Update the NodeBase type to have a stronger NodeType field that can be undefined even if you specifically define it.
|
Hey @fezproof thanks for your input here. Why did you close the PR? |
Sorry didn’t mean to! |
My 2 cents: this change would mean that user could not omit For example: { id: 'a', type: 'input', position: { x: 0, y: 0 }, data: { label: 'wire' } }, // <--- this node is fine
{ id: 'b', position: { x: -100, y: 100 }, data: { label: 'drag me!' }, }, // <--- this node gives an error because `type` property is missing |
I checked this again and unfortunately we can't make this change because it would be a breaking change. In a lot of examples (and real world apps), nodes do not have a |
Let me have another crack at this, I am sure I can get this to work |
… ones Updated svelte and react packages to accommodate this
@moklick @bcakmakoglu I have taken a second pass at this and updated the generic to be able to handle both defined and undefined |
Hey @moklick and @bcakmakoglu, does those changes fix your concerns? |
@fezproof Can you please explain what |
The way I understand this it checks whether the type provided as NodeType is undefined (i.e. no type provided) or can be undefined (e.g. @fezproof is this what you intended? |
Changes
Issue:
NodeType
inNodeBase
always resolves to be potentially undefined.Solution: Update the
NodeBase
type to have a strongerNodeType
field that can be undefined only if you don't specify it.Use case
Current behaviour
Desired behaviour
This also now works for union types:
Version info
I consider this type issue a bug, but you probably want to link it to a minor version update to not shock people if the type suddenly change. Up to you though :)