expr-eval icon indicating copy to clipboard operation
expr-eval copied to clipboard

Evalulate function limited to number?

Open Gillardo opened this issue 7 years ago • 1 comments
trafficstars

Why is the Evalulate function limited to returning a number (i am using typescript) and not any object? I would like to calculate the difference between 2 dates and write my own DATEADD and DATEDIFF functions.

Is this not possible in this library?

Gillardo avatar Jun 25 '18 10:06 Gillardo

The support for objects is very limited at the moment, but technically there's nothing preventing you from returning one from an expression other than the TypeScript type definition. There's just not much you can do with them within an expression other than passing them to or returning them from custom functions.

I haven't used TypeScript personally, so there's a good chance the type definitions are wrong in other places as well. It's something I'm hoping to address with the next major version, since fixing it will probably involve breaking changes.

I'm not familiar enough with TypeScript to offer a good workaround, so forking the project and changing the return type to any might be the best alternative until it's fixed.

silentmatt avatar Jun 25 '18 16:06 silentmatt