diff --git a/angular-translate/index.d.ts b/angular-translate/index.d.ts index 19e1962fab..3b911ba313 100644 --- a/angular-translate/index.d.ts +++ b/angular-translate/index.d.ts @@ -51,8 +51,8 @@ declare module 'angular' { cloakClassName(name: string): ITranslateProvider; fallbackLanguage(langKey?: string): string; fallbackLanguage(langKey?: string[]): string; - instant(translationId: string, interpolateParams?: any, interpolationId?: string): string; - instant(translationId: string[], interpolateParams?: any, interpolationId?: string): { [key: string]: string }; + instant(translationId: string, interpolateParams?: any, interpolationId?: string, forceLanguage?: string, sanitizeStrategy?: string): string; + instant(translationId: string[], interpolateParams?: any, interpolationId?: string, forceLanguage?: string, sanitizeStrategy?: string): { [key: string]: string }; isPostCompilingEnabled(): boolean; preferredLanguage(langKey?: string): string; proposedLanguage(): string; diff --git a/angular-ui-router/angular-ui-router-tests.ts b/angular-ui-router/angular-ui-router-tests.ts index 38ddcca26b..174c319f97 100644 --- a/angular-ui-router/angular-ui-router-tests.ts +++ b/angular-ui-router/angular-ui-router-tests.ts @@ -143,7 +143,7 @@ class UrlLocatorTestService implements IUrlLocatorTestService { private $state: ng.ui.IStateService ) { $rootScope.$on("$locationChangeSuccess", (event: ng.IAngularEvent) => this.onLocationChangeSuccess(event)); - $rootScope.$on('$stateNotFound', (event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) => + $rootScope.$on('$stateNotFound', (event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) => this.onStateNotFound(event, unfoundState, fromState, fromParams)); } @@ -157,8 +157,8 @@ class UrlLocatorTestService implements IUrlLocatorTestService { // Note that we do not concern ourselves with what to do if this request fails, // because if it fails, the web page will be redirected away to the login screen. - this.$http({ url: "/api/me", method: "GET" }).success((user: any) => { - this.currentUser = user; + this.$http({ url: "/api/me", method: "GET" }).then((response: ng.IHttpPromiseCallbackArg) => { + this.currentUser = response.data; // sync the ui-state with the location in the browser, which effectively // restarts the state change that was stopped previously @@ -166,14 +166,14 @@ class UrlLocatorTestService implements IUrlLocatorTestService { }); } } - + private onStateNotFound(event: ng.IAngularEvent, unfoundState: ng.ui.IUnfoundState, fromState: ng.ui.IState, fromParams: {}) { var unfoundTo: string = unfoundState.to; var unfoundToParams: {} = unfoundState.toParams; - var unfoundOptions: ng.ui.IStateOptions = unfoundState.options + var unfoundOptions: ng.ui.IStateOptions = unfoundState.options } private stateServiceTest() { diff --git a/angular/angular-tests.ts b/angular/angular-tests.ts index cca4dfc420..8634269fb0 100644 --- a/angular/angular-tests.ts +++ b/angular/angular-tests.ts @@ -108,11 +108,6 @@ namespace HttpAndRegularPromiseTests { } function someController($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) { - $http.get('http://somewhere/some/resource') - .success((data: ExpectedResponse) => { - $scope.person = data; - }); - $http.get('http://somewhere/some/resource') .then((response: ng.IHttpPromiseCallbackArg) => { // typing lost, so something like @@ -156,21 +151,6 @@ namespace HttpAndRegularPromiseTests { $scope.nothing = 'really nothing'; }); } - - // Test that we can pass around a type-checked success/error Promise Callback - function anotherController($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) { - function buildFooData(): ng.IRequestShortcutConfig { - return {}; - } - - function doFoo(callback: ng.IHttpPromiseCallback) { - $http - .get('/foo', buildFooData()) - .success(callback); - }; - - doFoo((data: any) => console.log(data)); - }; } // Test for AngularJS Syntax @@ -441,10 +421,10 @@ httpFoo.then((x) => { x.toFixed(); }); -httpFoo.success((data, status, headers, config) => { - const h = headers('test'); +httpFoo.then((response: ng.IHttpPromiseCallbackArg) => { + const h = response.headers('test'); h.charAt(0); - const hs = headers(); + const hs = response.headers(); hs['content-type'].charAt(1); }); diff --git a/angular/index.d.ts b/angular/index.d.ts index 099ac2fc27..67979435f1 100644 --- a/angular/index.d.ts +++ b/angular/index.d.ts @@ -1505,18 +1505,6 @@ declare namespace angular { } interface IHttpPromise extends IPromise> { - /** - * The $http legacy promise methods success and error have been deprecated. Use the standard then method instead. - * If $httpProvider.useLegacyPromiseExtensions is set to false then these methods will throw $http/legacy error. - * @deprecated - */ - success?(callback: IHttpPromiseCallback): IHttpPromise; - /** - * The $http legacy promise methods success and error have been deprecated. Use the standard then method instead. - * If $httpProvider.useLegacyPromiseExtensions is set to false then these methods will throw $http/legacy error. - * @deprecated - */ - error?(callback: IHttpPromiseCallback): IHttpPromise; } // See the jsdoc for transformData() at https://github.com/angular/angular.js/blob/master/src/ng/http.js#L228 diff --git a/auth0/index.d.ts b/auth0/index.d.ts index b24b808529..a8a6242bb4 100644 --- a/auth0/index.d.ts +++ b/auth0/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for auth0 v2.3.1 +// Type definitions for auth0 2.4 // Project: https://github.com/auth0/node-auth0 -// Definitions by: Seth Westphal +// Definitions by: Wilson Hobbs , Seth Westphal // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as Promise from 'bluebird'; @@ -10,8 +10,8 @@ export interface ManagementClientOptions { domain?: string; } -export type UserMetadata = {}; -export type AppMetadata = {}; +export interface UserMetadata { } +export interface AppMetadata { } export interface UserData { connection: string; @@ -71,34 +71,353 @@ export interface UpdateUserParameters { id: string; } -export class ManagementClient { - constructor(options: ManagementClientOptions); - - getUsers(params?: GetUsersData): Promise; - getUsers(params?: GetUsersData, cb?: (err: Error, users: User[]) => void): void; - createUser(data: UserData): Promise; - createUser(data: UserData, cb: (err: Error, data: User) => void): void; - updateUser(params: UpdateUserParameters, data: User): Promise; - updateUser(params: UpdateUserParameters, data: User, cb: (err: Error, data: User) => void): void; - updateUserMetadata(params: UpdateUserParameters, data: UserMetadata): Promise; - updateUserMetadata(params: UpdateUserParameters, data: UserMetadata, cb: (err: Error, data: User) => void): void - updateAppMetadata(params: UpdateUserParameters, data: AppMetadata): Promise; - updateAppMetadata(params: UpdateUserParameters, data: AppMetadata, cb: (err: Error, data: User) => void): void -} - export interface AuthenticationClientOptions { clientId?: string; domain: string; } -export interface RequestChangePasswordEmailData { +interface Environment { + name: string; + version: string; +} + +export interface ClientInfo { + name: string; + version: string; + dependencies: any[]; + environment: Environment[]; +} + +export interface RequestEmailOptions { + email: string; + authParams: {}; +} + +export interface RequestSMSOptions { + phone_number: string; +} + +export interface VerifyOptions { + username: string; + password: string; +} + +export interface DelegationTokenOptions { + id_token: string; + api_type: string; + scope: string; + target: string; + grant_type: string; +} + +export interface ResetPasswordOptions { connection: string; email: string; + password: string; } +export interface ResetPasswordEmailOptions { + email: string; + connection: string; +} + +export interface ObjectWithId { + id: string; +} + +export interface Data { + name?: string; + [propName: string]: any; +} + +export interface ClientParams { + client_id: string; +} + +export interface DeleteMultifactorParams { + id: string; + provider: string; +} + +export interface LinkAccountsParams { + id: string; + provider: string; + user_id: string; +} + +export interface LinkAccountsData { + user_id: string; + connection_id: string; +} + +export interface Token { + aud: string; + jti: string; +} + +export interface StatsParams { + from: string; + to: string; +} + +export interface ImportUsersOptions { + connection_id: string; + users: string; +} + +export interface UserIdParams { + user_id: string; +} + +export interface PasswordChangeTicketParams { + result_url: string; + user_id: string; + email: string; + new_password: string; +} + +export interface EmailVerificationTicketOptions { + user_id: string; + result_url: string; +} + + + export class AuthenticationClient { constructor(options: AuthenticationClientOptions); + getClientInfo(): ClientInfo; + + requestMagicLink(data: RequestEmailOptions): Promise; + requestMagicLink(data: RequestEmailOptions, cb: (err: Error, message: string) => void): void; + + requestEmailCode(data: RequestEmailOptions): Promise; + requestEmailCode(data: RequestEmailOptions, cb: (err: Error, message: string) => void): void; + + requestSMSCode(data: RequestSMSOptions): Promise; + requestSMSCode(data: RequestSMSOptions, cb: (err: Error, message: string) => void): void; + + verifyEmailCode(data: VerifyOptions): Promise; + verifyEmailCode(data: VerifyOptions, cb: (err: Error, message: string) => void): void; + + verifySMSCode(data: VerifyOptions): Promise; + verifySMSCode(data: VerifyOptions, cb: (err: Error, message: string) => void): void; + + getDelegationToken(data: DelegationTokenOptions): Promise; + getDelegationToken(data: DelegationTokenOptions, cb: (err: Error, message: string) => void): void; + + changePassword(data: ResetPasswordOptions): Promise; + changePassword(data: ResetPasswordOptions, cb: (err: Error, message: string) => void): void; + + requestChangePasswordEmail(data: ResetPasswordEmailOptions): Promise; + requestChangePasswordEmail(data: ResetPasswordEmailOptions, cb: (err: Error, message: string) => void): void; + + getProfile(accessToken: string): Promise; + getProfile(accessToken: string, cb: (err: Error, message: string) => void): void; + + getCredentialsGrant(scope: string): Promise; + getCredentialsGrant(scope: string, cb: (err: Error, message: string) => void): void; + +} + + +export class ManagementClient { + constructor(options: ManagementClientOptions); + + getClientInfo(): ClientInfo; + + // Connections + getConnections(): Promise; + getConnections(cb: (err: Error, data: any) => void): void; + + createConnection(data: ObjectWithId): Promise; + createConnection(data: ObjectWithId, cb: (err: Error, data: any) => void): void; + + getConnection(params: ObjectWithId, cb: (err: Error, data: any) => void): void; + getConnection(params: ObjectWithId): Promise; + + deleteConnection(params: ObjectWithId, cb: (err: Error, data: any) => void): void; + deleteConnection(params: ObjectWithId): Promise; + + deleteConnection(params: ObjectWithId, cb: (err: Error, data: any) => void): void; + deleteConnection(params: ObjectWithId): Promise; + + updateConnection(params: ObjectWithId, data: Data, cb: (err: Error, data: any) => void): void; + updateConnection(params: ObjectWithId, data: Data): Promise; + + + // Clients + getClients(): Promise; + getClients(cb: (err: Error, data: any) => void): void; + + getClient(params: ClientParams): Promise; + getClient(params: ClientParams, cb: (err: Error, data: any) => void): void; + + createClient(data: Data): Promise; + createClient(data: Data, cb: (err: Error, data: any) => void): void; + + updateClient(params: ClientParams, data: Data): Promise; + updateClient(params: ClientParams, data: Data, cb: (err: Error, data: any) => void): void; + + deleteClient(params: ClientParams): Promise; + deleteClient(params: ClientParams, cb: (err: Error, data: any) => void): void; + + // Client Grants + getClientGrants(): Promise; + getClientGrants(cb: (err: Error, data: any) => void): void; + + createClientGrant(data: Data): Promise; + createClientGrant(data: Data, cb: (err: Error, data: any) => void): void; + + updateClientGrant(params: ObjectWithId, data: Data): Promise; + updateClientGrant(params: ObjectWithId, data: Data, cb: (err: Error, data: any) => void): void; + + deleteClientGrant(params: ObjectWithId): Promise; + deleteClientGrant(params: ObjectWithId, cb: (err: Error, data: any) => void): void; + + + // Device Keys + getDeviceCredentials(): Promise; + getDeviceCredentials(cb: (err: Error, data: any) => void): void; + + createDevicePublicKey(data: Data): Promise; + createDevicePublicKey(data: Data, cb: (err: Error, data: any) => void): void; + + deleteDeviceCredential(params: ClientParams): Promise; + deleteDeviceCredential(params: ClientParams, cb: (err: Error, data: any) => void): void; + + + // Rules + getRules(): Promise; + getRules(cb: (err: Error, data: any) => void): void; + + getRule(params: ClientParams): Promise; + getRule(params: ClientParams, cb: (err: Error, data: any) => void): void; + + createRules(data: Data): Promise; + createRules(data: Data, cb: (err: Error, data: any) => void): void; + + updateRule(params: ObjectWithId, data: Data): Promise; + updateRule(params: ObjectWithId, data: Data, cb: (err: Error, data: any) => void): void; + + deleteRule(params: ObjectWithId): Promise; + deleteRule(params: ObjectWithId, cb: (err: Error, data: any) => void): void; + + + // Users + getUsers(params?: GetUsersData): Promise; + getUsers(params?: GetUsersData, cb?: (err: Error, users: User[]) => void): void; + + getUser(params?: ObjectWithId): Promise; + getUser(params?: ObjectWithId, cb?: (err: Error, users: User[]) => void): void; + + createUser(data: UserData): Promise; + createUser(data: UserData, cb: (err: Error, data: User) => void): void; + + updateUser(params: UpdateUserParameters, data: User): Promise; + updateUser(params: UpdateUserParameters, data: User, cb: (err: Error, data: User) => void): void; + + updateUserMetadata(params: UpdateUserParameters, data: UserMetadata): Promise; + updateUserMetadata(params: UpdateUserParameters, data: UserMetadata, cb: (err: Error, data: User) => void): void; + + deleteAllUsers(): Promise; + deleteAllUsers(cb: (err: Error, data: any) => void): void; + + deleteUser(params?: ObjectWithId): Promise; + deleteUser(params?: ObjectWithId, cb?: (err: Error, users: User[]) => void): void; + + updateAppMetadata(params: UpdateUserParameters, data: AppMetadata): Promise; + updateAppMetadata(params: UpdateUserParameters, data: AppMetadata, cb: (err: Error, data: User) => void): void; + + deleteUserMultifactor(params: DeleteMultifactorParams): Promise; + deleteUserMultifactor(params: DeleteMultifactorParams, cb: (err: Error, data: any) => void): void; + + unlinkUsers(params: LinkAccountsParams): Promise; + unlinkUsers(params: LinkAccountsParams, cb: (err: Error, data: any) => void): void; + + linkUsers(params: ObjectWithId, data: LinkAccountsData): Promise; + linkUsers(params: ObjectWithId, data: LinkAccountsData, cb: (err: Error, data: any) => void): void; + + + // Tokens + getBlacklistedTokens(): Promise; + getBlacklistedTokens(cb?: (err: Error, data: any) => void): void; + + blacklistToken(token: Token): Promise; + blacklistToken(token: Token, cb: (err: Error, data: any) => void): void; + + + // Providers + getEmailProvider(): Promise; + getEmailProvider(cb?: (err: Error, data: any) => void): void; + + configureEmailProvider(data: Data): Promise; + configureEmailProvider(data: Data, cb: (err: Error, data: any) => void): void; + + deleteEmailProvider(): Promise; + deleteEmailProvider(cb?: (err: Error, data: any) => void): void; + + updateEmailProvider(data: Data): Promise; + updateEmailProvider(data: Data, cb?: (err: Error, data: any) => void): void; + + + // Statistics + getActiveUsersCount(): Promise; + getActiveUsersCount(cb?: (err: Error, data: any) => void): void; + + getDailyStats(data: StatsParams): Promise; + getDailyStats(data: StatsParams, cb: (err: Error, data: any) => void): void; + + + // Tenant + getTenantSettings(): Promise; + getTenantSettings(cb?: (err: Error, data: any) => void): void; + + updateTenantSettings(data: Data): Promise; + updateTenantSettings(data: Data, cb?: (err: Error, data: any) => void): void; + + + // Jobs + getJob(params: ObjectWithId): Promise; + getJob(params: ObjectWithId, cb?: (err: Error, data: any) => void): void; + + importUsers(data: ImportUsersOptions): Promise; + importUsers(data: ImportUsersOptions, cb?: (err: Error, data: any) => void): void; + + sendEmailVerification(data: UserIdParams): Promise; + sendEmailVerification(data: UserIdParams, cb?: (err: Error, data: any) => void): void; + + // Tickets + createPasswordChangeTicket(params: PasswordChangeTicketParams): Promise; + createPasswordChangeTicket(params: PasswordChangeTicketParams, cb?: (err: Error, data: any) => void): void; + + createEmailVerificationTicket(data: EmailVerificationTicketOptions): Promise; + createEmailVerificationTicket(data: EmailVerificationTicketOptions, cb?: (err: Error, data: any) => void): void; + + // Logs + getLog(params: ObjectWithId): Promise; + getLog(params: ObjectWithId, cb?: (err: Error, data: any) => void): void; + + getLogs(): Promise; + getLogs(cb?: (err: Error, data: any) => void): void; + + + // Resource Server + createResourceServer(data: Data): Promise; + createResourceServer(data: Data, cb?: (err: Error, data: any) => void): void; + + getResourceServers(): Promise; + getResourceServers(cb?: (err: Error, data: any) => void): void; + + getResourceServer(data: ObjectWithId): Promise; + getResourceServer(data: ObjectWithId, cb?: (err: Error, data: any) => void): void; + + deleteResourceServer(params: ObjectWithId): Promise; + deleteResourceServer(params: ObjectWithId, cb?: (err: Error, data: any) => void): void; + + updateResourceServer(params: ObjectWithId, data: Data): Promise; + updateResourceServer(params: ObjectWithId, data: Data, cb?: (err: Error, data: any) => void): void; + + + - requestChangePasswordEmail(data: RequestChangePasswordEmailData): Promise; - requestChangePasswordEmail(data: RequestChangePasswordEmailData, cb: (err: Error, message: string) => void): void; } diff --git a/body-parser/index.d.ts b/body-parser/index.d.ts index b8a1b0dc86..4627c2c5b3 100644 --- a/body-parser/index.d.ts +++ b/body-parser/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for body-parser // Project: http://expressjs.com -// Definitions by: Santi Albo , VILIC VANE , Jonathan Häberle +// Definitions by: Santi Albo , VILIC VANE , Jonathan Häberle , Gevik Babakhani // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -41,7 +41,14 @@ declare function bodyParser(options?: { }): express.RequestHandler; declare namespace bodyParser { - export function json(options?: { + + /** + * Interface for defining the options for the json() middleware + * + * @export + * @interface JsonOptions + */ + export interface JsonOptions { /** * if deflated bodies will be inflated. (default: true) */ @@ -66,9 +73,15 @@ declare namespace bodyParser { * passed to JSON.parse(). */ reviver?: (key: string, value: any) => any; - }): express.RequestHandler; + } - export function raw(options?: { + /** + * Interface for defining the options the raw() middleware + * + * @export + * @interface RawOptions + */ + export interface RawOptions { /** * if deflated bodies will be inflated. (default: true) */ @@ -85,9 +98,15 @@ declare namespace bodyParser { * function to verify body content, the parsing can be aborted by throwing an error. */ verify?: (req: express.Request, res: express.Response, buf: Buffer, encoding: string) => void; - }): express.RequestHandler; + } - export function text(options?: { + /** + * Interface for defining the options for the text() middleware + * + * @export + * @interface TextOptions + */ + export interface TextOptions { /** * if deflated bodies will be inflated. (default: true) */ @@ -108,9 +127,15 @@ declare namespace bodyParser { * the default charset to parse as, if not specified in content-type. (default: 'utf-8') */ defaultCharset?: string; - }): express.RequestHandler; + } - export function urlencoded(options: { + /** + * Interface for defining the options for the urlencoded() middleware + * + * @export + * @interface UrlEncodedOptions + */ + export interface UrlEncodedOptions { /** * if deflated bodies will be inflated. (default: true) */ @@ -131,7 +156,47 @@ declare namespace bodyParser { * parse extended syntax with the qs module. */ extended: boolean; - }): express.RequestHandler; + } + + /** + * Returns middleware that only parses json. This parser accepts any Unicode encoding + * of the body and supports automatic inflation of gzip and deflate encodings. + * + * @export + * @param {JsonOptions} [options] + * @returns {express.RequestHandler} + */ + export function json(options?: JsonOptions): express.RequestHandler; + + /** + * Returns middleware that parses all bodies as a Buffer. This parser supports automatic + * inflation of gzip and deflate encodings. + * + * @export + * @param {RawOptions} [options] + * @returns {express.RequestHandler} + */ + export function raw(options?: RawOptions): express.RequestHandler; + + /** + * Returns middleware that parses all bodies as a string. This parser supports + * automatic inflation of gzip and deflate encodings. + * + * @export + * @param {TextOptions} [options] + * @returns {express.RequestHandler} + */ + export function text(options?: TextOptions): express.RequestHandler; + + /** + * Returns middleware that only parses urlencoded bodies. This parser accepts only + * UTF-8 encoding of the body and supports automatic inflation of gzip and deflate encodings. + * + * @export + * @param {UrlEncodedOptions} [options] + * @returns {express.RequestHandler} + */ + export function urlencoded(options?: UrlEncodedOptions): express.RequestHandler; } export = bodyParser; diff --git a/chai/index.d.ts b/chai/index.d.ts index 44750136c8..532aa3b579 100644 --- a/chai/index.d.ts +++ b/chai/index.d.ts @@ -358,6 +358,7 @@ declare namespace Chai { sameMembers(set1: any[], set2: any[], msg?: string): void; sameDeepMembers(set1: any[], set2: any[], msg?: string): void; includeMembers(superset: any[], subset: any[], msg?: string): void; + includeDeepMembers(superset: any[], subset: any[], msg?: string): void; ifError(val: any, msg?: string): void; diff --git a/chart.js/index.d.ts b/chart.js/index.d.ts index 0830e68498..08781f4463 100644 --- a/chart.js/index.d.ts +++ b/chart.js/index.d.ts @@ -103,6 +103,7 @@ declare namespace Chart { animation?: ChartAnimationOptions; elements?: ChartElementsOptions; scales?: ChartScales; + cutoutPercentage?: number; } export interface ChartFontOptions { diff --git a/d3-array/d3-array-tests.ts b/d3-array/d3-array-tests.ts index 26ef2d3ef5..e086fd2502 100644 --- a/d3-array/d3-array-tests.ts +++ b/d3-array/d3-array-tests.ts @@ -25,7 +25,6 @@ class NumCoercible { } } - class MixedObject { public num: number; @@ -40,18 +39,23 @@ class MixedObject { this.date = date; } } + let num: number; -let str: string; -let numeric: NumCoercible; let date: Date; -let extentNum: [number, number]; -let extentStr: [string, string]; -let extentNumeric: [NumCoercible, NumCoercible]; -let extentDateMixed: [d3Array.Primitive, d3Array.Primitive]; -let extentMixed: [d3Array.Primitive | NumCoercible, d3Array.Primitive | NumCoercible]; -let extentDate: [Date, Date]; + +let numOrUndefined: number | undefined; +let strOrUndefined: string | undefined; +let numericOrUndefined: NumCoercible | undefined; +let dateOrUndefined: Date | undefined; +let numOrUndefinedExtent: [number, number] | [undefined, undefined]; +let strOrUndefinedExtent: [string, string] | [undefined, undefined]; +let numericOrUndefinedExtent: [NumCoercible, NumCoercible] | [undefined, undefined]; +let dateMixedOrUndefined: [Date , Date] | [undefined, undefined]; +let mixedOrUndefinedExtent: [d3Array.Primitive | NumCoercible, d3Array.Primitive | NumCoercible] | [undefined, undefined]; +let dateOrUndefinedExtent: [Date, Date] | [undefined, undefined]; let numbersArray = [10, 20, 30, 40, 50]; +let numbersOrUndefinedArray = [10, 20, undefined, null, 40, 50]; let stringyNumbersArray = ['10', '20', '30', '40', '50']; let numericArray = [new NumCoercible(10), new NumCoercible(20), new NumCoercible(30), new NumCoercible(40), new NumCoercible(50)]; let dateArray = [new Date(2016, 6, 1), new Date(2016, 7, 30), new Date(2015, 3, 15)]; @@ -62,7 +66,31 @@ let mixedObjectArray = [ new MixedObject(40, new Date(2014, 3, 15)), new MixedObject(50, new Date(2017, 4, 15)) ]; +let mixedObjectOrUndefinedArray = [...mixedObjectArray, undefined] +function accessorMixedObjectToNum(datum: MixedObject, index: number, array: Array): number { + return datum.num; +} + +function accessorMixedObjectToStr(datum: MixedObject, index: number, array: Array): string { + return datum.str; +} + +function accessorMixedObjectToNumeric(datum: MixedObject, index: number, array: Array): NumCoercible { + return datum.numeric; +} + +function accessorMixedObjectToDate(datum: MixedObject, index: number, array: Array): Date { + return datum.date; +} + +function accessorMixedObjectToNumOrUndefined(datum: MixedObject | undefined, index: number, array: Array): number | undefined | null { + return datum ? datum.num : undefined; +} + +function accessorMixedObjectToStrOrUndefined(datum: MixedObject | undefined, index: number, array: Array): string | undefined | null { + return datum ? datum.str : undefined; +} // ----------------------------------------------------------------------------- // Test Statistics @@ -72,186 +100,109 @@ let mixedObjectArray = [ // without accessors -num = d3Array.max(numbersArray); -str = d3Array.max(stringyNumbersArray); -numeric = d3Array.max(numericArray); -date = d3Array.max(dateArray); +numOrUndefined = d3Array.max(numbersArray); +strOrUndefined = d3Array.max(stringyNumbersArray); +numericOrUndefined = d3Array.max(numericArray); +dateOrUndefined = d3Array.max(dateArray); // with accessors -num = d3Array.max(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.num; -}); - -str = d3Array.max(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.str; -}); - -numeric = d3Array.max(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.numeric; -}); - -date = d3Array.max(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.date; -}); +numOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNum); +strOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToStr); +numericOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNumeric); +dateOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToDate); +numOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToNumOrUndefined); +strOrUndefined = d3Array.max(mixedObjectArray, accessorMixedObjectToStrOrUndefined); // min() ----------------------------------------------------------------------- // without accessors -num = d3Array.min(numbersArray); -str = d3Array.min(stringyNumbersArray); -numeric = d3Array.min(numericArray); -date = d3Array.min(dateArray); +numOrUndefined = d3Array.min(numbersArray); +strOrUndefined = d3Array.min(stringyNumbersArray); +numericOrUndefined = d3Array.min(numericArray); +dateOrUndefined = d3Array.min(dateArray); // with accessors -num = d3Array.min(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.num; -}); - -str = d3Array.min(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.str; -}); - -numeric = d3Array.min(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.numeric; -}); - -date = d3Array.min(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.date; -}); +numOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNum); +strOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToStr); +numericOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNumeric); +dateOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToDate); +numOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToNumOrUndefined); +strOrUndefined = d3Array.min(mixedObjectArray, accessorMixedObjectToStrOrUndefined); // extent() -------------------------------------------------------------------- // without accessors -extentNum = d3Array.extent(numbersArray); -extentStr = d3Array.extent(stringyNumbersArray); -extentNumeric = d3Array.extent(numericArray); -extentDate = d3Array.extent(dateArray); -extentMixed = d3Array.extent([new NumCoercible(10), 13, '12', true]); +numOrUndefinedExtent = d3Array.extent(numbersArray); +strOrUndefinedExtent = d3Array.extent(stringyNumbersArray); +numericOrUndefinedExtent = d3Array.extent(numericArray); +dateOrUndefinedExtent = d3Array.extent(dateArray); // with accessors -extentNum = d3Array.extent(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.num; -}); - -extentStr = d3Array.extent(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.str; -}); - -extentMixed = d3Array.extent(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.numeric; -}); - -extentDateMixed = d3Array.extent(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.date; -}); +numOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToNum); +strOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToStr); +mixedOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToNumeric); +dateMixedOrUndefined = d3Array.extent(mixedObjectArray, accessorMixedObjectToDate); +numOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToNumOrUndefined); +strOrUndefinedExtent = d3Array.extent(mixedObjectArray, accessorMixedObjectToStrOrUndefined); // mean() ---------------------------------------------------------------------- -num = d3Array.mean(numbersArray); +numOrUndefined = d3Array.mean(numbersArray); +numOrUndefined = d3Array.mean(numericArray); +numOrUndefined = d3Array.mean(numbersOrUndefinedArray); -num = d3Array.mean(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.num; -}); +numOrUndefined = d3Array.mean(mixedObjectArray, accessorMixedObjectToNum); +numOrUndefined = d3Array.mean(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); // median() -------------------------------------------------------------------- -num = d3Array.median(numbersArray); +numOrUndefined = d3Array.median(numbersArray); +numOrUndefined = d3Array.median(numericArray); +numOrUndefined = d3Array.median(numbersOrUndefinedArray); -num = d3Array.median(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.num; -}); +numOrUndefined = d3Array.median(mixedObjectArray, accessorMixedObjectToNum); +numOrUndefined = d3Array.median(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); // quantile() ------------------------------------------------------------------ -num = d3Array.quantile(numbersArray, 0.5); +numOrUndefined = d3Array.quantile(numbersArray, 0.5); +numOrUndefined = d3Array.quantile(numericArray, 0.5); +numOrUndefined = d3Array.quantile(numbersOrUndefinedArray, 0.5); -num = d3Array.quantile(mixedObjectArray, 0.5, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.num; -}); +numOrUndefined = d3Array.quantile(mixedObjectArray, 0.5, accessorMixedObjectToNum); +numOrUndefined = d3Array.quantile(mixedObjectOrUndefinedArray, 0.5, accessorMixedObjectToNumOrUndefined); // sum() ----------------------------------------------------------------------- +numOrUndefined = d3Array.sum(numbersArray); +numOrUndefined = d3Array.sum(numericArray); +numOrUndefined = d3Array.sum(numbersOrUndefinedArray); -num = d3Array.sum(numbersArray); - -num = d3Array.sum(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.num; -}); +numOrUndefined = d3Array.sum(mixedObjectArray, accessorMixedObjectToNum); +numOrUndefined = d3Array.sum(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); // deviation() ----------------------------------------------------------------- -num = d3Array.deviation(numbersArray); +numOrUndefined = d3Array.deviation(numbersArray); +numOrUndefined = d3Array.deviation(numericArray); +numOrUndefined = d3Array.deviation(numbersOrUndefinedArray); -num = d3Array.deviation(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.num; -}); +numOrUndefined = d3Array.deviation(mixedObjectArray, accessorMixedObjectToNum); +numOrUndefined = d3Array.deviation(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); // variance() ------------------------------------------------------------------ -num = d3Array.variance(numbersArray); +numOrUndefined = d3Array.variance(numbersArray); +numOrUndefined = d3Array.variance(numericArray); +numOrUndefined = d3Array.variance(numbersOrUndefinedArray); -num = d3Array.variance(mixedObjectArray, function (datum, index, array) { - let d: MixedObject = datum; - let i: number = index; - let arr: Array = array; - return datum.num; -}); +numOrUndefined = d3Array.variance(mixedObjectArray, accessorMixedObjectToNum); +numOrUndefined = d3Array.variance(mixedObjectOrUndefinedArray, accessorMixedObjectToNumOrUndefined); // ----------------------------------------------------------------------------- // Test Searching Arrays @@ -259,8 +210,18 @@ num = d3Array.variance(mixedObjectArray, function (datum, index, array) { // scan() ---------------------------------------------------------------------- -num = d3Array.scan(mixedObjectArray, function (a, b) { - return a.num - b.num; // a and b are of type MixedObject +numOrUndefined = d3Array.scan(numbersArray) + +numOrUndefined = d3Array.scan(mixedObjectArray, function (a, b) { + let aElem: MixedObject = a; + let bElem: MixedObject = b; + return a.num - b.num; +}); + +numOrUndefined = d3Array.scan(mixedObjectOrUndefinedArray, function (a, b) { + let aElem: MixedObject | undefined = a; + let bElem: MixedObject | undefined = b; + return a && b ? a.num - b.num : NaN; }); // bisectLeft() ---------------------------------------------------------------- @@ -334,12 +295,14 @@ num = mixedObjectDateBisectorObject.right(mixedObjectArray, new Date(2015, 3, 14 // ascending() ----------------------------------------------------------------- +num = d3Array.ascending(undefined, 20); num = d3Array.ascending(10, 20); num = d3Array.ascending('10', '20'); num = d3Array.ascending(new Date(2016, 6, 13), new Date(2016, 6, 14)); // descending() ---------------------------------------------------------------- +num = d3Array.descending(undefined, 20); num = d3Array.descending(10, 20); num = d3Array.descending('10', '20'); num = d3Array.descending(new Date(2016, 6, 13), new Date(2016, 6, 14)); @@ -364,12 +327,11 @@ let testArrays: MixedObject[][] = [ ] ]; - let mergedArray: MixedObject[]; mergedArray = d3Array.merge(testArrays); // inferred type mergedArray = d3Array.merge(testArrays); // explicit type -// mergedArray = d3.merge([[10, 40, 30], [15, 30]]); // fails, type mismatch +// mergedArray = d3Array.merge([[10, 40, 30], [15, 30]]); // fails, type mismatch // pairs() --------------------------------------------------------------------- diff --git a/d3-array/index.d.ts b/d3-array/index.d.ts index e3bd2d549d..336eb2bc83 100644 --- a/d3-array/index.d.ts +++ b/d3-array/index.d.ts @@ -1,8 +1,10 @@ -// Type definitions for D3JS d3-array module v1.0.1 +// Type definitions for D3JS d3-array module 1.0 // Project: https://github.com/d3/d3-array // Definitions by: Alex Ford , Boris Yankov , Tom Wanzek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Last module patch version validated against: 1.0.2 + // -------------------------------------------------------------------------- // Shared Types and Interfaces // -------------------------------------------------------------------------- @@ -20,17 +22,11 @@ interface Numeric { valueOf(): number; } - // -------------------------------------------------------------------------------------- // Descriptive Statistics // -------------------------------------------------------------------------------------- -/** - * Return the maximum value in the array of numbers using natural order. - */ -export function max(array: number[]): number | undefined; - /** * Return the maximum value in the array of strings using natural order. */ @@ -41,25 +37,15 @@ export function max(array: string[]): string | undefined; */ export function max(array: T[]): T | undefined; -/** - * Return the maximum value in the array using natural order and a projection function to map values to numbers. - */ -export function max(array: T[], accessor: (datum: T, index: number, array: T[]) => number): number | undefined; - /** * Return the maximum value in the array using natural order and a projection function to map values to strings. */ -export function max(array: T[], accessor: (datum: T, index: number, array: T[]) => string): string | undefined; +export function max(array: T[], accessor: (datum: T, index: number, array: T[]) => string | undefined | null): string | undefined; /** * Return the maximum value in the array using natural order and a projection function to map values to easily-sorted values. */ -export function max(array: T[], accessor: (datum: T, index: number, array: T[]) => U): U | undefined; - -/** - * Return the minimum value in the array using natural order. - */ -export function min(array: number[]): number | undefined; +export function max(array: T[], accessor: (datum: T, index: number, array: T[]) => U | undefined | null): U | undefined; /** * Return the minimum value in the array using natural order. @@ -74,25 +60,15 @@ export function min(array: T[]): T | undefined; /** * Return the minimum value in the array using natural order. */ -export function min(array: T[], accessor: (datum: T, index: number, array: T[]) => number): number | undefined; +export function min(array: T[], accessor: (datum: T, index: number, array: T[]) => string | undefined | null): string | undefined; /** * Return the minimum value in the array using natural order. */ -export function min(array: T[], accessor: (datum: T, index: number, array: T[]) => string): string | undefined; - -/** - * Return the minimum value in the array using natural order. - */ -export function min(array: T[], accessor: (datum: T, index: number, array: T[]) => U): U | undefined; +export function min(array: T[], accessor: (datum: T, index: number, array: T[]) => U | undefined | null): U | undefined; -/** - * Return the min and max simultaneously. - */ -export function extent(array: number[]): [number, number] | [undefined, undefined]; - /** * Return the min and max simultaneously. */ @@ -106,79 +82,70 @@ export function extent(array: T[]): [T, T] | [undefined, unde /** * Return the min and max simultaneously. */ -export function extent(array: Array): [T | Primitive, T | Primitive] | [undefined, undefined]; +export function extent(array: T[], accessor: (datum: T, index: number, array: T[]) => string | undefined | null): [string, string] | [undefined, undefined]; /** * Return the min and max simultaneously. */ -export function extent(array: T[], accessor: (datum: T, index: number, array: T[]) => number): [number, number] | [undefined, undefined]; - -/** - * Return the min and max simultaneously. - */ -export function extent(array: T[], accessor: (datum: T, index: number, array: T[]) => string): [string, string] | [undefined, undefined]; - -/** - * Return the min and max simultaneously. - */ -export function extent(array: T[], accessor: (datum: T, index: number, array: T[]) => U): [U, U ] | [undefined, undefined]; +export function extent(array: T[], accessor: (datum: T, index: number, array: T[]) => U | undefined | null): [U, U] | [undefined, undefined]; /** * Return the mean of an array of numbers */ -export function mean(array: number[]): number | undefined; -export function mean(array: T[], accessor: (datum: T, index: number, array: T[]) => number): number | undefined; +export function mean(array: Array): number | undefined; +export function mean(array: T[], accessor: (datum: T, index: number, array: T[]) => number | undefined | null): number | undefined; /** * Return the median of an array of numbers */ -export function median(array: number[]): number | undefined; -export function median(array: T[], accessor: (element: T, i: number, array: T[]) => number): number | undefined; +export function median(array: Array): number | undefined; +export function median(array: T[], accessor: (element: T, i: number, array: T[]) => number | undefined | null): number | undefined; /** * Returns the p-quantile of an array of numbers */ -export function quantile(array: number[], p: number): number | undefined; -export function quantile(array: T[], p: number, accessor: (element: T, i: number, array: T[]) => number): number | undefined; +export function quantile(array: Array, p: number): number | undefined; +export function quantile(array: T[], p: number, accessor: (element: T, i: number, array: T[]) => number | undefined | null): number | undefined; /** * Compute the sum of an array of numbers. */ -export function sum(array: number[]): number; +export function sum(array: Array): number; /** * Compute the sum of an array, using the given accessor to convert values to numbers. */ -export function sum(array: T[], accessor: (datum: T, index: number, array: T[]) => number): number; +export function sum(array: T[], accessor: (datum: T, index: number, array: T[]) => number | undefined | null): number; /** * Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array of numbers. */ -export function deviation(array: number[]): number | undefined; +export function deviation(array: Array): number | undefined; /** * Compute the standard deviation, defined as the square root of the bias-corrected variance, of the given array, * using the given accessor to convert values to numbers. */ -export function deviation(array: T[], accessor: (datum: T, index: number, array: T[]) => number): number | undefined; +export function deviation(array: T[], accessor: (datum: T, index: number, array: T[]) => number | undefined | null): number | undefined; /** * Compute an unbiased estimator of the population variance of the given array of numbers. */ -export function variance(array: number[]): number | undefined; +export function variance(array: Array): number | undefined; /** * Compute an unbiased estimator of the population variance of the given array, * using the given accessor to convert values to numbers. */ -export function variance(array: T[], accessor: (datum: T, index: number, array: T[]) => number): number | undefined; +export function variance(array: T[], accessor: (datum: T, index: number, array: T[]) => number | undefined | null): number | undefined; // -------------------------------------------------------------------------------------- // Searching Arrays // -------------------------------------------------------------------------------------- -export function scan(array: T[], comparator: (a: T, b: T) => number): number; +export function scan(array: number[], comparator?: (a: number, b: number) => number): number | undefined; +export function scan(array: T[], comparator: (a: T, b: T) => number): number | undefined; export function bisectLeft(array: number[], x: number, lo?: number, hi?: number): number; export function bisectLeft(array: string[], x: string, lo?: number, hi?: number): number; @@ -202,16 +169,16 @@ export function bisector(accessor: (x: T) => U): Bisector; /** * Compares two primitive values for sorting (in ascending order). */ -export function ascending(a: Primitive, b: Primitive): number; +export function ascending(a: Primitive | undefined, b: Primitive | undefined): number; // NB. this is limited to primitive values due to D3's use of the <, >, and >= operators. Results get weird for object instances. /** * Compares two primitive values for sorting (in ascending order). */ -export function descending(a: Primitive, b: Primitive): number; +export function descending(a: Primitive | undefined, b: Primitive | undefined): number; // -------------------------------------------------------------------------------------- -// Transforming Arrays +// Transforming Arrays // -------------------------------------------------------------------------------------- @@ -236,7 +203,6 @@ export function permute(array: { [key: number]: T }, keys: number[]): T[]; */ export function permute(object: { [key: string]: T }, keys: string[]): T[]; - /** * Generates a 0-based numeric sequence. The output range does not include 'stop'. */ diff --git a/d3-array/tsconfig.json b/d3-array/tsconfig.json index db900a4087..b70f6aed80 100644 --- a/d3-array/tsconfig.json +++ b/d3-array/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/d3-array/tslint.json b/d3-array/tslint.json new file mode 100644 index 0000000000..68d10d72a6 --- /dev/null +++ b/d3-array/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "../tslint.json", + "rules": { + "unified-signatures": false + } +} diff --git a/easeljs/index.d.ts b/easeljs/index.d.ts index a5916a56f2..d47f631728 100644 --- a/easeljs/index.d.ts +++ b/easeljs/index.d.ts @@ -735,6 +735,7 @@ declare namespace createjs { intersection(rect: Rectangle): Rectangle; intersects(rect: Rectangle): boolean; isEmpty(): boolean; + pad(top: number, left: number, bottom: number, right: number): Rectangle; setValues(x?: number, y?: number, width?: number, height?: number): Rectangle; toString(): string; union(rect: Rectangle): Rectangle; diff --git a/gapi.auth2/gapi.auth2-tests.ts b/gapi.auth2/gapi.auth2-tests.ts index 2cfaa49980..621ca6f056 100644 --- a/gapi.auth2/gapi.auth2-tests.ts +++ b/gapi.auth2/gapi.auth2-tests.ts @@ -19,6 +19,22 @@ function test_getAuthInstance(){ var auth = gapi.auth2.getAuthInstance(); } +function test_signIn(){ + gapi.auth2.getAuthInstance().signIn({ + scope: 'email profile', + prompt: 'content' + }); +} + +function test_signInOptionsBuild(){ + var options = new gapi.auth2.SigninOptionsBuilder(); + options.setAppPackageName('com.example.app'); + options.setFetchBasicProfile(true); + options.setPrompt('select_account'); + options.setScope('profile').setScope('email'); + gapi.auth2.getAuthInstance().signIn(options); +} + function test_getAuthResponse(){ var user = gapi.auth2.getAuthInstance().currentUser.get(); var authResponse = user.getAuthResponse(); diff --git a/gapi.auth2/index.d.ts b/gapi.auth2/index.d.ts index 6037f0238e..6146a87e28 100644 --- a/gapi.auth2/index.d.ts +++ b/gapi.auth2/index.d.ts @@ -31,12 +31,7 @@ declare namespace gapi.auth2 { /** * Signs in the user using the specified options. */ - signIn(options?: { - app_package_name?: string; - fetch_basic_profile?: boolean; - prompt?: boolean; - scope?: string; - }, optionBuilder?: SigninOptionsBuilder): any; + signIn(options?: SigninOptions | SigninOptionsBuilder): any; /** * Signs out all accounts from the application. @@ -59,12 +54,8 @@ declare namespace gapi.auth2 { /** * Attaches the sign-in flow to the specified container's click handler. */ - attachClickHandler(container: any, options: { - app_package_name?: string; - fetch_basic_profile?: boolean; - prompt?: boolean; - scope?: string; - }, onsuccess: (googleUser: GoogleUser) => any, onfailure: (reason: string) => any): any; + attachClickHandler(container: any, options: SigninOptions, + onsuccess: (googleUser: GoogleUser) => any, onfailure: (reason: string) => any): any; } export interface IsSignedIn{ @@ -93,6 +84,32 @@ declare namespace gapi.auth2 { listen(listener: (user: GoogleUser) => any): void; } + export interface SigninOptions { + /** + * The package name of the Android app to install over the air. + * See Android app installs from your web site: + * https://developers.google.com/identity/sign-in/web/android-app-installs + */ + app_package_name?: string; + /** + * Fetch users' basic profile information when they sign in. + * Adds 'profile', 'email' and 'openid' to the requested scopes. + * True if unspecified. + */ + fetch_basic_profile?: boolean; + /** + * Specifies whether to prompt the user for re-authentication. + * See OpenID Connect Request Parameters: + * https://openid.net/specs/openid-connect-basic-1_0.html#RequestParameters + */ + prompt?: string; + /** + * The scopes to request, as a space-delimited string. + * Optional if fetch_basic_profile is not set to false. + */ + scope?: string; + } + export class SigninOptionsBuilder { setAppPackageName(name: string): any; setFetchBasicProfile(fetch: boolean): any; @@ -164,22 +181,12 @@ declare namespace gapi.auth2 { * When you use GoogleUser.signIn(), the sign-in flow skips the account chooser step. * See GoogleAuth.signIn(). */ - signIn(options?: { - app_package_name?: string; - fetch_basic_profile?: boolean; - prompt?: boolean; - scope?: string; - }, optionBuilder?: SigninOptionsBuilder): any; + signIn(options?: SigninOptions | SigninOptionsBuilder): any; /** - * + * See GoogleUser.signIn() */ - grant(options?: { - app_package_name?: string; - fetch_basic_profile?: boolean; - prompt?: boolean; - scope?: string; - }, optionBuilder?: SigninOptionsBuilder): any; + grant(options?: SigninOptions | SigninOptionsBuilder): any; /** * Get permission from the user to access the specified scopes offline. diff --git a/jquery.datatables/index.d.ts b/jquery.datatables/index.d.ts index 5d1bbd50c9..2640dbabe6 100644 --- a/jquery.datatables/index.d.ts +++ b/jquery.datatables/index.d.ts @@ -1587,7 +1587,8 @@ declare namespace DataTables { } interface FunctionColumnData { - (row: any, t: string, s: any, meta: CellMetaSettings): void; + (row: any, t: 'set', s: any, meta: CellMetaSettings): void; + (row: any, t: 'display' | 'sort' | 'filter' | 'type', s: undefined, meta: CellMetaSettings): any; } interface ObjectColumnData { diff --git a/jquery.datatables/jquery.datatables-tests.ts b/jquery.datatables/jquery.datatables-tests.ts index 1bf6e26593..3bcc931a5f 100644 --- a/jquery.datatables/jquery.datatables-tests.ts +++ b/jquery.datatables/jquery.datatables-tests.ts @@ -43,10 +43,17 @@ $(document).ready(function () { sort: "asc" }; - var colDataFunc: DataTables.FunctionColumnData = function (row, type, set, meta) { + var colDataFunc: DataTables.FunctionColumnData = (row: any, type: 'set' | 'display' | 'sort' | 'filter' | 'type', set: any, meta: DataTables.CellMetaSettings) => { meta.col; meta.row; meta.settings; + switch (type) { + case 'set': + row.value = set; + return; + default: + return row.value; + } }; var colRenderObject: DataTables.ObjectColumnRender = { @@ -276,7 +283,7 @@ $(document).ready(function () { bScrollbarLeft: true, bScrollOversize: true } - + //#endregion //#region "Init" diff --git a/jquery.tools/index.d.ts b/jquery.tools/index.d.ts new file mode 100644 index 0000000000..e511a961fd --- /dev/null +++ b/jquery.tools/index.d.ts @@ -0,0 +1,161 @@ +// Type definitions for jQuery TOOLS 1.2 +// Project: https://github.com/jquerytools/jquerytools +// Definitions by: Joe Skeen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +/// + +declare interface JQuery { + overlay(opts?: JQueryTools.overlay.OverlayOptions): JQuery; + overlay(opts?: JQueryTools.overlay.OverlayOptions): T; + data(key: 'overlay'): JQueryTools.overlay.Overlay; +} + +declare interface JQueryStatic { + tools: JQueryTools.ToolsStatic; +} + +/** jQuery Tools (http://jquerytools.github.io/documentation/overlay/index.html) */ +declare namespace JQueryTools { + interface ToolsStatic { + overlay: overlay.OverlayStatic; + } + + namespace overlay { + interface OverlayStatic { + addEffect(effectName: string, + effectFn: (this: Overlay, position: CssOptions, done: () => void) => void, + closeFn: (this: Overlay, done: () => void) => void): void; + } + + interface CssOptions { + [key: string]: any; + } + + interface OverlayOptions { + /** + * A jQuery selector for the closing elements inside the overlay. These + * can be any elements such as links, buttons or images. If this is not + * supplied, a close element is auto-generated. Read more about this in + * defining close actions. + */ + close?: JQuery; + /** + * By default, overlays are closed when the mouse is clicked outside the + * overlay area. Setting this property to false suppresses this behaviour + * which is suitable for modal dialogs. + * @default true + */ + closeOnClick?: boolean; + /** + * By default, overlays are closed when the ESC keyboard key is pressed. + * Setting this property to false suppresses this behaviour. + * @default true + */ + closeOnEsc?: boolean; + /** The speed to close the overlay, in milliseconds */ + closeSpeed?: number; + /** + * The effect to be used when an overlay is opened and closed. This can + * dramatically change the behaviour of the overlay. By default this tool + * uses an effect called "default" which is a simple show/hide effect. + * @default 'default' + */ + effect?: string; + /** + * since 1.2.0. whether overlay stays in the same position while the screen + * is scrolled. This is the default behaviour for all browsers except IE6 + * and below. IE6 does not support fixed positioning. If this property is + * set to false then the overlay is positioned in relationship to the document + * so that when the screen is scrolled then the overlay moves along with the document. + * @default true + */ + fixed?: boolean; + /** + * Previously known as expose. Overlay is very often used together with the + * Mask Tool. Because of this, the support for this feature has been built + * inside the tool. This option accepts the mask configuration. This is either + * a simple string specifying the background color of the mask or a more complex + * object literal specifying more configuration variables. See an example of an + * overlay together with mask. By default masking is disabled. + */ + mask?: string | MaskOptions; + /** + * Specifies how far from the left-hand edge of the screen the overlay should be + * placed. By default the overlay is horizontally centered with the value "center" + * but you can also supply a numerical value specifying a distance in pixels. + * @default 'center' + */ + left?: 'center' | number; + /** + * If enabled then the overlay loads immediately after it has been initialized. + * @default false + */ + load?: boolean; + /** + * By default, there can be only one overlay on the page at once. Setting this + * property to false allows you to have multiple overlay instances. + * @default true + */ + oneInstance?: boolean; + /** + * The speed of the fade-in animation on the "default" effect. Valid values are + * 'slow', 'normal' and 'fast', or you can supply a numerical value (in milliseconds). + * By setting this property to 0, the overlay will appear immediately without any animation. + * @default 'normal' + */ + speed?: 'slow' | 'normal' | 'fast' | number; + /** + * The element to be overlayed (if not specified in the rel attribute of the triggering element). + */ + target?: Element; + /** + * Specifies how far from the top edge of the screen the overlay should be placed. + * Acceptable values are an integer number specifying a distance in pixels, a string + * (such as '15%') specifying a percentage value or "center" in which case the overlay + * is vertically centered. Percentage values work consistently at different screen resolutions. + * @default '10%' + */ + top?: string | number; + + /** + * before the overlay is displayed. The overlay has already been positioned at the + * location from where it will start animating. + */ + onBeforeLoad?: (this: Overlay, event: JQueryEventObject) => void; + /** when the overlay has completely been displayed */ + onLoad?: (this: Overlay, event: JQueryEventObject) => void; + /** before the overlay is closed */ + onBeforeClose?: (this: Overlay, event: JQueryEventObject) => void; + /** when the overlay is closed */ + onClose?: (this: Overlay, event: JQueryEventObject) => void; + } + + interface MaskOptions { + /** CSS color string (i.e. hex value) */ + color?: string; + /** load speed in milliseconds */ + loadSpeed?: number; + /** Opacity of mask. Between 0 and 1. */ + opacity?: number; + } + + interface Overlay { + /** Closes the overlay. */ + close(): Overlay; + /** Returns the closing element(s) as a jQuery object. */ + getClosers(): JQuery; + /** Returns the configuration for the overlay. */ + getConf(): OverlayOptions; + /** Returns the overlayed element as a jQuery object. */ + getOverlay(): JQuery; + /** Returns the triggering element as a jQuery object. */ + getTrigger(): JQuery; + /** Returns `true` if the overlay is opened. */ + isOpened(): boolean; + /** Opens the overlay. */ + load(): Overlay; + } + } +} diff --git a/jquery.tools/jquery.tools-tests.ts b/jquery.tools/jquery.tools-tests.ts new file mode 100644 index 0000000000..f8a4e39f90 --- /dev/null +++ b/jquery.tools/jquery.tools-tests.ts @@ -0,0 +1,182 @@ +/// + +/* from documentation at http://jquerytools.github.io/documentation/overlay/index.html */ + + $("img[rel]").overlay(); + + var triggers = $(".modalInput").overlay({ +  + // some mask tweaks suitable for modal dialogs + mask: { + color: '#ebecff', + loadSpeed: 200, + opacity: 0.9 + }, +  + closeOnClick: false + }); + + var buttons = $("#yesno button").click(function(this: JQuery, e: JQueryEventObject) { +  + // get user input + var yes = buttons.index(this) === 0; +  + // do something with the answer + triggers.eq(0).html("You clicked " + (yes ? "yes" : "no")); + }); + +// select one or more elements to be overlay triggers +$(".my_overlay_trigger").overlay({ + // one configuration property + mask: { + color: '#ccc' + }, + // another property + top: 50 + // ... the rest of the configuration properties +}); + +$("#prompt form").submit(function(this: JQuery, e: JQueryEventObject) { +  + // close the overlay + triggers.eq(1).overlay().close(); + //or more straightforward: + triggers.data('overlay').close(); +  + // get user input + var input = $("input", this).val(); +  + // do something with the answer + triggers.eq(1).html(input); +  + // do not submit the form + return e.preventDefault(); + }); + +$.tools.overlay.addEffect('', function() {}, function() {}); + +/* custom effects */ +$.tools.overlay.addEffect("myEffect", function(position, done) { + /* + - 'this' variable is a reference to the overlay API + - here we use jQuery's fadeIn() method to perform the effect + */ + this.getOverlay().css(position).fadeIn(this.getConf().speed, done); + }, +  + // close function + function(done) { + // fade out the overlay + this.getOverlay().fadeOut(this.getConf().closeSpeed, done); + } +); + +$("#apple img[rel]").overlay({effect: 'apple'}); + + // select the overlay element - and "make it an overlay" + $("#facebox").overlay({ + // custom top position + top: 260, + // some mask tweaks suitable for facebox-looking dialogs + mask: { + // you might also consider a "transparent" color for the mask + color: '#fff', + // load mask a little faster + loadSpeed: 200, + // very transparent + opacity: 0.5 + }, + // disable this for modal dialog-type of overlays + closeOnClick: false, + // load it immediately after the construction + load: true +}); + +$(function() { +  + // if the function argument is given to overlay, + // it is assumed to be the onBeforeLoad event listener + $("a[rel]").overlay({ +  + mask: 'darkred', + effect: 'apple', +  + onBeforeLoad: function() { +  + // grab wrapper element inside content + var wrap = this.getOverlay().find(".contentWrap"); +  + // load the page specified in the trigger + wrap.load(this.getTrigger().attr("href")); + } +  + }); +}); + +$(function() { + // positions for each overlay + var positions = [ + [0, 530], + [400, 20], + [400, 530], + [0, 20] + ]; +  + // setup triggers + $("button[rel]").each(function(this: JQuery, i: number) { +  + $(this).overlay({ +  + // common configuration for each overlay + oneInstance: false, + closeOnClick: false, +  + // setup custom finish position + top: positions[i][0], + left: positions[i][1], +  + // use apple effect + effect: 'apple' +  + }); + }); +}); + +// loading animation +$.tools.overlay.addEffect("drop", function(css, done) { +  + // use Overlay API to gain access to crucial elements + var conf = this.getConf(), + overlay = this.getOverlay(); +  + // determine initial position for the overlay + if (conf.fixed) { + css['position'] = 'fixed'; + } else { + css['top'] += $(window).scrollTop(); + css['left'] += $(window).scrollLeft(); + css['position'] = 'absolute'; + } +  + // position the overlay and show it + overlay.css(css).show(); +  + // begin animating with our custom easing + overlay.animate( + { top: '+=55', opacity: 1, width: '+=20'}, 400, 'drop', done + ); +  + /* closing animation */ +}, function(done) { + this.getOverlay().animate( + {top:'-=55', opacity:0, width:'-=20'}, 300, 'drop', + function(this: JQuery) { + $(this).hide(); + done.call(null); + }); +}); + +$("img[rel]").overlay({ + effect: 'drop', + mask: '#789' +}); diff --git a/jquery.tools/tsconfig.json b/jquery.tools/tsconfig.json new file mode 100644 index 0000000000..64e79cb10d --- /dev/null +++ b/jquery.tools/tsconfig.json @@ -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", + "jquery.tools-tests.ts" + ] +} \ No newline at end of file diff --git a/jquery.tools/tslint.json b/jquery.tools/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/jquery.tools/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/later/index.d.ts b/later/index.d.ts index c5c2449a00..5dd68ec90a 100644 --- a/later/index.d.ts +++ b/later/index.d.ts @@ -142,7 +142,7 @@ declare namespace later { * For acces to custom time periods created as extension to the later static type * and modifiers created on the later modifier static type. */ - [ timeperiodAndModifierName: string ]: number[]; + [ timeperiodAndModifierName: string ]: number[] | undefined; } interface ParseStatic { diff --git a/later/tsconfig.json b/later/tsconfig.json index 78a6cefd34..add4a07667 100644 --- a/later/tsconfig.json +++ b/later/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index 5ca606811a..717e589877 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -1405,8 +1405,8 @@ declare namespace L { */ export function map(element: string | HTMLElement, options?: MapOptions): Map; - export interface IconOptions extends LayerOptions { - iconUrl: string; + interface BaseIconOptions extends LayerOptions { + iconUrl?: string; iconRetinaUrl?: string; iconSize?: PointExpression; iconAnchor?: PointExpression; @@ -1418,25 +1418,38 @@ declare namespace L { className?: string; } - class InternalIcon extends Layer { - constructor(options: IconOptions); - createIcon(oldIcon?: HTMLElement): HTMLElement; + export interface IconOptions extends BaseIconOptions { + iconUrl: string; } - export class Icon extends InternalIcon { + // This class does not exist in reality, it's just a way to provide + // options of more specific types in the sub classes + class BaseIcon extends Layer { + createIcon(oldIcon?: HTMLElement): HTMLElement; createShadow(oldIcon?: HTMLElement): HTMLElement; + options: BaseIconOptions; + } + + export class Icon extends BaseIcon { + constructor(options: IconOptions); options: IconOptions; } export namespace Icon { - export class Default extends InternalIcon { - imagePath: string; + export interface DefaultIconOptions extends BaseIconOptions { + imagePath?: string; + } + + export class Default extends BaseIcon { + static imagePath?: string; + constructor(options?: DefaultIconOptions); + options: DefaultIconOptions; } } export function icon(options: IconOptions): Icon; - export interface DivIconOptions extends LayerOptions { + export interface DivIconOptions extends BaseIconOptions { html?: string; bgPos?: PointExpression; iconSize?: PointExpression; @@ -1445,7 +1458,7 @@ declare namespace L { className?: string; } - export class DivIcon extends InternalIcon { + export class DivIcon extends BaseIcon { constructor(options?: DivIconOptions); options: DivIconOptions; } @@ -1463,8 +1476,6 @@ declare namespace L { opacity?: number; riseOnHover?: boolean; riseOffset?: number; - - options?: DivIconOptions; } export class Marker extends Layer { diff --git a/leaflet/leaflet-tests.ts b/leaflet/leaflet-tests.ts index 8d9b91e37b..bce7afdab6 100644 --- a/leaflet/leaflet-tests.ts +++ b/leaflet/leaflet-tests.ts @@ -404,22 +404,29 @@ class MyMarker extends L.Marker { super([12, 13]); } } + class MyLayer extends L.Layer { constructor() { super(); } } + class MyIcon extends L.Icon { constructor() { super({iconUrl: 'icon.png'}); } } + class MyDivIcon extends L.DivIcon { constructor() { super(); } } +const divIcon = L.divIcon({html: ''}); +let defaultIcon = new L.Icon.Default(); +defaultIcon = new L.Icon.Default({imagePath: 'apath'}); + let myControlClass = L.Control.extend({}); let myControl = new myControlClass(); diff --git a/ltx/index.d.ts b/ltx/index.d.ts new file mode 100644 index 0000000000..c5794f12bb --- /dev/null +++ b/ltx/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for ltx 2.6 +// Project: github.com/node-xmpp/ltx/ +// Definitions by: PJakcson +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export {Element} from './lib/Element' +export {nameEqual, attrsEqual, childrenEqual, equal} from './lib/equal'; +export {isNode, isElement, isText} from './lib/is'; +export {clone} from './lib/clone'; +export {createElement} from './lib/createElement'; +export {escapeXML, unescapeXML, escapeXMLText, unescapeXMLText} from './lib/escape'; +export {Parser} from './lib/Parser'; +export {parse} from './lib/parse'; +export {tag} from './lib/tag'; +export {tagString} from './lib/tagString'; +export {stringify} from './lib/stringify'; diff --git a/ltx/lib/Element.d.ts b/ltx/lib/Element.d.ts new file mode 100644 index 0000000000..d0f50ae783 --- /dev/null +++ b/ltx/lib/Element.d.ts @@ -0,0 +1,119 @@ +/** + * Element + * + * Attributes are in the element.attrs object. Children is a list of + * either other Elements or Strings for text content. + **/ +export declare class Element { + name: string; + parent: Element; + children: Element[]; + attrs: any; + + constructor(name: string, attrs?: any); + + /** + * if (element.is('message', 'jabber:client')) ... + **/ + is(name: string, xmlns?: any): boolean; + + /** + * without prefix. + */ + getName(): string; + + /** + * retrieves the namespace of the current element, upwards recursively + **/ + getNS(): any; + + /** + * find the namespace to the given prefix, upwards recursively + **/ + findNS(prefix: string): any; + + /** + * Recursiverly gets all xmlns defined, in the form of {url:prefix} + **/ + getXmlns(): any; + + setAttrs(attrs: any): void; + + /** + * xmlns can be null, returns the matching attribute. + **/ + getAttr(name: string, xmlns?: any): any; + + /** + * xmlns can be null + **/ + getChild(name: string, xmlns?: any): Element; + + /** + * xmlns can be null + **/ + getChildren(name: string, xmlns?: any): Element[]; + + /** + * xmlns and recursive can be null + **/ + getChildByAttr(attr: any, val: any, xmlns?: any, recursive?: any): Element; + + + /** + * xmlns and recursive can be null + **/ + getChildrenByAttr(attr: any, val: any, xmlns?: any, recursive?: any): Element[]; + + getText(): string; + + getChildText(name: string, xmlns: any): string; + + /** + * Return all direct descendents that are Elements. + * This differs from `getChildren` in that it will exclude text nodes, + * processing instructions, etc. + */ + getChildElements(): Element[]; + + /** returns uppermost parent */ + root(): Element; + + tree(): Element; + + /** just parent or itself */ + up(): Element; + + /** create child node and return it */ + c(name: string, attrs?: any): Element; + + /** add text node and return element */ + t(text: string): Element; + + /** + * Either: + * el.remove(childEl) + * el.remove('author', 'urn:...') + */ + remove(el: Element, xmlns?: any): Element; + + clone(): Element; + + text(val: string): string; + + attr(attr: any, val: any): any; + + toString(): string; + + toJSON(): any; + + write(writer: any): void; + + nameEquals(el: Element): boolean; + + attrsEquals(el: Element): boolean; + + childrenEquals(el: Element): boolean; + + equals(el: Element): boolean; +} diff --git a/ltx/lib/Parser.d.ts b/ltx/lib/Parser.d.ts new file mode 100644 index 0000000000..3af418d21f --- /dev/null +++ b/ltx/lib/Parser.d.ts @@ -0,0 +1,5 @@ +/// +import {EventEmitter} from 'events'; +export declare class Parser extends EventEmitter { + constructor(options?: any); +} diff --git a/ltx/lib/clone.d.ts b/ltx/lib/clone.d.ts new file mode 100644 index 0000000000..41193a3f40 --- /dev/null +++ b/ltx/lib/clone.d.ts @@ -0,0 +1 @@ +export declare function clone(el: any): any; diff --git a/ltx/lib/createElement.d.ts b/ltx/lib/createElement.d.ts new file mode 100644 index 0000000000..2deead1663 --- /dev/null +++ b/ltx/lib/createElement.d.ts @@ -0,0 +1,2 @@ +import {Element} from './Element'; +export declare function createElement(name: string, attrs: any): Element; diff --git a/ltx/lib/equal.d.ts b/ltx/lib/equal.d.ts new file mode 100644 index 0000000000..520555e098 --- /dev/null +++ b/ltx/lib/equal.d.ts @@ -0,0 +1,4 @@ +export declare function nameEqual(a: any, b: any): boolean; +export declare function attrsEqual(a: any, b: any): boolean; +export declare function childrenEqual(a: any, b: any): boolean; +export declare function equal(a: any, b: any): boolean; diff --git a/ltx/lib/escape.d.ts b/ltx/lib/escape.d.ts new file mode 100644 index 0000000000..4bc45c223a --- /dev/null +++ b/ltx/lib/escape.d.ts @@ -0,0 +1,4 @@ +export declare function escapeXML(s: string): string; +export declare function unescapeXML(s: string): string; +export declare function escapeXMLText(s: string): string; +export declare function unescapeXMLText(s: string): string; diff --git a/ltx/lib/is.d.ts b/ltx/lib/is.d.ts new file mode 100644 index 0000000000..6515d23f80 --- /dev/null +++ b/ltx/lib/is.d.ts @@ -0,0 +1,3 @@ +export declare function isNode(el: any): boolean; +export declare function isElement(el: any): boolean; +export declare function isText(el: any): boolean; diff --git a/ltx/lib/parse.d.ts b/ltx/lib/parse.d.ts new file mode 100644 index 0000000000..cc4073113a --- /dev/null +++ b/ltx/lib/parse.d.ts @@ -0,0 +1 @@ +export declare function parse(data: any, options?: any): any; diff --git a/ltx/lib/stringify.d.ts b/ltx/lib/stringify.d.ts new file mode 100644 index 0000000000..770f7d324f --- /dev/null +++ b/ltx/lib/stringify.d.ts @@ -0,0 +1 @@ +export declare function stringify(el: any, indent: any, level: any): string; diff --git a/ltx/lib/tag.d.ts b/ltx/lib/tag.d.ts new file mode 100644 index 0000000000..8bbcb6fe7b --- /dev/null +++ b/ltx/lib/tag.d.ts @@ -0,0 +1 @@ +export declare function tag(d: any): any; diff --git a/ltx/lib/tagString.d.ts b/ltx/lib/tagString.d.ts new file mode 100644 index 0000000000..44036ce037 --- /dev/null +++ b/ltx/lib/tagString.d.ts @@ -0,0 +1 @@ +export declare function tagString(d: any): string; diff --git a/ltx/ltx-tests.ts b/ltx/ltx-tests.ts new file mode 100644 index 0000000000..18140eb670 --- /dev/null +++ b/ltx/ltx-tests.ts @@ -0,0 +1,19 @@ +import * as ltx from './index'; + +ltx.parse(''); + +let p = new ltx.Parser(); + +p.on('tree', function (ignored: any) { +}); + +p.on('error', function (ignored: any) { +}); + + +let el = new ltx.Element('root').c('children'); +el.c('child', {age: 5}).t('Hello').up() + .c('child', {age: 7}).t('Hello').up() + .c('child', {age: 99}).t('Hello').up(); + +el.root().toString(); diff --git a/ltx/tsconfig.json b/ltx/tsconfig.json new file mode 100644 index 0000000000..28beec26d4 --- /dev/null +++ b/ltx/tsconfig.json @@ -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", + "ltx-tests.ts" + ] +} diff --git a/ltx/tslint.json b/ltx/tslint.json new file mode 100644 index 0000000000..ec365f164b --- /dev/null +++ b/ltx/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} diff --git a/mongoose/index.d.ts b/mongoose/index.d.ts index 40821b8968..7ef5615436 100644 --- a/mongoose/index.d.ts +++ b/mongoose/index.d.ts @@ -2163,6 +2163,11 @@ declare module "mongoose" { * @param fields the field(s) to unwind */ unwind(...fields: string[]): this; + /** + * Appends new custom $unwind operator(s) to this aggregate pipeline + * new in mongodb 3.2 + */ + unwind(...opts: { path: string, includeArrayIndex?: string, preserveNullAndEmptyArrays?: boolean }[]): this; } /* diff --git a/mongoose/mongoose-tests.ts b/mongoose/mongoose-tests.ts index c6dfe20fdc..dc170dccd9 100644 --- a/mongoose/mongoose-tests.ts +++ b/mongoose/mongoose-tests.ts @@ -1016,7 +1016,41 @@ aggregate.sort('field -test'); aggregate.then(cb).catch(cb); aggregate.unwind("tags").unwind('tags'); aggregate.unwind("a", "b", "c").unwind('tag1', 'tag2'); - +aggregate.unwind( + { + path: "tags", + includeArrayIndex: "idx", + preserveNullAndEmptyArrays: true + }) + .unwind({ + path: "tags", + includeArrayIndex: "idx", + preserveNullAndEmptyArrays: true + }); +aggregate.unwind( + { + path: "a", + includeArrayIndex: "idx", + preserveNullAndEmptyArrays: true + }, { + path: "b", + includeArrayIndex: "idx", + preserveNullAndEmptyArrays: true + }, { + path: "c", + includeArrayIndex: "idx", + preserveNullAndEmptyArrays: true + }) + .unwind({ + path: "tag1", + includeArrayIndex: "idx", + preserveNullAndEmptyArrays: true + }, { + path: "tag2", + includeArrayIndex: "idx", + preserveNullAndEmptyArrays: true + }); + /* * section schematype.js * http://mongoosejs.com/docs/api.html#schematype-js diff --git a/ng-file-upload/ng-file-upload-tests.ts b/ng-file-upload/ng-file-upload-tests.ts index 7252231661..08fbafdb6b 100644 --- a/ng-file-upload/ng-file-upload-tests.ts +++ b/ng-file-upload/ng-file-upload-tests.ts @@ -26,7 +26,7 @@ class UploadController { ngfValidateForce: true }); } - + onFileSelect(files: Array) { this.Upload @@ -44,11 +44,11 @@ class UploadController { }).progress((evt: angular.angularFileUpload.IFileProgressEvent) => { let percent = parseInt((100.0 * evt.loaded / evt.total).toString(), 10); console.log("upload progress: " + percent + "% for " + evt.config.data.media[0]); - }).error((data: any, status: number, response: any, headers: any) => { - console.error(data, status, response, headers); - }).success((data: any, status: number, headers: any, config: angular.angularFileUpload.IFileUploadConfigFile) => { + }).catch((response: ng.IHttpPromiseCallbackArg) => { + console.error(response.data, response.status, response.statusText, response.headers); + }).then((response: ng.IHttpPromiseCallbackArg) => { // file is uploaded successfully - console.log("Success!", data, status, headers, config); + console.log("Success!", response.data, response.status, response.headers, response.config); }); this.Upload @@ -72,16 +72,16 @@ class UploadController { this.Upload.isResizeSupported(); this.Upload.isResumeSupported(); this.Upload.isUploadInProgress(); - + let json = this.Upload.json({ test: true }), jsonBlob = this.Upload.jsonBlob({ test: true }), fileWithNewName = this.Upload.rename(files[0], "newName.jpg"); this.Upload - .resize(files[0], { + .resize(files[0], { height: 1024, width: 1024, - quality: 0.7, + quality: 0.7, ratio: 0.9, centerCrop: true, restoreExif: true, diff --git a/node-xmpp-client/index.d.ts b/node-xmpp-client/index.d.ts new file mode 100644 index 0000000000..874df37de7 --- /dev/null +++ b/node-xmpp-client/index.d.ts @@ -0,0 +1,71 @@ +// Type definitions for node-xmpp-client 3.1 +// Project: https://github.com/node-xmpp/node-xmpp/tree/master/packages/node-xmpp-client/ +// Definitions by: PJakcson +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export declare class Client { + static Stanza: Stanza; + + constructor(options: XmppOptions); + + connect(): void; + + disconnect(): void; + + on(event: string, c: (e: any, d: any) => any): void; + + send(stanza: any): void; +} + +interface Stanza extends Element { + // This has to be used for the static class initializer new Client.Stanza(..). If there is a better way feel free to + // contribute. + // tslint:disable-next-line + new(name: string, attr: any): Stanza; + from: string; + to: string; + id: string; + type: string; +} + +interface Element { + is(name: string, xmlns: string): boolean; + getName(): string; + getNS(): string; + findNS(prefix: string): string; + getXmlns(): string; + setAttrs(attrs: any): void; + getAttrs(): any; + + up(): Element; + c(name: string, attrs?: any): Element; + cnode(child: Element): Element; + t(text: string): Element; + remove(el: Element, xmnls: string): Element; + attr(attr: any, val: any): any; + + toString(): string; + toJSON(): any; +} + +interface XmppOptions { + jid: string; + password: string; + host?: string; + port?: number; + reconnect?: boolean; + autostart?: boolean; // if we start connecting to a given port + register?: boolean; // register account before authentication + legacySSL?: boolean; // connect to the legacy SSL port, requires at least the host to be specified + credentials?: any; // Dictionary (optional) - TLS or SSL key and certificate credentials + actAs?: string; // if admin user act on behalf of another user (just user) + disallowTLS?: boolean; // prevent upgrading the connection to a secure one via TLS + preferred?: string; // Preferred SASL mechanism to use + bosh?: Bosh; +} + +interface Bosh { + url?: string; + prebind?: (error: any, data: any) => void; +} diff --git a/node-xmpp-client/node-xmpp-client-tests.ts b/node-xmpp-client/node-xmpp-client-tests.ts new file mode 100644 index 0000000000..52a54a0453 --- /dev/null +++ b/node-xmpp-client/node-xmpp-client-tests.ts @@ -0,0 +1,22 @@ +import {Client} from './index'; + +let client = new Client({ + jid: 'user@example.com', + password: 'password' +}); + +client.connect(); + +client.on('online', function () { +}); + +client.on('stanza', function (stanza) { + let _ = stanza; +}); + +let stanza = new Client.Stanza('chat', {}) + .c('show').t('chat').up() + .c('status').t('message'); +client.send(stanza); + +client.disconnect(); diff --git a/node-xmpp-client/tsconfig.json b/node-xmpp-client/tsconfig.json new file mode 100644 index 0000000000..c76db9a985 --- /dev/null +++ b/node-xmpp-client/tsconfig.json @@ -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", + "node-xmpp-client-tests.ts" + ] +} diff --git a/node-xmpp-client/tslint.json b/node-xmpp-client/tslint.json new file mode 100644 index 0000000000..ec365f164b --- /dev/null +++ b/node-xmpp-client/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} diff --git a/nvd3/index.d.ts b/nvd3/index.d.ts index 45e933eb82..de2bbddefe 100644 --- a/nvd3/index.d.ts +++ b/nvd3/index.d.ts @@ -1355,6 +1355,12 @@ id(value: number|string): this; valueFormatter(func: (d: any) => string): this; } + interface SankeyNodeStyleOptions { + title?: any; + fillColor?: any; + strokeColor?: any; + } + //#endregion //#region Charts @@ -3274,6 +3280,58 @@ id(value: number|string): this; } + interface SankeyChart extends Chart { + /*Y-position of the middle of a node.*/ + center(): number; + /*Y-position of the middle of a node.*/ + center(value: (d: any) => any): this; + + /*Formatting settings for nodes. */ + format(): string; + /*Formatting settings for nodes. */ + format(formatter: (d: any) => string): this; + + /*The height the graph or component created inside the SVG should be made*/ + height(): number; + /*The height the graph or component created inside the SVG should be made.*/ + height(value: number): this; + + /*Format annotation on links. */ + linkTitle(): string; + /*Format annotation on links. */ + linkTitle(formatter: (d: any) => string): this; + + /* The padding of nodes.*/ + nodePadding(): number; + /*The padding of nodes.*/ + nodePadding(value: number): this; + + /*Styling options for nodes. */ + margin(): Margin; + /*Styling options for nodes. */ + margin(value: Margin): this; + + /* The width of nodes.*/ + nodeWidth(): number; + /*The width of nodes.*/ + nodeWidth(value: number): this; + + /*Styling options for nodes. */ + nodeStyle(): SankeyNodeStyleOptions; + /*Styling options for nodes. */ + nodeStyle(value: SankeyNodeStyleOptions): this; + + /* The width the graph or component created inside the SVG should be made*/ + width(): number; + /*The width the graph or component created inside the SVG should be made.*/ + width(value: number): this; + + /*Units to be used. */ + units(): string + /*Units to be used. */ + units(value: string): this; + } + interface StackedAreaChart extends StackedArea, Chart { stacked: StackedArea; legend: Legend; @@ -3378,6 +3436,7 @@ id(value: number|string): this; parallelCoordinatesChart(): ParallelCoordinatesChart; pie(): Pie; pieChart(): PieChart; + sankeyChart(): SankeyChart; scatter(): Scatter; scatterChart(): ScatterChart; sparkline(): SparkLine; diff --git a/react-bootstrap/index.d.ts b/react-bootstrap/index.d.ts index e211264bc7..6c17fb4cee 100644 --- a/react-bootstrap/index.d.ts +++ b/react-bootstrap/index.d.ts @@ -528,6 +528,7 @@ declare namespace ReactBootstrap { // interface NavbarToggleProps { + onClick?: React.MouseEventHandler; } type NavbarToggle = React.ClassicComponent; var NavbarToggle: React.ClassicComponentClass; @@ -535,7 +536,7 @@ declare namespace ReactBootstrap { // interface NavbarLinkProps { href: string; - onClick?: React.MouseEventHandler<{}>; + onClick?: React.MouseEventHandler; } type NavbarLink = React.ClassicComponent; const NavbarLink: React.ClassicComponentClass; @@ -615,7 +616,7 @@ declare namespace ReactBootstrap { interface TabProps extends React.HTMLProps { animation?: boolean; 'aria-labelledby'?:string; - bsClass?:string; + bsClass?:string; eventKey?: any; // TODO: Add more specific type onEnter?: Function; onEntered?: Function; @@ -766,7 +767,7 @@ declare namespace ReactBootstrap { interface GridProps extends React.HTMLProps { componentClass?: React.ReactType; fluid?: boolean; - bsClass?: string; + bsClass?: string; } type Grid = React.ClassicComponent; var Grid: React.ClassicComponentClass; diff --git a/react-bootstrap/react-bootstrap-tests.tsx b/react-bootstrap/react-bootstrap-tests.tsx index 00bfae517c..f3772d0fef 100644 --- a/react-bootstrap/react-bootstrap-tests.tsx +++ b/react-bootstrap/react-bootstrap-tests.tsx @@ -528,7 +528,7 @@ export class ReactBootstrapTest extends Component { React-Bootstrap - + {} } />