in

How to define nodeCategoryProperty function for a Model in typescript?


nodeCategoryProperty function expects to have the signature –
(a: ObjectData, b?: string) => string, which, IMO, should be (a: ObjectData, b?: string) => string | undefined, as this function should not return anything if it is being used as a setter.

If the second argument is supplied, the function should modify the node data
object so that it has that new category name.

https://gojs.net/latest/api/symbols/Model.html#nodeCategoryProperty

For the function I have defined –

const categoryPropertyFunction = (partData: GraphPart, category?: string): string => 
{
  if (category) partData.model.type = category;
  else return partData.model.type;
};

I am getting typescript error –

TS2366: Function lacks ending return statement and return type does not include 'undefined'.

Please help. Thanks in advance.



Source: https://stackoverflow.com/questions/70539279/how-to-define-nodecategoryproperty-function-for-a-model-in-typescript

High-level bindings to the Valhalla framework

Bharti Airtel Didn’t Discontinue Rs 699 Plan After All