How to access a function in typescript?

56 views Asked by At

I have written a code to calculate the today's date

function today() {
   const now = new Date();
   const monthday = ("0" + now.getDate().toString()).slice(-2);
   const month = ("0" + (now.getMonth() + 1).toString()).slice(-2);
   const year = now.getFullYear();

   return `${monthday}.${month}.${year}`;
}

I am accessing this with name 'today' to check if the present date exists , but failing to do so

await _assertExists(_cell(today, _under(_tableHeader("Calculate"))

Error is as below

semantic error TS2345: Argument of type '() => string' is not assignable to parameter of type 'AccessorIdentifier'. Type '() => string' has no properties in common with type 'Partial<AccessorIdentifierAttributesWithClassName & AccessorIdentifierAttributesWithSahiIndex & AccessorIdentifierAttrbutesWithText>

0

There are 0 answers