DefinitelyTyped/expr-eval/index.d.ts
Connor Peet 1afa463988 Add typings for expr-eval (#13628)
* Add typings for expr-eval

* Avoid use of Function type

* Use (slightly) stricter typings for expr-eval

* Update with more PR comments

* Disable linter due to bugs, allow CI to pass
2017-01-03 06:25:39 -08:00

38 lines
1.3 KiB
TypeScript

// Type definitions for expr-eval 1.0
// Project: https://github.com/silentmatt/expr-eval#readme
// Definitions by: Connor Peet <https://github.com/connor4312>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace exprEval {
type Value = number
| string
| ((...args: Value[]) => Value)
| { [propertyName: string]: Value };
interface Values {
[propertyName: string]: Value;
}
export class Parser {
constructor(options?: { allowMemberAccess?: boolean });
parse(expression: string): Expression;
evaluate(expression: string, values?: Value): number;
// todo(connor4312): tslint is disabled on the following two lines, as
// thinks that the above instance methods are overloads for the static methods.
static parse(expression: string): Expression; // tslint:disable-line
static evaluate(expression: string, values?: Value): number; // tslint:disable-line
}
export interface Expression {
simplify(values?: Values): Expression;
evaluate(values?: Values): number;
substitute(values: Values): Expression;
symbols(): string[];
variables(): string[];
toJSFunction(params: string, values?: Values): (...args: Value[]) => number;
}
}
export = exprEval;