mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 12:56:46 +08:00
Add missing literal/constant properties in ICompiledExpression
As documented in https://docs.angularjs.org/api/ng/service/$parse
This commit is contained in:
committed by
Shahar Talmi
parent
b937e64fc9
commit
ac1292d9fc
@@ -387,31 +387,31 @@ module TestPromise {
|
||||
|
||||
var tresult: TResult;
|
||||
var tresultPromise: ng.IPromise<TResult>;
|
||||
|
||||
|
||||
var tother: TOther;
|
||||
var totherPromise: ng.IPromise<TOther>;
|
||||
|
||||
|
||||
var promise: angular.IPromise<TResult>;
|
||||
|
||||
// promise.then
|
||||
result = <angular.IPromise<any>>promise.then((result) => any);
|
||||
result = <angular.IPromise<any>>promise.then((result) => any, (any) => any);
|
||||
result = <angular.IPromise<any>>promise.then((result) => any, (any) => any, (any) => any);
|
||||
|
||||
|
||||
result = <angular.IPromise<TResult>>promise.then((result) => result);
|
||||
result = <angular.IPromise<TResult>>promise.then((result) => result, (any) => any);
|
||||
result = <angular.IPromise<TResult>>promise.then((result) => result, (any) => any, (any) => any);
|
||||
result = <angular.IPromise<TResult>>promise.then((result) => tresultPromise);
|
||||
result = <angular.IPromise<TResult>>promise.then((result) => tresultPromise, (any) => any);
|
||||
result = <angular.IPromise<TResult>>promise.then((result) => tresultPromise, (any) => any, (any) => any);
|
||||
|
||||
|
||||
result = <angular.IPromise<TOther>>promise.then((result) => tother);
|
||||
result = <angular.IPromise<TOther>>promise.then((result) => tother, (any) => any);
|
||||
result = <angular.IPromise<TOther>>promise.then((result) => tother, (any) => any, (any) => any);
|
||||
result = <angular.IPromise<TOther>>promise.then((result) => totherPromise);
|
||||
result = <angular.IPromise<TOther>>promise.then((result) => totherPromise, (any) => any);
|
||||
result = <angular.IPromise<TOther>>promise.then((result) => totherPromise, (any) => any, (any) => any);
|
||||
|
||||
|
||||
// promise.catch
|
||||
result = <angular.IPromise<any>>promise.catch((err) => any);
|
||||
result = <angular.IPromise<TResult>>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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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}}});
|
||||
}
|
||||
}
|
||||
|
||||
3
angularjs/angular.d.ts
vendored
3
angularjs/angular.d.ts
vendored
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user