Merge branch 'master' into react-navigation/update-from-flow

This commit is contained in:
abrahambotros
2017-06-24 08:54:29 -07:00
3498 changed files with 19395 additions and 8550 deletions

View File

@@ -3,6 +3,9 @@
// Default usage:
accounting.formatMoney(12345678); // $12,345,678.00
// Stringified usage:
accounting.formatMoney('$4394958309392.9401'); // $4,394,958,309,392.94
// European formatting (custom symbol and separators), could also use options object as second param:
accounting.formatMoney(4999.99, "€", 2, ".", ","); // €4.999,99

View File

@@ -1,6 +1,7 @@
// Type definitions for accounting.js 0.3
// Project: http://josscrowcroft.github.io/accounting.js/
// Type definitions for accounting.js 0.4
// Project: http://openexchangerates.github.io/accounting.js/
// Definitions by: Sergey Gerasimov <https://github.com/gerich-home/>
// Christopher Eck <https://github.com/chrisleck/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace accounting {
@@ -30,9 +31,9 @@ declare namespace accounting {
}
interface Static {
// format any number into currency
formatMoney(number: number, symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): string;
formatMoney(number: number, options: CurrencySettings<string> | CurrencySettings<CurrencyFormat>): string;
// format any number or stringified number into currency
formatMoney(number: number | string, symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): string;
formatMoney(number: number | string, options: CurrencySettings<string> | CurrencySettings<CurrencyFormat>): string;
formatMoney(numbers: number[], symbol?: string, precision?: number, thousand?: string, decimal?: string, format?: string): string[];
formatMoney(numbers: number[], options: CurrencySettings<string> | CurrencySettings<CurrencyFormat>): string[];

View File

@@ -2,7 +2,7 @@
// Project: https://github.com/goatslacker/alt
// Definitions by: Michael Shearer <https://github.com/Shearerbeard>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.3
///<reference types="react"/>
@@ -141,7 +141,7 @@ declare module "alt/utils/chromeDebug" {
declare module "alt/AltContainer" {
import React = require("react");
import * as React from "react";
interface ContainerProps {
store?:AltJS.AltStore<any>;
@@ -152,7 +152,7 @@ declare module "alt/AltContainer" {
flux?:AltJS.Alt;
transform?:(store:AltJS.AltStore<any>, actions:any) => any;
shouldComponentUpdate?:(props:any) => boolean;
component?:React.Component<any, any>;
component?:React.Component<any>;
}
type AltContainer = React.ReactElement<ContainerProps>;

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/squaremo/amqp.node
// Definitions by: Michael Nahkies <https://github.com/mnahkies>, Ab Reitsma <https://github.com/abreits>, Nicolás Fantone <https://github.com/nfantone>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/McNull/angular-block-ui
// Definitions by: Lasse Nørregaard <https://github.com/lassebn>, Stephan Classen <https://github.com/sclassen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as angular from "angular";

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/ManifestWebDesign/angular-gridster
// Definitions by: Joao Monteiro <https://github.com/jpmnteiro>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as angular from "angular";

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/oauthjs/angular-oauth2
// Definitions by: Antério Vieira <https://github.com/anteriovieira>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as angular from 'angular';

View File

@@ -337,6 +337,16 @@ namespace TestQ {
let result: angular.IPromise<{a: number; b: string; }>;
result = $q.all<{a: number; b: string; }>({a: promiseAny, b: promiseAny});
}
{
let result = $q.all({ num: $q.when(2), str: $q.when('test') });
// TS should infer that num is a number and str is a string
result.then(r => (r.num * 2) + r.str.indexOf('s'));
}
{
let result = $q.all({ num: $q.when(2), str: 'test' });
// TS should infer that num is a number and str is a string
result.then(r => (r.num * 2) + r.str.indexOf('s'));
}
// $q.defer
{
@@ -367,8 +377,7 @@ namespace TestQ {
let result: angular.IPromise<TResult>;
result = $q.resolve<TResult>(tResult);
result = $q.resolve<TResult>(promiseTResult);
result = $q.resolve<TResult | TOther>(Math.random() > 0.5 ? tResult : promiseTOther);
result = $q.resolve(Math.random() > 0.5 ? tResult : promiseTOther);
let result2: angular.IPromise<TResult | TOther> = $q.resolve<TResult | TOther>(Math.random() > 0.5 ? tResult : promiseTOther);
}
// $q.when
@@ -378,7 +387,8 @@ namespace TestQ {
}
{
let result: angular.IPromise<TResult>;
let resultOther: angular.IPromise<TOther>;
let other: angular.IPromise<TOther>;
let resultOther: angular.IPromise<TResult | TOther>;
result = $q.when<TResult>(tResult);
result = $q.when<TResult>(promiseTResult);
@@ -388,20 +398,21 @@ namespace TestQ {
result = $q.when<TResult, TValue>(tValue, (result: TValue) => tResult, (any) => any, (any) => any);
result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => tResult);
result = resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => tResult, (any) => tOther);
result = resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => tResult, (any) => tOther, (any) => any);
result = resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther);
result = resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther, (any) => any);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => tResult, (any) => tOther);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => tResult, (any) => tOther);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => tResult, (any) => tOther, (any) => any);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => tResult, (any) => promiseTOther, (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 = resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther);
result = resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther, (any) => any);
result = resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther);
result = resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther, (any) => any);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => tOther, (any) => any);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther);
resultOther = $q.when<TResult, TOther, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => promiseTOther, (any) => any);
}
}
@@ -547,7 +558,7 @@ namespace TestPromise {
assertPromiseType<TResult>(promise.then((result) => result, (any) => any, (any) => any));
assertPromiseType<TResult>(promise.then((result) => result, (any) => reject, (any) => any));
assertPromiseType<TResult>(promise.then((result) => anyOf2(reject, result)));
assertPromiseType<angular.IPromise<never> | TResult>(promise.then((result) => anyOf2(reject, result)));
assertPromiseType<TResult>(promise.then((result) => anyOf3(result, tresultPromise, reject)));
assertPromiseType<TResult>(promise.then(
(result) => anyOf3(reject, result, tresultPromise),
@@ -557,7 +568,7 @@ namespace TestPromise {
assertPromiseType<ng.IHttpPromiseCallbackArg<TResult>>(promise.then((result) => tresultHttpPromise));
assertPromiseType<TResult | TOther>(promise.then((result) => result, (any) => tother));
assertPromiseType<TResult | TOther>(promise.then(
assertPromiseType<TResult | angular.IPromise<TResult> | angular.IPromise<never> | TOther | angular.IPromise<TOther>>(promise.then(
(result) => anyOf3(reject, result, totherPromise),
(reason) => anyOf3(reject, tother, tresultPromise)
));
@@ -588,7 +599,7 @@ namespace TestPromise {
assertPromiseType<any>(promise.catch((err) => err));
assertPromiseType<any>(promise.catch((err) => any));
assertPromiseType<TResult>(promise.catch((err) => tresult));
assertPromiseType<TResult>(promise.catch((err) => anyOf2(tresult, reject)));
assertPromiseType<TResult | angular.IPromise<never>>(promise.catch((err) => anyOf2(tresult, reject)));
assertPromiseType<TResult>(promise.catch((err) => anyOf3(tresult, tresultPromise, reject)));
assertPromiseType<TResult>(promise.catch((err) => tresultPromise));
assertPromiseType<TResult | ng.IHttpPromiseCallbackArg<TResult>>(promise.catch((err) => tresultHttpPromise));

View File

@@ -1029,8 +1029,7 @@ declare namespace angular {
*
* @param promises A hash of promises.
*/
all(promises: { [id: string]: IPromise<any>; }): IPromise<{ [id: string]: any; }>;
all<T extends {}>(promises: { [id: string]: IPromise<any>; }): IPromise<T>;
all<T>(promises: { [K in keyof T]: (IPromise<T[K]> | T[K]); }): IPromise<T>;
/**
* Creates a Deferred object which represents a task which will finish in the future.
*/
@@ -1049,6 +1048,10 @@ declare namespace angular {
* @param value Value or a promise
*/
resolve<T>(value: IPromise<T>|T): IPromise<T>;
/**
* @deprecated Since TS 2.4, inference is stricter and no longer produces the desired type when T1 !== T2.
* To use resolve with two different types, pass a union type to the single-type-argument overload.
*/
resolve<T1, T2>(value: IPromise<T1>|T2): IPromise<T1|T2>;
/**
* 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.
@@ -1846,6 +1849,10 @@ declare namespace angular {
* different in Angular 1 there is no direct mapping and care should be taken when upgrading.
*/
$postLink?(): void;
// IController implementations frequently do not implement any of its methods.
// A string indexer indicates to TypeScript not to issue a weak type error in this case.
[s: string]: any;
}
/**

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/spion/anydb-sql-migrations
// Definitions by: Gorgi Kosev <https://github.com/spion>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import Promise = require('bluebird');
import { Column, Table, Transaction, AnydbSql } from 'anydb-sql';

View File

@@ -39,7 +39,7 @@ const withFont = StyleSheet.create({
});
class App extends React.Component<{}, {}> {
class App extends React.Component {
render() {
return <div>
<span className={css(styles.red)}>

View File

@@ -2,7 +2,7 @@
// Project: https://github.com/Khan/aphrodite
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.3
import * as React from "react";

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/Asana/node-asana
// Definitions by: Qubo <https://github.com/tkqubo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="bluebird" />

View File

@@ -0,0 +1,15 @@
import { AskmethatRating, AskmethatRatingSteps } from "askmethat-rating";
let options = {
backgroundColor: "#e5e500",
hoverColor: "#ffff66",
fontClass: "fa fa-star",
minRating: 1,
maxRating: 5,
readonly: false,
step: AskmethatRatingSteps["OnePerOneStep"],
inputName: "AskmethatRating"
};
let div = document.createElement("div");
let amcRating = new AskmethatRating(div, 2 , options);

131
types/askmethat-rating/index.d.ts vendored Normal file
View File

@@ -0,0 +1,131 @@
// Type definitions for askmethat-rating 0.3
// Project: https://alexteixeira.github.io/Askmethat-Rating/
// Definitions by: Alexandre Teixeira <https://github.com/AlexTeixeira/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
export enum AskmethatRatingSteps {
/**
* Step 0.1 per 0.1
*/
DecimalStep = 0,
/**
* Step 0.5 per 0.5
*/
HalfStep = 1,
/**
* Step 1 per 1
*/
OnePerOneStep = 2,
}
export interface AskmethatRatingOptions {
hoverColor?: string;
/**
* Color when the rating is not hovered
*/
backgroundColor?: string;
/**
* Mininmum rating that the user can set
*/
minRating?: number;
/**
* Maximum rating that the plugin display
*/
maxRating?: number;
/**
* Class to display as rating (FontAwesome or Rating for exemple)
*/
fontClass: string;
/**
* Set the rating to readonly
*/
readonly: boolean;
/**
* The stepping for the rating
*/
step: AskmethatRatingSteps;
/**
* Input name (Default is AskmethatRating)
*/
inputName: string;
}
export class AskmethatRating {
private parentElement;
private pValue;
private styleSheet;
private changeEvent;
private ratingClick;
private mouseMove;
/**
* @function get the current value for the rating
*/
/**
* @function set a new value for the rating
*
* @param _value this is the new value you want to set to the rating
* @returns the current number
*/
value: number;
/**
* Default option base on @type IAskmethatRatingOptions
*/
private _defaultOptions;
/**
* @function get the default option for the rating
*
* @return options based on @type AskmethatRatingOptions
*/
readonly defaultOptions: any;
/**
* constructor with div element, default rating value & default options
*
* @param element This is the html container for the rating elements
* @param defaultValue Default value set when the plugin render the rating
* @param options Default option base on AskmethatRatingOptions type
*/
constructor(element: HTMLDivElement, defaultValue?: number, options?: any);
/**
* render a new rating, by default value is the minRating
*
* @param value this is the default value set when the plugin is rendered, by default IAskmethatRatingOptions.minRating
*/
render(value?: number): void;
/**
* @function when a rating is clicked
* @param {type} event : Event {event object}
*/
private onRatingClick(event?);
/**
* @function Calculate the value according to the step provided in options
* @param {Number} value:number the current value
* @return {Number} the new value according to step
*/
protected getValueAccordingToStep(value: number): number;
/**
* @function mouse event enter in rating
* @param {type} event?: Event {event}
*/
private onMouseMove(event?);
/**
* @function mouse out event in rating
* @param {type} event?: Event {event}
*/
private onMouseLeave(event?);
/**
* @function set or unset the active class and color
* @param {HTMLSpanElement} current : current span element
* @param {number} current : value needed for the if
*/
protected setOrUnsetActive(value: number): void;
/**
* Check if disabled attribute is added or removed from the input
* Update readonly status if needed for the rating
*/
private mutationEvent();
/**
* @function static method to retrieve with identifier the value
* @param {string} identifier: string container identifier
* @return {number} current rating
*/
static value(identifier: string): number;
}

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"askmethat-rating-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -2,7 +2,7 @@
// Project: https://github.com/thejameskyle/assert-equal-jsx
// Definitions by: Josh Toft <https://github.com/seryl>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// TypeScript Version: 2.3
import * as React from 'react';

View File

@@ -0,0 +1,26 @@
import * as audiosprite from 'audiosprite';
const files = ['file1.mp3', 'file2.mp3'];
const opts = {output: 'result'};
audiosprite(files, opts, (err, obj) => {
if (err) {
return err;
}
return JSON.stringify(obj, null, 2);
});
audiosprite(files, {
path: "aaa",
format: "howler",
export: "ogg,mp3",
minlength: 9999,
vbr: 9,
'vbr:vorbis': 10,
logger: {
debug(a) {
}
}
}, (err, obj) => {
});

55
types/audiosprite/index.d.ts vendored Normal file
View File

@@ -0,0 +1,55 @@
// Type definitions for audiosprite 0.6
// Project: https://github.com/tonistiigi/audiosprite
// Definitions by: Gyusun Yeom <https://github.com/Perlmint>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export as namespace audiosprite;
export = audiosprite;
declare function audiosprite(files: string[], callback: (error: Error, obj: audiosprite.Result) => void): void;
declare function audiosprite(files: string[], option: audiosprite.Option, callback: (error: Error, obj: audiosprite.Result) => void): void;
declare namespace audiosprite {
type ExportType = "jukebox" | "howler" | "createjs" | null;
type LogLevel = "debug" | "info" | "notice" | "warning" | "error";
type VBR = -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
type VBR_Vorbis = VBR | 10;
type Channels = 1 | 2;
interface Option {
output?: string;
path?: string;
export?: string;
format?: ExportType;
log?: LogLevel;
autoplay?: string | null;
loop?: string[];
silence?: number;
gap?: number;
minlength?: number;
bitrate?: number;
vbr?: VBR;
'vbr:vorbis'?: VBR_Vorbis;
samplerate?: number;
channels?: Channels;
rawparts?: string;
logger?: Logger;
}
interface Logger {
debug?(...log: any[]): void;
info?(...log: any[]): void;
log?(...log: any[]): void;
}
interface Result {
resources: string[];
spritemap: {
[key: string]: {
start: number;
end: number;
loop: boolean;
}
};
autoplay?: string;
}
}

View File

@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"audiosprite-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -650,8 +650,9 @@ interface RenewAuthOptions {
interface AuthorizeOptions {
domain?: string;
clientID?: string;
redirectUri: string;
responseType: string;
connection?:string;
redirectUri?: string;
responseType?: string;
responseMode?: string;
state?: string;
nonce?: string;

View File

@@ -28,6 +28,42 @@ management
// Handle the error.
});
// Using a callback.
management.getUser({id: 'user_id'},(err: Error, user: auth0.User) => {
if (err) {
// Handle error.
}
console.log(user);
});
// Using a Promise.
management
.getUser({id: 'user_id'})
.then((user) => {
console.log(user);
})
.catch((err) => {
// Handle the error.
});
// Using a callback.
management.deleteUser({id: 'user_id'},(err: Error) => {
if (err) {
// Handle error.
}
console.log('deleted');
});
// Using a Promise.
management
.deleteUser({id: 'user_id'})
.then(() => {
console.log('deleted');
})
.catch((err) => {
// Handle the error.
});
management
.createUser({
connection: 'My-Connection',

View File

@@ -1,7 +1,8 @@
// Type definitions for auth0 2.4
// Type definitions for auth0 3.0
// Project: https://github.com/auth0/node-auth0
// Definitions by: Wilson Hobbs <https://github.com/wbhob>, Seth Westphal <https://github.com/westy92>
// Definitions by: Wilson Hobbs <https://github.com/wbhob>, Seth Westphal <https://github.com/westy92>, Amiram Korach <https://github.com/amiram>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import * as Promise from 'bluebird';
@@ -14,16 +15,29 @@ export interface UserMetadata { }
export interface AppMetadata { }
export interface UserData {
connection: string;
email?: string;
username?: string;
email_verified?: boolean;
verify_email?: boolean;
password?: string;
phone_number?: string;
phone_verified?: boolean,
user_metadata?: UserMetadata;
email_verified?: boolean;
app_metadata?: AppMetadata;
}
export interface CreateUserData extends UserData {
connection: string;
}
export interface UpdateUserData extends UserData {
connection?: string;
blocked?: boolean;
verify_phone_number?: boolean,
verify_password?: boolean,
client_id?: string
}
export interface GetUsersData {
per_page?: number;
page?: number;
@@ -67,10 +81,6 @@ export interface Identity {
isSocial: boolean;
}
export interface UpdateUserParameters {
id: string;
}
export interface AuthenticationClientOptions {
clientId?: string;
domain: string;
@@ -134,17 +144,47 @@ export interface ClientParams {
client_id: string;
}
export type DeleteDeleteMultifactorParamsProvider = 'duo' | 'google-authenticator';
export interface DeleteMultifactorParams {
id: string;
provider: string;
provider: DeleteDeleteMultifactorParamsProvider;
}
export interface LinkAccountsParams {
export type UnlinkAccountsParamsProvider = 'ad' | 'adfs' | 'amazon' | 'dropbox' | 'bitbucket' | 'aol' | 'auth0-adldap' |
'auth0-oidc' | 'auth0' | 'baidu' | 'bitly' | 'box' | 'custom' | 'dwolla' | 'email' | 'evernote-sandbox' | 'evernote' |
'exact' | 'facebook' | 'fitbit' | 'flickr' | 'github' | 'google-apps' | 'google-oauth2' | 'guardian' | 'instagram' |
'ip' | 'linkedin' | 'miicard' | 'oauth1' | 'oauth2' | 'office365' | 'paypal' | 'paypal-sandbox' | 'pingfederate' |
'planningcenter' | 'renren' | 'salesforce-community' | 'salesforce-sandbox' | 'salesforce' | 'samlp' | 'sharepoint' |
'shopify' | 'sms' | 'soundcloud' | 'thecity-sandbox' | 'thecity' | 'thirtysevensignals' | 'twitter' | 'untappd' |
'vkontakte' | 'waad' | 'weibo' | 'windowslive' | 'wordpress' | 'yahoo' | 'yammer' | 'yandex';
export interface UnlinkAccountsParams {
id: string;
provider: string;
provider: UnlinkAccountsParamsProvider;
user_id: string;
}
export interface UnlinkAccountsResponseProfile {
email?: string;
email_verified?: boolean;
name?: string;
username?: string;
given_name?: string;
phone_number?: string;
phone_verified?: boolean;
family_name?: string;
}
export interface UnlinkAccountsResponse {
connection: string;
user_id: string;
provider: string;
isSocial?: boolean;
access_token?: string;
profileData?: UnlinkAccountsResponseProfile
}
export interface LinkAccountsData {
user_id: string;
connection_id: string;
@@ -307,32 +347,33 @@ export class ManagementClient {
getUsers(params?: GetUsersData): Promise<User[]>;
getUsers(params?: GetUsersData, cb?: (err: Error, users: User[]) => void): void;
getUser(params?: ObjectWithId): Promise<User[]>;
getUser(params?: ObjectWithId, cb?: (err: Error, users: User[]) => void): void;
getUser(params: ObjectWithId): Promise<User>;
getUser(params: ObjectWithId, cb?: (err: Error, user: User) => void): void;
createUser(data: UserData): Promise<User>;
createUser(data: UserData, cb: (err: Error, data: User) => void): void;
createUser(data: CreateUserData): Promise<User>;
createUser(data: CreateUserData, cb: (err: Error, data: User) => void): void;
updateUser(params: UpdateUserParameters, data: User): Promise<User>;
updateUser(params: UpdateUserParameters, data: User, cb: (err: Error, data: User) => void): void;
updateUser(params: ObjectWithId, data: UpdateUserData): Promise<User>;
updateUser(params: ObjectWithId, data: UpdateUserData, cb: (err: Error, data: User) => void): void;
updateUserMetadata(params: UpdateUserParameters, data: UserMetadata): Promise<User>;
updateUserMetadata(params: UpdateUserParameters, data: UserMetadata, cb: (err: Error, data: User) => void): void;
updateUserMetadata(params: ObjectWithId, data: UserMetadata): Promise<User>;
updateUserMetadata(params: ObjectWithId, data: UserMetadata, cb: (err: Error, data: User) => void): void;
// Should be removed from auth0 also. Doesn't exist in api.
deleteAllUsers(): Promise<User>;
deleteAllUsers(cb: (err: Error, data: any) => void): void;
deleteUser(params?: ObjectWithId): Promise<any>;
deleteUser(params?: ObjectWithId, cb?: (err: Error, users: User[]) => void): void;
deleteUser(params: ObjectWithId): Promise<void>;
deleteUser(params: ObjectWithId, cb?: (err: Error) => void): void;
updateAppMetadata(params: UpdateUserParameters, data: AppMetadata): Promise<User>;
updateAppMetadata(params: UpdateUserParameters, data: AppMetadata, cb: (err: Error, data: User) => void): void;
updateAppMetadata(params: ObjectWithId, data: AppMetadata): Promise<User>;
updateAppMetadata(params: ObjectWithId, data: AppMetadata, cb: (err: Error, data: User) => void): void;
deleteUserMultifactor(params: DeleteMultifactorParams): Promise<any>;
deleteUserMultifactor(params: DeleteMultifactorParams, cb: (err: Error, data: any) => void): void;
deleteUserMultifactor(params: DeleteMultifactorParams): Promise<void>;
deleteUserMultifactor(params: DeleteMultifactorParams, cb: (err: Error) => void): void;
unlinkUsers(params: LinkAccountsParams): Promise<any>;
unlinkUsers(params: LinkAccountsParams, cb: (err: Error, data: any) => void): void;
unlinkUsers(params: UnlinkAccountsParams): Promise<UnlinkAccountsResponse>;
unlinkUsers(params: UnlinkAccountsParams, cb: (err: Error, data: UnlinkAccountsResponse) => void): void;
linkUsers(params: ObjectWithId, data: LinkAccountsData): Promise<any>;
linkUsers(params: ObjectWithId, data: LinkAccountsData, cb: (err: Error, data: any) => void): void;

View File

@@ -61,6 +61,8 @@ var S3CreateEvent: AWSLambda.S3CreateEvent = {
]
};
var cognitoUserPoolEvent: AWSLambda.CognitoUserPoolEvent;
var cloudformationCustomResourceEvent: AWSLambda.CloudFormationCustomResourceEvent;
var cloudformationCustomResourceResponse: AWSLambda.CloudFormationCustomResourceResponse;
/* API Gateway Event */
str = apiGwEvt.body;
@@ -213,6 +215,33 @@ str = cognitoUserPoolEvent.response.privateChallengeParameters["answer"];
str = cognitoUserPoolEvent.response.challengeMetaData;
b = cognitoUserPoolEvent.response.answerCorrect;
// CloudFormation Custom Resource
switch (cloudformationCustomResourceEvent.RequestType) {
case "Create":
str = cloudformationCustomResourceEvent.LogicalResourceId;
str = cloudformationCustomResourceEvent.RequestId;
anyObj = cloudformationCustomResourceEvent.ResourceProperties;
str = cloudformationCustomResourceEvent.ResourceProperties.ServiceToken;
str = cloudformationCustomResourceEvent.ResourceType;
str = cloudformationCustomResourceEvent.ResponseURL;
str = cloudformationCustomResourceEvent.ServiceToken;
str = cloudformationCustomResourceEvent.StackId;
break;
case "Update":
anyObj = cloudformationCustomResourceEvent.OldResourceProperties;
break;
case "Delete":
str = cloudformationCustomResourceEvent.PhysicalResourceId;
break;
}
anyObj = cloudformationCustomResourceResponse.Data;
str = cloudformationCustomResourceResponse.LogicalResourceId;
str = cloudformationCustomResourceResponse.PhysicalResourceId;
str = cloudformationCustomResourceResponse.Reason;
str = cloudformationCustomResourceResponse.RequestId;
str = cloudformationCustomResourceResponse.StackId;
str = cloudformationCustomResourceResponse.Status;
/* Context */
b = context.callbackWaitsForEmptyEventLoop;
str = context.functionName;

View File

@@ -168,6 +168,64 @@ interface CognitoUserPoolEvent {
};
}
/**
* CloudFormation Custom Resource event and response
* http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/crpg-ref.html
*/
type CloudFormationCustomResourceEventCommon = {
ServiceToken: string;
ResponseURL: string;
StackId: string;
RequestId: string;
LogicalResourceId: string;
ResourceType: string;
ResourceProperties: {
ServiceToken: string;
[Key: string]: any;
}
}
type CloudFormationCustomResourceCreateEvent = CloudFormationCustomResourceEventCommon & {
RequestType: "Create";
}
type CloudFormationCustomResourceUpdateEvent = CloudFormationCustomResourceEventCommon & {
RequestType: "Update";
PhysicalResourceId: string;
OldResourceProperties: {
[Key: string]: any;
};
}
type CloudFormationCustomResourceDeleteEvent = CloudFormationCustomResourceEventCommon & {
RequestType: "Delete";
PhysicalResourceId: string;
}
export type CloudFormationCustomResourceEvent = CloudFormationCustomResourceCreateEvent | CloudFormationCustomResourceUpdateEvent | CloudFormationCustomResourceDeleteEvent;
type CloudFormationCustomResourceResponseCommon = {
PhysicalResourceId: string;
StackId: string;
RequestId: string;
LogicalResourceId: string;
Data?: {
[Key: string]: any;
}
}
type CloudFormationCustomResourceSuccessResponse = CloudFormationCustomResourceResponseCommon & {
Status: "SUCCESS";
Reason?: string;
}
type CloudFormationCustomResourceFailedResponse = CloudFormationCustomResourceResponseCommon & {
Status: "FAILED";
Reason: string;
}
export type CloudFormationCustomResourceResponse = CloudFormationCustomResourceSuccessResponse | CloudFormationCustomResourceFailedResponse;
// Context
// http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html
interface Context {

View File

@@ -1,24 +1,24 @@
import "./index"
namespace BMapTests {
export class TestFixture {
//document: http://lbsyun.baidu.com/index.php?title=jspopular
public createMap(container: string | HTMLElement) {
navigator.geolocation.getCurrentPosition((position: Position) => {
let point = new BMap.Point(position.coords.longitude, position.coords.latitude);
let map = new BMap.Map(container);
map.centerAndZoom(point, 15);
}, console.log, { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true });
}
public addControl(map: BMap.Map) {
map.addControl(new BMap.ScaleControl({ anchor: BMAP_ANCHOR_TOP_LEFT }));
map.addControl(new BMap.NavigationControl());
map.addControl(new BMap.MapTypeControl({ mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP] }));
map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT }));
}
public addMarker(map: BMap.Map, point: BMap.Point) {
var marker = new BMap.Marker(point);
map.addOverlay(marker);
marker.setAnimation(BMAP_ANIMATION_BOUNCE);
}
}
}
import "./index"
namespace BMapTests {
export class TestFixture {
//document: http://lbsyun.baidu.com/index.php?title=jspopular
public createMap(container: string | HTMLElement) {
navigator.geolocation.getCurrentPosition((position: Position) => {
let point = new BMap.Point(position.coords.longitude, position.coords.latitude);
let map = new BMap.Map(container);
map.centerAndZoom(point, 15);
}, console.log, { maximumAge: 3000, timeout: 5000, enableHighAccuracy: true });
}
public addControl(map: BMap.Map) {
map.addControl(new BMap.ScaleControl({ anchor: BMAP_ANCHOR_TOP_LEFT }));
map.addControl(new BMap.NavigationControl());
map.addControl(new BMap.MapTypeControl({ mapTypes: [BMAP_NORMAL_MAP, BMAP_HYBRID_MAP] }));
map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT }));
}
public addMarker(map: BMap.Map, point: BMap.Point) {
var marker = new BMap.Marker(point);
map.addOverlay(marker);
marker.setAnimation(BMAP_ANIMATION_BOUNCE);
}
}
}

View File

@@ -1,56 +1,56 @@
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
declare namespace BMap {
class Point {
constructor (lng: number, lat: number)
lng: number
lat: number
equals(other: Point): boolean
}
class Pixel {
constructor (x: number, y: number)
x: number
y: number
equals(other: Pixel): boolean
}
class Size {
constructor (width: number, height: number)
width: number
height: number
equals(other: Size): boolean
}
class Bounds {
constructor (minX: number, minY: number, maxX: number, maxY: number)
constructor (sw: Point, ne: Point)
minX: number
minY: number
maxX: number
maxY: number
equals(other: Bounds): boolean
containsPoint(point: Point): boolean
containsBounds(bounds: Bounds): boolean
intersects(other: Bounds): boolean
extend(point: Point): void
getCenter(): Point
isEmpty(): boolean
getSouthWest(): Point
getNorthEast(): Point
toSpan(): Point
}
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
declare namespace BMap {
class Point {
constructor (lng: number, lat: number)
lng: number
lat: number
equals(other: Point): boolean
}
class Pixel {
constructor (x: number, y: number)
x: number
y: number
equals(other: Pixel): boolean
}
class Size {
constructor (width: number, height: number)
width: number
height: number
equals(other: Size): boolean
}
class Bounds {
constructor (minX: number, minY: number, maxX: number, maxY: number)
constructor (sw: Point, ne: Point)
minX: number
minY: number
maxX: number
maxY: number
equals(other: Bounds): boolean
containsPoint(point: Point): boolean
containsBounds(bounds: Bounds): boolean
intersects(other: Bounds): boolean
extend(point: Point): void
getCenter(): Point
isEmpty(): boolean
getSouthWest(): Point
getNorthEast(): Point
toSpan(): Point
}
}

View File

@@ -1,132 +1,132 @@
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.maptype.d.ts" />
/// <reference path="./baidumap.overlay.d.ts" />
declare namespace BMap {
class Control {
constructor()
defaultAnchor: ControlAnchor
defaultOffset: Size
initialize(map: Map): HTMLElement
setAnchor(anchor: ControlAnchor): void
getAnchor(): ControlAnchor
setOffset(offset: Size): void
getOffset(): Size
show(): void
hide(): void
isVisible(): boolean
}
interface NavigationControlOptions {
anchor?: ControlAnchor
offset?: Size
type?: NavigationControlType
showZoomInfo?: boolean
enableGeolocation?: boolean
}
interface ScaleControlOptions {
anchor?: ControlAnchor
offset?: Size
}
interface CopyrightControlOptions {
anchor?: ControlAnchor
offset?: Size
}
type ControlAnchor = number
class OverviewMapControl extends Control {
constructor(opts: OverviewMapControlOptions)
changeView(): void
setSize(size: Size): void
getSize(): Size
onviewchanged: (event: { type: string, target: any, isOpen: boolean }) => void
onviewchanging: (event: { type: string, target: any }) => void
}
type LengthUnit = string
class MapTypeControl extends Control {
constructor(opts?: MapTypeControlOptions)
}
class NavigationControl extends Control {
constructor(opts?: NavigationControlOptions)
getType(): NavigationControlOptions
setType(type: NavigationControlType): void
}
interface OverviewMapControlOptions {
anchor?: ControlAnchor
offset?: Size
size?: Size
isOpen?: boolean
}
class CopyrightControl extends Control {
constructor(opts?: CopyrightControlOptions)
addCopyright(copyright: Copyright): void
removeCopyright(id: number): void
getCopyright(id: number): Copyright
getCopyrightCollection(): Copyright[]
}
interface MapTypeControlOptions {
type?: MapTypeControlType,
mapTypes?: MapType[]
}
type NavigationControlType = number
class ScaleControl extends Control {
constructor(opts?: ScaleControlOptions)
getUnit(): LengthUnit
setUnit(unit: LengthUnit): void
}
interface Copyright {
id?: number
content?: string
bounds?: Bounds
}
type MapTypeControlType = number
class GeolocationControl extends Control {
constructor(opts?: GeolocationControlOptions)
}
interface GeolocationControlOptions {
anchor?: ControlAnchor
offset?: Size
showAddressBar?: boolean
enableAutoLocation?: boolean
locationIcon?: Icon
}
type StatusCode = number
class PanoramaControl extends Control {
constructor()
}
}
declare const BMAP_UNIT_METRIC: BMap.LengthUnit
declare const BMAP_UNIT_IMPERIAL: BMap.LengthUnit
declare const BMAP_ANCHOR_TOP_LEFT: BMap.ControlAnchor
declare const BMAP_ANCHOR_TOP_RIGHT: BMap.ControlAnchor
declare const BMAP_ANCHOR_BOTTOM_LEFT: BMap.ControlAnchor
declare const BMAP_ANCHOR_BOTTOM_RIGHT: BMap.ControlAnchor
declare const BMAP_NAVIGATION_CONTROL_LARGE: BMap.NavigationControlType
declare const BMAP_NAVIGATION_CONTROL_SMALL: BMap.NavigationControlType
declare const BMAP_NAVIGATION_CONTROL_PAN: BMap.NavigationControlType
declare const BMAP_NAVIGATION_CONTROL_ZOOM: BMap.NavigationControlType
declare const BMAP_MAPTYPE_CONTROL_HORIZONTAL: BMap.MapTypeControlType
declare const BMAP_MAPTYPE_CONTROL_DROPDOWN: BMap.MapTypeControlType
declare const BMAP_MAPTYPE_CONTROL_MAP: BMap.MapTypeControlType
declare const BMAP_STATUS_PERMISSION_DENIED: BMap.StatusCode
declare const BMAP_STATUS_SERVICE_UNAVAILABLE: BMap.StatusCode
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.maptype.d.ts" />
/// <reference path="./baidumap.overlay.d.ts" />
declare namespace BMap {
class Control {
constructor()
defaultAnchor: ControlAnchor
defaultOffset: Size
initialize(map: Map): HTMLElement
setAnchor(anchor: ControlAnchor): void
getAnchor(): ControlAnchor
setOffset(offset: Size): void
getOffset(): Size
show(): void
hide(): void
isVisible(): boolean
}
interface NavigationControlOptions {
anchor?: ControlAnchor
offset?: Size
type?: NavigationControlType
showZoomInfo?: boolean
enableGeolocation?: boolean
}
interface ScaleControlOptions {
anchor?: ControlAnchor
offset?: Size
}
interface CopyrightControlOptions {
anchor?: ControlAnchor
offset?: Size
}
type ControlAnchor = number
class OverviewMapControl extends Control {
constructor(opts: OverviewMapControlOptions)
changeView(): void
setSize(size: Size): void
getSize(): Size
onviewchanged: (event: { type: string, target: any, isOpen: boolean }) => void
onviewchanging: (event: { type: string, target: any }) => void
}
type LengthUnit = string
class MapTypeControl extends Control {
constructor(opts?: MapTypeControlOptions)
}
class NavigationControl extends Control {
constructor(opts?: NavigationControlOptions)
getType(): NavigationControlOptions
setType(type: NavigationControlType): void
}
interface OverviewMapControlOptions {
anchor?: ControlAnchor
offset?: Size
size?: Size
isOpen?: boolean
}
class CopyrightControl extends Control {
constructor(opts?: CopyrightControlOptions)
addCopyright(copyright: Copyright): void
removeCopyright(id: number): void
getCopyright(id: number): Copyright
getCopyrightCollection(): Copyright[]
}
interface MapTypeControlOptions {
type?: MapTypeControlType,
mapTypes?: MapType[]
}
type NavigationControlType = number
class ScaleControl extends Control {
constructor(opts?: ScaleControlOptions)
getUnit(): LengthUnit
setUnit(unit: LengthUnit): void
}
interface Copyright {
id?: number
content?: string
bounds?: Bounds
}
type MapTypeControlType = number
class GeolocationControl extends Control {
constructor(opts?: GeolocationControlOptions)
}
interface GeolocationControlOptions {
anchor?: ControlAnchor
offset?: Size
showAddressBar?: boolean
enableAutoLocation?: boolean
locationIcon?: Icon
}
type StatusCode = number
class PanoramaControl extends Control {
constructor()
}
}
declare const BMAP_UNIT_METRIC: BMap.LengthUnit
declare const BMAP_UNIT_IMPERIAL: BMap.LengthUnit
declare const BMAP_ANCHOR_TOP_LEFT: BMap.ControlAnchor
declare const BMAP_ANCHOR_TOP_RIGHT: BMap.ControlAnchor
declare const BMAP_ANCHOR_BOTTOM_LEFT: BMap.ControlAnchor
declare const BMAP_ANCHOR_BOTTOM_RIGHT: BMap.ControlAnchor
declare const BMAP_NAVIGATION_CONTROL_LARGE: BMap.NavigationControlType
declare const BMAP_NAVIGATION_CONTROL_SMALL: BMap.NavigationControlType
declare const BMAP_NAVIGATION_CONTROL_PAN: BMap.NavigationControlType
declare const BMAP_NAVIGATION_CONTROL_ZOOM: BMap.NavigationControlType
declare const BMAP_MAPTYPE_CONTROL_HORIZONTAL: BMap.MapTypeControlType
declare const BMAP_MAPTYPE_CONTROL_DROPDOWN: BMap.MapTypeControlType
declare const BMAP_MAPTYPE_CONTROL_MAP: BMap.MapTypeControlType
declare const BMAP_STATUS_PERMISSION_DENIED: BMap.StatusCode
declare const BMAP_STATUS_SERVICE_UNAVAILABLE: BMap.StatusCode
declare const BMAP_STATUS_TIMEOUT: BMap.StatusCode

View File

@@ -1,154 +1,154 @@
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.maptype.d.ts" />
/// <reference path="./baidumap.panorama.d.ts" />
declare namespace BMap {
class Map {
constructor(container: string | HTMLElement, opts?: MapOptions)
enableDragging(): void
disableDragging(): void
enableScrollWheelZoom(): void
disableScrollWheelZoom(): void
enableDoubleClickZoom(): void
disableDoubleClickZoom(): void
enableKeyboard(): void
disableKeyboard(): void
enableInertialDragging(): void
disableInertialDragging(): void
enableContinuousZoom(): void
disableContinuousZoom(): void
enablePinchToZoom(): void
disablePinchToZoom(): void
enableAutoResize(): void
disableAutoResize(): void
setDefaultCursor(cursor: string): void
getDefaultCursor(): string
setDraggingCursor(cursor: string): void
getDraggingCursor(): string
setMinZoom(zoom: number): void
setMaxZoom(zoom: number): void
setMapStyle(mapStyle: MapStyle): void
setPanorama(pano: Panorama): void
disable3DBuilding(): void
getBounds(): Bounds
getCenter(): Point
getDistance(start: Point, end: Point): number
getMapType(): MapType
getSize(): Size
getViewport(view: Point[], viewportOptions?: ViewportOptions): Viewport
getZoom(): number
getPanorama(): Panorama
centerAndZoom(center: Point, zoom: number): void
panTo(center: Point, opts?: PanOptions): void
panBy(x: number, y: number, opts?: PanOptions): void
reset(): void
setCenter(center: Point | string): void
setCurrentCity(city: string): void
setMapType(mapType: MapType): void
setViewport(view: Point[], viewportOptions?: ViewportOptions): void
setZoom(zoom: number): void
highResolutionEnabled(): boolean
zoomIn(): void
zoomOut(): void
addHotspot(hotspot: Hotspot): void
removeHotspot(hotspot: Hotspot): void
clearHotspots(): void
addControl(control: Control): void
removeControl(control: Control): void
getContainer(): HTMLElement
addContextMenu(menu: ContextMenu): void
removeContextMenu(menu: ContextMenu): void
addOverlay(overlay: Overlay): void
removeOverlay(overlay: Overlay): void
clearOverlays(): void
openInfoWindow(infoWnd: InfoWindow, point: Point): void
closeInfoWindow(): void
pointToOverlayPixel(point: Point): Pixel
overlayPixelToPoint(pixel: Pixel): Point
getInfoWindow(): InfoWindow
getOverlays(): Overlay[]
getPanes(): MapPanes
addTileLayer(tileLayer: TileLayer): void
removeTileLayer(tilelayer: TileLayer): void
getTileLayer(mapType: string): TileLayer
pixelToPoint(pixel: Pixel): Point
pointToPixel(point: Point): Pixel
onclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void
ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onrightclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void
onrightdblclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void
onmaptypechange: (event: { type: string, target: any }) => void
onmousemove: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void
onmouseover: (event: { type: string, target: any }) => void
onmouseout: (event: { type: string, target: any }) => void
onmovestart: (event: { type: string, target: any }) => void
onmoving: (event: { type: string, target: any }) => void
onmoveend: (event: { type: string, target: any }) => void
onzoomstart: (event: { type: string, target: any }) => void
onzoomend: (event: { type: string, target: any }) => void
onaddoverlay: (event: { type: string, target: any }) => void
onaddcontrol: (event: { type: string, target: any }) => void
onremovecontrol: (event: { type: string, target: any }) => void
onremoveoverlay: (event: { type: string, target: any }) => void
onclearoverlays: (event: { type: string, target: any }) => void
ondragstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
ondragging: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
ondragend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onaddtilelayer: (event: { type: string, target: any }) => void
onremovetilelayer: (event: { type: string, target: any }) => void
onload: (event: { type: string, target: any, point: Point, pixel: Pixel, zoom: number }) => void
onresize: (event: { type: string, target: any, size: Size }) => void
onhotspotclick: (event: { type: string, target: any, spots: HotspotOptions }) => void
onhotspotover: (event: { type: string, target: any, spots: HotspotOptions }) => void
onhotspotout: (event: { type: string, target: any, spots: HotspotOptions }) => void
ontilesloaded: (event: { type: string, target: any }) => void
ontouchstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
ontouchmove: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
ontouchend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onlongpress: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
}
interface PanOptions {
noAnimation?: boolean
}
interface MapOptions {
minZoom?: number
maxZoom?: number
mapType?: MapType
enableHighResolution?: boolean
enableAutoResize?: boolean
enableMapClick?: boolean
}
interface Viewport {
center: Point
zoom: number
}
interface ViewportOptions {
enableAnimation?: boolean
margins?: number[]
zoomFactor?: number
delay?: number
}
type APIVersion = number
interface MapStyle {
features: any[]
style: string
}
}
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.maptype.d.ts" />
/// <reference path="./baidumap.panorama.d.ts" />
declare namespace BMap {
class Map {
constructor(container: string | HTMLElement, opts?: MapOptions)
enableDragging(): void
disableDragging(): void
enableScrollWheelZoom(): void
disableScrollWheelZoom(): void
enableDoubleClickZoom(): void
disableDoubleClickZoom(): void
enableKeyboard(): void
disableKeyboard(): void
enableInertialDragging(): void
disableInertialDragging(): void
enableContinuousZoom(): void
disableContinuousZoom(): void
enablePinchToZoom(): void
disablePinchToZoom(): void
enableAutoResize(): void
disableAutoResize(): void
setDefaultCursor(cursor: string): void
getDefaultCursor(): string
setDraggingCursor(cursor: string): void
getDraggingCursor(): string
setMinZoom(zoom: number): void
setMaxZoom(zoom: number): void
setMapStyle(mapStyle: MapStyle): void
setPanorama(pano: Panorama): void
disable3DBuilding(): void
getBounds(): Bounds
getCenter(): Point
getDistance(start: Point, end: Point): number
getMapType(): MapType
getSize(): Size
getViewport(view: Point[], viewportOptions?: ViewportOptions): Viewport
getZoom(): number
getPanorama(): Panorama
centerAndZoom(center: Point, zoom: number): void
panTo(center: Point, opts?: PanOptions): void
panBy(x: number, y: number, opts?: PanOptions): void
reset(): void
setCenter(center: Point | string): void
setCurrentCity(city: string): void
setMapType(mapType: MapType): void
setViewport(view: Point[], viewportOptions?: ViewportOptions): void
setZoom(zoom: number): void
highResolutionEnabled(): boolean
zoomIn(): void
zoomOut(): void
addHotspot(hotspot: Hotspot): void
removeHotspot(hotspot: Hotspot): void
clearHotspots(): void
addControl(control: Control): void
removeControl(control: Control): void
getContainer(): HTMLElement
addContextMenu(menu: ContextMenu): void
removeContextMenu(menu: ContextMenu): void
addOverlay(overlay: Overlay): void
removeOverlay(overlay: Overlay): void
clearOverlays(): void
openInfoWindow(infoWnd: InfoWindow, point: Point): void
closeInfoWindow(): void
pointToOverlayPixel(point: Point): Pixel
overlayPixelToPoint(pixel: Pixel): Point
getInfoWindow(): InfoWindow
getOverlays(): Overlay[]
getPanes(): MapPanes
addTileLayer(tileLayer: TileLayer): void
removeTileLayer(tilelayer: TileLayer): void
getTileLayer(mapType: string): TileLayer
pixelToPoint(pixel: Pixel): Point
pointToPixel(point: Point): Pixel
onclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void
ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onrightclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void
onrightdblclick: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void
onmaptypechange: (event: { type: string, target: any }) => void
onmousemove: (event: { type: string, target: any, point: Point, pixel: Pixel, overlay: Overlay }) => void
onmouseover: (event: { type: string, target: any }) => void
onmouseout: (event: { type: string, target: any }) => void
onmovestart: (event: { type: string, target: any }) => void
onmoving: (event: { type: string, target: any }) => void
onmoveend: (event: { type: string, target: any }) => void
onzoomstart: (event: { type: string, target: any }) => void
onzoomend: (event: { type: string, target: any }) => void
onaddoverlay: (event: { type: string, target: any }) => void
onaddcontrol: (event: { type: string, target: any }) => void
onremovecontrol: (event: { type: string, target: any }) => void
onremoveoverlay: (event: { type: string, target: any }) => void
onclearoverlays: (event: { type: string, target: any }) => void
ondragstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
ondragging: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
ondragend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onaddtilelayer: (event: { type: string, target: any }) => void
onremovetilelayer: (event: { type: string, target: any }) => void
onload: (event: { type: string, target: any, point: Point, pixel: Pixel, zoom: number }) => void
onresize: (event: { type: string, target: any, size: Size }) => void
onhotspotclick: (event: { type: string, target: any, spots: HotspotOptions }) => void
onhotspotover: (event: { type: string, target: any, spots: HotspotOptions }) => void
onhotspotout: (event: { type: string, target: any, spots: HotspotOptions }) => void
ontilesloaded: (event: { type: string, target: any }) => void
ontouchstart: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
ontouchmove: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
ontouchend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onlongpress: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
}
interface PanOptions {
noAnimation?: boolean
}
interface MapOptions {
minZoom?: number
maxZoom?: number
mapType?: MapType
enableHighResolution?: boolean
enableAutoResize?: boolean
enableMapClick?: boolean
}
interface Viewport {
center: Point
zoom: number
}
interface ViewportOptions {
enableAnimation?: boolean
margins?: number[]
zoomFactor?: number
delay?: number
}
type APIVersion = number
interface MapStyle {
features: any[]
style: string
}
}
declare const BMAP_API_VERSION: BMap.APIVersion

View File

@@ -1,82 +1,82 @@
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.control.d.ts" />
declare namespace BMap {
class TileLayer {
constructor(opts?: TileLayerOptions)
getTilesUrl(tileCoord: Pixel, zoom: number): string
getCopyright(): Copyright
isTransparentPng(): boolean
}
interface TileLayerOptions {
transparentPng?: boolean
tileUrlTemplate?: string
copyright?: Copyright
zIndex?: number
}
class TrafficLayer extends TileLayer {
constructor(opts?: TrafficLayerOptions)
}
interface TrafficLayerOptions {
predictDate?: PredictDate
}
interface PredictDate {
weekday: number
hour: number
}
class CustomLayer extends TileLayer {
constructor(opts: CustomLayerOptions)
onhotspotclick: (event: { type: string, target: any, content: any }) => void
}
interface Custompoi {
poiId: string
databoxId: string
title: string
address: string
phoneNumber: string
postcode: string
provinceCode: number
province: string
cityCode: number
city: string
districtCode: number
district: string
point: Point
tags: string[]
typeId: number
extendedData: any
}
class PanoramaCoverageLayer extends TileLayer {
constructor()
}
interface CustomLayerOptions {
databoxId?: string
geotableId?: string
q?: string
tags?: string
filter?: string
pointDensityType?: PointDensityType
}
type PointDensityType = number
}
declare const BMAP_POINT_DENSITY_HIGH: BMap.PointDensityType
declare const BMAP_POINT_DENSITY_MEDIUM: BMap.PointDensityType
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.control.d.ts" />
declare namespace BMap {
class TileLayer {
constructor(opts?: TileLayerOptions)
getTilesUrl(tileCoord: Pixel, zoom: number): string
getCopyright(): Copyright
isTransparentPng(): boolean
}
interface TileLayerOptions {
transparentPng?: boolean
tileUrlTemplate?: string
copyright?: Copyright
zIndex?: number
}
class TrafficLayer extends TileLayer {
constructor(opts?: TrafficLayerOptions)
}
interface TrafficLayerOptions {
predictDate?: PredictDate
}
interface PredictDate {
weekday: number
hour: number
}
class CustomLayer extends TileLayer {
constructor(opts: CustomLayerOptions)
onhotspotclick: (event: { type: string, target: any, content: any }) => void
}
interface Custompoi {
poiId: string
databoxId: string
title: string
address: string
phoneNumber: string
postcode: string
provinceCode: number
province: string
cityCode: number
city: string
districtCode: number
district: string
point: Point
tags: string[]
typeId: number
extendedData: any
}
class PanoramaCoverageLayer extends TileLayer {
constructor()
}
interface CustomLayerOptions {
databoxId?: string
geotableId?: string
q?: string
tags?: string
filter?: string
pointDensityType?: PointDensityType
}
type PointDensityType = number
}
declare const BMAP_POINT_DENSITY_HIGH: BMap.PointDensityType
declare const BMAP_POINT_DENSITY_MEDIUM: BMap.PointDensityType
declare const BMAP_POINT_DENSITY_LOW: BMap.PointDensityType

View File

@@ -1,51 +1,51 @@
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.maplayer.d.ts" />
declare namespace BMap {
class MapType {
constructor(name: string, layers: TileLayer | TileLayer[], opts?: MapTypeOptions)
getName(): string
getTileLayer(): TileLayer
getMinZoom(): number
getMaxZoom(): number
getProjection(): Projection
getTextColor(): string
getTips(): string
}
interface MapTypeOptions {
minZoom?: number
maxZoom?: number
errorImageUrl?: string
textColor?: number
tips?: string
}
interface Projection {
lngLatToPoint(lngLat: Point): Pixel
pointToLngLat(point: Pixel): Point
}
interface MercatorProjection extends Projection {
}
interface PerspectiveProjection extends Projection {
}
}
declare const BMAP_NORMAL_MAP: BMap.MapType
declare const BMAP_PERSPECTIVE_MAP: BMap.MapType
declare const BMAP_SATELLITE_MAP: BMap.MapType
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.maplayer.d.ts" />
declare namespace BMap {
class MapType {
constructor(name: string, layers: TileLayer | TileLayer[], opts?: MapTypeOptions)
getName(): string
getTileLayer(): TileLayer
getMinZoom(): number
getMaxZoom(): number
getProjection(): Projection
getTextColor(): string
getTips(): string
}
interface MapTypeOptions {
minZoom?: number
maxZoom?: number
errorImageUrl?: string
textColor?: number
tips?: string
}
interface Projection {
lngLatToPoint(lngLat: Point): Pixel
pointToLngLat(point: Pixel): Point
}
interface MercatorProjection extends Projection {
}
interface PerspectiveProjection extends Projection {
}
}
declare const BMAP_NORMAL_MAP: BMap.MapType
declare const BMAP_PERSPECTIVE_MAP: BMap.MapType
declare const BMAP_SATELLITE_MAP: BMap.MapType
declare const BMAP_HYBRID_MAP: BMap.MapType

View File

@@ -1,438 +1,438 @@
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.core.d.ts" />
/// <reference path="./baidumap.rightmenu.d.ts" />
declare namespace BMap {
interface Overlay {
initialize?(map: Map): HTMLElement
isVisible?(): boolean
draw?(): void
show?(): void
hide?(): void
}
type SymbolShapeType = number
interface PolylineOptions {
strokeColor?: string
strokeWeight?: number
strokeOpacity?: number
strokeStyle?: string
enableMassClear?: boolean
enableEditing?: boolean
enableClicking?: boolean
}
interface GroundOverlayOptions {
opacity?: number
imageURL?: string
displayOnMinLevel?: number
displayOnMaxLevel?: number
}
class Marker implements Overlay {
constructor(point: Point, opts?: MarkerOptions)
openInfoWindow(infoWnd: InfoWindow): void
closeInfoWindow(): void
setIcon(icon: Icon): void
getIcon(): Icon
setPosition(position: Point): void
getPosition(): Point
setOffset(offset: Size): void
getOffset(): Size
setLabel(label: Label): void
getLabel(): Label
setTitle(title: string): void
getTitle(): string
setTop(isTop: boolean): void
enableDragging(): void
disableDragging(): void
enableMassClear(): void
disableMassClear(): void
setZIndex(zIndex: number): void
getMap(): Map
addContextMenu(menu: ContextMenu): void
removeContextMenu(menu: ContextMenu): void
setAnimation(animation?: Animation): void
setRotation(rotation: number): void
getRotation(): number
setShadow(shadow: Icon): void
getShadow(): void
addEventListener(event: string, handler: Function): void
removeEventListener(event: string, handler: Function): void
onclick: (event: { type: string, target: any }) => void
ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onremove: (event: { type: string, target: any }) => void
oninfowindowclose: (event: { type: string, target: any }) => void
oninfowindowopen: (event: { type: string, target: any }) => void
ondragstart: (event: { type: string, target: any }) => void
ondragging: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
ondragend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onrightclick: (event: { type: string, target: any }) => void
}
interface SymbolOptions {
anchor?: Size
fillColor?: string
fillOpacity?: number
scale?: number
rotation?: number
strokeColor?: string
strokeOpacity?: number
strokeWeight?: number
}
class IconSequence {
constructor(symbol: Symbol, offset?: string, repeat?: string, fixedRotation?: boolean)
}
class PointCollection implements Overlay {
constructor(points: Point[], opts?: PointCollectionOption)
setPoints(points: Point[]): void
setStyles(styles: PointCollectionOption): void
clear(): void
onclick: (event: { type: string, target: any, point: Point }) => void
onmouseover: (event: { type: string, target: any, point: Point }) => void
onmouseout: (event: { type: string, target: any, point: Point }) => void
}
interface MarkerOptions {
offset?: Size
icon?: Icon
enableMassClear?: boolean
enableDragging?: boolean
enableClicking?: boolean
raiseOnDrag?: boolean
draggingCursor?: string
rotation?: number
shadow?: Icon
title?: string
}
class InfoWindow implements Overlay {
constructor(content: string | HTMLElement, opts?: InfoWindowOptions)
setWidth(width: number): void
setHeight(height: number): void
redraw(): void
setTitle(title: string | HTMLElement): void
getTitle(): string | HTMLElement
setContent(content: string | HTMLElement): void
getContent(): string | HTMLElement
getPosition(): Point
enableMaximize(): void
disableMaximize(): void
isOpen(): boolean
setMaxContent(content: string): void
maximize(): void
restore(): void
enableAutoPan(): void
disableAutoPan(): void
enableCloseOnClick(): void
disableCloseOnClick(): void
addEventListener(event: string, handler: Function): void
removeEventListener(event: string, handler: Function): void
onclose: (event: { type: string, target: any, point: Point }) => void
onopen: (event: { type: string, target: any, point: Point }) => void
onmaximize: (event: { type: string, target: any }) => void
onrestore: (event: { type: string, target: any }) => void
onclickclose: (event: { type: string, target: any }) => void
}
class Polygon implements Overlay {
constructor(points: Array<Point>, opts?: PolygonOptions)
setPath(path: Point[]): void
getPath(): Point[]
setStrokeColor(color: string): void
getStrokeColor(): string
setFillColor(color: string): void
getFillColor(): string
setStrokeOpacity(opacity: number): void
getStrokeOpacity(): number
setFillOpacity(opacity: number): void
getFillOpacity(): number
setStrokeWeight(weight: number): void
getStrokeWeight(): number
setStrokeStyle(style: string): void
getStrokeStyle(): string
getBounds(): Bounds
enableEditing(): void
disableEditing(): void
enableMassClear(): void
disableMassClear(): void
setPointAt(index: number, point: Point): void
setPositionAt(index: number, point: Point): void
getMap(): Map
addEventListener(event: string, handler: Function): void
removeEventListener(event: string, handler: Function): void
onclick: (event: { type: string, target: any }) => void
ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onremove: (event: { type: string, target: any }) => void
onlineupdate: (event: { type: string, target: any }) => void
}
interface PointCollectionOption {
shape?: ShapeType
color?: string
size?: SizeType
}
type Animation = number
interface InfoWindowOptions {
width?: number
height?: number
maxWidth?: number
offset?: Size
title?: string
enableAutoPan?: boolean
enableCloseOnClick?: boolean
enableMessage?: boolean
message?: string
}
interface PolygonOptions {
strokeColor?: string
fillColor?: string
strokeWeight?: number
strokeOpacity?: number
fillOpacity?: number
strokeStyle?: number
enableMassClear?: boolean
enableEditing?: boolean
enableClicking?: boolean
}
type ShapeType = number
class Icon implements Overlay {
constructor(url: string, size: Size, opts?: IconOptions)
anchor: Size
size: Size
imageOffset: Size
imageSize: Size
imageUrl: Size
infoWindowAnchor: Size
printImageUrl: string
setImageUrl(imageUrl: string): void
setSize(size: Size): void
setImageSize(offset: Size): void
setAnchor(anchor: Size): void
setImageOffset(offset: Size): void
setInfoWindowAnchor(anchor: Size): void
setPrintImageUrl(url: string): void
}
class Label implements Overlay {
constructor(content: string, opts?: LabelOptions)
setStyle(styles: Object): void
setContent(content: string): void
setPosition(position: Point): void
getPosition(): Point
setOffset(offset: Size): void
getOffset(): Size
setTitle(title: string): void
getTitle(): string
enableMassClear(): void
disableMassClear(): void
setZIndex(zIndex: number): void
setPosition(position: Point): void
getMap(): Map
addEventListener(event: string, handler: Function): void
removeEventListener(event: string, handler: Function): void
onclick: (event: { type: string, target: any }) => void
ondblclick: (event: { type: string, target: any }) => void
onmousedown: (event: { type: string, target: any }) => void
onmouseup: (event: { type: string, target: any }) => void
onmouseout: (event: { type: string, target: any }) => void
onmouseover: (event: { type: string, target: any }) => void
onremove: (event: { type: string, target: any }) => void
onrightclick: (event: { type: string, target: any }) => void
}
class Circle implements Overlay {
constructor(center: Point, radius: number, opts?: CircleOptions)
setCenter(center: Point): void
getCenter(): Point
setRadius(radius: number): void
getRadius(): number
getBounds(): Bounds
setStrokeColor(color: string): void
getStrokeColor(): string
setFillColor(color: string): void
getFillColor(): string
setStrokeOpacity(opacity: number): void
getStrokeOpacity(): number
setFillOpacity(opacity: number): void
getFillOpacity(): number
setStrokeWeight(weight: number): void
getStrokeWeight(): number
setStrokeStyle(style: string): void
getStrokeStyle(): string
getBounds(): Bounds
enableEditing(): void
disableEditing(): void
enableMassClear(): void
disableMassClear(): void
getMap(): Map
addEventListener(event: string, handler: Function): void
removeEventListener(event: string, handler: Function): void
onclick: (event: { type: string, target: any }) => void
ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onremove: (event: { type: string, target: any }) => void
onlineupdate: (event: { type: string, target: any }) => void
}
type SizeType = number
interface IconOptions {
anchor?: Size
imageOffset?: Size
infoWindowAnchor?: Size
printImageUrl?: string
}
interface LabelOptions {
offset?: Size
position?: Point
enableMassClear?: boolean
}
interface CircleOptions {
strokeColor?: string
fillColor?: string
strokeWeight?: number
strokeOpacity?: number
fillOpacity?: number
strokeStyle?: string
enableMassClear?: boolean
enableEditing?: boolean
enableClicking?: boolean
}
class Hotspot implements Overlay {
constructor(position: Point, opts?: HotspotOptions)
setPosition(position: Point): void
getPosition(): Point
setText(text: string): void
getText(): string
setUserData(data: any): void
getUserData(): any
}
class Symbol implements Overlay {
constructor(path: string | SymbolShapeType, opts?: SymbolOptions)
setPath(path: string | SymbolShapeType): void
setAnchor(anchor: Size): void
setRotation(rotation: number): void
setScale(scale: number): void
setStrokeWeight(strokeWeight: number): void
setStrokeColor(color: string): void
setStrokeOpacity(opacity: number): void
setFillOpacity(opacity: number): void
setFillColor(color: string): void
}
class Polyline implements Overlay {
constructor(points: Point[], opts?: PolylineOptions)
setPath(path: Point[]): void
getPath(): Point[]
setStrokeColor(color: string): void
getStrokeColor(): string
setFillColor(color: string): void
getFillColor(): string
setStrokeOpacity(opacity: number): void
getStrokeOpacity(): number
setFillOpacity(opacity: number): void
getFillOpacity(): number
setStrokeWeight(weight: number): void
getStrokeWeight(): number
setStrokeStyle(style: string): void
getStrokeStyle(): string
getBounds(): Bounds
enableEditing(): void
disableEditing(): void
enableMassClear(): void
disableMassClear(): void
setPointAt(index: number, point: Point): void
setPositionAt(index: number, point: Point): void
getMap(): Map
addEventListener(event: string, handler: Function): void
removeEventListener(event: string, handler: Function): void
onclick: (event: { type: string, target: any }) => void
ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onremove: (event: { type: string, target: any }) => void
onlineupdate: (event: { type: string, target: any }) => void
}
class GroundOverlay implements Overlay {
constructor(bounds: Bounds, opts?: GroundOverlayOptions)
setBounds(bounds: Bounds): void
getBounds(): Bounds
setOpacity(opcity: number): void
getOpacity(): number
setImageURL(url: string): void
getImageURL(): string
setDisplayOnMinLevel(level: number): void
getDisplayOnMinLevel(): number
setDispalyOnMaxLevel(level: number): void
getDispalyOnMaxLevel(): number
onclick: (event: { type: string, target: any }) => void
ondblclick: (event: { type: string, target: any }) => void
}
interface HotspotOptions {
text?: string
offsets?: number[]
userData?: any
minZoom?: number
maxZoom?: number
}
interface MapPanes {
floatPane?: HTMLElement
markerMouseTarget?: HTMLElement
floatShadow?: HTMLElement
labelPane?: HTMLElement
markerPane?: HTMLElement
markerShadow?: HTMLElement
mapPane?: HTMLElement
}
}
declare const BMap_Symbol_SHAPE_CIRCLE: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_RECTANGLE: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_RHOMBUS: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_STAR: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_BACKWARD_CLOSED_ARROW: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_FORWARD_CLOSED_ARROW: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_BACKWARD_OPEN_ARROW: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_FORWARD_OPEN_ARROW: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_POINT: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_PLANE: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_CAMERA: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_WARNING: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_SMILE: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_CLOCK: BMap.SymbolShapeType
declare const BMAP_ANIMATION_DROP: BMap.Animation
declare const BMAP_ANIMATION_BOUNCE: BMap.Animation
declare const BMAP_POINT_SHAPE_CIRCLE: BMap.ShapeType
declare const APE_STAR: BMap.ShapeType
declare const APE_SQUARE: BMap.ShapeType
declare const APE_RHOMBUS: BMap.ShapeType
declare const APE_WATERDROP: BMap.ShapeType
declare const BMAP_POINT_SIZE_TINY: BMap.SizeType
declare const BMAP_POINT_SIZE_SMALLER: BMap.SizeType
declare const BMAP_POINT_SIZE_SMALL: BMap.SizeType
declare const BMAP_POINT_SIZE_NORMAL: BMap.SizeType
declare const BMAP_POINT_SIZE_BIG: BMap.SizeType
declare const BMAP_POINT_SIZE_BIGGER: BMap.SizeType
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.core.d.ts" />
/// <reference path="./baidumap.rightmenu.d.ts" />
declare namespace BMap {
interface Overlay {
initialize?(map: Map): HTMLElement
isVisible?(): boolean
draw?(): void
show?(): void
hide?(): void
}
type SymbolShapeType = number
interface PolylineOptions {
strokeColor?: string
strokeWeight?: number
strokeOpacity?: number
strokeStyle?: string
enableMassClear?: boolean
enableEditing?: boolean
enableClicking?: boolean
}
interface GroundOverlayOptions {
opacity?: number
imageURL?: string
displayOnMinLevel?: number
displayOnMaxLevel?: number
}
class Marker implements Overlay {
constructor(point: Point, opts?: MarkerOptions)
openInfoWindow(infoWnd: InfoWindow): void
closeInfoWindow(): void
setIcon(icon: Icon): void
getIcon(): Icon
setPosition(position: Point): void
getPosition(): Point
setOffset(offset: Size): void
getOffset(): Size
setLabel(label: Label): void
getLabel(): Label
setTitle(title: string): void
getTitle(): string
setTop(isTop: boolean): void
enableDragging(): void
disableDragging(): void
enableMassClear(): void
disableMassClear(): void
setZIndex(zIndex: number): void
getMap(): Map
addContextMenu(menu: ContextMenu): void
removeContextMenu(menu: ContextMenu): void
setAnimation(animation?: Animation): void
setRotation(rotation: number): void
getRotation(): number
setShadow(shadow: Icon): void
getShadow(): void
addEventListener(event: string, handler: Function): void
removeEventListener(event: string, handler: Function): void
onclick: (event: { type: string, target: any }) => void
ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onremove: (event: { type: string, target: any }) => void
oninfowindowclose: (event: { type: string, target: any }) => void
oninfowindowopen: (event: { type: string, target: any }) => void
ondragstart: (event: { type: string, target: any }) => void
ondragging: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
ondragend: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onrightclick: (event: { type: string, target: any }) => void
}
interface SymbolOptions {
anchor?: Size
fillColor?: string
fillOpacity?: number
scale?: number
rotation?: number
strokeColor?: string
strokeOpacity?: number
strokeWeight?: number
}
class IconSequence {
constructor(symbol: Symbol, offset?: string, repeat?: string, fixedRotation?: boolean)
}
class PointCollection implements Overlay {
constructor(points: Point[], opts?: PointCollectionOption)
setPoints(points: Point[]): void
setStyles(styles: PointCollectionOption): void
clear(): void
onclick: (event: { type: string, target: any, point: Point }) => void
onmouseover: (event: { type: string, target: any, point: Point }) => void
onmouseout: (event: { type: string, target: any, point: Point }) => void
}
interface MarkerOptions {
offset?: Size
icon?: Icon
enableMassClear?: boolean
enableDragging?: boolean
enableClicking?: boolean
raiseOnDrag?: boolean
draggingCursor?: string
rotation?: number
shadow?: Icon
title?: string
}
class InfoWindow implements Overlay {
constructor(content: string | HTMLElement, opts?: InfoWindowOptions)
setWidth(width: number): void
setHeight(height: number): void
redraw(): void
setTitle(title: string | HTMLElement): void
getTitle(): string | HTMLElement
setContent(content: string | HTMLElement): void
getContent(): string | HTMLElement
getPosition(): Point
enableMaximize(): void
disableMaximize(): void
isOpen(): boolean
setMaxContent(content: string): void
maximize(): void
restore(): void
enableAutoPan(): void
disableAutoPan(): void
enableCloseOnClick(): void
disableCloseOnClick(): void
addEventListener(event: string, handler: Function): void
removeEventListener(event: string, handler: Function): void
onclose: (event: { type: string, target: any, point: Point }) => void
onopen: (event: { type: string, target: any, point: Point }) => void
onmaximize: (event: { type: string, target: any }) => void
onrestore: (event: { type: string, target: any }) => void
onclickclose: (event: { type: string, target: any }) => void
}
class Polygon implements Overlay {
constructor(points: Array<Point>, opts?: PolygonOptions)
setPath(path: Point[]): void
getPath(): Point[]
setStrokeColor(color: string): void
getStrokeColor(): string
setFillColor(color: string): void
getFillColor(): string
setStrokeOpacity(opacity: number): void
getStrokeOpacity(): number
setFillOpacity(opacity: number): void
getFillOpacity(): number
setStrokeWeight(weight: number): void
getStrokeWeight(): number
setStrokeStyle(style: string): void
getStrokeStyle(): string
getBounds(): Bounds
enableEditing(): void
disableEditing(): void
enableMassClear(): void
disableMassClear(): void
setPointAt(index: number, point: Point): void
setPositionAt(index: number, point: Point): void
getMap(): Map
addEventListener(event: string, handler: Function): void
removeEventListener(event: string, handler: Function): void
onclick: (event: { type: string, target: any }) => void
ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onremove: (event: { type: string, target: any }) => void
onlineupdate: (event: { type: string, target: any }) => void
}
interface PointCollectionOption {
shape?: ShapeType
color?: string
size?: SizeType
}
type Animation = number
interface InfoWindowOptions {
width?: number
height?: number
maxWidth?: number
offset?: Size
title?: string
enableAutoPan?: boolean
enableCloseOnClick?: boolean
enableMessage?: boolean
message?: string
}
interface PolygonOptions {
strokeColor?: string
fillColor?: string
strokeWeight?: number
strokeOpacity?: number
fillOpacity?: number
strokeStyle?: number
enableMassClear?: boolean
enableEditing?: boolean
enableClicking?: boolean
}
type ShapeType = number
class Icon implements Overlay {
constructor(url: string, size: Size, opts?: IconOptions)
anchor: Size
size: Size
imageOffset: Size
imageSize: Size
imageUrl: Size
infoWindowAnchor: Size
printImageUrl: string
setImageUrl(imageUrl: string): void
setSize(size: Size): void
setImageSize(offset: Size): void
setAnchor(anchor: Size): void
setImageOffset(offset: Size): void
setInfoWindowAnchor(anchor: Size): void
setPrintImageUrl(url: string): void
}
class Label implements Overlay {
constructor(content: string, opts?: LabelOptions)
setStyle(styles: Object): void
setContent(content: string): void
setPosition(position: Point): void
getPosition(): Point
setOffset(offset: Size): void
getOffset(): Size
setTitle(title: string): void
getTitle(): string
enableMassClear(): void
disableMassClear(): void
setZIndex(zIndex: number): void
setPosition(position: Point): void
getMap(): Map
addEventListener(event: string, handler: Function): void
removeEventListener(event: string, handler: Function): void
onclick: (event: { type: string, target: any }) => void
ondblclick: (event: { type: string, target: any }) => void
onmousedown: (event: { type: string, target: any }) => void
onmouseup: (event: { type: string, target: any }) => void
onmouseout: (event: { type: string, target: any }) => void
onmouseover: (event: { type: string, target: any }) => void
onremove: (event: { type: string, target: any }) => void
onrightclick: (event: { type: string, target: any }) => void
}
class Circle implements Overlay {
constructor(center: Point, radius: number, opts?: CircleOptions)
setCenter(center: Point): void
getCenter(): Point
setRadius(radius: number): void
getRadius(): number
getBounds(): Bounds
setStrokeColor(color: string): void
getStrokeColor(): string
setFillColor(color: string): void
getFillColor(): string
setStrokeOpacity(opacity: number): void
getStrokeOpacity(): number
setFillOpacity(opacity: number): void
getFillOpacity(): number
setStrokeWeight(weight: number): void
getStrokeWeight(): number
setStrokeStyle(style: string): void
getStrokeStyle(): string
getBounds(): Bounds
enableEditing(): void
disableEditing(): void
enableMassClear(): void
disableMassClear(): void
getMap(): Map
addEventListener(event: string, handler: Function): void
removeEventListener(event: string, handler: Function): void
onclick: (event: { type: string, target: any }) => void
ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onremove: (event: { type: string, target: any }) => void
onlineupdate: (event: { type: string, target: any }) => void
}
type SizeType = number
interface IconOptions {
anchor?: Size
imageOffset?: Size
infoWindowAnchor?: Size
printImageUrl?: string
}
interface LabelOptions {
offset?: Size
position?: Point
enableMassClear?: boolean
}
interface CircleOptions {
strokeColor?: string
fillColor?: string
strokeWeight?: number
strokeOpacity?: number
fillOpacity?: number
strokeStyle?: string
enableMassClear?: boolean
enableEditing?: boolean
enableClicking?: boolean
}
class Hotspot implements Overlay {
constructor(position: Point, opts?: HotspotOptions)
setPosition(position: Point): void
getPosition(): Point
setText(text: string): void
getText(): string
setUserData(data: any): void
getUserData(): any
}
class Symbol implements Overlay {
constructor(path: string | SymbolShapeType, opts?: SymbolOptions)
setPath(path: string | SymbolShapeType): void
setAnchor(anchor: Size): void
setRotation(rotation: number): void
setScale(scale: number): void
setStrokeWeight(strokeWeight: number): void
setStrokeColor(color: string): void
setStrokeOpacity(opacity: number): void
setFillOpacity(opacity: number): void
setFillColor(color: string): void
}
class Polyline implements Overlay {
constructor(points: Point[], opts?: PolylineOptions)
setPath(path: Point[]): void
getPath(): Point[]
setStrokeColor(color: string): void
getStrokeColor(): string
setFillColor(color: string): void
getFillColor(): string
setStrokeOpacity(opacity: number): void
getStrokeOpacity(): number
setFillOpacity(opacity: number): void
getFillOpacity(): number
setStrokeWeight(weight: number): void
getStrokeWeight(): number
setStrokeStyle(style: string): void
getStrokeStyle(): string
getBounds(): Bounds
enableEditing(): void
disableEditing(): void
enableMassClear(): void
disableMassClear(): void
setPointAt(index: number, point: Point): void
setPositionAt(index: number, point: Point): void
getMap(): Map
addEventListener(event: string, handler: Function): void
removeEventListener(event: string, handler: Function): void
onclick: (event: { type: string, target: any }) => void
ondblclick: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmousedown: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseup: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseout: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onmouseover: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onremove: (event: { type: string, target: any }) => void
onlineupdate: (event: { type: string, target: any }) => void
}
class GroundOverlay implements Overlay {
constructor(bounds: Bounds, opts?: GroundOverlayOptions)
setBounds(bounds: Bounds): void
getBounds(): Bounds
setOpacity(opcity: number): void
getOpacity(): number
setImageURL(url: string): void
getImageURL(): string
setDisplayOnMinLevel(level: number): void
getDisplayOnMinLevel(): number
setDispalyOnMaxLevel(level: number): void
getDispalyOnMaxLevel(): number
onclick: (event: { type: string, target: any }) => void
ondblclick: (event: { type: string, target: any }) => void
}
interface HotspotOptions {
text?: string
offsets?: number[]
userData?: any
minZoom?: number
maxZoom?: number
}
interface MapPanes {
floatPane?: HTMLElement
markerMouseTarget?: HTMLElement
floatShadow?: HTMLElement
labelPane?: HTMLElement
markerPane?: HTMLElement
markerShadow?: HTMLElement
mapPane?: HTMLElement
}
}
declare const BMap_Symbol_SHAPE_CIRCLE: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_RECTANGLE: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_RHOMBUS: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_STAR: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_BACKWARD_CLOSED_ARROW: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_FORWARD_CLOSED_ARROW: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_BACKWARD_OPEN_ARROW: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_FORWARD_OPEN_ARROW: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_POINT: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_PLANE: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_CAMERA: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_WARNING: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_SMILE: BMap.SymbolShapeType
declare const BMap_Symbol_SHAPE_CLOCK: BMap.SymbolShapeType
declare const BMAP_ANIMATION_DROP: BMap.Animation
declare const BMAP_ANIMATION_BOUNCE: BMap.Animation
declare const BMAP_POINT_SHAPE_CIRCLE: BMap.ShapeType
declare const APE_STAR: BMap.ShapeType
declare const APE_SQUARE: BMap.ShapeType
declare const APE_RHOMBUS: BMap.ShapeType
declare const APE_WATERDROP: BMap.ShapeType
declare const BMAP_POINT_SIZE_TINY: BMap.SizeType
declare const BMAP_POINT_SIZE_SMALLER: BMap.SizeType
declare const BMAP_POINT_SIZE_SMALL: BMap.SizeType
declare const BMAP_POINT_SIZE_NORMAL: BMap.SizeType
declare const BMAP_POINT_SIZE_BIG: BMap.SizeType
declare const BMAP_POINT_SIZE_BIGGER: BMap.SizeType
declare const BMAP_POINT_SIZE_HUGE: BMap.SizeType

View File

@@ -1,121 +1,121 @@
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.control.d.ts" />
declare namespace BMap {
class Panorama {
constructor(container: string | HTMLElement, opts?: PanoramaOptions)
getLinks(): PanoramaLink[]
getId(): string
getPosition(): Point
getPov(): PanoramaPov
getZoom(): number
setId(id: string): void
setPosition(position: Point): void
setPov(pov: PanoramaPov): void
setZoom(zoom: number): void
enableScrollWheelZoom(): void
disableScrollWheelZoom(): void
show(): void
hide(): void
addOverlay(overlay: PanoramaLabel): void
removeOverlay(overlay: PanoramaLabel): void
getSceneType(): PanoramaSceneType
setOptions(opts?: PanoramaOptions): void
setPanoramaPOIType(): PanoramaPOIType
onposition_changed: () => void
onlinks_changed: () => void
onpov_changed: () => void
onzoom_changed: () => void
onscene_type_changed: () => void
}
interface PanoramaOptions {
navigationControl?: boolean
linksControl?: boolean
indoorSceneSwitchControl?: boolean
albumsControl?: boolean
albumsControlOptions?: AlbumsControlOptions
}
interface PanoramaLink {
description: string
heading: string
id: string
}
interface PanoramaPov {
heading: number
pitch: number
}
class PanoramaService {
constructor()
getPanoramaById(id: string, callback: (data: PanoramaData) => void): void
getPanoramaByLocation(point: Point, radius?: number, callback?: (data: PanoramaData) => void): void
}
interface PanoramaData {
id: string
description: string
links: PanoramaLink[]
position: Point
tiles: PanoramaTileData
}
interface PanoramaTileData {
centerHeading: number
tileSize: Size
worldSize: Size
}
class PanoramaLabel {
constructor(content: string, opts?: PanoramaLabelOptions)
setPosition(position: Point): void
getPosition(): Point
getPov(): PanoramaPov
setContent(content: string): void
getContent(): string
show(): void
hide(): void
setAltitude(altitude: number): void
getAltitude(): number
addEventListener(event: string, handler: Function): void
removeEventListener(event: string, handler: Function): void
onclick: (event: { type: string, target: any }) => void
onmouseover: (event: { type: string, target: any }) => void
onmouseout: (event: { type: string, target: any }) => void
onremove: (event: { type: string, target: any }) => void
}
interface PanoramaLabelOptions {
position?: Point
altitude?: number
}
interface AlbumsControlOptions {
anchor?: ControlAnchor
offset?: Size
maxWidth?: number | string
imageHeight?: number
}
type PanoramaSceneType = string
type PanoramaPOIType = string
}
declare const BMAP_PANORAMA_INDOOR_SCENE: string
declare const BMAP_PANORAMA_STREET_SCENE: string
declare const BMAP_PANORAMA_POI_HOTEL: string
declare const BMAP_PANORAMA_POI_CATERING: string
declare const BMAP_PANORAMA_POI_MOVIE: string
declare const BMAP_PANORAMA_POI_TRANSIT: string
declare const BMAP_PANORAMA_POI_INDOOR_SCENE: string
declare const BMAP_PANORAMA_POI_NONE: string
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.control.d.ts" />
declare namespace BMap {
class Panorama {
constructor(container: string | HTMLElement, opts?: PanoramaOptions)
getLinks(): PanoramaLink[]
getId(): string
getPosition(): Point
getPov(): PanoramaPov
getZoom(): number
setId(id: string): void
setPosition(position: Point): void
setPov(pov: PanoramaPov): void
setZoom(zoom: number): void
enableScrollWheelZoom(): void
disableScrollWheelZoom(): void
show(): void
hide(): void
addOverlay(overlay: PanoramaLabel): void
removeOverlay(overlay: PanoramaLabel): void
getSceneType(): PanoramaSceneType
setOptions(opts?: PanoramaOptions): void
setPanoramaPOIType(): PanoramaPOIType
onposition_changed: () => void
onlinks_changed: () => void
onpov_changed: () => void
onzoom_changed: () => void
onscene_type_changed: () => void
}
interface PanoramaOptions {
navigationControl?: boolean
linksControl?: boolean
indoorSceneSwitchControl?: boolean
albumsControl?: boolean
albumsControlOptions?: AlbumsControlOptions
}
interface PanoramaLink {
description: string
heading: string
id: string
}
interface PanoramaPov {
heading: number
pitch: number
}
class PanoramaService {
constructor()
getPanoramaById(id: string, callback: (data: PanoramaData) => void): void
getPanoramaByLocation(point: Point, radius?: number, callback?: (data: PanoramaData) => void): void
}
interface PanoramaData {
id: string
description: string
links: PanoramaLink[]
position: Point
tiles: PanoramaTileData
}
interface PanoramaTileData {
centerHeading: number
tileSize: Size
worldSize: Size
}
class PanoramaLabel {
constructor(content: string, opts?: PanoramaLabelOptions)
setPosition(position: Point): void
getPosition(): Point
getPov(): PanoramaPov
setContent(content: string): void
getContent(): string
show(): void
hide(): void
setAltitude(altitude: number): void
getAltitude(): number
addEventListener(event: string, handler: Function): void
removeEventListener(event: string, handler: Function): void
onclick: (event: { type: string, target: any }) => void
onmouseover: (event: { type: string, target: any }) => void
onmouseout: (event: { type: string, target: any }) => void
onremove: (event: { type: string, target: any }) => void
}
interface PanoramaLabelOptions {
position?: Point
altitude?: number
}
interface AlbumsControlOptions {
anchor?: ControlAnchor
offset?: Size
maxWidth?: number | string
imageHeight?: number
}
type PanoramaSceneType = string
type PanoramaPOIType = string
}
declare const BMAP_PANORAMA_INDOOR_SCENE: string
declare const BMAP_PANORAMA_STREET_SCENE: string
declare const BMAP_PANORAMA_POI_HOTEL: string
declare const BMAP_PANORAMA_POI_CATERING: string
declare const BMAP_PANORAMA_POI_MOVIE: string
declare const BMAP_PANORAMA_POI_TRANSIT: string
declare const BMAP_PANORAMA_POI_INDOOR_SCENE: string
declare const BMAP_PANORAMA_POI_NONE: string

View File

@@ -1,47 +1,47 @@
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
declare namespace BMap {
type ContextMenuIcon = string
interface MenuItemOptions {
width?: number
id?: string
iconUrl?: string
}
class MenuItem {
constructor(text: string, callback: (point: Point) => void, opts?: MenuItemOptions)
setText(text: string): void
setIcon(iconUrl: string): void
enable(): void
disable(): void
}
class ContextMenu {
constructor()
addItem(item: MenuItem): void
getItem(index: number): MenuItem
removeItem(item: MenuItem): void
addSeparator(): void
removeSeparator(index: number): void
onopen: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onclose: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
}
}
declare const BMAP_CONTEXT_MENU_ICON_ZOOMIN: string
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
declare namespace BMap {
type ContextMenuIcon = string
interface MenuItemOptions {
width?: number
id?: string
iconUrl?: string
}
class MenuItem {
constructor(text: string, callback: (point: Point) => void, opts?: MenuItemOptions)
setText(text: string): void
setIcon(iconUrl: string): void
enable(): void
disable(): void
}
class ContextMenu {
constructor()
addItem(item: MenuItem): void
getItem(index: number): MenuItem
removeItem(item: MenuItem): void
addSeparator(): void
removeSeparator(index: number): void
onopen: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
onclose: (event: { type: string, target: any, point: Point, pixel: Pixel }) => void
}
}
declare const BMAP_CONTEXT_MENU_ICON_ZOOMIN: string
declare const BMAP_CONTEXT_MENU_ICON_ZOOMOUT: string

View File

@@ -1,432 +1,432 @@
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.core.d.ts" />
declare namespace BMap {
class LocalSearch {
constructor(location: Map | Point | string, opts?: LocalSearchOptions)
search(keyword: string | Array<string>, option?: Object): void
searchInBounds(keyword: string | Array<string>, bounds: Bounds, option?: Object): void
searchNearby(keyword: string | Array<string>, center: LocalResultPoi | string | Point, radius: number, option?: Object): void
getResults(): LocalResult | LocalResult[]
clearResults(): void
gotoPage(page: number): void
enableAutoViewport(): void
disableAutoViewport(): void
enableFirstResultSelection(): void
disableFirstResultSelection(): void
setLocation(location: Map | Point | string): void
setPageCapacity(capacity: number): void
getPageCapacity(): number
setSearchCompleteCallback(callback: (results: LocalResult | LocalResult[]) => void): void
setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void
setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void
setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void
getStatus(): ServiceStatusCode
}
type LineType = number
interface WalkingRouteResult {
city: string
getStart(): LocalResultPoi
getEnd(): LocalResultPoi
getNumPlans(): number
getPlan(i: number): RoutePlan
}
class BusLineSearch {
constructor(location: Map | Point | string, opts?: BusLineSearchOptions)
getBusList(keyword: string): void
getBusLine(busLstItem: BusListItem): void
clearResults(): void
enableAutoViewport(): void
disableAutoViewport(): void
setLocation(location: Map | Point | string): void
getStatus(): ServiceStatusCode
toString(): string
setGetBusListCompleteCallback(callback: (rs: BusListResult) => void): void
setGetBusLineCompleteCallback(callback: (rs: BusLine) => void): void
setBusListHtmlSetCallback(callback: (container: HTMLElement) => void): void
setBusLineHtmlSetCallback(callback: (container: HTMLElement) => void): void
setPolylinesSetCallback(callback: (ply: Polyline) => void): void
setMarkersSetCallback(callback: (markers: Marker[]) => void): void
}
interface LocalSearchOptions {
renderOptions?: RenderOptions
onMarkersSet?: (pois: LocalResultPoi[]) => void
onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void
onResultsHtmlSet?: (container: HTMLElement) => void
pageCapacity?: number
onSearchComplete?: (results: LocalResult[]) => void
}
class DrivingRoute {
constructor(location: Map | Point | string, opts?: DrivingRouteOptions)
search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi, opts?: Object): void
getResults(): DrivingRouteResult
clearResults(): void
enableAutoViewport(): void
disableAutoViewport(): void
setLocation(location: Map | Point | string): void
setPolicy(policy: DrivingPolicy): void
setSearchCompleteCallback(callback: (results: DrivingRouteResult) => void): void
setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void
setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void
setPolylinesSetCallback(callback: (routes: Route[]) => void): void
setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void
getStatus(): ServiceStatusCode
toString(): string
}
class Geocoder {
constructor()
getPoint(address: string, callback: (point: Point) => void, city: string): void
getLocation(point: Point, callback: (result: GeocoderResult) => void, opts?: LocationOptions): void
}
interface BusLineSearchOptions {
renderOptions?: RenderOptions
onGetBusListComplete?: (rs: BusListResult) => void
onGetBusLineComplete?: (rs: BusLine) => void
onBusListHtmlSet?: (container: HTMLElement) => void
onBusLineHtmlSet?: (container: HTMLElement) => void
onPolylinesSet?: (ply: Polyline) => void
onMarkersSet?: (sts: Marker[]) => void
}
interface CustomData {
geotableId: number
tags: string
filter: string
}
interface DrivingRouteOptions {
renderOptions?: RenderOptions
policy?: DrivingPolicy
onSearchComplete?: (results: DrivingRouteResult) => void
onMarkersSet?: (pois: LocalResultPoi[]) => void
onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void
onPolylinesSet?: (routes: Route[]) => void
onResultsHtmlSet?: (container: HTMLElement) => void
}
interface GeocoderResult {
point: Point
address: string
addressComponents: AddressComponent
surroundingPoi: LocalResultPoi[]
business: string
}
interface BusListResult {
keyword: string
city: string
moreResultsUrl: string
getNumBusList(): number
getBusListItem(i: number): BusListItem
}
interface RenderOptions {
map: Map
panel?: string | HTMLElement
selectFirstResult?: boolean
autoViewport?: boolean
highlightMode?: HighlightModes
}
type DrivingPolicy = number
interface AddressComponent {
streetNumber: string
street: string
district: string
city: string
province: string
}
interface BusLine {
name: string
startTime: string
endTime: string
company: string
getNumBusStations(): string
getBusStation(i: number): BusStation
getPath(): Point[]
getPolyline(): Polyline
}
interface LocalResult {
keyword: string
center: LocalResultPoi
radius: number
bounds: Bounds
city: string
moreResultsUrl: string
province: string
suggestions: string[]
getPoi(i: number): LocalResultPoi
getCurrentNumPois(): number
getNumPois(): number
getNumPages(): number
getPageIndex(): number
getCityList(): any[]
}
interface DrivingRouteResult {
policy: DrivingPolicy
city: string
moreResultsUrl: string
taxiFare: TaxiFare
getStart(): LocalResultPoi
getEnd(): LocalResultPoi
getNumPlans(): number
getPlan(i: number): RoutePlan
}
interface LocationOptions {
poiRadius?: number
numPois?: number
}
interface BusListItem {
name: string
}
interface LocalResultPoi {
title: string
point: Point
url: string
address: string
city: string
phoneNumber: string
postcode: string
type: PoiType
isAccurate: boolean
province: string
tags: string[]
detailUrl: string
}
interface TaxiFare {
day: TaxiFareDetail
night: TaxiFareDetail
distance: number
remark: string
}
class LocalCity {
constructor(opts?: LocalCityOptions)
get(callback: (result: LocalCityResult) => void): void
}
interface BusStation {
name: string
position: Point
}
type PoiType = number
interface TaxiFareDetail {
initialFare: number
unitFare: number
totalFare: number
}
interface LocalCityOptions {
renderOptions?: RenderOptions
}
class Autocomplete {
constructor(opts?: AutocompleteOptions)
show(): void
hide(): void
setTypes(types: string[]): void
setLocation(location: string | Map | Point): void
search(keywords: string): void
getResults(): AutocompleteResult
setInputValue(keyword: string): void
dispose(): void
onconfirm: (event: { type: string, target: any, item: any }) => void
onhighlight: (event: { type: string, target: any, fromitem: any, toitem: any }) => void
}
class TransitRoute {
constructor(location: Map | Point | string, opts?: TransitRouteOptions)
search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi): void
getResults(): TransitRouteResult
clearResults(): void
enableAutoViewport(): void
disableAutoViewport(): void
setPageCapacity(capacity: number): void
setLocation(location: Map | Point | string): void
setPolicy(policy: TransitPolicy): void
setSearchCompleteCallback(callback: (results: TransitRouteResult) => void): void
setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void
setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void
setPolylinesSetCallback(callback: (lines: Line[], routes: Route[]) => void): void
setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void
getStatus(): ServiceStatusCode
toString(): string
}
interface RoutePlan {
getNumRoutes(): number
getRoute(i: number): Route
getDistance(format?: boolean): string | number
getDuration(format?: boolean): string | number
getDragPois(): LocalResultPoi[]
}
interface LocalCityResult {
center: Point
level: number
name: string
}
interface AutocompleteOptions {
location?: string | Map | Point
types?: string[]
onSearchComplete?: (result: AutocompleteResult) => void
input?: string | HTMLElement
}
interface TransitRouteOptions {
renderOptions?: RenderOptions
policy?: TransitPolicy
pageCapacity?: number
onSearchComplete?: (result: TransitRouteResult) => void
onMarkersSet?: (pois: LocalResultPoi[], transfers: LocalResultPoi[]) => void
onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void
onPolylinesSet?: (lines: Line[]) => void
onResultsHtmlSet?: (container: HTMLElement) => void
}
interface Route {
getNumRoutes(): number
getStep(i: number): Step
getDistance(format?: boolean): string | number
getIndex(): number
getPolyline(): Polyline
getPoints(): Point[]
getPath(): Point[]
getRouteType(): RouteType
}
class TrafficControl {
constructor()
setPanelOffset(offset: Size): void
show(): void
hide(): void
}
interface AutocompleteResultPoi {
province: string
City: string//wtf
district: string
street: string
streetNumber: string
business: string
}
type TransitPolicy = number
type RouteType = number
class Geolocation {
constructor()
getCurrentPosition(callback: (result: GeolocationResult) => void, opts?: PositionOptions): void
getStatus(): ServiceStatusCode
}
interface AutocompleteResult {
keyword: string
getPoi(i: number): AutocompleteResultPoi
getNumPois(): number
}
interface TransitRouteResult {
policy: TransitPolicy
city: string
moreResultsUrl: string
getStart(): LocalResultPoi
getEnd(): LocalResultPoi
getNumPlans(): number
getPlan(i: number): TransitRoutePlan
}
interface Step {
getPoint(): Point
getPosition(): Point
getIndex(): number
getDescription(includeHtml: boolean): string
getDistance(format?: boolean): string | number
}
interface GeolocationResult {
point: Point
accuracy: number
}
class Boundary {
constructor()
get(name: string, callback: (result: string[]) => void): void
}
interface TransitRoutePlan {
getNumLines(): number
getLine(i: number): Line
getNumRoutes(): number
getRoute(i: number): Route
getDistance(format?: boolean): string | number
getDuration(format?: boolean): string | number
getDescription(includeHtml: boolean): string
}
class WalkingRoute {
constructor(location: Map | Point | string, opts?: WalkingRouteOptions)
search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi): void
getResults(): WalkingRouteResult
clearResults(): void
enableAutoViewport(): void
disableAutoViewport(): void
setLocation(location: Map | Point | string): void
setSearchCompleteCallback(callback: (result: WalkingRouteResult) => void): void
setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void
setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void
setPolylinesSetCallback(callback: (routes: Route[]) => void): void
setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void
getStatus(): ServiceStatusCode
toString(): string
}
interface PositionOptions {
enableHighAccuracy?: boolean
timeout?: number
maximumAge?: number
}
interface Line {
title: string
type: LineType
getNumViaStops(): number
getGetOnStop(): LocalResultPoi
getGetOffStop(): LocalResultPoi
getPoints(): Point[]
getPath(): Point[]
getPolyline(): Polyline
getDistance(format?: boolean): string | number
}
interface WalkingRouteOptions {
renderOptions?: RenderOptions,
onSearchComplete?: (result: WalkingRouteResult) => void,
onMarkersSet?: (pois: LocalResultPoi[]) => void,
onPolylinesSet?: (routes: Route[]) => void,
onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void,
onResultsHtmlSet?: (container: HTMLElement) => void
}
type HighlightModes = number
type ServiceStatusCode = number
}
declare const BMAP_LINE_TYPE_BUS: BMap.LineType
declare const BMAP_LINE_TYPE_SUBWAY: BMap.LineType
declare const BMAP_LINE_TYPE_FERRY: BMap.LineType
declare const BMAP_DRIVING_POLICY_LEAST_TIME: BMap.DrivingPolicy
declare const BMAP_DRIVING_POLICY_LEAST_DISTANCE: BMap.DrivingPolicy
declare const BMAP_DRIVING_POLICY_AVOID_HIGHWAYS: BMap.DrivingPolicy
declare const BMAP_POI_TYPE_NORMAL: BMap.PoiType
declare const BMAP_POI_TYPE_BUSSTOP: BMap.PoiType
declare const BMAP_POI_TYPE_SUBSTOP: BMap.PoiType
declare const BMAP_TRANSIT_POLICY_LEAST_TIME: BMap.TransitPolicy
declare const BMAP_TRANSIT_POLICY_LEAST_TRANSFER: BMap.TransitPolicy
declare const BMAP_TRANSIT_POLICY_LEAST_WALKING: BMap.TransitPolicy
declare const BMAP_TRANSIT_POLICY_AVOID_SUBWAYS: BMap.TransitPolicy
declare const BMAP_ROUTE_TYPE_DRIVING: BMap.RouteType
declare const BMAP_ROUTE_TYPE_WALKING: BMap.RouteType
declare const BMAP_HIGHLIGHT_STEP: BMap.HighlightModes
declare const BMAP_HIGHLIGHT_ROUTE: BMap.HighlightModes
declare const BMAP_STATUS_SUCCESS: BMap.ServiceStatusCode
declare const BMAP_STATUS_CITY_LIST: BMap.ServiceStatusCode
declare const BMAP_STATUS_UNKNOWN_LOCATION: BMap.ServiceStatusCode
declare const BMAP_STATUS_UNKNOWN_ROUTE: BMap.ServiceStatusCode
declare const BMAP_STATUS_INVALID_KEY: BMap.ServiceStatusCode
declare const BMAP_STATUS_INVALID_REQUEST: BMap.ServiceStatusCode
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.core.d.ts" />
declare namespace BMap {
class LocalSearch {
constructor(location: Map | Point | string, opts?: LocalSearchOptions)
search(keyword: string | Array<string>, option?: Object): void
searchInBounds(keyword: string | Array<string>, bounds: Bounds, option?: Object): void
searchNearby(keyword: string | Array<string>, center: LocalResultPoi | string | Point, radius: number, option?: Object): void
getResults(): LocalResult | LocalResult[]
clearResults(): void
gotoPage(page: number): void
enableAutoViewport(): void
disableAutoViewport(): void
enableFirstResultSelection(): void
disableFirstResultSelection(): void
setLocation(location: Map | Point | string): void
setPageCapacity(capacity: number): void
getPageCapacity(): number
setSearchCompleteCallback(callback: (results: LocalResult | LocalResult[]) => void): void
setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void
setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void
setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void
getStatus(): ServiceStatusCode
}
type LineType = number
interface WalkingRouteResult {
city: string
getStart(): LocalResultPoi
getEnd(): LocalResultPoi
getNumPlans(): number
getPlan(i: number): RoutePlan
}
class BusLineSearch {
constructor(location: Map | Point | string, opts?: BusLineSearchOptions)
getBusList(keyword: string): void
getBusLine(busLstItem: BusListItem): void
clearResults(): void
enableAutoViewport(): void
disableAutoViewport(): void
setLocation(location: Map | Point | string): void
getStatus(): ServiceStatusCode
toString(): string
setGetBusListCompleteCallback(callback: (rs: BusListResult) => void): void
setGetBusLineCompleteCallback(callback: (rs: BusLine) => void): void
setBusListHtmlSetCallback(callback: (container: HTMLElement) => void): void
setBusLineHtmlSetCallback(callback: (container: HTMLElement) => void): void
setPolylinesSetCallback(callback: (ply: Polyline) => void): void
setMarkersSetCallback(callback: (markers: Marker[]) => void): void
}
interface LocalSearchOptions {
renderOptions?: RenderOptions
onMarkersSet?: (pois: LocalResultPoi[]) => void
onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void
onResultsHtmlSet?: (container: HTMLElement) => void
pageCapacity?: number
onSearchComplete?: (results: LocalResult[]) => void
}
class DrivingRoute {
constructor(location: Map | Point | string, opts?: DrivingRouteOptions)
search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi, opts?: Object): void
getResults(): DrivingRouteResult
clearResults(): void
enableAutoViewport(): void
disableAutoViewport(): void
setLocation(location: Map | Point | string): void
setPolicy(policy: DrivingPolicy): void
setSearchCompleteCallback(callback: (results: DrivingRouteResult) => void): void
setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void
setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void
setPolylinesSetCallback(callback: (routes: Route[]) => void): void
setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void
getStatus(): ServiceStatusCode
toString(): string
}
class Geocoder {
constructor()
getPoint(address: string, callback: (point: Point) => void, city: string): void
getLocation(point: Point, callback: (result: GeocoderResult) => void, opts?: LocationOptions): void
}
interface BusLineSearchOptions {
renderOptions?: RenderOptions
onGetBusListComplete?: (rs: BusListResult) => void
onGetBusLineComplete?: (rs: BusLine) => void
onBusListHtmlSet?: (container: HTMLElement) => void
onBusLineHtmlSet?: (container: HTMLElement) => void
onPolylinesSet?: (ply: Polyline) => void
onMarkersSet?: (sts: Marker[]) => void
}
interface CustomData {
geotableId: number
tags: string
filter: string
}
interface DrivingRouteOptions {
renderOptions?: RenderOptions
policy?: DrivingPolicy
onSearchComplete?: (results: DrivingRouteResult) => void
onMarkersSet?: (pois: LocalResultPoi[]) => void
onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void
onPolylinesSet?: (routes: Route[]) => void
onResultsHtmlSet?: (container: HTMLElement) => void
}
interface GeocoderResult {
point: Point
address: string
addressComponents: AddressComponent
surroundingPoi: LocalResultPoi[]
business: string
}
interface BusListResult {
keyword: string
city: string
moreResultsUrl: string
getNumBusList(): number
getBusListItem(i: number): BusListItem
}
interface RenderOptions {
map: Map
panel?: string | HTMLElement
selectFirstResult?: boolean
autoViewport?: boolean
highlightMode?: HighlightModes
}
type DrivingPolicy = number
interface AddressComponent {
streetNumber: string
street: string
district: string
city: string
province: string
}
interface BusLine {
name: string
startTime: string
endTime: string
company: string
getNumBusStations(): string
getBusStation(i: number): BusStation
getPath(): Point[]
getPolyline(): Polyline
}
interface LocalResult {
keyword: string
center: LocalResultPoi
radius: number
bounds: Bounds
city: string
moreResultsUrl: string
province: string
suggestions: string[]
getPoi(i: number): LocalResultPoi
getCurrentNumPois(): number
getNumPois(): number
getNumPages(): number
getPageIndex(): number
getCityList(): any[]
}
interface DrivingRouteResult {
policy: DrivingPolicy
city: string
moreResultsUrl: string
taxiFare: TaxiFare
getStart(): LocalResultPoi
getEnd(): LocalResultPoi
getNumPlans(): number
getPlan(i: number): RoutePlan
}
interface LocationOptions {
poiRadius?: number
numPois?: number
}
interface BusListItem {
name: string
}
interface LocalResultPoi {
title: string
point: Point
url: string
address: string
city: string
phoneNumber: string
postcode: string
type: PoiType
isAccurate: boolean
province: string
tags: string[]
detailUrl: string
}
interface TaxiFare {
day: TaxiFareDetail
night: TaxiFareDetail
distance: number
remark: string
}
class LocalCity {
constructor(opts?: LocalCityOptions)
get(callback: (result: LocalCityResult) => void): void
}
interface BusStation {
name: string
position: Point
}
type PoiType = number
interface TaxiFareDetail {
initialFare: number
unitFare: number
totalFare: number
}
interface LocalCityOptions {
renderOptions?: RenderOptions
}
class Autocomplete {
constructor(opts?: AutocompleteOptions)
show(): void
hide(): void
setTypes(types: string[]): void
setLocation(location: string | Map | Point): void
search(keywords: string): void
getResults(): AutocompleteResult
setInputValue(keyword: string): void
dispose(): void
onconfirm: (event: { type: string, target: any, item: any }) => void
onhighlight: (event: { type: string, target: any, fromitem: any, toitem: any }) => void
}
class TransitRoute {
constructor(location: Map | Point | string, opts?: TransitRouteOptions)
search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi): void
getResults(): TransitRouteResult
clearResults(): void
enableAutoViewport(): void
disableAutoViewport(): void
setPageCapacity(capacity: number): void
setLocation(location: Map | Point | string): void
setPolicy(policy: TransitPolicy): void
setSearchCompleteCallback(callback: (results: TransitRouteResult) => void): void
setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void
setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void
setPolylinesSetCallback(callback: (lines: Line[], routes: Route[]) => void): void
setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void
getStatus(): ServiceStatusCode
toString(): string
}
interface RoutePlan {
getNumRoutes(): number
getRoute(i: number): Route
getDistance(format?: boolean): string | number
getDuration(format?: boolean): string | number
getDragPois(): LocalResultPoi[]
}
interface LocalCityResult {
center: Point
level: number
name: string
}
interface AutocompleteOptions {
location?: string | Map | Point
types?: string[]
onSearchComplete?: (result: AutocompleteResult) => void
input?: string | HTMLElement
}
interface TransitRouteOptions {
renderOptions?: RenderOptions
policy?: TransitPolicy
pageCapacity?: number
onSearchComplete?: (result: TransitRouteResult) => void
onMarkersSet?: (pois: LocalResultPoi[], transfers: LocalResultPoi[]) => void
onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void
onPolylinesSet?: (lines: Line[]) => void
onResultsHtmlSet?: (container: HTMLElement) => void
}
interface Route {
getNumRoutes(): number
getStep(i: number): Step
getDistance(format?: boolean): string | number
getIndex(): number
getPolyline(): Polyline
getPoints(): Point[]
getPath(): Point[]
getRouteType(): RouteType
}
class TrafficControl {
constructor()
setPanelOffset(offset: Size): void
show(): void
hide(): void
}
interface AutocompleteResultPoi {
province: string
City: string//wtf
district: string
street: string
streetNumber: string
business: string
}
type TransitPolicy = number
type RouteType = number
class Geolocation {
constructor()
getCurrentPosition(callback: (result: GeolocationResult) => void, opts?: PositionOptions): void
getStatus(): ServiceStatusCode
}
interface AutocompleteResult {
keyword: string
getPoi(i: number): AutocompleteResultPoi
getNumPois(): number
}
interface TransitRouteResult {
policy: TransitPolicy
city: string
moreResultsUrl: string
getStart(): LocalResultPoi
getEnd(): LocalResultPoi
getNumPlans(): number
getPlan(i: number): TransitRoutePlan
}
interface Step {
getPoint(): Point
getPosition(): Point
getIndex(): number
getDescription(includeHtml: boolean): string
getDistance(format?: boolean): string | number
}
interface GeolocationResult {
point: Point
accuracy: number
}
class Boundary {
constructor()
get(name: string, callback: (result: string[]) => void): void
}
interface TransitRoutePlan {
getNumLines(): number
getLine(i: number): Line
getNumRoutes(): number
getRoute(i: number): Route
getDistance(format?: boolean): string | number
getDuration(format?: boolean): string | number
getDescription(includeHtml: boolean): string
}
class WalkingRoute {
constructor(location: Map | Point | string, opts?: WalkingRouteOptions)
search(start: string | Point | LocalResultPoi, end: string | Point | LocalResultPoi): void
getResults(): WalkingRouteResult
clearResults(): void
enableAutoViewport(): void
disableAutoViewport(): void
setLocation(location: Map | Point | string): void
setSearchCompleteCallback(callback: (result: WalkingRouteResult) => void): void
setMarkersSetCallback(callback: (pois: LocalResultPoi[]) => void): void
setInfoHtmlSetCallback(callback: (poi: LocalResultPoi, html: HTMLElement) => void): void
setPolylinesSetCallback(callback: (routes: Route[]) => void): void
setResultsHtmlSetCallback(callback: (container: HTMLElement) => void): void
getStatus(): ServiceStatusCode
toString(): string
}
interface PositionOptions {
enableHighAccuracy?: boolean
timeout?: number
maximumAge?: number
}
interface Line {
title: string
type: LineType
getNumViaStops(): number
getGetOnStop(): LocalResultPoi
getGetOffStop(): LocalResultPoi
getPoints(): Point[]
getPath(): Point[]
getPolyline(): Polyline
getDistance(format?: boolean): string | number
}
interface WalkingRouteOptions {
renderOptions?: RenderOptions,
onSearchComplete?: (result: WalkingRouteResult) => void,
onMarkersSet?: (pois: LocalResultPoi[]) => void,
onPolylinesSet?: (routes: Route[]) => void,
onInfoHtmlSet?: (poi: LocalResultPoi, html: HTMLElement) => void,
onResultsHtmlSet?: (container: HTMLElement) => void
}
type HighlightModes = number
type ServiceStatusCode = number
}
declare const BMAP_LINE_TYPE_BUS: BMap.LineType
declare const BMAP_LINE_TYPE_SUBWAY: BMap.LineType
declare const BMAP_LINE_TYPE_FERRY: BMap.LineType
declare const BMAP_DRIVING_POLICY_LEAST_TIME: BMap.DrivingPolicy
declare const BMAP_DRIVING_POLICY_LEAST_DISTANCE: BMap.DrivingPolicy
declare const BMAP_DRIVING_POLICY_AVOID_HIGHWAYS: BMap.DrivingPolicy
declare const BMAP_POI_TYPE_NORMAL: BMap.PoiType
declare const BMAP_POI_TYPE_BUSSTOP: BMap.PoiType
declare const BMAP_POI_TYPE_SUBSTOP: BMap.PoiType
declare const BMAP_TRANSIT_POLICY_LEAST_TIME: BMap.TransitPolicy
declare const BMAP_TRANSIT_POLICY_LEAST_TRANSFER: BMap.TransitPolicy
declare const BMAP_TRANSIT_POLICY_LEAST_WALKING: BMap.TransitPolicy
declare const BMAP_TRANSIT_POLICY_AVOID_SUBWAYS: BMap.TransitPolicy
declare const BMAP_ROUTE_TYPE_DRIVING: BMap.RouteType
declare const BMAP_ROUTE_TYPE_WALKING: BMap.RouteType
declare const BMAP_HIGHLIGHT_STEP: BMap.HighlightModes
declare const BMAP_HIGHLIGHT_ROUTE: BMap.HighlightModes
declare const BMAP_STATUS_SUCCESS: BMap.ServiceStatusCode
declare const BMAP_STATUS_CITY_LIST: BMap.ServiceStatusCode
declare const BMAP_STATUS_UNKNOWN_LOCATION: BMap.ServiceStatusCode
declare const BMAP_STATUS_UNKNOWN_ROUTE: BMap.ServiceStatusCode
declare const BMAP_STATUS_INVALID_KEY: BMap.ServiceStatusCode
declare const BMAP_STATUS_INVALID_REQUEST: BMap.ServiceStatusCode

View File

@@ -1,61 +1,61 @@
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.core.d.ts" />
/// <reference path="./baidumap.overlay.d.ts" />
declare namespace BMap {
class PushpinTool {
constructor(map: Map, opts?: PushpinToolOptions)
open(): boolean
close(): boolean
setIcon(icon: Icon): Icon
getIcon(): Icon
setCursor(cursor: string): string
getCursor(): string
toString(): string
onmarkend: (event: { type: string, target: any, marker: Marker }) => void
}
interface PushpinToolOptions {
icon?: Icon
cursor?: string
followText?: string
}
class DistanceTool {
constructor(map: Map)
open(): boolean
close(): void
toString(): string
ondrawend: (event: { type: string, target: any, points: Point[], polylines: Polyline[], distance: number }) => void
}
class DragAndZoomTool {
constructor(map: Map, opts?: DragAndZoomToolOptions)
open(): boolean
close(): void
toString(): string
ondrawend: (event: { type: string, target: any, bounds: Bounds[] }) => void
}
interface DragAndZoomToolOptions {
zoomType?: ZoomType,
autoClose?: boolean,
followText?: string
}
type ZoomType = number
}
declare const BMAP_ZOOM_IN: BMap.ZoomType
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.core.d.ts" />
/// <reference path="./baidumap.overlay.d.ts" />
declare namespace BMap {
class PushpinTool {
constructor(map: Map, opts?: PushpinToolOptions)
open(): boolean
close(): boolean
setIcon(icon: Icon): Icon
getIcon(): Icon
setCursor(cursor: string): string
getCursor(): string
toString(): string
onmarkend: (event: { type: string, target: any, marker: Marker }) => void
}
interface PushpinToolOptions {
icon?: Icon
cursor?: string
followText?: string
}
class DistanceTool {
constructor(map: Map)
open(): boolean
close(): void
toString(): string
ondrawend: (event: { type: string, target: any, points: Point[], polylines: Polyline[], distance: number }) => void
}
class DragAndZoomTool {
constructor(map: Map, opts?: DragAndZoomToolOptions)
open(): boolean
close(): void
toString(): string
ondrawend: (event: { type: string, target: any, bounds: Bounds[] }) => void
}
interface DragAndZoomToolOptions {
zoomType?: ZoomType,
autoClose?: boolean,
followText?: string
}
type ZoomType = number
}
declare const BMAP_ZOOM_IN: BMap.ZoomType
declare const BMAP_ZOOM_OUT: BMap.ZoomType

View File

@@ -1,28 +1,28 @@
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.control.d.ts" />
/// <reference path="./baidumap.core.d.ts" />
/// <reference path="./baidumap.maplayer.d.ts" />
/// <reference path="./baidumap.maptype.d.ts" />
/// <reference path="./baidumap.overlay.d.ts" />
/// <reference path="./baidumap.panorama.d.ts" />
/// <reference path="./baidumap.rightmenu.d.ts" />
/// <reference path="./baidumap.service.d.ts" />
/// <reference path="./baidumap.tools.d.ts" />
// Type definitions for BaiduMap v2.0
// Project: http://lbsyun.baidu.com/index.php?title=jspopular
// Definitions by: Codemonk <http://www.youxianxueche.com/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/* *****************************************************************************
Copyright [Codemonk] [Codemonk@live.cn]
This project is licensed under the MIT license.
Copyrights are respective of each contributor listed at the beginning of each definition file.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
***************************************************************************** */
/// <reference path="./baidumap.base.d.ts" />
/// <reference path="./baidumap.control.d.ts" />
/// <reference path="./baidumap.core.d.ts" />
/// <reference path="./baidumap.maplayer.d.ts" />
/// <reference path="./baidumap.maptype.d.ts" />
/// <reference path="./baidumap.overlay.d.ts" />
/// <reference path="./baidumap.panorama.d.ts" />
/// <reference path="./baidumap.rightmenu.d.ts" />
/// <reference path="./baidumap.service.d.ts" />
/// <reference path="./baidumap.tools.d.ts" />

View File

@@ -0,0 +1,15 @@
{
"extends": "dtslint/dt.json",
"rules": {
// All are TODOs
"eofline": false,
"comment-format": false,
"dt-header": false,
"max-line-length": false,
"member-access": false,
"no-namespace": false,
"no-useless-files": false,
"no-var": false,
"semicolon": false
}
}

View File

@@ -81,7 +81,7 @@ declare namespace BittorrentProtocol {
// TODO: bitfield is a bitfield instance
on(event: 'bitfield', listener: (bitfield: any) => void): this;
on(event: string | 'keep-alive' | 'choke' | 'unchoke' | 'interested' | 'uninterested' | 'timeout', listener: () => void): this;
on(event: 'keep-alive' | 'choke' | 'unchoke' | 'interested' | 'uninterested' | 'timeout', listener: () => void): this;
on(event: 'upload' | 'have' | 'download' | 'port', listener: (length: number) => void): this;
on(event: 'handshake', listener: (infoHash: string, peerId: string, extensions: Extension[]) => void): this;
on(event: 'request', listener: (index: number, offset: number, length: number, respond: () => void) => void): this;
@@ -89,6 +89,7 @@ declare namespace BittorrentProtocol {
on(event: 'cancel', listener: (index: number, offset: number, length: number) => void): this;
on(event: 'extended', listener: (ext: 'handshake' | string, buf: any) => void): void;
on(event: 'unknownmessage', listener: (buffer: Buffer) => void): this;
on(event: string, listener: (...args: any[]) => void): this;
}
}

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/spion/blue-tape
// Definitions by: Haoqun Jiang <https://github.com/sodatea>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node" />

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/petkaantonov/bluebird
// Definitions by: d-ph <https://github.com/d-ph>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/*
* 1. Why use `bluebird-global` instead of `bluebird`?
@@ -117,19 +118,19 @@ declare global {
*
* @todo Duplication of code is never ideal. See whether there's a better way of achieving this.
*/
catch(predicate: (error: any) => boolean, onReject: (error: any) => T | Bluebird.Thenable<T> | void | Bluebird.Thenable<void>): Bluebird<T>;
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | T>;
catch<E extends Error>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => T | Bluebird.Thenable<T> | void | Bluebird.Thenable<void>): Bluebird<T>;
catch<E extends Error, U>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable<U>): Bluebird<U | T>;
catch(predicate: Object, onReject: (error: any) => T | Bluebird.Thenable<T> | void | Bluebird.Thenable<void>): Bluebird<T>;
catch<U>(predicate: Object, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | T>;
catch(predicate: (error: any) => boolean, onReject: (error: any) => T | PromiseLike<T> | void | PromiseLike<void>): Bluebird<T>;
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | PromiseLike<U>): Bluebird<U | T>;
catch<E extends Error>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => T | PromiseLike<T> | void | PromiseLike<void>): Bluebird<T>;
catch<E extends Error, U>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | PromiseLike<U>): Bluebird<U | T>;
catch(predicate: Object, onReject: (error: any) => T | PromiseLike<T> | void | PromiseLike<void>): Bluebird<T>;
catch<U>(predicate: Object, onReject: (error: any) => U | PromiseLike<U>): Bluebird<U | T>;
}
/*
* Patch all static methods and the constructor
*/
interface PromiseConstructor {
new <T>(callback: (resolve: (thenableOrResult?: T | Bluebird.Thenable<T>) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void): Promise<T>;
new <T>(callback: (resolve: (thenableOrResult?: T | PromiseLike<T>) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void): Promise<T>;
// all: typeof Bluebird.all;
any: typeof Bluebird.any;

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/jut-io/bluebird-retry
// Definitions by: Pascal Vomhoff <https://github.com/pvomhoff>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="bluebird" />

View File

@@ -373,6 +373,30 @@ fooProm = fooProm.catch(CustomError, reason => {
fooProm = fooProm.catch(CustomError1, CustomError2, CustomError3, error => {});
fooProm = fooProm.catch(CustomError1, CustomError2, CustomError3, CustomError4, error => {});
fooProm = fooProm.catch(CustomError1, CustomError2, CustomError3, CustomError4, CustomError5, error => {});
const booPredicate1 = (error: CustomError1) => true;
const booPredicate2 = (error: [number]) => true;
const booPredicate3 = (error: string) => true;
const booPredicate4 = (error: Object) => true;
const booPredicate5 = (error: any) => true;
fooProm = fooProm.catch(booPredicate1, error => {});
fooProm = fooProm.catch(booPredicate1, booPredicate2, error => {});
fooProm = fooProm.catch(booPredicate1, booPredicate2, booPredicate3, error => {});
fooProm = fooProm.catch(booPredicate1, booPredicate2, booPredicate3, booPredicate4, error => {});
fooProm = fooProm.catch(booPredicate1, booPredicate2, booPredicate3, booPredicate4, booPredicate5, error => {});
const booObject1 = new CustomError1();
const booObject2 = [400, 500];
const booObject3 = ["Error1", "Error2"];
const booObject4 = {code: 400};
const booObject5: any = null;
fooProm = fooProm.catch(booObject1, error => {});
fooProm = fooProm.catch(booObject1, booObject2, error => {});
fooProm = fooProm.catch(booObject1, booObject2, booObject3, error => {});
fooProm = fooProm.catch(booObject1, booObject2, booObject3, booObject4, error => {});
fooProm = fooProm.catch(booObject1, booObject2, booObject3, booObject4, booObject5, error => {});
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/petkaantonov/bluebird
// Definitions by: Leonard Hecker <https://github.com/lhecker>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/*!
* The code following this comment originates from:
@@ -34,30 +35,29 @@
* THE SOFTWARE.
*/
declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R> {
declare class Bluebird<R> implements PromiseLike<R>, Bluebird.Inspection<R> {
/**
* Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
* If promise cancellation is enabled, passed in function will receive one more function argument `onCancel` that allows to register an optional cancellation callback.
*/
constructor(callback: (resolve: (thenableOrResult?: R | Bluebird.Thenable<R>) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void);
constructor(callback: (resolve: (thenableOrResult?: R | PromiseLike<R>) => void, reject: (error?: any) => void, onCancel?: (callback: () => void) => void) => void);
/**
* Promises/A+ `.then()`. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
*/
then<U1, U2>(onFulfill: (value: R) => U1 | Bluebird.Thenable<U1>, onReject: (error: any) => U2 | Bluebird.Thenable<U2>): Bluebird<U1 | U2>;
then<U>(onFulfill: (value: R) => U | Bluebird.Thenable<U>, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U>;
then<U>(onFulfill: (value: R) => U | Bluebird.Thenable<U>): Bluebird<U>;
then(): Bluebird<R>;
// Based on PromiseLike.then, but returns a Bluebird instance.
then<U>(onFulfill?: (value: R) => U | Bluebird.Thenable<U>, onReject?: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U>; // For simpler signature help.
then<TResult1 = R, TResult2 = never>(onfulfilled?: ((value: R) => TResult1 | PromiseLike<TResult1>) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null): Bluebird<TResult1 | TResult2>;
/**
* This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
*
* Alias `.caught();` for compatibility with earlier ECMAScript version.
*/
catch(onReject?: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught(onReject?: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<U>(onReject?: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<U>(onReject?: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
catch(onReject?: (error: any) => R | PromiseLike<R> | void | PromiseLike<void>): Bluebird<R>;
caught(onReject?: (error: any) => R | PromiseLike<R> | void | PromiseLike<void>): Bluebird<R>;
catch<U>(onReject?: (error: any) => U | PromiseLike<U>): Bluebird<U | R>;
caught<U>(onReject?: (error: any) => U | PromiseLike<U>): Bluebird<U | R>;
/**
* This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called.
@@ -69,143 +69,263 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
* TODO: disallow non-objects
*/
catch<E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4 | E5) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
filter3: (new (...args: any[]) => E3),
filter4: (new (...args: any[]) => E4),
filter5: (new (...args: any[]) => E5),
onReject: (error: E1 | E2 | E3 | E4 | E5) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
catch<E1, E2, E3, E4, E5>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
filter3: ((error: E3) => boolean) | (E3 & object),
filter4: ((error: E4) => boolean) | (E4 & object),
filter5: ((error: E5) => boolean) | (E5 & object),
onReject: (error: E1 | E2 | E3 | E4 | E5) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
caught<E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4 | E5) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
filter3: (new (...args: any[]) => E3),
filter4: (new (...args: any[]) => E4),
filter5: (new (...args: any[]) => E5),
onReject: (error: E1 | E2 | E3 | E4 | E5) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
caught<E1, E2, E3, E4, E5>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
filter3: ((error: E3) => boolean) | (E3 & object),
filter4: ((error: E4) => boolean) | (E4 & object),
filter5: ((error: E5) => boolean) | (E5 & object),
onReject: (error: E1 | E2 | E3 | E4 | E5) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
catch<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4 | E5) => U | Bluebird.Thenable<U>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
filter3: (new (...args: any[]) => E3),
filter4: (new (...args: any[]) => E4),
filter5: (new (...args: any[]) => E5),
onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike<U> | void | PromiseLike<void>,
): Bluebird<U | R>;
catch<U, E1, E2, E3, E4, E5>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
filter3: ((error: E3) => boolean) | (E3 & object),
filter4: ((error: E4) => boolean) | (E4 & object),
filter5: ((error: E5) => boolean) | (E5 & object),
onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike<U>,
): Bluebird<U | R>;
caught<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4 | E5) => U | Bluebird.Thenable<U>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
filter3: (new (...args: any[]) => E3),
filter4: (new (...args: any[]) => E4),
filter5: (new (...args: any[]) => E5),
onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike<U>,
): Bluebird<U | R>;
caught<U, E1, E2, E3, E4, E5>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
filter3: ((error: E3) => boolean) | (E3 & object),
filter4: ((error: E4) => boolean) | (E4 & object),
filter5: ((error: E5) => boolean) | (E5 & object),
onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike<U>,
): Bluebird<U | R>;
catch<E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
filter3: (new (...args: any[]) => E3),
filter4: (new (...args: any[]) => E4),
onReject: (error: E1 | E2 | E3 | E4) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
catch<E1, E2, E3, E4>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
filter3: ((error: E3) => boolean) | (E3 & object),
filter4: ((error: E4) => boolean) | (E4 & object),
onReject: (error: E1 | E2 | E3 | E4) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
caught<E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
filter3: (new (...args: any[]) => E3),
filter4: (new (...args: any[]) => E4),
onReject: (error: E1 | E2 | E3 | E4) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
caught<E1, E2, E3, E4>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
filter3: ((error: E3) => boolean) | (E3 & object),
filter4: ((error: E4) => boolean) | (E4 & object),
onReject: (error: E1 | E2 | E3 | E4) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
catch<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4) => U | Bluebird.Thenable<U>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
filter3: (new (...args: any[]) => E3),
filter4: (new (...args: any[]) => E4),
onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike<U>,
): Bluebird<U | R>;
catch<U, E1, E2, E3, E4>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
filter3: ((error: E3) => boolean) | (E3 & object),
filter4: ((error: E4) => boolean) | (E4 & object),
onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike<U>,
): Bluebird<U | R>;
caught<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4) => U | Bluebird.Thenable<U>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
filter3: (new (...args: any[]) => E3),
filter4: (new (...args: any[]) => E4),
onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike<U>,
): Bluebird<U | R>;
caught<U, E1, E2, E3, E4>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
filter3: ((error: E3) => boolean) | (E3 & object),
filter4: ((error: E4) => boolean) | (E4 & object),
onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike<U>,
): Bluebird<U | R>;
catch<E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
filter3: (new (...args: any[]) => E3),
onReject: (error: E1 | E2 | E3) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
catch<E1, E2, E3>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
filter3: ((error: E3) => boolean) | (E3 & object),
onReject: (error: E1 | E2 | E3) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
caught<E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
filter3: (new (...args: any[]) => E3),
onReject: (error: E1 | E2 | E3) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
caught<E1, E2, E3>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
filter3: ((error: E3) => boolean) | (E3 & object),
onReject: (error: E1 | E2 | E3) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
catch<U, E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3) => U | Bluebird.Thenable<U>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
filter3: (new (...args: any[]) => E3),
onReject: (error: E1 | E2 | E3) => U | PromiseLike<U>,
): Bluebird<U | R>;
catch<U, E1, E2, E3>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
filter3: ((error: E3) => boolean) | (E3 & object),
onReject: (error: E1 | E2 | E3) => U | PromiseLike<U>,
): Bluebird<U | R>;
caught<U, E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3) => U | Bluebird.Thenable<U>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
filter3: (new (...args: any[]) => E3),
onReject: (error: E1 | E2 | E3) => U | PromiseLike<U>,
): Bluebird<U | R>;
caught<U, E1, E2, E3>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
filter3: ((error: E3) => boolean) | (E3 & object),
onReject: (error: E1 | E2 | E3) => U | PromiseLike<U>,
): Bluebird<U | R>;
catch<E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
onReject: (error: E1 | E2) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
catch<E1, E2>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
onReject: (error: E1 | E2) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
caught<E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
onReject: (error: E1 | E2) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
caught<E1, E2>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
onReject: (error: E1 | E2) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
catch<U, E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2) => U | Bluebird.Thenable<U>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
onReject: (error: E1 | E2) => U | PromiseLike<U>,
): Bluebird<U | R>;
catch<U, E1, E2>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
onReject: (error: E1 | E2) => U | PromiseLike<U>,
): Bluebird<U | R>;
caught<U, E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2) => U | Bluebird.Thenable<U>,
filter1: (new (...args: any[]) => E1),
filter2: (new (...args: any[]) => E2),
onReject: (error: E1 | E2) => U | PromiseLike<U>,
): Bluebird<U | R>;
caught<U, E1, E2>(
filter1: ((error: E1) => boolean) | (E1 & object),
filter2: ((error: E2) => boolean) | (E2 & object),
onReject: (error: E1 | E2) => U | PromiseLike<U>,
): Bluebird<U | R>;
catch<E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
onReject: (error: E1) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
filter1: (new (...args: any[]) => E1),
onReject: (error: E1) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
catch<E1>(
filter1: ((error: E1) => boolean) | (E1 & object),
onReject: (error: E1) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
caught<E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
onReject: (error: E1) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>,
filter1: (new (...args: any[]) => E1),
onReject: (error: E1) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
caught<E1>(
filter1: ((error: E1) => boolean) | (E1 & object),
onReject: (error: E1) => R | PromiseLike<R> | void | PromiseLike<void>,
): Bluebird<R>;
catch<U, E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
onReject: (error: E1) => U | Bluebird.Thenable<U>,
filter1: (new (...args: any[]) => E1),
onReject: (error: E1) => U | PromiseLike<U>,
): Bluebird<U | R>;
catch<U, E1>(
filter1: ((error: E1) => boolean) | (E1 & object),
onReject: (error: E1) => U | PromiseLike<U>,
): Bluebird<U | R>;
caught<U, E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
onReject: (error: E1) => U | Bluebird.Thenable<U>,
filter1: (new (...args: any[]) => E1),
onReject: (error: E1) => U | PromiseLike<U>,
): Bluebird<U | R>;
caught<U, E1>(
filter1: ((error: E1) => boolean) | (E1 & object),
onReject: (error: E1) => U | PromiseLike<U>,
): Bluebird<U | R>;
/**
* Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections.
*/
error<U>(onReject: (reason: any) => U | Bluebird.Thenable<U>): Bluebird<U>;
error<U>(onReject: (reason: any) => U | PromiseLike<U>): Bluebird<U>;
/**
* Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler.
*
* Alias `.lastly();` for compatibility with earlier ECMAScript version.
*/
finally<U>(handler: () => U | Bluebird.Thenable<U>): Bluebird<R>;
finally<U>(handler: () => U | PromiseLike<U>): Bluebird<R>;
lastly<U>(handler: () => U | Bluebird.Thenable<U>): Bluebird<R>;
lastly<U>(handler: () => U | PromiseLike<U>): Bluebird<R>;
/**
* Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
@@ -215,19 +335,19 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
/**
* Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
*/
done<U>(onFulfilled?: (value: R) => U | Bluebird.Thenable<U>, onRejected?: (error: any) => U | Bluebird.Thenable<U>): void;
done<U>(onFulfilled?: (value: R) => U | PromiseLike<U>, onRejected?: (error: any) => U | PromiseLike<U>): void;
/**
* Like `.finally()`, but not called for rejections.
*/
tap<U>(onFulFill: (value: R) => Bluebird.Thenable<U>): Bluebird<R>;
tap<U>(onFulFill: (value: R) => PromiseLike<U>): Bluebird<R>;
tap<U>(onFulfill: (value: R) => U): Bluebird<R>;
/**
* Like `.catch()` but rethrows the error
* TODO: disallow non-objects
*/
tapCatch<U>(onReject: (error?: any) => U | Bluebird.Thenable<U>): Bluebird<R>;
tapCatch<U>(onReject: (error?: any) => U | PromiseLike<U>): Bluebird<R>;
tapCatch<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error, E5 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
@@ -235,29 +355,29 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
filter5: (new (...args: any[]) => E5) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4 | E5) => U | Bluebird.Thenable<U>,
onReject: (error: E1 | E2 | E3 | E4 | E5) => U | PromiseLike<U>,
): Bluebird<R>;
tapCatch<U, E1 extends Error, E2 extends Error, E3 extends Error, E4 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
filter4: (new (...args: any[]) => E4) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3 | E4) => U | Bluebird.Thenable<U>,
onReject: (error: E1 | E2 | E3 | E4) => U | PromiseLike<U>,
): Bluebird<R>;
tapCatch<U, E1 extends Error, E2 extends Error, E3 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
filter3: (new (...args: any[]) => E3) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2 | E3) => U | Bluebird.Thenable<U>,
onReject: (error: E1 | E2 | E3) => U | PromiseLike<U>,
): Bluebird<R>;
tapCatch<U, E1 extends Error, E2 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
filter2: (new (...args: any[]) => E2) | ((error: any) => boolean) | Object,
onReject: (error: E1 | E2) => U | Bluebird.Thenable<U>,
onReject: (error: E1 | E2) => U | PromiseLike<U>,
): Bluebird<R>;
tapCatch<U, E1 extends Error>(
filter1: (new (...args: any[]) => E1) | ((error: any) => boolean) | Object,
onReject: (error: E1) => U | Bluebird.Thenable<U>,
onReject: (error: E1) => U | PromiseLike<U>,
): Bluebird<R>;
/**
@@ -488,7 +608,7 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
/**
* Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.
*/
spread<U, W>(fulfilledHandler: (...values: W[]) => U | Bluebird.Thenable<U>): Bluebird<U>;
spread<U, W>(fulfilledHandler: (...values: W[]) => U | PromiseLike<U>): Bluebird<U>;
spread<U>(fulfilledHandler: Function): Bluebird<U>;
/**
@@ -525,29 +645,29 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
* Same as calling `Bluebird.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
// TODO type inference from array-resolving promise?
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => U | Bluebird.Thenable<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
/**
* Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
// TODO type inference from array-resolving promise?
reduce<Q, U>(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U | Bluebird.Thenable<U>, initialValue?: U): Bluebird<U>;
reduce<Q, U>(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Bluebird<U>;
/**
* Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
// TODO type inference from array-resolving promise?
filter<U>(filterer: (item: U, index: number, arrayLength: number) => boolean | Bluebird.Thenable<boolean>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
filter<U>(filterer: (item: U, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
/**
* Same as calling ``Bluebird.each(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
each<R, U>(iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable<U>): Bluebird<R[]>;
each<R, U>(iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Bluebird<R[]>;
/**
* Same as calling ``Bluebird.mapSeries(thisPromise, iterator)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
*/
mapSeries<R, U>(iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable<U>): Bluebird<U[]>;
mapSeries<R, U>(iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Bluebird<U[]>;
/**
* Cancel this `promise`. Will not do anything if this promise is already settled or if the cancellation feature has not been enabled
@@ -568,8 +688,8 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
*
* Alias for `attempt();` for compatibility with earlier ECMAScript version.
*/
static try<R>(fn: () => R | Bluebird.Thenable<R>): Bluebird<R>;
static attempt<R>(fn: () => R | Bluebird.Thenable<R>): Bluebird<R>;
static try<R>(fn: () => R | PromiseLike<R>): Bluebird<R>;
static attempt<R>(fn: () => R | PromiseLike<R>): Bluebird<R>;
/**
* Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
@@ -581,7 +701,7 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
* Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state.
*/
static resolve(): Bluebird<void>;
static resolve<R>(value: R | Bluebird.Thenable<R>): Bluebird<R>;
static resolve<R>(value: R | PromiseLike<R>): Bluebird<R>;
/**
* Create a promise that is rejected with the given `reason`.
@@ -597,7 +717,7 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
/**
* Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable.
*/
static cast<R>(value: R | Bluebird.Thenable<R>): Bluebird<R>;
static cast<R>(value: R | PromiseLike<R>): Bluebird<R>;
/**
* Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`.
@@ -619,7 +739,7 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
* If value is a promise, the delay will start counting down when it is fulfilled and the returned
* promise will be fulfilled with the fulfillment value of the value promise.
*/
static delay<R>(ms: number, value: R | Bluebird.Thenable<R>): Bluebird<R>;
static delay<R>(ms: number, value: R | PromiseLike<R>): Bluebird<R>;
static delay(ms: number): Bluebird<void>;
/**
@@ -671,13 +791,13 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
*/
// TODO enable more overloads
// array with promises of different types
static all<T1, T2, T3, T4, T5>(values: [Bluebird.Thenable<T1> | T1, Bluebird.Thenable<T2> | T2, Bluebird.Thenable<T3> | T3, Bluebird.Thenable<T4> | T4, Bluebird.Thenable<T5> | T5]): Bluebird<[T1, T2, T3, T4, T5]>;
static all<T1, T2, T3, T4>(values: [Bluebird.Thenable<T1> | T1, Bluebird.Thenable<T2> | T2, Bluebird.Thenable<T3> | T3, Bluebird.Thenable<T4> | T4]): Bluebird<[T1, T2, T3, T4]>;
static all<T1, T2, T3>(values: [Bluebird.Thenable<T1> | T1, Bluebird.Thenable<T2> | T2, Bluebird.Thenable<T3> | T3]): Bluebird<[T1, T2, T3]>;
static all<T1, T2>(values: [Bluebird.Thenable<T1> | T1, Bluebird.Thenable<T2> | T2]): Bluebird<[T1, T2]>;
static all<T1>(values: [Bluebird.Thenable<T1> | T1]): Bluebird<[T1]>;
static all<T1, T2, T3, T4, T5>(values: [PromiseLike<T1> | T1, PromiseLike<T2> | T2, PromiseLike<T3> | T3, PromiseLike<T4> | T4, PromiseLike<T5> | T5]): Bluebird<[T1, T2, T3, T4, T5]>;
static all<T1, T2, T3, T4>(values: [PromiseLike<T1> | T1, PromiseLike<T2> | T2, PromiseLike<T3> | T3, PromiseLike<T4> | T4]): Bluebird<[T1, T2, T3, T4]>;
static all<T1, T2, T3>(values: [PromiseLike<T1> | T1, PromiseLike<T2> | T2, PromiseLike<T3> | T3]): Bluebird<[T1, T2, T3]>;
static all<T1, T2>(values: [PromiseLike<T1> | T1, PromiseLike<T2> | T2]): Bluebird<[T1, T2]>;
static all<T1>(values: [PromiseLike<T1> | T1]): Bluebird<[T1]>;
// array with values
static all<R>(values: Bluebird.Thenable<(Bluebird.Thenable<R> | R)[]> | (Bluebird.Thenable<R> | R)[]): Bluebird<R[]>;
static all<R>(values: PromiseLike<(PromiseLike<R> | R)[]> | (PromiseLike<R> | R)[]): Bluebird<R[]>;
/**
* Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason.
@@ -695,14 +815,14 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
/**
* Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly.
*/
static any<R>(values: Bluebird.Thenable<(Bluebird.Thenable<R> | R)[]> | (Bluebird.Thenable<R> | R)[]): Bluebird<R>;
static any<R>(values: PromiseLike<(PromiseLike<R> | R)[]> | (PromiseLike<R> | R)[]): Bluebird<R>;
/**
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value.
*
* **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending.
*/
static race<R>(values: Bluebird.Thenable<(Bluebird.Thenable<R> | R)[]> | (Bluebird.Thenable<R> | R)[]): Bluebird<R>;
static race<R>(values: PromiseLike<(PromiseLike<R> | R)[]> | (PromiseLike<R> | R)[]): Bluebird<R>;
/**
* Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.
@@ -712,11 +832,11 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
* *The original array is not modified.*
*/
// promise of array with promises of value
static some<R>(values: Bluebird.Thenable<Bluebird.Thenable<R>[]>, count: number): Bluebird<R[]>;
static some<R>(values: PromiseLike<PromiseLike<R>[]>, count: number): Bluebird<R[]>;
// promise of array with values
static some<R>(values: Bluebird.Thenable<R[]>, count: number): Bluebird<R[]>;
static some<R>(values: PromiseLike<R[]>, count: number): Bluebird<R[]>;
// array with promises of value
static some<R>(values: Bluebird.Thenable<R>[], count: number): Bluebird<R[]>;
static some<R>(values: PromiseLike<R>[], count: number): Bluebird<R[]>;
// array with values
static some<R>(values: R[], count: number): Bluebird<R[]>;
@@ -729,15 +849,15 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
*
* Note: In 1.x and 0.x Promise.join used to be a Promise.all that took the values in as arguments instead in an array. This behavior has been deprecated but is still supported partially - when the last argument is an immediate function value the new semantics will apply
*/
static join<R, A1>(arg1: A1 | Bluebird.Thenable<A1>, handler: (arg1: A1) => R | Bluebird.Thenable<R>): Bluebird<R>;
static join<R, A1, A2>(arg1: A1 | Bluebird.Thenable<A1>, arg2: A2 | Bluebird.Thenable<A2>, handler: (arg1: A1, arg2: A2) => R | Bluebird.Thenable<R>): Bluebird<R>;
static join<R, A1, A2, A3>(arg1: A1 | Bluebird.Thenable<A1>, arg2: A2 | Bluebird.Thenable<A2>, arg3: A3 | Bluebird.Thenable<A3>, handler: (arg1: A1, arg2: A2, arg3: A3) => R | Bluebird.Thenable<R>): Bluebird<R>;
static join<R, A1, A2, A3, A4>(arg1: A1 | Bluebird.Thenable<A1>, arg2: A2 | Bluebird.Thenable<A2>, arg3: A3 | Bluebird.Thenable<A3>, arg4: A4 | Bluebird.Thenable<A4>, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => R | Bluebird.Thenable<R>): Bluebird<R>;
static join<R, A1, A2, A3, A4, A5>(arg1: A1 | Bluebird.Thenable<A1>, arg2: A2 | Bluebird.Thenable<A2>, arg3: A3 | Bluebird.Thenable<A3>, arg4: A4 | Bluebird.Thenable<A4>, arg5: A5 | Bluebird.Thenable<A5>, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => R | Bluebird.Thenable<R>): Bluebird<R>;
static join<R, A1>(arg1: A1 | PromiseLike<A1>, handler: (arg1: A1) => R | PromiseLike<R>): Bluebird<R>;
static join<R, A1, A2>(arg1: A1 | PromiseLike<A1>, arg2: A2 | PromiseLike<A2>, handler: (arg1: A1, arg2: A2) => R | PromiseLike<R>): Bluebird<R>;
static join<R, A1, A2, A3>(arg1: A1 | PromiseLike<A1>, arg2: A2 | PromiseLike<A2>, arg3: A3 | PromiseLike<A3>, handler: (arg1: A1, arg2: A2, arg3: A3) => R | PromiseLike<R>): Bluebird<R>;
static join<R, A1, A2, A3, A4>(arg1: A1 | PromiseLike<A1>, arg2: A2 | PromiseLike<A2>, arg3: A3 | PromiseLike<A3>, arg4: A4 | PromiseLike<A4>, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4) => R | PromiseLike<R>): Bluebird<R>;
static join<R, A1, A2, A3, A4, A5>(arg1: A1 | PromiseLike<A1>, arg2: A2 | PromiseLike<A2>, arg3: A3 | PromiseLike<A3>, arg4: A4 | PromiseLike<A4>, arg5: A5 | PromiseLike<A5>, handler: (arg1: A1, arg2: A2, arg3: A3, arg4: A4, arg5: A5) => R | PromiseLike<R>): Bluebird<R>;
// variadic array
/** @deprecated use .all instead */
static join<R>(...values: (R | Bluebird.Thenable<R>)[]): Bluebird<R[]>;
static join<R>(...values: (R | PromiseLike<R>)[]): Bluebird<R[]>;
/**
* Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
@@ -747,16 +867,16 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
* *The original array is not modified.*
*/
// promise of array with promises of value
static map<R, U>(values: Bluebird.Thenable<Bluebird.Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
static map<R, U>(values: PromiseLike<PromiseLike<R>[]>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
// promise of array with values
static map<R, U>(values: Bluebird.Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
static map<R, U>(values: PromiseLike<R[]>, mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
// array with promises of value
static map<R, U>(values: Bluebird.Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
static map<R, U>(values: PromiseLike<R>[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
// array with values
static map<R, U>(values: R[], mapper: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
static map<R, U>(values: R[], mapper: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>, options?: Bluebird.ConcurrencyOption): Bluebird<U[]>;
/**
* Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
@@ -766,16 +886,16 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
* *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.*
*/
// promise of array with promises of value
static reduce<R, U>(values: Bluebird.Thenable<Bluebird.Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable<U>, initialValue?: U): Bluebird<U>;
static reduce<R, U>(values: PromiseLike<PromiseLike<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Bluebird<U>;
// promise of array with values
static reduce<R, U>(values: Bluebird.Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable<U>, initialValue?: U): Bluebird<U>;
static reduce<R, U>(values: PromiseLike<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Bluebird<U>;
// array with promises of value
static reduce<R, U>(values: Bluebird.Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable<U>, initialValue?: U): Bluebird<U>;
static reduce<R, U>(values: PromiseLike<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Bluebird<U>;
// array with values
static reduce<R, U>(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | Bluebird.Thenable<U>, initialValue?: U): Bluebird<U>;
static reduce<R, U>(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U | PromiseLike<U>, initialValue?: U): Bluebird<U>;
/**
* Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
@@ -785,16 +905,16 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
* *The original array is not modified.
*/
// promise of array with promises of value
static filter<R>(values: Bluebird.Thenable<Bluebird.Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable<boolean>, option?: Bluebird.ConcurrencyOption): Bluebird<R[]>;
static filter<R>(values: PromiseLike<PromiseLike<R>[]>, filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Bluebird.ConcurrencyOption): Bluebird<R[]>;
// promise of array with values
static filter<R>(values: Bluebird.Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable<boolean>, option?: Bluebird.ConcurrencyOption): Bluebird<R[]>;
static filter<R>(values: PromiseLike<R[]>, filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Bluebird.ConcurrencyOption): Bluebird<R[]>;
// array with promises of value
static filter<R>(values: Bluebird.Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable<boolean>, option?: Bluebird.ConcurrencyOption): Bluebird<R[]>;
static filter<R>(values: PromiseLike<R>[], filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Bluebird.ConcurrencyOption): Bluebird<R[]>;
// array with values
static filter<R>(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean | Bluebird.Thenable<boolean>, option?: Bluebird.ConcurrencyOption): Bluebird<R[]>;
static filter<R>(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean | PromiseLike<boolean>, option?: Bluebird.ConcurrencyOption): Bluebird<R[]>;
/**
* Iterate over an array, or a promise of an array, which contains promises (or a mix of promises and values) with the given iterator function with the signature (item, index, value) where item is the resolved value of a respective promise in the input array. Iteration happens serially. If any promise in the input array is rejected the returned promise is rejected as well.
@@ -802,11 +922,11 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
* Resolves to the original array unmodified, this method is meant to be used for side effects. If the iterator function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
*/
// promise of array with promises of value
static each<R, U>(values: Bluebird.Thenable<Bluebird.Thenable<R>[]>, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable<U>): Bluebird<R[]>;
static each<R, U>(values: PromiseLike<PromiseLike<R>[]>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Bluebird<R[]>;
// array with promises of value
static each<R, U>(values: Bluebird.Thenable<R>[], iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable<U>): Bluebird<R[]>;
static each<R, U>(values: PromiseLike<R>[], iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Bluebird<R[]>;
// array with values OR promise of array with values
static each<R, U>(values: R[] | Bluebird.Thenable<R[]>, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable<U>): Bluebird<R[]>;
static each<R, U>(values: R[] | PromiseLike<R[]>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Bluebird<R[]>;
/**
* Given an Iterable(arrays are Iterable), or a promise of an Iterable, which produces promises (or a mix of promises and values), iterate over all the values in the Iterable into an array and iterate over the array serially, in-order.
@@ -815,7 +935,7 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
*
* If any promise in the input array is rejected or any promise returned by the iterator function is rejected, the result will be rejected as well.
*/
static mapSeries<R, U>(values: (R | Bluebird.Thenable<R>)[] | Bluebird.Thenable<(R | Bluebird.Thenable<R>)[]>, iterator: (item: R, index: number, arrayLength: number) => U | Bluebird.Thenable<U>): Bluebird<U[]>;
static mapSeries<R, U>(values: (R | PromiseLike<R>)[] | PromiseLike<(R | PromiseLike<R>)[]>, iterator: (item: R, index: number, arrayLength: number) => U | PromiseLike<U>): Bluebird<U[]>;
/**
* A meta method used to specify the disposer method that cleans up a resource when using `Promise.using`.
@@ -827,16 +947,16 @@ declare class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R
* The second argument passed to a disposer is the result promise of the using block, which you can
* inspect synchronously.
*/
disposer(disposeFn: (arg: R, promise: Bluebird<R>) => void | Bluebird.Thenable<void>): Bluebird.Disposer<R>;
disposer(disposeFn: (arg: R, promise: Bluebird<R>) => void | PromiseLike<void>): Bluebird.Disposer<R>;
/**
* In conjunction with `.disposer`, using will make sure that no matter what, the specified disposer
* will be called when the promise returned by the callback passed to using has settled. The disposer is
* necessary because there is no standard interface in node for disposing resources.
*/
static using<R, T>(disposer: Bluebird.Disposer<R>, executor: (transaction: R) => Bluebird.Thenable<T>): Bluebird<T>;
static using<R1, R2, T>(disposer: Bluebird.Disposer<R1>, disposer2: Bluebird.Disposer<R2>, executor: (transaction1: R1, transaction2: R2) => Bluebird.Thenable<T>): Bluebird<T>;
static using<R1, R2, R3, T>(disposer: Bluebird.Disposer<R1>, disposer2: Bluebird.Disposer<R2>, disposer3: Bluebird.Disposer<R3>, executor: (transaction1: R1, transaction2: R2, transaction3: R3) => Bluebird.Thenable<T>): Bluebird<T>;
static using<R, T>(disposer: Bluebird.Disposer<R>, executor: (transaction: R) => PromiseLike<T>): Bluebird<T>;
static using<R1, R2, T>(disposer: Bluebird.Disposer<R1>, disposer2: Bluebird.Disposer<R2>, executor: (transaction1: R1, transaction2: R2) => PromiseLike<T>): Bluebird<T>;
static using<R1, R2, R3, T>(disposer: Bluebird.Disposer<R1>, disposer2: Bluebird.Disposer<R2>, disposer3: Bluebird.Disposer<R3>, executor: (transaction1: R1, transaction2: R2, transaction3: R3) => PromiseLike<T>): Bluebird<T>;
/**
* Add handler as the handler to call when there is a possibly unhandled rejection.
@@ -891,7 +1011,7 @@ declare namespace Bluebird {
suffix?: string;
filter?: (name: string, func: Function, target?: any, passesDefaultFilter?: boolean) => boolean;
// The promisifier gets a reference to the original method and should return a function which returns a promise
promisifier?: (originalMethod: Function) => () => Thenable<any>;
promisifier?: (originalMethod: Function) => () => PromiseLike<any>;
}
/**
@@ -951,10 +1071,8 @@ declare namespace Bluebird {
export class Disposer<R> {
}
export interface Thenable<R> {
then<U>(onFulfilled: (value: R) => U | Thenable<U>, onRejected?: (error: any) => U | Thenable<U>): Thenable<U>;
then<U>(onFulfilled: (value: R) => U | Thenable<U>, onRejected?: (error: any) => void | Thenable<void>): Thenable<U>;
}
/** @deprecated Use PromiseLike<T> directly. */
export type Thenable<T> = PromiseLike<T>;
export interface Resolver<R> {
/**

View File

@@ -21,7 +21,7 @@ declare namespace bodyParser {
}
interface OptionsJson extends Options {
reviever?(key: string, value: any): any;
reviver?(key: string, value: any): any;
strict?: boolean;
}

View File

@@ -2,7 +2,7 @@
// Project: http://bookshelfjs.org/
// Definitions by: Andrew Schurman <http://github.com/arcticwaters>, Vesa Poikajärvi <https://github.com/vesse>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// TypeScript Version: 2.3
import Knex = require('knex');
import knex = require('knex');

View File

@@ -1,119 +1,146 @@
import $ = require('jquery');
$(function() {
$(() => {
// examples from http://seiyria.github.io/bootstrap-slider/
$('#ex1').slider({
formatter: function(value) {
formatter(value) {
return 'Current value: ' + value;
}
});
$('#ex2').slider({});
$("#ex2").slider({});
var RGBChange = function() {
$('#RGB').css('background', 'rgb('+r.getValue()+','+g.getValue()+','+b.getValue()+')')
const RGBChange = () => {
$('#RGB').css('background', 'rgb(' + r.getValue() + ',' + g.getValue() + ',' + b.getValue() + ')');
};
var r = $('#R').slider()
.on('slide', RGBChange)
.data('slider');
var g = $('#G').slider()
.on('slide', RGBChange)
.data('slider');
var b = $('#B').slider()
.on('slide', RGBChange)
.data('slider');
const r = $('#R').slider()
.on('slide', RGBChange)
.data('slider');
const g = $('#G').slider()
.on('slide', RGBChange)
.data('slider');
const b = $('#B').slider()
.on('slide', RGBChange)
.data('slider');
$("#ex4").slider({
reversed : true
$('#ex4').slider({
reversed: true
});
$('#ex5').slider();
$("#ex5").slider();
$("#destroyEx5Slider").click(function() {
$("#ex5").slider('destroy');
$('#destroyEx5Slider').click(() => {
$('#ex5').slider('destroy');
});
$("#ex6").slider();
$("#ex6").on("slide", function(slideEvt) {
$("#ex6SliderVal").text(<number>slideEvt.value);
$('#ex6').slider();
$('#ex6').on('slide', (slideEvt) => {
$('#ex6SliderVal').text(<number> slideEvt.value);
});
$('#ex7').slider();
$("#ex7").slider();
$("#ex7-enabled").click(function() {
if((this as HTMLInputElement).checked) {
$('#ex7-enabled').click(function(this: HTMLInputElement) {
if (this.checked) {
// With JQuery
$("#ex7").slider("enable");
}
else {
$('#ex7').slider('enable');
} else {
// With JQuery
$("#ex7").slider("disable");
$('#ex7').slider('disable');
}
});
$("#ex8").slider({
$('#ex8').slider({
tooltip: 'always'
});
$("#ex9").slider({
$('#ex9').slider({
precision: 2,
value: 8.115 // Slider will instantiate showing 8.12 due to specified precision
});
$('#ex11').slider({ step: 20000, min: 0, max: 200000 });
$('#ex12a').slider({ id: 'slider12a', min: 0, max: 10, value: 5 });
$('#ex12b').slider({ id: 'slider12b', min: 0, max: 10, range: true, value: [3, 7] });
$('#ex12c').slider({ id: 'slider12c', min: 0, max: 10, range: true, value: [3, 7] });
$("#ex11").slider({step: 20000, min: 0, max: 200000});
$("#ex12a").slider({ id: "slider12a", min: 0, max: 10, value: 5 });
$("#ex12b").slider({ id: "slider12b", min: 0, max: 10, range: true, value: [3, 7] });
$("#ex12c").slider({ id: "slider12c", min: 0, max: 10, range: true, value: [3, 7] });
$("#ex13").slider({
$('#ex13').slider({
ticks: [0, 100, 200, 300, 400],
ticks_labels: ['$0', '$100', '$200', '$300', '$400'],
ticks_snap_bounds: 30
});
$("#ex14").slider({
$('#ex14').slider({
ticks: [0, 100, 200, 300, 400],
ticks_positions: [0, 30, 60, 70, 90, 100],
ticks_labels: ['$0', '$100', '$200', '$300', '$400'],
ticks_snap_bounds: 30
});
$("#ex15").slider({
$('#ex15').slider({
min: 1000,
max: 10000000,
scale: 'logarithmic',
step: 10
});
$('#ex16a').slider({ min: 0, max: 10, value: 0, focus: true });
$('#ex16b').slider({ min: 0, max: 10, value: [0, 10], focus: true });
// examples from https://github.com/seiyria/bootstrap-slider/blob/master/README.md
$("#ex16a").slider({ min: 0, max: 10, value: 0, focus: true });
$("#ex16b").slider({ min: 0, max: 10, value: [0, 10], focus: true });
{
// Instantiate a slider
const mySlider = $('input.slider').slider();
// Call a method on the slider
const value = mySlider.slider('getValue');
// For non-getter methods, you can chain together commands
mySlider
.slider('setValue', 5)
.slider('setValue', 7);
}
{ // Instantiate a slider
const mySlider = $('input.slider').bootstrapSlider();
// Call a method on the slider
const value = mySlider.bootstrapSlider('getValue');
// For non-getter methods, you can chain together commands
mySlider
.bootstrapSlider('setValue', 5)
.bootstrapSlider('setValue', 7);
}
{
// Instantiate a slider
const mySlider = $('input.slider').bootstrapSlider();
// Call a method on the slider
const value = mySlider.bootstrapSlider('getValue');
// For non-getter methods, you can chain together commands
mySlider
.bootstrapSlider('setValue', 5)
.bootstrapSlider('setValue', 7);
}
{ // Instantiate a slider
const mySlider = new Slider('input.slider', {
// initial options object
});
// Call a method on the slider
const value = mySlider.getValue();
// For non-getter methods, you can chain together commands
mySlider
.setValue(5)
.setValue(7);
}
});

View File

@@ -1,7 +1,11 @@
// Type definitions for bootstrap-slider.js 4.8.3
// Type definitions for bootstrap-slider.js 9.8
// Project: https://github.com/seiyria/bootstrap-slider
// Definitions by: Daniel Beckwith <https://github.com/dbeckwith>
// Leonard Thieu <https://github.com/leonard-thieu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery" />
interface SliderOptions {
/**
@@ -38,7 +42,7 @@ interface SliderOptions {
* Default: 5
* initial value. Use array to have a range slider.
*/
value?: number|number[];
value?: number | number[];
/**
* Default: false
* make range slider. Optional if initial value is an array. If initial value is scalar, max will be used for second value.
@@ -79,10 +83,12 @@ interface SliderOptions {
* formatter callback. Return the value wanted to be displayed in the tooltip
* @param val the current value to display
*/
formatter?(val:number): string;
formatter?(val: number): string;
/**
* Default: false
* The natural order is used for the arrow keys. Arrow up select the upper slider value for vertical sliders, arrow right the righter slider value for a horizontal slider - no matter if the slider was reversed or not. By default the arrow keys are oriented by arrow up/right to the higher slider value, arrow down/left to the lower slider value.
* The natural order is used for the arrow keys. Arrow up select the upper slider value for vertical sliders,
* arrow right the righter slider value for a horizontal slider - no matter if the slider was reversed or not.
* By default the arrow keys are oriented by arrow up/right to the higher slider value, arrow down/left to the lower slider value.
*/
natural_arrow_keys?: boolean;
/**
@@ -118,12 +124,19 @@ interface SliderOptions {
}
interface JQuery {
slider: SliderPlugin<this>;
bootstrapSlider: SliderPlugin<this>;
on(event: 'slide', handler: (slideEvt: SliderEvent) => false | void): this;
}
interface SliderPlugin<TJQuery> {
(methodName: string, ...args: any[]): TJQuery;
/**
* Creates a slider from the current element.
* @param options
*/
slider(options?:SliderOptions): JQuery;
slider(methodName:string, ...args:any[]): JQuery;
(options?: SliderOptions): TJQuery;
}
interface ChangeValue {
@@ -131,46 +144,42 @@ interface ChangeValue {
newValue: number;
}
interface JQueryEventObject {
value: number|ChangeValue;
interface SliderEvent extends JQuery.Event {
value: number | ChangeValue;
}
interface SliderStatics {
new (selector: string, opts: SliderOptions): Slider;
prototype: Slider;
}
declare var Slider: SliderStatics;
/**
* This class is actually not used when using the jQuery version of bootstrap-slider
* The method documentation is still here thouh.
* When using jQuery, slider methods like setValue(3, true) have to be called like $slider.slider('setValue', 3, true)
*/
interface Slider extends JQuery {
declare class Slider {
constructor(selector: string, opts: SliderOptions);
/**
* Get the current value from the slider
*/
getValue(): number;
/**
* Set a new value for the slider. If optional triggerSlideEvent parameter is true, 'slide' events will be triggered. If optional triggerChangeEvent parameter is true, 'change' events will be triggered.
* Set a new value for the slider. If optional triggerSlideEvent parameter is true, 'slide' events will be triggered.
* If optional triggerChangeEvent parameter is true, 'change' events will be triggered.
* @param newValue
* @param triggerSlideEvent
* @param triggerChangeEvent
*/
setValue(newValue:number, triggerSlideEvent?:boolean, triggerChangeEvent?:boolean): void;
setValue(newValue: number, triggerSlideEvent?: boolean, triggerChangeEvent?: boolean): this;
/**
* Properly clean up and remove the slider instance
*/
destroy(): void;
destroy(): this;
/**
* Disables the slider and prevents the user from changing the value
*/
disable(): void;
disable(): this;
/**
* Enables the slider
*/
enable(): void;
enable(): this;
/**
* Returns true if enabled, false if disabled
*/
@@ -180,26 +189,18 @@ interface Slider extends JQuery {
* @param attribute
* @param value
*/
setAttribute(attribute:string, value:any): void;
setAttribute(attribute: string, value: any): this;
/**
* Get the slider's attributes
* @param attribute
*/
getAttribute(attribute:string): any;
getAttribute(attribute: string): any;
/**
* Refreshes the current slider
*/
refresh(): void;
refresh(): this;
/**
* Renders the tooltip again, after initialization. Useful in situations when the slider and tooltip are initially hidden.
*/
relayout(): void;
on: {
(eventType:string, callback:(eventObject:JQueryEventObject, ...args:any[]) => any): Slider;
(eventType:string, data:any, callback:(eventObject:JQueryEventObject, ...args:any[]) => any): Slider;
(eventType:string, selector:string, callback:(eventObject:JQueryEventObject, ...eventData:any[]) => any): Slider;
(eventType:string, selector:string, data:any, callback:(eventObject:JQueryEventObject, ...eventData:any[]) => any): Slider;
(eventType:{ [key: string]: any; }, selector?:string, data?:any): Slider;
(eventType:{ [key: string]: any; }, data?:any): Slider;
}
relayout(): this;
}

View File

@@ -6,17 +6,12 @@
"dom"
],
"noImplicitAny": true,
"noImplicitThis": false,
"strictNullChecks": false,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"paths": {
"jquery": [
"jquery/v2"
]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true

View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}

View File

@@ -36,13 +36,22 @@ interface FileOptions {
// for each file in a bundle.
type InputFile = string | NodeJS.ReadableStream | FileOptions;
/**
* Core options pertaining to a Browserify instance, extended by user options
*/
interface CustomOptions {
/**
* Custom properties can be defined on Options.
* These options are forwarded along to module-deps and browser-pack directly.
*/
[propName: string]: any;
/** the directory that Browserify starts bundling from for filenames that start with .. */
basedir?: string;
}
/**
* Options pertaining to a Browserify instance.
*/
interface Options {
// Custom properties can be defined on Options.
// These options are forwarded along to module-deps and browser-pack directly.
[propName: string]: any;
interface Options extends CustomOptions {
// String, file object, or array of those types (they may be mixed) specifying entry file(s).
entries?: InputFile | InputFile[];
// an array which will skip all require() and global parsing for each file in the array.
@@ -51,8 +60,6 @@ interface Options {
// an array of optional extra extensions for the module lookup machinery to use when the extension has not been specified.
// By default Browserify considers only .js and .json files in such cases.
extensions?: string[];
// the directory that Browserify starts bundling from for filenames that start with ..
basedir?: string;
// an array of directories that Browserify searches when looking for modules which are not referenced using relative path.
// Can be absolute or relative to basedir. Equivalent of setting NODE_PATH environmental variable when calling Browserify command.
paths?: string[];
@@ -115,32 +122,32 @@ interface BrowserifyObject extends NodeJS.EventEmitter {
* If file is an array, each item in file will be externalized.
* If file is another bundle, that bundle's contents will be read and excluded from the current bundle as the bundle in file gets bundled.
*/
external(file: string[], opts?: { basedir?: string }): BrowserifyObject;
external(file: string, opts?: { basedir?: string }): BrowserifyObject;
external(file: string[], opts?: CustomOptions): BrowserifyObject;
external(file: string, opts?: CustomOptions): BrowserifyObject;
external(file: BrowserifyObject): BrowserifyObject;
/**
* Prevent the module name or file at file from showing up in the output bundle.
* Instead you will get a file with module.exports = {}.
*/
ignore(file: string, opts?: { basedir?: string }): BrowserifyObject;
ignore(file: string, opts?: CustomOptions): BrowserifyObject;
/**
* Prevent the module name or file at file from showing up in the output bundle.
* If your code tries to require() that file it will throw unless you've provided another mechanism for loading it.
*/
exclude(file: string, opts?: { basedir?: string }): BrowserifyObject;
exclude(file: string, opts?: CustomOptions): BrowserifyObject;
/**
* Transform source code before parsing it for require() calls with the transform function or module name tr.
* If tr is a function, it will be called with tr(file) and it should return a through-stream that takes the raw file contents and produces the transformed source.
* If tr is a string, it should be a module name or file path of a transform module
*/
transform<T extends { basedir?: string }>(tr: string, opts?: T): BrowserifyObject;
transform<T extends { basedir?: string }>(tr: (file: string, opts: T) => NodeJS.ReadWriteStream, opts?: T): BrowserifyObject;
transform<T extends CustomOptions>(tr: string, opts?: T): BrowserifyObject;
transform<T extends CustomOptions>(tr: (file: string, opts: T) => NodeJS.ReadWriteStream, opts?: T): BrowserifyObject;
/**
* Register a plugin with opts. Plugins can be a string module name or a function the same as transforms.
* plugin(b, opts) is called with the Browserify instance b.
*/
plugin<T extends { basedir?: string }>(plugin: string, opts?: T): BrowserifyObject;
plugin<T extends { basedir?: string }>(plugin: (b: BrowserifyObject, opts: T) => any, opts?: T): BrowserifyObject;
plugin<T extends CustomOptions>(plugin: string, opts?: T): BrowserifyObject;
plugin<T extends CustomOptions>(plugin: (b: BrowserifyObject, opts: T) => any, opts?: T): BrowserifyObject;
/**
* Reset the pipeline back to a normal state. This function is called automatically when bundle() is called multiple times.
* This function triggers a 'reset' event.

View File

@@ -7,6 +7,23 @@
declare module "bunyan-config" {
import * as bunyan from "bunyan";
interface StreamConfiguration {
name: string,
params?: {
host: string,
port: number
}
}
interface Stream {
type?: string;
level?: bunyan.LogLevel;
path?: string;
stream?: string | StreamConfiguration
closeOnExit?: boolean;
period?: string;
count?: number;
}
/**
* Configuration.
@@ -14,7 +31,7 @@ declare module "bunyan-config" {
*/
interface Configuration {
name: string;
streams?: bunyan.Stream[];
streams?: Stream[];
level?: string | number;
stream?: NodeJS.WritableStream;
serializers?: {};

View File

@@ -5,7 +5,7 @@ import { shallow } from "enzyme";
const Test = () => <div/>;
class Test2 extends React.Component<{}, {}> {
class Test2 extends React.Component {
render() {
return <div/>;
}

View File

@@ -2,7 +2,7 @@
// Project: https://github.com/producthunt/chai-enzyme
// Definitions by: Alexey Svetliakov <https://github.com/asvetliakov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.3
/// <reference types="enzyme" />

View File

@@ -1017,6 +1017,24 @@ function sameDeepMembers() {
assert.sameDeepMembers([{ id: 5 }, { id: 4 }], [{ id: 4 }, { id: 5 }]);
}
function orderedMembers() {
expect([1, 2]).to.have.ordered.members([1, 2]).but.not.have.ordered.members([2, 1]);
expect([1, 2, 3]).to.include.ordered.members([1, 2]).but.not.include.ordered.members([2, 3]);
expect([1, 2, 3]).to.have.ordered.members([1, 2, 3]);
expect([1, 2, 3]).to.have.members([2, 1, 3]).but.not.ordered.members([2, 1, 3]);
expect([{a: 1}, {b: 2}, {c: 3}]).to.include.deep.ordered.members([{a: 1}, {b: 2}]).but.not.include.deep.ordered.members([{b: 2}, {c: 3}]);
assert.sameOrderedMembers([ 1, 2, 3 ], [ 1, 2, 3 ], 'same ordered members');
assert.notSameOrderedMembers([ 1, 2, 3 ], [ 2, 1, 3 ], 'not same ordered members');
assert.sameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 }, { c: 3 } ], 'same deep ordered members');
assert.notSameDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { a: 1 }, { c: 3 } ], 'not same deep ordered members');
assert.includeOrderedMembers([ 1, 2, 3 ], [ 1, 2 ], 'include ordered members');
assert.notIncludeOrderedMembers([ 1, 2, 3 ], [ 2, 1 ], 'not include ordered members');
assert.includeDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { a: 1 }, { b: 2 } ], 'include deep ordered members');
assert.notIncludeDeepOrderedMembers([ { a: 1 }, { b: 2 }, { c: 3 } ], [ { b: 2 }, { c: 3 } ], 'not include deep ordered members');
}
function members() {
expect([5, 4]).members([4, 5]);
expect([5, 4]).members([5, 4]);

98
types/chai/index.d.ts vendored
View File

@@ -61,6 +61,7 @@ declare namespace Chai {
interface Assertion extends LanguageChains, NumericComparison, TypeComparison {
not: Assertion;
deep: Deep;
ordered: Ordered;
nested: Nested;
any: KeyFilter;
all: KeyFilter;
@@ -134,6 +135,8 @@ declare namespace Chai {
at: Assertion;
of: Assertion;
same: Assertion;
but: Assertion;
does: Assertion;
}
interface NumericComparison {
@@ -181,6 +184,11 @@ declare namespace Chai {
include: Include;
property: Property;
members: Members;
ordered: Ordered;
}
interface Ordered {
members: Members;
}
interface KeyFilter {
@@ -213,6 +221,8 @@ declare namespace Chai {
(value: string, message?: string): Assertion;
(value: number, message?: string): Assertion;
keys: Keys;
deep: Deep;
ordered: Ordered;
members: Members;
any: KeyFilter;
all: KeyFilter;
@@ -999,6 +1009,94 @@ declare namespace Chai {
*/
sameDeepMembers<T>(set1: T[], set2: T[], message?: string): void;
/**
* Asserts that set1 and set2 have the same members in the same order.
* Uses a strict equality check (===).
*
* @type T Type of set values.
* @param set1 Actual set of values.
* @param set2 Potential expected set of values.
* @param message Message to display on error.
*/
sameOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
/**
* Asserts that set1 and set2 dont have the same members in the same order.
* Uses a strict equality check (===).
*
* @type T Type of set values.
* @param set1 Actual set of values.
* @param set2 Potential expected set of values.
* @param message Message to display on error.
*/
notSameOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
/**
* Asserts that set1 and set2 have the same members in the same order.
* Uses a deep equality check.
*
* @type T Type of set values.
* @param set1 Actual set of values.
* @param set2 Potential expected set of values.
* @param message Message to display on error.
*/
sameDeepOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
/**
* Asserts that set1 and set2 dont have the same members in the same order.
* Uses a deep equality check.
*
* @type T Type of set values.
* @param set1 Actual set of values.
* @param set2 Potential expected set of values.
* @param message Message to display on error.
*/
notSameDeepOrderedMembers<T>(set1: T[], set2: T[], message?: string): void;
/**
* Asserts that subset is included in superset in the same order beginning with the first element in superset.
* Uses a strict equality check (===).
*
* @type T Type of set values.
* @param superset Actual set of values.
* @param subset Potential contained set of values.
* @param message Message to display on error.
*/
includeOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
/**
* Asserts that subset isnt included in superset in the same order beginning with the first element in superset.
* Uses a strict equality check (===).
*
* @type T Type of set values.
* @param superset Actual set of values.
* @param subset Potential contained set of values.
* @param message Message to display on error.
*/
notIncludeOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
/**
* Asserts that subset is included in superset in the same order beginning with the first element in superset.
* Uses a deep equality check.
*
* @type T Type of set values.
* @param superset Actual set of values.
* @param subset Potential contained set of values.
* @param message Message to display on error.
*/
includeDeepOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
/**
* Asserts that subset isnt included in superset in the same order beginning with the first element in superset.
* Uses a deep equality check.
*
* @type T Type of set values.
* @param superset Actual set of values.
* @param subset Potential contained set of values.
* @param message Message to display on error.
*/
notIncludeDeepOrderedMembers<T>(superset: T[], subset: T[], message?: string): void;
/**
* Asserts that subset is included in superset. Order is not take into account.
*

View File

@@ -358,7 +358,7 @@ declare namespace Chart {
max?: number;
}
type ChartColor = string | CanvasGradient | CanvasPattern;
type ChartColor = string | CanvasGradient | CanvasPattern | string[];
interface ChartDataSets {
backgroundColor?: ChartColor | ChartColor[];
@@ -384,6 +384,10 @@ declare namespace Chart {
pointStyle?: string | string[] | HTMLImageElement | HTMLImageElement[];
xAxisID?: string;
yAxisID?: string;
type?: string;
hidden?: boolean;
hideInLegendAndTooltip?: boolean;
stack?: string;
}
interface ChartScales {

View File

@@ -1097,7 +1097,7 @@ declare namespace CodeMirror {
* Both modes get to parse all of the text, but when both assign a non-null style to a piece of code, the overlay wins, unless
* the combine argument was true and not overridden, or state.overlay.combineTokens was true, in which case the styles are combined.
*/
function overlayMode<T, S>(base: Mode<T>, overlay: Mode<S>, combine?: boolean): Mode<any>
function overlayMode<T, S>(base: Mode<T>, overlay: Mode<S>, combine?: boolean): Mode<any>;
/**
* async specifies that the lint process runs asynchronously. hasGutters specifies that lint errors should be displayed in the CodeMirror
@@ -1114,13 +1114,20 @@ declare namespace CodeMirror {
* linter.
*/
interface LintOptions extends LintStateOptions {
getAnnotations: AnnotationsCallback;
getAnnotations: Linter | AsyncLinter;
}
/**
* A function that return errors found during the linting process.
*/
interface Linter {
(content: string, options: LintStateOptions, codeMirror: Editor): Annotation[] | PromiseLike<Annotation[]>;
}
/**
* A function that calls the updateLintingCallback with any errors found during the linting process.
*/
interface AnnotationsCallback {
interface AsyncLinter {
(content: string, updateLintingCallback: UpdateLintingCallback, options: LintStateOptions, codeMirror: Editor): void;
}

View File

@@ -28,7 +28,7 @@ var lintStateOptions: CodeMirror.LintStateOptions = {
hasGutters: true
};
var lintOptions: CodeMirror.LintOptions = {
var asyncLintOptions: CodeMirror.LintOptions = {
async: true,
hasGutters: true,
getAnnotations: (content: string,
@@ -37,6 +37,14 @@ var lintOptions: CodeMirror.LintOptions = {
codeMirror: CodeMirror.Editor) => {}
};
var syncLintOptions: CodeMirror.LintOptions = {
async: false,
hasGutters: true,
getAnnotations: (content: string,
options: CodeMirror.LintStateOptions,
codeMirror: CodeMirror.Editor): CodeMirror.Annotation[] => { return []; }
};
var updateLintingCallback: CodeMirror.UpdateLintingCallback = (codeMirror: CodeMirror.Editor,
annotations: CodeMirror.Annotation[]) => {};

View File

@@ -0,0 +1,32 @@
import SortedSet = require('collections/sorted-set');
interface Person {
name: string;
}
let set = new SortedSet<Person>(
[{name: 'John'}, {name: 'Jack'}, {name: 'Linda'}],
(a: Person, b: Person) => a.name === b.name,
(a: Person, b: Person) => {
if (a.name < b.name) {
return -1;
}
if (a.name > b.name) {
return 1;
}
return 0;
}
);
let p1: Person | undefined = set.max();
let p2: Person | undefined = set.min();
set.push({name: 'Laurie'}, {name: 'Max'});
set.pop();
set.get({name: 'Laurie'});
set.has({name: 'John'});
let a = 1;
set.forEach((p: Person) => a++);

133
types/collections/index.d.ts vendored Normal file
View File

@@ -0,0 +1,133 @@
// Type definitions for collections v5.0.6
// Project: http://www.collectionsjs.com/
// Definitions by: Scarabe Dore <https://github.com/scarabedore>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'collections/sorted-set' {
namespace internal {
// TODO: These methods can be similar in others collection. One's should make some
// class model.
abstract class AbstractSet {
union(...plus: any[]): any;
intersection(...plus: any[]): any;
difference(...plus: any[]): any;
symmetricDifference(...plus: any[]): any;
remove(...plus: any[]): any;
contains(...plus: any[]): any;
toggle(...plus: any[]): any;
addEach(...plus: any[]): any;
deleteEach(...plus: any[]): any;
deleteAll(...plus: any[]): any;
findValue(...plus: any[]): any;
iterator(...plus: any[]): any;
forEach(...plus: any[]): any;
map(...plus: any[]): any;
filter(...plus: any[]): any;
group(...plus: any[]): any;
some(...plus: any[]): any;
every(...plus: any[]): any;
any(...plus: any[]): any;
all(...plus: any[]): any;
only(...plus: any[]): any;
sorted(...plus: any[]): any;
reversed(...plus: any[]): any;
join(...plus: any[]): any;
sum(...plus: any[]): any;
average(...plus: any[]): any;
zip(...plus: any[]): any;
enumerate(...plus: any[]): any;
concat(...plus: any[]): any;
flatten(...plus: any[]): any;
toArray(...plus: any[]): any;
toObject(...plus: any[]): any;
toJSON(...plus: any[]): any;
equals(...plus: any[]): any;
clone(...plus: any[]): any;
contentCompare(...plus: any[]): any;
contentEquals(...plus: any[]): any;
sortedSetLog(...plus: any[]): any;
addRangeChangeListener(...plus: any[]): any;
removeRangeChangeListener(...plus: any[]): any;
dispatchRangeChange(...plus: any[]): any;
addBeforeRangeChangeListener(...plus: any[]): any;
removeBeforeRangeChangeListener(...plus: any[]): any;
dispatchBeforeRangeChange(...plus: any[]): any;
addOwnPropertyChangeListener(...plus: any[]): any;
addBeforeOwnPropertyChangeListener(...plus: any[]): any;
removeOwnPropertyChangeListener(...plus: any[]): any;
removeBeforeOwnPropertyChangeListener(...plus: any[]): any;
dispatchOwnPropertyChange(...plus: any[]): any;
dispatchBeforeOwnPropertyChange(...plus: any[]): any;
makePropertyObservable(...plus: any[]): any;
}
class Node<T> {
reduce(cb: (result?: any, val?: any, key?: any, collection?: any) => any,
basis: any, index: number, thisp: any, tree: any, depth: number): any;
touch(...plus: any[]): void;
checkIntegrity(...plus: any[]): number;
getNext(...plus: any[]): Node<T> | undefined;
getPrevious(...plus: any[]): Node<T> | undefined;
summary(...plus: any[]): string;
log(charmap: any, logNode: any, log: any, logAbove: any): any;
}
class Iterator<T> {
next(): {done: true, value: T | null | undefined};
}
export class SortedSet<T> extends AbstractSet {
constructor(
values?: T[],
equals?: (a: T, b: T) => boolean,
compare?: (a: T, b: T) => number,
getDefault?: any
);
constructClone(values?: T[]): SortedSet<T>;
add(value: T): boolean;
clear(): void;
['delete'](value: T): boolean;
find(value: T): Node<T> | undefined;
findGreatest(n?: Node<T> | undefined): Node<T> | undefined;
findGreatestLessThan(value: T): Node<T> | undefined;
findGreatestLessThanOrEqual(value: T): Node<T> | undefined;
findLeast(n?: Node<T> | undefined): Node<T> | undefined;
findLeastGreaterThan(value: T): Node<T> | undefined;
findLeastGreaterThanOrEqual(value: T): Node<T> | undefined;
max(n?: Node<T>): T | undefined;
min(n?: Node<T>): T | undefined;
one(): T | undefined;
get(elt: T): T | undefined;
has(elt: T): boolean;
indexOf(value: T): number;
pop(): T | undefined;
push(...rest: T[]): void;
shift(): T | undefined;
unshift(...rest: T[]): void;
slice(start?: number, end?: number): T[];
splice(start: Node<T>, length: number, ...values: T[]): T[];
swap(start: number, length: number, values?: T[]): T[];
splay(value: T): void;
splayIndex(index: number): boolean;
reduce(callback: (result?: any, val?: any, key?: any, collection?: any) => any,
basis?: any, thisp?: any): any;
reduceRight(
callback: (result?: any, val?: any, key?: any, collection?: any) => any,
basis?: any, thisp?: any
): any;
iterate(start: number, stop: number): Iterator<T>;
}
}
export = internal.SortedSet;
}

View File

@@ -0,0 +1,16 @@
{
"files": [
"collections-tests.ts",
"index.d.ts"
],
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"lib": ["es6"],
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"noEmit": true
}
}

View File

@@ -1,9 +1,6 @@
import commonmark = require('commonmark');
function logNode(node: commonmark.Node) {
console.log(
node.destination,
node.firstChild,
@@ -24,12 +21,10 @@ function logNode(node: commonmark.Node) {
node.sourcepos,
node.title,
node.type);
}
var parser = new commonmark.Parser({ smart: true, time: true });
var node = parser.parse('# a piece of _markdown_');
const parser = new commonmark.Parser({ smart: true, time: true });
const node = parser.parse('# a piece of _markdown_');
let w = node.walker();
let step = w.next();
@@ -37,11 +32,75 @@ if (step.entering) {
logNode(step.node);
}
let xmlRenderer = new commonmark.XmlRenderer({ sourcepos: true, time: true });
let xml = xmlRenderer.render(node);
console.log(xml);
let htmlRenderer = new commonmark.HtmlRenderer({ safe: true, smart: true, sourcepos: true, time: true});
let htmlRenderer = new commonmark.HtmlRenderer({ safe: true, smart: true, sourcepos: true, time: true });
let html = htmlRenderer.render(node);
console.log(html);
console.log(html);
function basic_usage() {
const reader = new commonmark.Parser();
const writer = new commonmark.HtmlRenderer();
const parsed = reader.parse('Hello *world*'); // parsed is a 'Node' tree
// transform parsed if you like...
const result = writer.render(parsed); // result is a String
}
function constructor_optional_options() {
const writer = new commonmark.HtmlRenderer({ sourcepos: true });
}
function soft_breaks_as_hard_breaks() {
const writer = new commonmark.HtmlRenderer();
writer.softbreak = '<br />';
}
function soft_breaks_as_spaces() {
const writer = new commonmark.HtmlRenderer();
writer.softbreak = ' ';
}
function text_to_ALL_CAPS(parsed: commonmark.Node) {
const walker = parsed.walker();
let event: commonmark.NodeWalkingStep;
let node: commonmark.Node;
event = walker.next();
while (event) {
node = event.node;
if (event.entering && node.type === 'text') {
node.literal = node.literal!.toUpperCase();
}
event = walker.next();
}
}
function emphasis_to_ALL_CAPS(parsed: commonmark.Node) {
const walker = parsed.walker();
let event: commonmark.NodeWalkingStep;
let node: commonmark.Node;
let inEmph = false;
event = walker.next();
while (event) {
node = event.node;
if (node.type === 'emph') {
if (event.entering) {
inEmph = true;
} else {
inEmph = false;
// add Emph node's children as siblings
while (node.firstChild) {
node.insertBefore(node.firstChild);
}
// remove the empty Emph node
node.unlink();
}
} else if (inEmph && node.type === 'text') {
node.literal = node.literal!.toUpperCase();
}
event = walker.next();
}
}

View File

@@ -1,212 +1,221 @@
// Type definitions for commonmark.js 0.22.1
// Type definitions for commonmark.js 0.27
// Project: https://github.com/jgm/commonmark.js
// Definitions by: Nico Jansen <https://github.com/nicojs>
// Leonard Thieu <https://github.com/leonard-thieu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = commonmark;
export as namespace commonmark;
declare namespace commonmark {
export interface NodeWalkingStep {
/**
* a boolean, which is true when we enter a Node from a parent or sibling, and false when we reenter it from a child
*/
entering: boolean;
/**
* The node belonging to this step
*/
node: Node;
}
export interface NodeWalker {
/**
* Returns an object with properties entering and node. Returns null when we have finished walking the tree.
*/
next(): NodeWalkingStep;
/**
* Resets the iterator to resume at the specified node and setting for entering. (Normally this isn't needed unless you do destructive updates to the Node tree.)
*/
resumeAt(node: Node, entering?: boolean): void;
}
export interface Position extends Array<Array<number>> {
}
export interface ListData {
type?: string,
tight?: boolean,
delimiter?: string,
bulletChar?: string
}
export class Node {
constructor(nodeType: string, sourcepos?: Position);
isContainer: boolean;
/**
* (read-only): one of Text, Softbreak, Hardbreak, Emph, Strong, Html, Link, Image, Code, Document, Paragraph, BlockQuote, Item, List, Heading, CodeBlock, HtmlBlock ThematicBreak.
*/
type: string;
/**
* (read-only): a Node or null.
*/
firstChild: Node;
/**
* (read-only): a Node or null.
*/
lastChild: Node;
/**
* (read-only): a Node or null.
*/
next: Node;
/**
* (read-only): a Node or null.
*/
prev: Node;
/**
* (read-only): a Node or null.
*/
parent: Node;
/**
* (read-only): an Array with the following form: [[startline, startcolumn], [endline, endcolumn]]
*/
sourcepos: Position;
/**
* the literal String content of the node or null.
*/
literal: string;
/**
* link or image destination (String) or null.
*/
destination: string;
/**
* link or image title (String) or null.
*/
title: string;
/**
* fenced code block info string (String) or null.
*/
info: string;
/**
* heading level (Number).
*/
level: number;
/**
* either Bullet or Ordered (or undefined).
*/
listType: string;
/**
* true if list is tight
*/
listTight: boolean;
/**
* a Number, the starting number of an ordered list.
*/
listStart: number;
/**
* a String, either ) or . for an ordered list.
*/
listDelimiter: string;
/**
* used only for CustomBlock or CustomInline.
*/
onEnter: string;
/**
* used only for CustomBlock or CustomInline.
*/
onExit: string;
/**
* Append a Node child to the end of the Node's children.
*/
appendChild(child: Node): void;
/**
* Prepend a Node child to the beginning of the Node's children.
*/
prependChild(child: Node): void;
/**
* Remove the Node from the tree, severing its links with siblings and parents, and closing up gaps as needed.
*/
unlink(): void;
/**
* Insert a Node sibling after the Node.
*/
insertAfter(sibling: Node): void;
/**
* Insert a Node sibling before the Node.
*/
insertBefore(sibling: Node): void;
/**
* Returns a NodeWalker that can be used to iterate through the Node tree rooted in the Node
*/
walker(): NodeWalker;
/**
* Setting the backing object of listType, listTight, listStat and listDelimiter directly.
* Not needed unless creating list nodes directly. Should be fixed from v>0.22.1
* https://github.com/jgm/commonmark.js/issues/74
*/
_listData: ListData;
}
export class Node {
constructor(nodeType: string, sourcepos?: Position);
/**
* Instead of converting Markdown directly to HTML, as most converters do, commonmark.js parses Markdown to an AST (abstract syntax tree), and then renders this AST as HTML.
* This opens up the possibility of manipulating the AST between parsing and rendering. For example, one could transform emphasis into ALL CAPS.
* (read-only): a String, one of text, softbreak, linebreak, emph, strong, html_inline, link, image, code, document, paragraph,
* block_quote, item, list, heading, code_block, html_block, thematic_break.
*/
export class Parser {
/**
* Constructs a new Parser
*/
constructor(options?: ParserOptions);
parse(input: string): Node;
}
readonly type: 'text' | 'softbreak' | 'linebreak' | 'emph' | 'strong' | 'html_inline' | 'link' | 'image' | 'code' | 'document' | 'paragraph' |
'block_quote' | 'item' | 'list' | 'heading' | 'code_block' | 'html_block' | 'thematic_break' | 'custom_inline' | 'custom_block';
/**
* (read-only): a Node or null.
*/
readonly firstChild: Node | null;
/**
* (read-only): a Node or null.
*/
readonly lastChild: Node | null;
/**
* (read-only): a Node or null.
*/
readonly next: Node | null;
/**
* (read-only): a Node or null.
*/
readonly prev: Node | null;
/**
* (read-only): a Node or null.
*/
readonly parent: Node | null;
/**
* (read-only): an Array with the following form: [[startline, startcolumn], [endline, endcolumn]]
*/
readonly sourcepos: Position;
/**
* (read-only): true if the Node can contain other Nodes as children.
*/
readonly isContainer: boolean;
/**
* the literal String content of the node or null.
*/
literal: string | null;
/**
* link or image destination (String) or null.
*/
destination: string | null;
/**
* link or image title (String) or null.
*/
title: string | null;
/**
* fenced code block info string (String) or null.
*/
info: string | null;
/**
* heading level (Number).
*/
level: number;
/**
* either Bullet or Ordered (or undefined).
*/
listType: 'Bullet' | 'Ordered';
/**
* true if list is tight
*/
listTight: boolean;
/**
* a Number, the starting number of an ordered list.
*/
listStart: number;
/**
* a String, either ) or . for an ordered list.
*/
listDelimiter: ')' | '.';
/**
* used only for CustomBlock or CustomInline.
*/
onEnter: string;
/**
* used only for CustomBlock or CustomInline.
*/
onExit: string;
export interface ParserOptions {
/**
* if true, straight quotes will be made curly, -- will be changed to an en dash, --- will be changed to an em dash, and ... will be changed to ellipses.
*/
smart?: boolean;
time?: boolean;
}
/**
* Append a Node child to the end of the Node's children.
*/
appendChild(child: Node): void;
export interface HtmlRenderingOptions extends XmlRenderingOptions {
/**
* if true, raw HTML will not be passed through to HTML output (it will be replaced by comments), and potentially unsafe URLs in links and images (those beginning with javascript:, vbscript:, file:, and with a few exceptions data:) will be replaced with empty strings.
*/
safe?: boolean;
/**
* if true, straight quotes will be made curly, -- will be changed to an en dash, --- will be changed to an em dash, and ... will be changed to ellipses.
*/
smart?: boolean;
/**
* if true, source position information for block-level elements will be rendered in the data-sourcepos attribute (for HTML) or the sourcepos attribute (for XML).
*/
sourcepos?: boolean;
}
/**
* Prepend a Node child to the beginning of the Node's children.
*/
prependChild(child: Node): void;
export class HtmlRenderer {
constructor(options?: HtmlRenderingOptions)
render(root: Node): string;
/**
* Let's you override the softbreak properties of a renderer. So, to make soft breaks render as hard breaks in HTML:
* writer.softbreak = "<br />";
*/
softbreak: string;
/**
* Override the function that will be used to escape (sanitize) the html output. Return value is used to add to the html output
* @param input the input to escape
* @param isAttributeValue indicates wheter or not the input value will be used as value of an html attribute.
*/
escape: (input: string, isAttributeValue: boolean) => string;
}
/**
* Remove the Node from the tree, severing its links with siblings and parents, and closing up gaps as needed.
*/
unlink(): void;
export interface XmlRenderingOptions {
time?: boolean;
sourcepos?: boolean;
}
/**
* Insert a Node sibling after the Node.
*/
insertAfter(sibling: Node): void;
export class XmlRenderer {
constructor(options?: XmlRenderingOptions)
render(root: Node): string;
}
/**
* Insert a Node sibling before the Node.
*/
insertBefore(sibling: Node): void;
/**
* Returns a NodeWalker that can be used to iterate through the Node tree rooted in the Node
*/
walker(): NodeWalker;
/**
* Setting the backing object of listType, listTight, listStat and listDelimiter directly.
* Not needed unless creating list nodes directly. Should be fixed from v>0.22.1
* https://github.com/jgm/commonmark.js/issues/74
*/
_listData: ListData;
}
/**
* Instead of converting Markdown directly to HTML, as most converters do, commonmark.js parses Markdown to an AST (abstract syntax tree), and then renders this AST as HTML.
* This opens up the possibility of manipulating the AST between parsing and rendering. For example, one could transform emphasis into ALL CAPS.
*/
export class Parser {
/**
* Constructs a new Parser
*/
constructor(options?: ParserOptions);
parse(input: string): Node;
}
export class HtmlRenderer {
constructor(options?: HtmlRenderingOptions)
render(root: Node): string;
/**
* Let's you override the softbreak properties of a renderer. So, to make soft breaks render as hard breaks in HTML:
* writer.softbreak = "<br />";
*/
softbreak: string;
/**
* Override the function that will be used to escape (sanitize) the html output. Return value is used to add to the html output
* @param input the input to escape
* @param isAttributeValue indicates wheter or not the input value will be used as value of an html attribute.
*/
escape: (input: string, isAttributeValue: boolean) => string;
}
export class XmlRenderer {
constructor(options?: XmlRenderingOptions)
render(root: Node): string;
}
export interface NodeWalkingStep {
/**
* a boolean, which is true when we enter a Node from a parent or sibling, and false when we reenter it from a child
*/
entering: boolean;
/**
* The node belonging to this step
*/
node: Node;
}
export interface NodeWalker {
/**
* Returns an object with properties entering and node. Returns null when we have finished walking the tree.
*/
next(): NodeWalkingStep;
/**
* Resets the iterator to resume at the specified node and setting for entering. (Normally this isn't needed unless you do destructive updates to the Node tree.)
*/
resumeAt(node: Node, entering?: boolean): void;
}
export type Position = [[number, number], [number, number]];
export interface ListData {
type?: string;
tight?: boolean;
delimiter?: string;
bulletChar?: string;
}
export interface ParserOptions {
/**
* if true, straight quotes will be made curly, -- will be changed to an en dash, --- will be changed to an em dash, and ... will be changed to ellipses.
*/
smart?: boolean;
time?: boolean;
}
export interface HtmlRenderingOptions extends XmlRenderingOptions {
/**
* if true, raw HTML will not be passed through to HTML output (it will be replaced by comments), and potentially unsafe URLs in links and images
* (those beginning with javascript:, vbscript:, file:, and with a few exceptions data:) will be replaced with empty strings.
*/
safe?: boolean;
/**
* if true, straight quotes will be made curly, -- will be changed to an en dash, --- will be changed to an em dash, and ... will be changed to ellipses.
*/
smart?: boolean;
/**
* if true, source position information for block-level elements will be rendered in the data-sourcepos attribute (for HTML) or the sourcepos attribute (for XML).
*/
sourcepos?: boolean;
}
export interface XmlRenderingOptions {
time?: boolean;
sourcepos?: boolean;
}

View File

@@ -7,7 +7,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -20,4 +20,4 @@
"index.d.ts",
"commonmark-tests.ts"
]
}
}

View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/visionmedia/consolidate.js
// Definitions by: Carlos Ballesteros Velasco <https://github.com/soywiz>, Theo Sherry <https://github.com/theosherry>, Nicolas Henry <https://github.com/nicolashenry>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// Imported from: https://github.com/soywiz/typescript-node-definitions/consolidate.d.ts

View File

@@ -1,19 +1,18 @@
import contentType = require('content-type');
import express = require('express');
var obj = contentType.parse('image/svg+xml; charset=utf-8');
let obj = contentType.parse('image/svg+xml; charset=utf-8');
console.log(obj.type); // => 'image/svg+xml'
console.log(obj.parameters.charset); // => 'utf-8'
var req: express.Request;
let req: express.Request;
obj = contentType.parse(req);
var res: express.Response;
let res: express.Response;
obj = contentType.parse(res);
var str: string = contentType.format({type: 'image/svg+xml'});
let str: string = contentType.format({type: 'image/svg+xml'});
var media: contentType.MediaType;
let media: contentType.MediaType;
contentType.format(media);

View File

@@ -1,16 +1,16 @@
// Type definitions for content-type v1.0.1
// Type definitions for content-type 1.1
// Project: https://www.npmjs.com/package/content-type
// Definitions by: Hiroki Horiuchi <https://github.com/horiuchi>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
import * as express from 'express';
declare var ct: ct.StaticFunctions;
export = ct;
declare namespace ct {
interface StaticFunctions {
parse(string: string): MediaType;
parse(req: { headers: any; }): MediaType;
parse(res: { getHeader(key: string): string; }): MediaType;
parse(input: express.Request | express.Response | string): MediaType;
format(obj: MediaType): string;
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -1,10 +1,10 @@
// InAppBrowser plugin
//----------------------------------------------------------------------
// ----------------------------------------------------------------------
// signature of window.open() added by InAppBrowser plugin
// is similar to native window.open signature, so the compiler can's
// select proper overload, but we cast result to InAppBrowser manually.
var iab = <InAppBrowser>window.open('google.com', '_self');
const iab = <InAppBrowser> window.open('google.com', '_self');
iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); });
iab.addEventListener('loadstart', (ev) => { console.log('loadstart' + ev.url); });
@@ -30,5 +30,5 @@ iab.removeEventListener('exit', inAppBrowserCallBack);
iab.show();
iab.executeScript(
{ code: "console.log('Injected script in action')" },
()=> { console.log('Script is executed'); }
);
() => { console.log('Script is executed'); }
);

View File

@@ -1,40 +1,14 @@
// Type definitions for Apache Cordova InAppBrowser plugin
// Type definitions for Apache Cordova InAppBrowser plugin 1.7
// Project: https://github.com/apache/cordova-plugin-inappbrowser
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
//
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
// TypeScript Version: 2.3
type channel = "loadstart" | "loadstop" | "loaderror" | "exit";
interface Window {
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
open(url: string, target?: "_self", options?: string): InAppBrowser;
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
open(url: string, target?: "_blank", options?: string): InAppBrowser;
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
* The options string must not contain any blank space, and each feature's
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
open(url: string, target?: "_system", options?: string): InAppBrowser;
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
@@ -51,10 +25,10 @@ interface Window {
* NOTE: The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs.
*/
interface InAppBrowser extends Window {
onloadstart: (type: InAppBrowserEvent) => void;
onloadstop: (type: InAppBrowserEvent) => void;
onloaderror: (type: InAppBrowserEvent) => void;
onexit: (type: InAppBrowserEvent) => void;
onloadstart(type: InAppBrowserEvent): void;
onloadstop(type: InAppBrowserEvent): void;
onloaderror(type: InAppBrowserEvent): void;
onexit(type: InAppBrowserEvent): void;
// addEventListener overloads
/**
* Adds a listener for an event from the InAppBrowser.
@@ -65,7 +39,7 @@ interface InAppBrowser extends Window {
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: "loadstart" | "loadstop" | "loaderror" | "exit", callback: (event: InAppBrowserEvent) => void): void;
addEventListener(type: channel, callback: (event: InAppBrowserEvent) => void): void;
// removeEventListener overloads
/**
* Removes a listener for an event from the InAppBrowser.
@@ -77,7 +51,7 @@ interface InAppBrowser extends Window {
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: "loadstart" | "loadstop" | "loaderror" | "exit", callback: (event: InAppBrowserEvent) => void): void;
removeEventListener(type: channel, callback: (event: InAppBrowserEvent) => void): void;
/** Closes the InAppBrowser window. */
close(): void;
/** Hides the InAppBrowser window. Calling this has no effect if the InAppBrowser was already hidden. */
@@ -96,29 +70,13 @@ interface InAppBrowser extends Window {
* For multi-line scripts, this is the return value of the last statement,
* or the last expression evaluated.
*/
executeScript(script: { code: string }, callback: (result: any) => void): void;
/**
* Injects JavaScript code into the InAppBrowser window.
* @param script Details of the script to run, specifying either a file or code key.
* @param callback The function that executes after the JavaScript code is injected.
* If the injected script is of type code, the callback executes with
* a single parameter, which is the return value of the script, wrapped in an Array.
* For multi-line scripts, this is the return value of the last statement,
* or the last expression evaluated.
*/
executeScript(script: { file: string }, callback: (result: any) => void): void;
executeScript(script: { code: string } | { file: string }, callback: (result: any) => void): void;
/**
* Injects CSS into the InAppBrowser window.
* @param css Details of the script to run, specifying either a file or code key.
* @param callback The function that executes after the CSS is injected.
*/
insertCSS(css: { code: string }, callback: () => void): void;
/**
* Injects CSS into the InAppBrowser window.
* @param css Details of the script to run, specifying either a file or code key.
* @param callback The function that executes after the CSS is injected.
*/
insertCSS(css: { file: string }, callback: () => void): void;
insertCSS(css: { code: string } | { file: string }, callback: () => void): void;
}
interface InAppBrowserEvent extends Event {
@@ -130,4 +88,8 @@ interface InAppBrowserEvent extends Event {
code: number;
/** the error message, only in the case of loaderror. */
message: string;
}
}
interface Cordova {
InAppBrowser: InAppBrowser;
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -60,3 +60,4 @@ window.plugins.socialsharing.shareViaFacebook("Optional message, may be ignored
window.plugins.socialsharing.share("Optional message", "Optional title", ["www/manual.pdf", "https://www.google.nl/images/srpr/logo4w.png"], "http://www.myurl.com");
window.plugins.socialsharing.saveToPhotoAlbum(["https://www.google.nl/images/srpr/logo4w.png", "www/image.gif"], function () { console.log("share ok") }, function (msg) { alert("error: " + msg) });
window.plugins.socialsharing.shareWithOptions({"message":"sharethis","subject":"thesubject","files":["",""],"url":"https: //www.website.com/foo/#bar?a=b","chooserTitle":"Pickanapp"}, function () { console.log("share ok") }, function (msg) { alert("error: " + msg) });

View File

@@ -1,6 +1,6 @@
// Type definitions for SocialSharing-PhoneGap-Plugin v5.0.12
// Type definitions for SocialSharing-PhoneGap-Plugin v5.1.8
// Project: https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin
// Definitions by: Markus Wagner <https://github.com/Ritzlgrmft/>
// Definitions by: Markus Wagner <https://github.com/Ritzlgrmft/>, Larry Bahr <https://github.com/larrybahr>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Window {
@@ -18,6 +18,7 @@ declare module SocialSharingPlugin {
subject?: string;
files?: string | string[];
url?: string;
chooserTitle?: string;
}
interface ShareResult {

View File

@@ -243,15 +243,15 @@ promiseLikeOfPoint = promiseLikeOfPoint.then(p => promiseLikeOfPoint);
promiseLikeOfPoint = promiseLikeOfPoint.then(p => point, e => point);
promiseLikeOfPoint = promiseLikeOfPoint.then(p => promiseLikeOfPoint, e => point);
promiseLikeOfPoint = promiseLikeOfPoint.then(p => point, e => promiseLikeOfPoint);
promiseLikeOfPoint = promiseLikeOfPoint.then(p => point, e => { });
promiseLikeOfPoint = promiseLikeOfPoint.then(p => promiseLikeOfPoint, e => { });
promiseLikeOfPoint = promiseLikeOfPoint.then(p => point, e => { throw e; });
promiseLikeOfPoint = promiseLikeOfPoint.then(p => promiseLikeOfPoint, e => { throw e; });
promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d);
promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => promiseLikeOfPoint3D);
promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d, e => point3d);
promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => promiseLikeOfPoint3D, e => point3d);
promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d, e => promiseLikeOfPoint3D);
promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d, e => { });
promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => promiseLikeOfPoint3D, e => { });
promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => point3d, e => { throw e; });
promiseLikeOfPoint3D = promiseLikeOfPoint.then(p => promiseLikeOfPoint3D, e => { throw e; });
promiseOfPoint.then((point: Point) => { });
promiseOfPoint = promiseOfPoint.then();
promiseOfPoint = promiseOfPoint.then(p => point);
@@ -262,9 +262,9 @@ promiseOfPoint = promiseOfPoint.then(p => promiseOfPoint, e => point);
promiseOfPoint = promiseOfPoint.then(p => promiseLikeOfPoint, e => point);
promiseOfPoint = promiseOfPoint.then(p => point, e => promiseOfPoint);
promiseOfPoint = promiseOfPoint.then(p => point, e => promiseLikeOfPoint);
promiseOfPoint = promiseOfPoint.then(p => point, e => { });
promiseOfPoint = promiseOfPoint.then(p => promiseOfPoint, e => { });
promiseOfPoint = promiseOfPoint.then(p => promiseLikeOfPoint, e => { });
promiseOfPoint = promiseOfPoint.then(p => point, e => { throw e; });
promiseOfPoint = promiseOfPoint.then(p => promiseOfPoint, e => { throw e; });
promiseOfPoint = promiseOfPoint.then(p => promiseLikeOfPoint, e => { throw e; });
promiseOfPoint3D = promiseOfPoint.then(p => point3d);
promiseOfPoint3D = promiseOfPoint.then(p => promiseOfPoint3D);
promiseOfPoint3D = promiseOfPoint.then(p => promiseLikeOfPoint3D);
@@ -273,16 +273,16 @@ promiseOfPoint3D = promiseOfPoint.then(p => promiseOfPoint3D, e => point3d);
promiseOfPoint3D = promiseOfPoint.then(p => promiseLikeOfPoint3D, e => point3d);
promiseOfPoint3D = promiseOfPoint.then(p => point3d, e => promiseOfPoint3D);
promiseOfPoint3D = promiseOfPoint.then(p => point3d, e => promiseLikeOfPoint3D);
promiseOfPoint3D = promiseOfPoint.then(p => point3d, e => { });
promiseOfPoint3D = promiseOfPoint.then(p => promiseOfPoint3D, e => { });
promiseOfPoint3D = promiseOfPoint.then(p => promiseLikeOfPoint3D, e => { });
promiseOfPoint3D = promiseOfPoint.then(p => point3d, e => { throw e; });
promiseOfPoint3D = promiseOfPoint.then(p => promiseOfPoint3D, e => { throw e; });
promiseOfPoint3D = promiseOfPoint.then(p => promiseLikeOfPoint3D, e => { throw e; });
promiseOfPoint = promiseOfPoint.catch(e => point);
promiseOfPoint = promiseOfPoint.catch(e => promiseOfPoint);
promiseOfPoint = promiseOfPoint.catch(e => promiseLikeOfPoint);
promiseOfPoint = promiseOfPoint.catch(e => { });
promiseOfPoint3D = promiseOfPoint.catch(e => point3d);
promiseOfPoint3D = promiseOfPoint.catch(e => promiseOfPoint3D);
promiseOfPoint3D = promiseOfPoint.catch(e => promiseLikeOfPoint3D);
promiseOfPoint = promiseOfPoint.catch(e => { throw e; });
promiseOfPoint3D = promiseOfPoint.then(p2d => ({ ...p2d, z: 0 })).catch(e => point3d);
promiseOfPoint3D = promiseOfPoint.then(p2d => ({ ...p2d, z: 0 })).catch(e => promiseOfPoint3D);
promiseOfPoint3D = promiseOfPoint.then(p2d => ({ ...p2d, z: 0 })).catch(e => promiseLikeOfPoint3D);
promiseOfPoint = new Promise<Point>((resolve, reject) => resolve(point));
promiseOfPoint = new Promise<Point>((resolve, reject) => resolve(promiseOfPoint));
promiseOfPoint = new Promise<Point>((resolve, reject) => resolve(promiseLikeOfPoint));

185
types/cote/cote-tests.ts Normal file
View File

@@ -0,0 +1,185 @@
import * as cote from 'cote';
/**
* Examples from https://github.com/dashersw/cote. Note some differences, such
* as stricter request shape and Promises everywhere.
*/
class Readme {
requester() {
const randomRequester = new cote.Requester({
name: 'Random Requester',
namespace: 'rnd',
key: 'a certain key',
requests: ['randomRequest']
});
const req = {
type: 'randomRequest',
payload: {
val: Math.floor(Math.random() * 10)
}
};
randomRequester.send(req)
.then(console.log)
.catch(console.log)
.then(() => process.exit());
}
responder() {
const randomResponder = new cote.Responder({
name: 'Random Responder',
namespace: 'rnd',
key: 'a certain key',
respondsTo: ['randomRequest']
});
randomResponder.on('randomRequest', (req: cote.Action<{ val: number }>) => {
const answer = Math.floor(Math.random() * 10);
console.log('request', req.payload.val, 'answering with', answer);
return Promise.resolve(answer);
});
}
mongooseResponder() {
const UserModel = require('UserModel'); // a promise-based model API
const userResponder = new cote.Responder({ name: 'User Responder' });
userResponder.on('find', (req: cote.Action<{ username: string }>) => UserModel.findOne(req.payload));
}
mongooseRequester() {
const userRequester = new cote.Requester({ name: 'User Requester' });
userRequester
.send({ type: 'find', payload: { username: 'foo' } })
.then(user => console.log(user))
.then(() => process.exit());
}
publisher() {
const randomPublisher = new cote.Publisher({
name: 'Random Publisher',
namespace: 'rnd',
key: 'a certain key',
broadcasts: ['randomUpdate']
});
setInterval(() => {
const action = {
type: 'randomUpdate',
payload: {
val: Math.floor(Math.random() * 1000)
}
};
console.log('emitting', action);
randomPublisher.publish('randomUpdate', action);
}, 3000);
}
subscriber() {
const randomSubscriber = new cote.Subscriber({
name: 'Random Subscriber',
namespace: 'rnd',
key: 'a certain key',
subscribesTo: ['randomUpdate']
});
randomSubscriber.on('randomUpdate', (req) => {
console.log('notified of ', req);
});
}
sockend() {
const app = require('http').createServer(handler);
const io = require('socket.io').listen(app);
const fs = require('fs');
app.listen(process.argv[2] || 5555);
function handler(req: any, res: any) {
fs.readFile(__dirname + '/index.html', (err: Error, data: Buffer) => {
if (err) {
res.writeHead(500);
return res.end('Error loading index.html');
}
res.writeHead(200);
res.end(data);
});
}
const sockend = new cote.Sockend(io, {
name: 'Sockend',
key: 'a certain key'
});
}
keys() {
const purchaseRequester = new cote.Requester({
name: 'Purchase Requester',
key: 'purchase'
});
const inventoryRequester = new cote.Requester({
name: 'Inventory Requester',
key: 'inventory'
});
}
namespacesFront() {
const responder = new cote.Responder({
name: 'Conversion Sockend Responder',
namespace: 'conversion'
});
const conversionRequester = new cote.Requester({
name: 'Conversion Requester',
key: 'conversion backend'
});
responder.on('convert', (req) => {
return conversionRequester.send(req); // proxy the request
});
}
namespacesBack() {
const responder = new cote.Responder({
name: 'Conversion Responder',
key: 'conversion backend'
});
const rates: { [key: string]: number } = {
usd_eur: 0.91,
eur_usd: 1.10
};
responder.on('convert', (req: cote.Action<{
amount: number,
from: string,
to: string
}>) => {
const { payload } = req;
return Promise.resolve(payload.amount * rates[`${payload.from}_${payload.to}`]);
});
}
multicast() {
const cote = require('cote')({ multicast: '239.1.11.111' });
}
multicastComponent() {
const req = new cote.Requester({ name: 'req' }, { multicast: '239.1.11.111' });
}
broadcast() {
const cote = require('cote')({ broadcast: '255.255.255.255' });
}
broadcastComponent() {
const req = new cote.Requester({ name: 'req' }, { broadcast: '255.255.255.255' });
}
}

211
types/cote/index.d.ts vendored Normal file
View File

@@ -0,0 +1,211 @@
// Type definitions for cote 0.14
// Project: https://github.com/dashersw/cote#readme
// Definitions by: makepost <https://github.com/makepost>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as SocketIO from "socket.io";
import { Stream } from "stream";
import { Server } from "http";
export class Requester {
constructor(
/**
* Configuration which controls the data being advertised for auto-discovery.
*/
advertisement: Advertisement,
/**
* Controls the network-layer configuration and environments for components.
*/
discoveryOptions?: DiscoveryOptions
);
/**
* Queues a request until a Responder is available, and once so, delivers
* the request. Requests are dispatched to Responders in a round-robin way.
*
* @param action Request.
*/
send<T>(action: Action<T>): Promise<any>;
}
export class Responder {
constructor(
/**
* Configuration which controls the data being advertised for auto-discovery.
*/
advertisement: Advertisement,
/**
* Controls the network-layer configuration and environments for components.
*/
discoveryOptions?: DiscoveryOptions
);
/**
* Responds to certain requests from a Requester.
*
* @param type Type. May be wildcarded or namespaced like in EventEmitter2.
* @param listener Callback. Should return a result.
*/
on<T>(
type: string,
listener: (action: Action<T>) => Promise<any>
): void;
}
export class Publisher {
constructor(
/**
* Configuration which controls the data being advertised for auto-discovery.
*/
advertisement: Advertisement,
/**
* Controls the network-layer configuration and environments for components.
*/
discoveryOptions?: DiscoveryOptions
);
/**
* Publishes an event to all Subscribers. Does not wait for results. If
* there are no Subscribers listening, the event is lost.
*
* @param type EventEmitter-compatible type.
* @param action Request.
*/
publish<T>(
type: string,
action: Action<T>
): void;
}
export class Subscriber {
constructor(
/**
* Configuration which controls the data being advertised for auto-discovery.
*/
advertisement: Advertisement,
/**
* Controls the network-layer configuration and environments for components.
*/
discoveryOptions?: DiscoveryOptions
);
/**
* Subscribes to events emitted from a Publisher.
*
* @param type Type. May be wildcarded or namespaced like in EventEmitter2.
* @param listener Callback. Returns nothing.
*/
on<T>(
type: string,
listener: (action: Action<T>) => void
): void;
}
export class Sockend {
/**
* Exposes APIs directly to front-end. Make sure to use namespaces.
*/
constructor(
io: SocketIO.Server,
/**
* Configuration which controls the data being advertised for auto-discovery.
*/
advertisement: Advertisement,
/**
* Controls the network-layer configuration and environments for components.
*/
discoveryOptions?: DiscoveryOptions
);
}
export class Monitor {
constructor(
/**
* Configuration which controls the data being advertised for auto-discovery.
*/
advertisement: Advertisement,
/**
* Controls the network-layer configuration and environments for components.
*/
discoveryOptions?: DiscoveryOptions,
stream?: Stream
)
}
/**
* Displays the cote ecosystem running in your environment in a nice graph.
*
* @param port Open in browser to see network graph in action.
*/
export function MonitoringTool(port: number): {
monitor: Monitor,
server: Server
};
/**
* Flux standard action.
* @see https://github.com/acdlite/flux-standard-action
*/
export interface Action<T> {
type: string;
payload: T;
error?: boolean;
meta?: {};
}
/**
* Configuration which controls the data being advertised for auto-discovery.
*/
export interface Advertisement {
name: string;
/**
* Maps to a socket.io namespace. Shields a service from the rest of the
* system. Components with different namespaces won't recognize each other
* and try to communicate.
*/
namespace?: string;
/**
* Tunes the performance by grouping certain components. Two components
* with exact same `environment`s with different `key`s wouldn't be able
* to communicate. Think of it as `${environment}_${key}`.
*/
key?: string;
/**
* Request types that a Requester can send.
*/
requests?: string[];
/**
* Response types that a Responder can listen to.
*/
respondsTo?: string[];
/**
* Event types that a Publisher can publish.
*/
broadcasts?: string[];
/**
* Event types that a Subscriber can listen to.
*/
subscribesTo?: string[];
}
/**
* Controls the network-layer configuration and environments for components.
*/
export interface DiscoveryOptions {
multicast?: string;
broadcast?: string;
}

22
types/cote/tsconfig.json Normal file
View File

@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"cote-tests.ts"
]
}

1
types/cote/tslint.json Normal file
View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -60,12 +60,35 @@ $(document).ready(function () {
sort: "asc"
};
var colRenderFunc: DataTables.FunctionColumnRender = function (data, type, row, meta) {
var colRenderFunc: DataTables.FunctionColumnRender = (data: any, type: 'filter' | 'display' | 'type' | 'sort' | undefined | any, row: any, meta: DataTables.CellMetaSettings): any => {
meta.col;
meta.row;
meta.settings;
switch (type) {
case undefined:
return data.value;
case 'filter':
return data.filterValue;
case 'display':
return data.displayValue;
case 'type':
return data.typeValue;
case 'sort':
return data.sortValue;
default:
// Extensibility: the render type can be a custom value, useful for plugins that require custom rendering.
// Custom values are declared as any.
return data.valueForPlugin;
}
};
colRenderFunc({}, 'filter', {}, null);
colRenderFunc({}, 'display', {}, null);
colRenderFunc({}, 'type', {}, null);
colRenderFunc({}, 'sort', {}, null);
colRenderFunc({}, undefined, {}, null);
colRenderFunc({}, 'custom value', {}, null);
var col: DataTables.ColumnSettings =
{
cellType: "th",

View File

@@ -1604,7 +1604,7 @@ declare namespace DataTables {
}
interface FunctionColumnRender {
(data: any, t: string, row: any, meta: CellMetaSettings): void;
(data: any, type: 'filter' | 'display' | 'type' | 'sort' | undefined | any, row: any, meta: CellMetaSettings): any;
}
interface CellMetaSettings {

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/db-migrate/db-migrate-base
// Definitions by: nickiannone <https://github.com/nickiannone>
// Definitions: https://github.com/nickiannone/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="node"/>

View File

@@ -2,6 +2,7 @@
// Project: https://github.com/db-migrate/pg
// Definitions by: nickiannone <http://github.com/nickiannone>
// Definitions: https://github.com/nickiannone/DefinitelyTyped
// TypeScript Version: 2.3
import * as pg from "pg";
import * as DbMigrateBase from "db-migrate-base";

View File

@@ -11,7 +11,7 @@ import {
RichUtils,
SelectionState,
getDefaultKeyBinding,
ContentState,
ContentState,
convertFromHTML
} from 'draft-js';
@@ -183,7 +183,7 @@ function getBlockStyle(block: ContentBlock) {
}
}
class StyleButton extends React.Component<{key: string, active: boolean, label: string, onToggle: (blockType: string) => void, style: string}, {}> {
class StyleButton extends React.Component<{key: string, active: boolean, label: string, onToggle: (blockType: string) => void, style: string}> {
constructor() {
super();
}

View File

@@ -5,7 +5,7 @@
// Yale Cason <https://github.com/ghotiphud>
// Ryan Schwers <https://github.com/schwers>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.3
import * as React from 'react';
import * as Immutable from 'immutable';
@@ -37,7 +37,7 @@ declare namespace Draft {
* div, and provides a wide variety of useful function props for managing the
* state of the editor. See `DraftEditorProps` for details.
*/
class DraftEditor extends React.Component<DraftEditorProps, any> {
class DraftEditor extends React.Component<DraftEditorProps> {
// Force focus back onto the editor node.
focus(): void;
// Remove focus from the editor node.
@@ -162,7 +162,7 @@ declare namespace Draft {
}
namespace Components {
class DraftEditorBlock extends React.Component<any, any> {
class DraftEditorBlock extends React.Component<any> {
}
}

View File

@@ -1,4 +1,4 @@
import * as settings from 'electron-settings';
import settings = require('electron-settings');
function test_configure() {
settings.configure({
@@ -59,6 +59,7 @@ async function test_clear() {
function test_clearSync() {
settings.clearSync() === undefined;
}
async function test_applyDefaults() {
await settings.applyDefaults({ overwrite: true }) === undefined;
}
@@ -100,3 +101,23 @@ function test_on_write() {
console.log();
}) === settings;
}
function test_settings_type_annotation(s: typeof settings) {
s.getSettingsFilePath();
}
function test_observer_type_annotation(observer: settings.Observer) {
observer.dispose();
}
function test_options_type_annotation(options: settings.Options) {
options.atomicSaving;
}
function test_applyDefaultOptions_type_annotation(options: settings.ApplyDefaultsOptions) {
options.overwrite;
}
function test_changeEvent_type_annotation(e: settings.ChangeEvent) {
e.oldValue === e.newValue;
}

View File

@@ -6,7 +6,10 @@
/// <reference types="node" />
import * as EventEmitter from 'events';
import { EventEmitter } from 'events';
declare const SettingsInstance: Settings;
export = SettingsInstance;
/**
* The Settings class.
@@ -17,7 +20,7 @@ declare class Settings extends EventEmitter {
*
* @throws if options is not an object.
*/
configure(options: ElectronSettings.Options | object): void;
configure(options: ElectronSettings.Options.Param): void;
/**
* Globally configures default settings.
@@ -76,14 +79,14 @@ declare class Settings extends EventEmitter {
* @throws if options is not an object.
* @see setSync
*/
set(keyPath: string, value: any, options?: ElectronSettings.Options | object): Promise<void>;
set(keyPath: string, value: any, options?: ElectronSettings.Options.Param): Promise<void>;
/**
* The synchronous version of set().
*
* @see set
*/
setSync(keyPath: string, value: any, options?: ElectronSettings.Options | object): void;
setSync(keyPath: string, value: any, options?: ElectronSettings.Options.Param): void;
/**
* Deletes the key and value at the chosen key path.
@@ -94,14 +97,14 @@ declare class Settings extends EventEmitter {
* @throws if options is not an object.
* @see deleteSync
*/
delete(keyPath: string, options?: ElectronSettings.Options | object): Promise<void>;
delete(keyPath: string, options?: ElectronSettings.Options.Param): Promise<void>;
/**
* The synchronous version of delete().
*
* @see delete
*/
deleteSync(keyPath: string, options?: ElectronSettings.Options | object): void;
deleteSync(keyPath: string, options?: ElectronSettings.Options.Param): void;
/**
* Clears the entire settings object.
@@ -110,14 +113,14 @@ declare class Settings extends EventEmitter {
* @throws if options is not an object.
* @see clearSync
*/
clear(options?: ElectronSettings.Options | object): Promise<void>;
clear(options?: ElectronSettings.Options.Param): Promise<void>;
/**
* The synchronous version of clear().
*
* @see clear
*/
clearSync(options?: ElectronSettings.Options | object): void;
clearSync(options?: ElectronSettings.Options.Param): void;
/**
* Applies defaults to the current settings object (deep).
@@ -130,14 +133,14 @@ declare class Settings extends EventEmitter {
* @see defaults
* @see applyDefaultsSync
*/
applyDefaults(options?: ElectronSettings.ApplyDefaultsOptions | object): Promise<void>;
applyDefaults(options?: ElectronSettings.ApplyDefaultsOptions.Param): Promise<void>;
/**
* The synchronous version of applyDefaults().
*
* @see applyDefaults
*/
applyDefaultsSync(options?: ElectronSettings.ApplyDefaultsOptions | object): void;
applyDefaultsSync(options?: ElectronSettings.ApplyDefaultsOptions.Param): void;
/**
* Resets all settings to defaults.
@@ -148,14 +151,14 @@ declare class Settings extends EventEmitter {
* @see defaults
* @see resetToDefaultsSync
*/
resetToDefaults(options?: ElectronSettings.Options | object): Promise<void>;
resetToDefaults(options?: ElectronSettings.Options.Param): Promise<void>;
/**
* The synchronous version of resetToDefaults().
*
* @see resetToDefaults
*/
resetToDefaultsSync(options?: ElectronSettings.Options | object): void;
resetToDefaultsSync(options?: ElectronSettings.Options.Param): void;
/**
* Observes the chosen key path for changes and calls the handler if the value changes.
@@ -187,8 +190,12 @@ declare class Settings extends EventEmitter {
on(event: 'write', listener: () => void): this;
}
declare const SettingsInstance: Settings;
export = SettingsInstance;
declare namespace SettingsInstance {
type Observer = ElectronSettings.Observer;
type Options = ElectronSettings.Options;
type ApplyDefaultsOptions = ElectronSettings.ApplyDefaultsOptions;
type ChangeEvent = ElectronSettings.ChangeEvent;
}
declare namespace ElectronSettings {
/**
@@ -205,6 +212,8 @@ declare namespace ElectronSettings {
interface Options extends Pick<Options._Impl, keyof Options._Impl> { }
namespace Options {
type Param = Options | object;
interface _Impl {
/**
* Whether electron-settings should create a tmp file during save to ensure data-write consistency.
@@ -224,6 +233,8 @@ declare namespace ElectronSettings {
interface ApplyDefaultsOptions extends Pick<ApplyDefaultsOptions._Impl, keyof ApplyDefaultsOptions._Impl> { }
namespace ApplyDefaultsOptions {
type Param = ApplyDefaultsOptions | object;
interface _Impl extends Options._Impl {
/**
* Overwrite pre-existing settings with their respective default values.

View File

@@ -8,14 +8,14 @@
// huhuanming <https://github.com/huhuanming>
// MartynasZilinskas <https://github.com/MartynasZilinskas>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.3
/// <reference types="cheerio" />
import { ReactElement, Component, HTMLAttributes as ReactHTMLAttributes, SVGAttributes as ReactSVGAttributes } from "react";
export type HTMLAttributes = ReactHTMLAttributes<{}> & ReactSVGAttributes<{}>;
export class ElementClass extends Component<any, any> {
export class ElementClass extends Component<any> {
}
/* These are purposefully stripped down versions of React.ComponentClass and React.StatelessComponent.
@@ -23,7 +23,7 @@ export class ElementClass extends Component<any, any> {
* all specified in the implementation. TS chooses the EnzymePropSelector overload and loses the generics
*/
export interface ComponentClass<Props> {
new (props?: Props, context?: any): Component<Props, any>;
new (props?: Props, context?: any): Component<Props>;
}
export type StatelessComponent<Props> = (props: Props, context?: any) => JSX.Element;

View File

@@ -0,0 +1,6 @@
import express = require('express');
import expressEnforcesSsl = require('express-enforces-ssl');
let app: express.Express = express();
app.use(expressEnforcesSsl());

13
types/express-enforces-ssl/index.d.ts vendored Normal file
View File

@@ -0,0 +1,13 @@
// Type definitions for express-enforces-ssl 1.1
// Project: https://github.com/aredo/express-enforces-ssl
// Definitions by: Kevin Stubbs <https://github.com/kevinstubbs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Request, Response, NextFunction } from 'express';
/**
* Enforces HTTPS connections on any incoming requests.
*/
declare function enforceHTTPS(): (req: Request, res: Response, next: NextFunction) => void;
export = enforceHTTPS;

View File

@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"express-enforces-ssl-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@@ -57,3 +57,8 @@ request
.post('')
.send({})
.json();
request
.post('')
.append('key', 'value')
.append({key: 'value'});

View File

@@ -1,4 +1,4 @@
// Type definitions for fetch.io 3.1
// Type definitions for fetch.io 4.0
// Project: https://github.com/haoxins/fetch.io
// Definitions by: newraina <https://github.com/newraina>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -95,7 +95,9 @@ export class Request {
/**
* ppend formData
*/
append(key: string, value: string): this;
append(key: string, value: any): this;
append(object: {[key: string]: any}): this;
/**
* Get Response directly

View File

@@ -0,0 +1,3 @@
import * as ffmpegStatic from 'ffmpeg-static';
ffmpegStatic.path;

10
types/ffmpeg-static/index.d.ts vendored Normal file
View File

@@ -0,0 +1,10 @@
// Type definitions for ffmpeg-static 2.0
// Project: https://github.com/eugeneware/ffmpeg-static#readme
// Definitions by: Steve Tran <https://github.com/iamstevetran>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/*~ You can declare properties of the module using const, let, or var */
/**
* Binary location
*/
export const path: string;

View File

@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"ffmpeg-static-tests.ts"
]
}

Some files were not shown because too many files have changed in this diff Show More