diff --git a/ejs/ejs.d.ts b/ejs/ejs.d.ts index 95ca168c38..56e755a460 100644 --- a/ejs/ejs.d.ts +++ b/ejs/ejs.d.ts @@ -5,7 +5,7 @@ declare module "ejs" { - module Ejs { + namespace Ejs { type Data = { [name: string]: any }; type Dependencies = string[]; var cache: Cache; @@ -60,7 +60,7 @@ declare module "ejs" { function shallowCopy(to: T1, fro: any): T1; interface Cache { _data: { [name: string]: any }; - set(key: string, val: any); + set(key: string, val: any): any; get(key: string): any; } var cache: Cache; diff --git a/static-eval/static-eval-tests.ts b/static-eval/static-eval-tests.ts index 5657a8c62b..fe42c3d4d2 100644 --- a/static-eval/static-eval-tests.ts +++ b/static-eval/static-eval-tests.ts @@ -1,14 +1,17 @@ -/// /// +/// import evaluate = require('static-eval'); -import parse = require('../esprima/esprima').parse; +import esprima = require('esprima'); +var parse = esprima.parse; + var src = '[1,2,3+4*10+n,foo(3+5),obj[""+"x"].y]'; -var ast = parse(src).body[0].expression; + +var ast = ((parse(src).body[0])).expression; console.log(evaluate(ast, { n: 6, - foo: function (x) { return x * 100 }, + foo: function (x: number) { return x * 100 }, obj: { x: { y: 555 } } })); \ No newline at end of file diff --git a/static-eval/static-eval.d.ts b/static-eval/static-eval.d.ts index bb3461ad69..e44294c27e 100644 --- a/static-eval/static-eval.d.ts +++ b/static-eval/static-eval.d.ts @@ -3,8 +3,14 @@ // Definitions by: Ben Liddicott // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// declare module 'static-eval' { - function evaluate(ast, vars: { [name: string]: any }); + /** + * Evaluates the given ESTree.Expression, with the given named variables in place. + * @param ast [ESTree.Expression] An esprima expression derived from parse.body[].expression + * @param vars Named variables, objects or functions which may be referenced in the expression. + */ + function evaluate(ast : ESTree.Expression, vars: { [name: string]: any }): any; export =evaluate; }