mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Add angular-q-extras
This commit is contained in:
parent
2437e3c5bc
commit
a64e81d551
34
types/angular-q-extras/angular-q-extras-tests.ts
Normal file
34
types/angular-q-extras/angular-q-extras-tests.ts
Normal file
@ -0,0 +1,34 @@
|
||||
interface MyService {
|
||||
getFirstname(): ng.IPromise<string>;
|
||||
getLastname(): ng.IPromise<string>;
|
||||
}
|
||||
|
||||
function TestCtrl($q: ng.IQService, MyService: MyService) {
|
||||
function arrayCallback(result: [ng.PromiseValue<string>, ng.PromiseValue<string>]) {
|
||||
const firstnameOk: boolean = $q.isFulfilledState(result[0]);
|
||||
const lastnameOk: boolean = $q.isFulfilledState(result[1]);
|
||||
}
|
||||
|
||||
function objectCallback(result: {firstname: ng.PromiseValue<string>, lastname: ng.PromiseValue<string>}) {
|
||||
const firstnameOk: boolean = $q.isFulfilledState(result.firstname);
|
||||
const lastnameOk: boolean = $q.isFulfilledState(result.lastname);
|
||||
}
|
||||
|
||||
$q
|
||||
.allSettled([
|
||||
MyService.getFirstname(),
|
||||
MyService.getLastname()
|
||||
])
|
||||
.then(arrayCallback);
|
||||
|
||||
$q
|
||||
.allSettled({
|
||||
firstname: MyService.getFirstname(),
|
||||
lastname: MyService.getLastname()
|
||||
})
|
||||
.then(objectCallback);
|
||||
}
|
||||
|
||||
TestCtrl.$inject = ['$q', 'MyService'];
|
||||
|
||||
angular.module('test').controller('TestCtrl', TestCtrl);
|
||||
42
types/angular-q-extras/index.d.ts
vendored
Normal file
42
types/angular-q-extras/index.d.ts
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
// Type definitions for angular-q-extras 1.1
|
||||
// Project: https://github.com/niqdev/angular-q-extras
|
||||
// Definitions by: Damien Sorel <https://github.com/mistic100>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
declare var _: string;
|
||||
export = _;
|
||||
|
||||
import * as angular from 'angular';
|
||||
|
||||
declare module 'angular' {
|
||||
type PromiseState = 'fulfilled' | 'rejected';
|
||||
|
||||
interface PromiseValue<T> {
|
||||
state: PromiseState;
|
||||
value?: T;
|
||||
reason?: any;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line interface-name
|
||||
interface IQService {
|
||||
// tslint:disable:max-line-length
|
||||
allSettled<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise<T4>, T5 | IPromise<T5>, T6 | IPromise<T6>, T7 | IPromise<T7>, T8 | IPromise<T8>, T9 | IPromise<T9>, T10 | IPromise<T10>]): IPromise<[PromiseValue<T1>, PromiseValue<T2>, PromiseValue<T3>, PromiseValue<T4>, PromiseValue<T5>, PromiseValue<T6>, PromiseValue<T7>, PromiseValue<T8>, PromiseValue<T9>, PromiseValue<T10>]>;
|
||||
allSettled<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise<T4>, T5 | IPromise<T5>, T6 | IPromise<T6>, T7 | IPromise<T7>, T8 | IPromise<T8>, T9 | IPromise<T9>]): IPromise<[PromiseValue<T1>, PromiseValue<T2>, PromiseValue<T3>, PromiseValue<T4>, PromiseValue<T5>, PromiseValue<T6>, PromiseValue<T7>, PromiseValue<T8>, PromiseValue<T9>]>;
|
||||
allSettled<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise<T4>, T5 | IPromise<T5>, T6 | IPromise<T6>, T7 | IPromise<T7>, T8 | IPromise<T8>]): IPromise<[PromiseValue<T1>, PromiseValue<T2>, PromiseValue<T3>, PromiseValue<T4>, PromiseValue<T5>, PromiseValue<T6>, PromiseValue<T7>, PromiseValue<T8>]>;
|
||||
allSettled<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise<T4>, T5 | IPromise<T5>, T6 | IPromise<T6>, T7 | IPromise<T7>]): IPromise<[PromiseValue<T1>, PromiseValue<T2>, PromiseValue<T3>, PromiseValue<T4>, PromiseValue<T5>, PromiseValue<T6>, PromiseValue<T7>]>;
|
||||
allSettled<T1, T2, T3, T4, T5, T6>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise<T4>, T5 | IPromise<T5>, T6 | IPromise<T6>]): IPromise<[PromiseValue<T1>, PromiseValue<T2>, PromiseValue<T3>, PromiseValue<T4>, PromiseValue<T5>, PromiseValue<T6>]>;
|
||||
allSettled<T1, T2, T3, T4, T5>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise<T4>, T5 | IPromise<T5>]): IPromise<[PromiseValue<T1>, PromiseValue<T2>, PromiseValue<T3>, PromiseValue<T4>, PromiseValue<T5>]>;
|
||||
allSettled<T1, T2, T3, T4>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>, T4 | IPromise<T4>]): IPromise<[PromiseValue<T1>, PromiseValue<T2>, PromiseValue<T3>, PromiseValue<T4>]>;
|
||||
allSettled<T1, T2, T3>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>, T3 | IPromise<T3>]): IPromise<[PromiseValue<T1>, PromiseValue<T2>, PromiseValue<T3>]>;
|
||||
allSettled<T1, T2>(values: [T1 | IPromise<T1>, T2 | IPromise<T2>]): IPromise<[PromiseValue<T1>, PromiseValue<T2>]>;
|
||||
// tslint:enable:max-line-length
|
||||
|
||||
allSettled<TAll>(promises: Array<TAll | IPromise<TAll>>): IPromise<Array<PromiseValue<TAll>>>;
|
||||
|
||||
allSettled<T>(promises: { [K in keyof T]: (T[K] | IPromise<T[K]>); }): IPromise<{ [K in keyof T]: PromiseValue<T[K]>; }>;
|
||||
|
||||
isFulfilledState(promise: PromiseValue<any>): boolean;
|
||||
isRejectedState(promise: PromiseValue<any>): boolean;
|
||||
}
|
||||
}
|
||||
23
types/angular-q-extras/tsconfig.json
Normal file
23
types/angular-q-extras/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"angular-q-extras-tests.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
3
types/angular-q-extras/tslint.json
Normal file
3
types/angular-q-extras/tslint.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user