Skip to content

Commit

Permalink
Merge pull request #5 from DefinitelyTyped/master
Browse files Browse the repository at this point in the history
Pull latest changes from head
  • Loading branch information
christophercr committed Oct 19, 2016
2 parents 99237c1 + 35b2457 commit fe91970
Show file tree
Hide file tree
Showing 212 changed files with 37,530 additions and 17,932 deletions.
39 changes: 39 additions & 0 deletions angular-ui-router-default/angular-ui-router-default-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/// <reference path="./angular-ui-router-default.d.ts" />

angular.module("test", [
"ui.router",
"ui.router.default"
])
.config(function($stateProvider: angular.ui.IStateProvider) {
$stateProvider
.state('concrete', {
// no abstract or default
})
.state('string', {
abstract: true,
default: 'concrete'
})
.state('func_str', {
abstract: true,
default: function($rootScope): string { return $rootScope.test; }
})
.state('func_promise', {
abstract: true,
default: function($q: ng.IQService): ng.IPromise<string> {
return $q.when("concrete");
}
})
.state('injection_str', {
abstract: true,
default: ["$rootScope", function($rootScope) {
return $rootScope.test;
}]
})
.state('injection_promise', {
abstract: true,
default: ["$q", function($q: ng.IQService) {
return $q.when("concrete");
}]
})
;
});
17 changes: 17 additions & 0 deletions angular-ui-router-default/angular-ui-router-default.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Type definitions for angular-ui-router-default 0.5+
// Project: https://github.com/nonplus/angular-ui-router-default
// Definitions by: Stepan Riha <https://github.com/nonplus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference path="../angular-ui-router/angular-ui-router.d.ts" />

declare namespace angular.ui {
export type StateDefaultSpecifier = string
| ((...args: any[]) => string)
| ((...args: any[]) => ng.IPromise<string>)
| (string | ((...args: any[]) => string))[]
| (string | ((...args: any[]) => ng.IPromise<string>))[];
interface IState {
default?: StateDefaultSpecifier
}
}
30 changes: 30 additions & 0 deletions angular-ui-router-uib-modal/angular-ui-router-uib-modal-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/// <reference path="./angular-ui-router-uib-modal.d.ts" />

angular.module("test", [
"ui.bootstrap",
"ui.router",
"ui.router.default"
])
.config(function($stateProvider: angular.ui.IStateProvider) {
$stateProvider
.state('contacts', {
// no modal
resolve: {
a: function() {
return "a";
},
b: function() {
return ["a", "b"];
}
}
})
.state('contacts.contact', {
// boolean modal
modal: true
})
.state('contacts.contact.edit', {
// string[] modal
modal: ["a", "b"]
})
;
});
12 changes: 12 additions & 0 deletions angular-ui-router-uib-modal/angular-ui-router-uib-modal.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Type definitions for angular-ui-uib-modal 0.11+ (ui.router module)
// Project: https://github.com/nonplus/angular-ui-router-uib-modal
// Definitions by: Stepan Riha <https://github.com/nonplus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference path="../angular-ui-router/angular-ui-router.d.ts" />

declare namespace angular.ui {
interface IState {
modal?: boolean | string[];
}
}
22 changes: 22 additions & 0 deletions angularjs/angular-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,14 @@ namespace TestQ {
b: string;
c: boolean;
}
interface TValue {
e: number;
f: boolean;
}
var tResult: TResult;
var promiseTResult: angular.IPromise<TResult>;
var tValue: TValue;
var promiseTValue: angular.IPromise<TValue>;

var $q: angular.IQService;
var promiseAny: angular.IPromise<any>;
Expand Down Expand Up @@ -349,6 +355,22 @@ namespace TestQ {
let result: angular.IPromise<TResult>;
result = $q.when<TResult>(tResult);
result = $q.when<TResult>(promiseTResult);

result = $q.when<TResult, TValue>(tValue, (result: TValue) => tResult);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => tResult, (any) => any);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => tResult, (any) => any, (any) => any);

result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => tResult);
result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => tResult, (any) => any);
result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => tResult, (any) => any, (any) => any);

result = $q.when<TResult, TValue>(tValue, (result: TValue) => promiseTResult);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => promiseTResult, (any) => any);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => promiseTResult, (any) => any, (any) => any);

result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => promiseTResult);
result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => any);
result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => any, (any) => any);
}
}

Expand Down
1 change: 1 addition & 0 deletions angularjs/angular.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,7 @@ declare namespace angular {
* @param value Value or a promise
*/
when<T>(value: IPromise<T>|T): IPromise<T>;
when<TResult, T>(value: IPromise<T>|T, successCallback: (promiseValue: T) => IPromise<TResult>|TResult, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise<TResult>;
/**
* Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
*/
Expand Down
64 changes: 64 additions & 0 deletions async-polling/async-polling-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/// <reference path="async-polling.d.ts" />

import * as AsyncPolling from "async-polling";

// Tests based on examples in https://github.com/cGuille/async-polling#readme

AsyncPolling(end => {
end();
}, 3000).run();

function someAsynchroneProcess(callback: (error?: Error, response?: any) => any): any {
callback();
}

let polling = AsyncPolling(end => {
someAsynchroneProcess(function (error, response) {
if (error) {
end(error);
return;
}

end(null, response);
});
}, 3000);
polling.on("error", (error: Error) => {});
polling.on("result", (result: any) => {});
polling.run();
polling.stop();

AsyncPolling(function(end) {
this.stop();
end();
}, 3000).run();

let i = 0;

polling = AsyncPolling(function(end) {
++i;
if (i === 3) {
return end(new Error("i is " + i));
}
if (i >= 5) {
this.stop();
return end(null, `#${i} stop`);
}
end(null, `#${i} wait a second...`);
}, 1000);

const eventNames: AsyncPolling.EventName[] = ["run", "start", "end", "schedule", "stop"];
eventNames.forEach(eventName => {
polling.on(eventName, () => {
console.log("lifecycle:", eventName);
});
});

polling.on("result", (result: any) => {
console.log("result:", result);
});

polling.on("error", (error: Error) => {
console.error("error:", error);
});

polling.run();
18 changes: 18 additions & 0 deletions async-polling/async-polling.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Type definitions for AsyncPolling
// Project: https://github.com/cGuille/async-polling
// Definitions by: Zlatko Andonovski <https://github.com/Goldsmith42/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

declare module "async-polling" {
module AsyncPolling {
export type EventName = "run"|"start"|"error"|"result"|"end"|"schedule"|"stop";
}

function AsyncPolling<Result>(pollingFunc: (end: (err?: Error, result?: Result) => any) => any, delay: number): {
run: () => any;
stop: () => any;
on: (eventName: AsyncPolling.EventName, listener: Function) => any;
}

export = AsyncPolling;
}
24 changes: 17 additions & 7 deletions aws-lambda/aws-lambda-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

import lambda = require('aws-lambda');

var str: string;
var date: Date;
var anyObj: any;
var num: number;
var str: string = "any string";
var date: Date = new Date();
var anyObj: any = { abc: 123 };
var num: number = 5;
var identity: lambda.CognitoIdentity;
var error: Error;
var b: boolean;
var error: Error = new Error();
var b: boolean = true;
var clientCtx: lambda.ClientContext;

/* Context */
Expand Down Expand Up @@ -37,4 +37,14 @@ function callback(cb: lambda.Callback) {
cb(null);
cb(error);
cb(null, anyObj);
}
}

/* Compatibility functions */
context.done();
context.done(error);
context.done(error, anyObj);
context.succeed(str);
context.succeed(anyObj);
context.succeed(str, anyObj);
context.fail(error);
context.fail(str);
4 changes: 3 additions & 1 deletion aws-lambda/aws-lambda.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ declare module "aws-lambda" {
getRemainingTimeInMillis(): number;

// Functions for compatibility with earlier Node.js Runtime v0.10.42
log(message: string, object: any): void;
// For more details see http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-using-old-runtime.html#nodejs-prog-model-oldruntime-context-methods
done(error?: Error, result?: any): void;
fail(error: Error): void;
fail(message: string): void;
succeed(message: string): void;
succeed(object: any): void;
Expand Down
4 changes: 4 additions & 0 deletions axios/axios-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ axios.post("http://example.com/", {
]
});

var config: Axios.AxiosXHRConfigBase<any> = {headers: {}};
config.headers['X-Custom-Header'] = 'baz';
axios.post("http://example.com/", config);

var getRepoIssue = axios.get<Issue>("https://api.github.com/repos/mzabriskie/axios/issues/1");

var axiosInstance = axios.create({
Expand Down
2 changes: 1 addition & 1 deletion axios/axios.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ declare namespace Axios {
/**
* custom headers to be sent
*/
headers?: Object;
headers?: {[key: string]: any};

/**
* URL parameters to be sent with the request
Expand Down
10 changes: 10 additions & 0 deletions bases/bases-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/// <reference path="./bases.d.ts" />
import * as bases from 'bases';

let bs16String: string = bases.toBase(200, 16); // => 'c8'
let bs62String: string = bases.toBase(99999, 62); // => 'q0T'
let customBaseString: string = bases.toAlphabet(300, 'aAbBcC'); // => 'Abba'

let frombs16Int: number = bases.fromBase('c8', 16); // => 200
let frombs62Int: number = bases.fromBase('q0T', 62); // => 99999
let customBaseInt: number = bases.fromAlphabet('Abba', 'aAbBcC'); // => 300
22 changes: 22 additions & 0 deletions bases/bases.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Type definitions for bases 0.2.1
// Project: https://github.com/aseemk/bases.js
// Definitions by: Hari Krishna <https://github.com/harikv>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

declare module "bases" {
export function toAlphabet(num: number, alphabet: string): string;

export function fromAlphabet(str: string, alphabet: string): number;

export function toBase(num: number, base: number): string;

export function fromBase(str: string, base:number): number;

export let KNOWN_ALPHABETS: any;

export let NUMERALS: string;

export let LETTERS_LOWERCASE: string;

export let LETTERS_UPPERCASE: string;
}
21 changes: 21 additions & 0 deletions bonjour/bonjour-tests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/// <reference path="bonjour.d.ts" />
import * as bonjour from 'bonjour';

var bonjourOptions: bonjour.BonjourOptions;
var bonjourInstance: bonjour.Bonjour;

var serviceOptions: bonjour.ServiceOptions;
var service: bonjour.Service;

var browserOptions: bonjour.BrowserOptions;
var browser: bonjour.Browser;

bonjourOptions = { interface: '192.168.1.1', port: 5353 };
bonjourInstance = new bonjour.Bonjour(bonjourOptions);

serviceOptions = { name: 'My Web Server', type: 'http', port: 3000 };
service = bonjourInstance.publish(serviceOptions);

browserOptions = { protocol: 'tcp', type: 'http' };
browser = bonjour.find(browserOptions);

Loading

0 comments on commit fe91970

Please sign in to comment.