From ac1292d9fc638271de1942c80948607c2b5503ba Mon Sep 17 00:00:00 2001 From: Shahar Talmi Date: Mon, 28 Sep 2015 01:21:23 +0300 Subject: [PATCH] Add missing literal/constant properties in ICompiledExpression As documented in https://docs.angularjs.org/api/ng/service/$parse --- angularjs/angular-tests.ts | 24 +++++++++++++++++------- angularjs/angular.d.ts | 3 +++ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 0174a0d61..94b38d565 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -387,31 +387,31 @@ module TestPromise { var tresult: TResult; var tresultPromise: ng.IPromise; - + var tother: TOther; var totherPromise: ng.IPromise; - + var promise: angular.IPromise; // promise.then result = >promise.then((result) => any); result = >promise.then((result) => any, (any) => any); result = >promise.then((result) => any, (any) => any, (any) => any); - + result = >promise.then((result) => result); result = >promise.then((result) => result, (any) => any); result = >promise.then((result) => result, (any) => any, (any) => any); result = >promise.then((result) => tresultPromise); result = >promise.then((result) => tresultPromise, (any) => any); result = >promise.then((result) => tresultPromise, (any) => any, (any) => any); - + result = >promise.then((result) => tother); result = >promise.then((result) => tother, (any) => any); result = >promise.then((result) => tother, (any) => any, (any) => any); result = >promise.then((result) => totherPromise); result = >promise.then((result) => totherPromise, (any) => any); result = >promise.then((result) => totherPromise, (any) => any, (any) => any); - + // promise.catch result = >promise.catch((err) => any); result = >promise.catch((err) => tresult); @@ -937,7 +937,7 @@ function NgModelControllerTyping() { function ngFilterTyping() { var $filter: angular.IFilterService; var items: string[]; - + $filter("name")(items, "test"); $filter("name")(items, {name: "test"}); $filter("name")(items, (val, index, array) => { @@ -948,4 +948,14 @@ function ngFilterTyping() { }, (actual, expected) => { return actual == expected; }); -} \ No newline at end of file +} + +function parseTyping() { + var $parse: angular.IParseService; + var compiledExp = $parse('a.b.c'); + if (compiledExp.constant) { + return compiledExp({}); + } else if (compiledExp.literal) { + return compiledExp({}, {a: {b: {c: 42}}}); + } +} diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 9f7fa07b0..4abe6542d 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -910,6 +910,9 @@ declare module angular { interface ICompiledExpression { (context: any, locals?: any): any; + literal: boolean; + constant: boolean; + // If value is not provided, undefined is gonna be used since the implementation // does not check the parameter. Let's force a value for consistency. If consumer // whants to undefine it, pass the undefined value explicitly.