-
IntroductionI have a custom shape, which purpose is to contain the implementation details as functions, like this:
When I use the element through pointerclick, all works fine:
Steps to reproduceBut if I need to use it through non-jointjs action, I don't know how to get it as correct type.
So even though it finds the correct element based on type and is able to apply the change, the found object is not correct type. Is there a way to do this with JointJS typings? Restrictions & ConstraintsCode example here, JointJS version is 4.0.4. Does your question relate to JointJS or JointJS+. Select both if applicable.JointJS |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
You might need to cast the base model to the public test() {
const cells = this.graph.getCells();
const changed = cells.find((cell: dia.Cell) => {
const meta = cell.get('meta');
return cell instanceof CustomElement && meta.id === 1;
}) as CustomElement;
if (changed) {
changed.setBorder(true);
}
} |
Beta Was this translation helpful? Give feedback.
-
I found out that I can have a "type guard predicate function" -
and then find the cell:
Apparently the type guard can't be combined with another condition, so that's why filter and find need to be done separately. So, seems this was a typescript problem rather than jointJS :) |
Beta Was this translation helpful? Give feedback.
I found out that I can have a "type guard predicate function" -
and then find the cell:
Apparently the type guard can't be combined with another condition, so that's why filter and find need to be done separately.
So, seems this was a typescript problem rather than jointJS :)