TomFrost / Jexl

Javascript Expression Language: Powerful context-based expression parser and evaluator
MIT License
559 stars 90 forks source link

@types/jexl for 2.3.0 #98

Closed jvalkeal closed 3 years ago

jvalkeal commented 3 years ago

Sorry if this would be wrong place to request this but DefinitelyTyped https://www.npmjs.com/package/@types/jexl latest types is on 2.2.0 level. It'd be nice to get new function stuff there.

jvalkeal commented 3 years ago

I played locally to use d.ts files and came up with something like this(also exported function types to be able to use those as well). If these looks ok I could try to PR these to DefinitelyTyped:

$ diff ../DefinitelyTyped/types/jexl/index.d.ts types/jexl/index.d.ts
9c9
< type TransformFunction = (value: any, ...args: any[]) => any;
---
> export type TransformFunction = (value: any, ...args: any[]) => any;
11c11
< type BinaryOpFunction = (left: any, right: any) => any;
---
> export type BinaryOpFunction = (left: any, right: any) => any;
13c13,15
< type UnaryOpFunction = (right: any) => any;
---
> export type UnaryOpFunction = (right: any) => any;
> 
> export type FunctionFunction = (value: any, ...args: any[]) => any;
37a40,45
> 
>     addFunction(name: string, fn: FunctionFunction): void;
> 
>     addFunctions(map: { [key: string]: FunctionFunction }): void;
> 
>     getFunction(name: string): FunctionFunction;

FunctionFunction looks a bit zen but it would follow existing naming conventions.

jvalkeal commented 3 years ago

Better to create issue on DT repo.