diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index 50e7562178..0174a0d616 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -933,3 +933,19 @@ function NgModelControllerTyping() { }); }; } + +function ngFilterTyping() { + var $filter: angular.IFilterService; + var items: string[]; + + $filter("name")(items, "test"); + $filter("name")(items, {name: "test"}); + $filter("name")(items, (val, index, array) => { + return array; + }); + $filter("name")(items, (val, index, array) => { + return array; + }, (actual, expected) => { + return actual == expected; + }); +} \ No newline at end of file diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 6a098b5716..dac88280d6 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -782,7 +782,23 @@ declare module angular { * * @param name Name of the filter function to retrieve */ - (name: string): Function; + (name: string): IFilterFunc; + } + + interface IFilterFunc { + (array: T[], expression: string | IFilterPatternObject | IFilterPredicateFunc, comparator?: IFilterComparatorFunc|boolean): T[]; + } + + interface IFilterPatternObject { + [name: string]: string; + } + + interface IFilterPredicateFunc { + (value: T, index: number, array: T[]): T[]; + } + + interface IFilterComparatorFunc { + (actual: T, expected: T): boolean; } /** diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index 701cc6d9dc..f7c5945ad3 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -19,6 +19,7 @@ declare module Backbone { interface NavigateOptions { trigger?: boolean; + replace?: boolean; } interface RouterOptions { diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts index 2377da0d00..b8eecf2cad 100644 --- a/bluebird/bluebird-tests.ts +++ b/bluebird/bluebird-tests.ts @@ -550,6 +550,13 @@ fooArrProm = fooArrProm.filter((item: Foo) => { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +fooArrProm = fooArrProm.each((item: Foo): Bar => bar); +fooArrProm = fooArrProm.each((item: Foo, index: number): Bar => index ? bar : null); +fooArrProm = fooArrProm.each((item: Foo, index: number, arrayLength: number): Bar => bar); +fooArrProm = fooArrProm.each((item: Foo, index: number, arrayLength: number): Promise => barProm); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + fooProm = Promise.try(() => { return foo; @@ -1123,3 +1130,43 @@ fooArrProm = Promise.filter(fooArr, (item: Foo, index: number, arrayLength: numb }); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// each() + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooThenArrThen + +fooArrThen = Promise.each(fooThenArrThen, (item: Foo) => bar); +fooArrThen = Promise.each(fooThenArrThen, (item: Foo) => barThen); +fooArrThen = Promise.each(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => bar); +fooArrThen = Promise.each(fooThenArrThen, (item: Foo, index: number, arrayLength: number) => barThen); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooArrThen + +fooArrThen = Promise.each(fooArrThen, (item: Foo) => bar); +fooArrThen = Promise.each(fooArrThen, (item: Foo) => barThen); +fooArrThen = Promise.each(fooArrThen, (item: Foo, index: number, arrayLength: number) => bar); +fooArrThen = Promise.each(fooArrThen, (item: Foo, index: number, arrayLength: number) => barThen); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooThenArr + +fooArrThen = Promise.each(fooThenArr, (item: Foo) => bar); +fooArrThen = Promise.each(fooThenArr, (item: Foo) => barThen); +fooArrThen = Promise.each(fooThenArr, (item: Foo, index: number, arrayLength: number) => bar); +fooArrThen = Promise.each(fooThenArr, (item: Foo, index: number, arrayLength: number) => barThen); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooArr + +fooArrThen = Promise.each(fooArr, (item: Foo) => bar); +fooArrThen = Promise.each(fooArr, (item: Foo) => barThen); +fooArrThen = Promise.each(fooArr, (item: Foo, index: number, arrayLength: number) => bar); +fooArrThen = Promise.each(fooArr, (item: Foo, index: number, arrayLength: number) => barThen); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bluebird/bluebird.d.ts b/bluebird/bluebird.d.ts index 543a2ef0a0..350761fddc 100644 --- a/bluebird/bluebird.d.ts +++ b/bluebird/bluebird.d.ts @@ -328,6 +328,11 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { filter(filterer: (item: U, index: number, arrayLength: number) => Promise.Thenable, options?: Promise.ConcurrencyOption): Promise; filter(filterer: (item: U, index: number, arrayLength: number) => boolean, options?: Promise.ConcurrencyOption): Promise; + /** + * Same as calling ``Promise.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(iterator: (item: R, index: number, arrayLength: number) => U | Promise.Thenable): Promise; + /** * Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise. * @@ -607,6 +612,18 @@ declare class Promise implements Promise.Thenable, Promise.Inspection { // array with values static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => Promise.Thenable, option?: Promise.ConcurrencyOption): Promise; static filter(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean, option?: Promise.ConcurrencyOption): Promise; + + /** + * 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. + * + * 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(values: Promise.Thenable[]>, iterator: (item: R, index: number, arrayLength: number) => U | Promise.Thenable): Promise; + // array with promises of value + static each(values: Promise.Thenable[], iterator: (item: R, index: number, arrayLength: number) => U | Promise.Thenable): Promise; + // array with values OR promise of array with values + static each(values: R[] | Promise.Thenable, iterator: (item: R, index: number, arrayLength: number) => U | Promise.Thenable): Promise; } declare module Promise { diff --git a/chartjs/chart.d.ts b/chartjs/chart.d.ts index 9da7245f61..d337d144a6 100644 --- a/chartjs/chart.d.ts +++ b/chartjs/chart.d.ts @@ -27,7 +27,7 @@ interface LinearChartData { interface CircularChartData { value: number; - color: string; + color?: string; highlight?: string; label?: string; } diff --git a/chrome/chrome-tests.ts b/chrome/chrome-tests.ts index f4e208d89b..3417384358 100644 --- a/chrome/chrome-tests.ts +++ b/chrome/chrome-tests.ts @@ -245,3 +245,12 @@ function contentSettings() { } }); } + +// https://developer.chrome.com/extensions/runtime#method-openOptionsPage +function testOptionsPage() { + chrome.runtime.openOptionsPage(); + chrome.runtime.openOptionsPage(function() { + // Do a thing ... + }); +} + diff --git a/chrome/chrome.d.ts b/chrome/chrome.d.ts index 2fc2fb6fc6..34bb95205c 100755 --- a/chrome/chrome.d.ts +++ b/chrome/chrome.d.ts @@ -1649,6 +1649,7 @@ declare module chrome.runtime { export function getPackageDirectoryEntry(callback: (directoryEntry: any) => void): void; export function getPlatformInfo(callback: (platformInfo: PlatformInfo) => void): void; export function getURL(path: string): string; + export function openOptionsPage(callback?: () => void): void; export function reload(): void; export function requestUpdateCheck(callback: (status: string, details?: UpdateCheckDetails) => void): void; export function restart(): void; diff --git a/cordova-plugin-app-version/cordova-plugin-app-version-tests.ts b/cordova-plugin-app-version/cordova-plugin-app-version-tests.ts new file mode 100644 index 0000000000..3b27435bd4 --- /dev/null +++ b/cordova-plugin-app-version/cordova-plugin-app-version-tests.ts @@ -0,0 +1,19 @@ +/// +/// + +cordova.getAppVersion.getAppName() + .then(appName=> { + console.log(appName) + }); +cordova.getAppVersion.getPackageName() + .then(packageName=> { + console.log(packageName); + }); +cordova.getAppVersion.getVersionCode() + .then(versionCode=> { + console.log(versionCode); + }); +cordova.getAppVersion.getVersionNumber() + .then(versionNumber=> { + console.log(versionNumber); + }); \ No newline at end of file diff --git a/cordova-plugin-app-version/cordova-plugin-app-version.d.ts b/cordova-plugin-app-version/cordova-plugin-app-version.d.ts new file mode 100644 index 0000000000..a754368e38 --- /dev/null +++ b/cordova-plugin-app-version/cordova-plugin-app-version.d.ts @@ -0,0 +1,15 @@ +// Type definitions for cordova-plugin-app-version v0.1.7 +// Project: https://github.com/whiteoctober/cordova-plugin-app-version +// Definitions by: Markus Wagner +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface Cordova { + getAppVersion: { + getAppName: () => Q.IPromise; + getPackageName: () => Q.IPromise; + getVersionCode: () => Q.IPromise; + getVersionNumber: () => Q.IPromise; + }; +} \ No newline at end of file diff --git a/cordova-plugin-ibeacon/cordova-plugin-ibeacon-tests.ts b/cordova-plugin-ibeacon/cordova-plugin-ibeacon-tests.ts new file mode 100644 index 0000000000..7520c39d52 --- /dev/null +++ b/cordova-plugin-ibeacon/cordova-plugin-ibeacon-tests.ts @@ -0,0 +1,62 @@ +/// +/// + +function registerDelegates() { + cordova.plugins.locationManager.enableDebugLogs(); + + cordova.plugins.locationManager.delegate.didRangeBeaconsInRegion = (pluginResult) => didRangeBeaconsInRegion(pluginResult); + cordova.plugins.locationManager.delegate.didEnterRegion = (pluginResult) => didEnterRegion(pluginResult); + cordova.plugins.locationManager.delegate.didExitRegion = (pluginResult) => didExitRegion(pluginResult); + cordova.plugins.locationManager.delegate.didDetermineStateForRegion = (pluginResult) => didDetermineStateForRegion(pluginResult); + cordova.plugins.locationManager.delegate.didChangeAuthorizationStatus = (authorizationStatus) => didChangeAuthorizationStatus(authorizationStatus); + cordova.plugins.locationManager.delegate.didStartMonitoringForRegion = (pluginResult) => didStartMonitoringForRegion(pluginResult); + cordova.plugins.locationManager.delegate.monitoringDidFailForRegionWithError = (pluginResult) => monitoringDidFailForRegionWithError(pluginResult); + + cordova.plugins.locationManager.onDomDelegateReady(); +} + +function didRangeBeaconsInRegion(pluginResult: BeaconPlugin.PluginResult): void { + for (var beacon of pluginResult.beacons) { + console.log(beacon.uuid, beacon.major, beacon.minor, beacon.accuracy, beacon.proximity, beacon.rssi, beacon.tx); + } +} + +function didEnterRegion(pluginResult: BeaconPlugin.PluginResult): void { + var region: BeaconPlugin.Region = new cordova.plugins.locationManager.BeaconRegion("identifier", "uuid", 1, 2);; + cordova.plugins.locationManager.startRangingBeaconsInRegion(this.createBeaconRegionFromPluginResult(pluginResult)) + .then(() => { + console.log("startRangingBeaconsInRegion succeeded"); + }) + .catch((reason: any) => { + console.error("startRangingBeaconsInRegion failed: " + reason); + }); +} + +function didExitRegion(pluginResult: BeaconPlugin.PluginResult): void { + var region: BeaconPlugin.Region; + cordova.plugins.locationManager.stopRangingBeaconsInRegion(region) + .then(() => { + console.log("stopRangingBeaconsInRegion succeeded"); + }) + .catch((reason: any) => { + console.error("stopRangingBeaconsInRegion failed: " + reason); + }); +} + +function didDetermineStateForRegion(pluginResult: BeaconPlugin.PluginResult): void { + if (pluginResult.state === "CLRegionStateInside") { + console.log(pluginResult.region.identifier); + } +} + +function didChangeAuthorizationStatus(authorizationStatus: string): void { + console.log(authorizationStatus); +} + +function didStartMonitoringForRegion(pluginResult: BeaconPlugin.PluginResult): void { + console.log(pluginResult.region.identifier); +} + +function monitoringDidFailForRegionWithError(pluginResult: BeaconPlugin.PluginResult): void { + console.log(pluginResult.region.identifier); +} \ No newline at end of file diff --git a/cordova-plugin-ibeacon/cordova-plugin-ibeacon.d.ts b/cordova-plugin-ibeacon/cordova-plugin-ibeacon.d.ts new file mode 100644 index 0000000000..8f1f6af1a6 --- /dev/null +++ b/cordova-plugin-ibeacon/cordova-plugin-ibeacon.d.ts @@ -0,0 +1,95 @@ +// Type definitions for cordova-plugin-ibeacon v3.3.0 +// Project: https://github.com/petermetz/cordova-plugin-ibeacon +// Definitions by: Markus Wagner +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface CordovaPlugins { + locationManager: BeaconPlugin.LocationManager; +} + +declare module BeaconPlugin { + /** + * Beacon Plugin. + */ + export interface LocationManager { + delegate: Delegate; + BeaconRegion: BeaconRegion; + onDomDelegateReady(): void; + startMonitoringForRegion(region: Region): Q.Promise; + stopMonitoringForRegion(region: Region): Q.Promise; + requestStateForRegion(region: Region): Q.Promise; + startRangingBeaconsInRegion(region: Region): Q.Promise; + stopRangingBeaconsInRegion(region: Region): Q.Promise; + getAuthorizationStatus(): Q.Promise; + requestWhenInUseAuthorization(): Q.Promise; + requestAlwaysAuthorization(): Q.Promise; + getMonitoredRegions(): Q.Promise; + getRangedRegions(): Q.Promise; + isRangingAvailable(): Q.Promise; + isMonitoringAvailableForClass(region: Region): Q.Promise; + startAdvertising(region: Region, measuredPower: boolean): Q.Promise; + stopAdvertising(): Q.Promise; + isAdvertisingAvailable(): Q.Promise; + isAdvertising(): Q.Promise; + disableDebugLogs(): Q.Promise; + enableDebugNotifications(): Q.Promise; + disableDebugNotifications(): Q.Promise; + enableDebugLogs(): Q.Promise; + isBluetoothEnabled(): Q.Promise; + enableBluetooth(): Q.Promise; + disableBluetooth(): Q.Promise; + appendToDeviceLog(message: string): Q.Promise; + } + + export interface PluginResult { + eventType: string; + region: Region; + beacons: Beacon[]; + authorizationStatus: string; + state: string; + } + + export interface Delegate { + didDetermineStateForRegion(pluginResult: PluginResult): void; + didStartMonitoringForRegion(pluginResult: PluginResult): void; + didExitRegion(pluginResult: PluginResult): void; + didEnterRegion(pluginResult: PluginResult): void; + didRangeBeaconsInRegion(pluginResult: PluginResult): void; + peripheralManagerDidStartAdvertising(pluginResult: PluginResult): void; + peripheralManagerDidUpdateState(pluginResult: PluginResult): void; + didChangeAuthorizationStatus(authorizationStatus: string): void; + monitoringDidFailForRegionWithError(pluginResult: PluginResult): void; + } + + export interface Region { + identifier: string; + new (identifier: string): Region; + } + + export interface BeaconRegion extends Region { + uuid: string; + major: string; + minor: string; + notifyEntryStateOnDisplay: boolean; + new (identifier: string, uuid: string, major?: number, minor?: number, notifyEntryStateOnDisplay?: boolean): BeaconRegion; + } + + export interface CircularRegion extends Region { + latitude: number; + longitude: number; + radius: number; + new (identifier: string, latitude: number, longitude: number, radius: number): CircularRegion; + } + + export interface Beacon { + uuid: string; + major: string; + minor: string; + proximity: string; + tx: number; + rssi: number; + accuracy: number; + } +} diff --git a/core-decorators/core-decorators-tests.ts b/core-decorators/core-decorators-tests.ts new file mode 100644 index 0000000000..e4a31432ba --- /dev/null +++ b/core-decorators/core-decorators-tests.ts @@ -0,0 +1,169 @@ +/// + +// +// @autobind +// + +import { autobind } from 'core-decorators'; + +class Person { + @autobind + getPerson() { + return this; + } +} + +let person = new Person(); +let getPerson = person.getPerson; + +getPerson() === person; + +// +// @readonly +// + +import { readonly } from 'core-decorators'; + +class Meal { + @readonly + entree: string = 'steak'; +} + +var dinner = new Meal(); +dinner.entree = 'salmon'; + +// +// @override +// + +import { override } from 'core-decorators'; + +class Parent { + speak(first: string, second: string) {} +} + +class Child extends Parent { + @override + speak() {} + // SyntaxError: Child#speak() does not properly override Parent#speak(first, second) +} + +// or + +class Child2 extends Parent { + @override + speaks() {} + // SyntaxError: No descriptor matching Child#speaks() was found on the prototype chain. + // + // Did you mean "speak"? +} + +// +// @deprecate (alias: @deprecated) +// + +import { deprecate, deprecated } from 'core-decorators'; + +class Person2 { + @deprecate + facepalm() {} + + @deprecate('We stopped facepalming') + facepalmHard() {} + + @deprecate('We stopped facepalming', { url: 'http://knowyourmeme.com/memes/facepalm' }) + facepalmHarder() {} +} + +let person2 = new Person2(); + +person2.facepalm(); +// DEPRECATION Person#facepalm: This function will be removed in future versions. + +person2.facepalmHard(); +// DEPRECATION Person#facepalmHard: We stopped facepalming + +person2.facepalmHarder(); +// DEPRECATION Person#facepalmHarder: We stopped facepalming +// +// See http://knowyourmeme.com/memes/facepalm for more details. +// + +// +// @debounce +// + +import { debounce } from 'core-decorators'; + +class Editor { + + content = ''; + + @debounce(500) + updateContent(content: string) { + this.content = content; + } +} + +// +// @suppressWarnings +// + +import { suppressWarnings } from 'core-decorators'; + +class Person3 { + @deprecated + facepalm() {} + + @suppressWarnings + facepalmWithoutWarning() { + this.facepalm(); + } +} + +let person3 = new Person3(); + +person3.facepalmWithoutWarning(); +// no warning is logged + +// +// @nonenumerable +// + +import { nonenumerable } from 'core-decorators'; + +class Meal2 { + entree = 'steak'; + + @nonenumerable + cost: number = 4.44; +} + +var dinner2 = new Meal2(); +for (var key in dinner2) { + key; + // "entree" only, not "cost" +} + +Object.keys(dinner2); +// ["entree"] + +// +// @nonconfigurable +// + +import { nonconfigurable } from 'core-decorators'; + +class Meal3 { + @nonconfigurable + entree: string = 'steak'; +} + +var dinner3 = new Meal3(); + +Object.defineProperty(dinner3, 'entree', { + enumerable: false +}); +// Cannot redefine property: entree + + diff --git a/core-decorators/core-decorators-tests.ts.tscparams b/core-decorators/core-decorators-tests.ts.tscparams new file mode 100644 index 0000000000..3f0863ac67 --- /dev/null +++ b/core-decorators/core-decorators-tests.ts.tscparams @@ -0,0 +1 @@ +--experimentalDecorators --noImplicitAny --target ES5 diff --git a/core-decorators/core-decorators.d.ts b/core-decorators/core-decorators.d.ts new file mode 100644 index 0000000000..160802fc1f --- /dev/null +++ b/core-decorators/core-decorators.d.ts @@ -0,0 +1,89 @@ +// Type definitions for core-decorators.js v0.1.5 +// Project: https://github.com/jayphelps/core-decorators.js +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "core-decorators" { + export interface ClassDecorator { + (target: TFunction): TFunction|void; + } + + export interface ParameterDecorator { + (target: Object, propertyKey: string|symbol, parameterIndex: number): void; + } + + export interface PropertyDecorator { + (target: Object, propertyKey: string|symbol): void; + } + + export interface MethodDecorator { + (target: Object, propertyKey: string|symbol, descriptor: TypedPropertyDescriptor): TypedPropertyDescriptor|void; + } + + export interface PropertyOrMethodDecorator extends MethodDecorator, PropertyDecorator { + (target: Object, propertyKey: string|symbol): void; + } + + export interface Deprecate extends MethodDecorator { + (message?: string, option?: DeprecateOption): MethodDecorator; + } + + export interface DeprecateOption { + url: string; + } + + /** + * Forces invocations of this function to always have this refer to the class instance, + * even if the function is passed around or would otherwise lose its this context. e.g. var fn = context.method; + */ + var autobind: MethodDecorator; + /** + * Marks a property or method as not being writable. + */ + var readonly: PropertyOrMethodDecorator; + /** + * Checks that the marked method indeed overrides a function with the same signature somewhere on the prototype chain. + */ + var override: MethodDecorator; + /** + * Calls console.warn() with a deprecation message. Provide a custom message to override the default one. You can also provide an options hash with a url, for further reading. + */ + var deprecate: Deprecate; + /** + * Calls console.warn() with a deprecation message. Provide a custom message to override the default one. You can also provide an options hash with a url, for further reading. + */ + var deprecated: Deprecate; + /** + * Creates a new debounced function which will be invoked after wait milliseconds since the time it was invoked. Default timeout is 300 ms. + */ + var debounce: (wait: number) => MethodDecorator; + /** + * Suppresses any JavaScript console.warn() call while the decorated function is called. (i.e. on the stack) + */ + var suppressWarnings: MethodDecorator; + /** + * Marks a property or method as not being enumerable. + */ + var nonenumerable: PropertyOrMethodDecorator; + /** + * Marks a property or method as not being writable. + */ + var nonconfigurable: PropertyOrMethodDecorator; + /** + * Initial implementation included, likely slow. WIP. + */ + var memoize: MethodDecorator; + + export { + autobind, + readonly, + override, + deprecate, + deprecated, + debounce, + suppressWarnings, + nonenumerable, + nonconfigurable, + memoize // WIP + }; +} diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index 105e8f29cc..414a2346ef 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -139,7 +139,7 @@ function groupedBarChart() { .style("text-anchor", "end") .text("Population"); - var state = svg.selectAll(".state") + var state = svg.selectAll(".state") .data(data) .enter().append("g") .attr("class", "g") @@ -672,8 +672,8 @@ function dragMultiples() { function dragmove(d: { x: number; y: number }) { d3.select(this) - .attr("cx", d.x = Math.max(radius, Math.min(width - radius, ( d3.event).x))) - .attr("cy", d.y = Math.max(radius, Math.min(height - radius, ( d3.event).y))); + .attr("cx", d.x = Math.max(radius, Math.min(width - radius, ( d3.event).x))) + .attr("cy", d.y = Math.max(radius, Math.min(height - radius, ( d3.event).y))); } } @@ -873,7 +873,7 @@ function populationPyramid() { // Allow the arrow keys to change the displayed year. window.focus(); d3.select(window).on("keydown", function () { - switch (d3.event.keyCode) { + switch (( d3.event).keyCode) { case 37: year = Math.max(year0, year - 10); break; case 39: year = Math.min(year1, year + 10); break; } @@ -1167,7 +1167,7 @@ function azimuthalEquidistant() { .translate([width / 2, height / 2]) .clipAngle(180 - 1e-3) .precision(.1); - + var path = d3.geo.path() .projection(projection); @@ -1209,7 +1209,7 @@ function azimuthalEquidistant() { d3.select(self.frameElement).style("height", height + "px"); } - + //Example from http://bl.ocks.org/mbostock/4060366 function voronoiTesselation() { var width = 960, @@ -1237,7 +1237,7 @@ function voronoiTesselation() { .attr("r", 2); redraw(); - + function redraw() { path = path.data(voronoi(vertices).map(function (d) { return "M" + d.join("L") + "Z"; } ), String); path.exit().remove(); @@ -1254,7 +1254,7 @@ function forceDirectedVoronoi() { simulate = true, zoomToAdd = true, color = d3.scale.quantize().domain([10000, 7250]).range(["#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]) - + var numVertices = (w*h) / 3000; var vertices = d3.range(numVertices).map(function(i) { var angle = radius * (i+10); @@ -1266,15 +1266,15 @@ function forceDirectedVoronoi() { var prevEventScale = 1; var zoom = d3.behavior.zoom().on("zoom", function(d,i) { if (zoomToAdd){ - if (( d3.event).scale > prevEventScale) { - var angle = radius * vertices.length; - vertices.push({x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)}) - } else if (vertices.length > 2 && ( d3.event).scale != prevEventScale) { - vertices.pop(); - } - force.nodes(vertices).start() + if (( d3.event).scale > prevEventScale) { + var angle = radius * vertices.length; + vertices.push({x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)}) + } else if (vertices.length > 2 && ( d3.event).scale != prevEventScale) { + vertices.pop(); + } + force.nodes(vertices).start() } else { - if (( d3.event).scale > prevEventScale) { + if (( d3.event).scale > prevEventScale) { radius+= .01 } else { radius -= .01 @@ -1285,18 +1285,18 @@ function forceDirectedVoronoi() { }); force.nodes(vertices).start() } - prevEventScale = ( d3.event).scale; + prevEventScale = ( d3.event).scale; }); - + d3.select(window) .on("keydown", function() { // shift - if(d3.event.keyCode == 16) { + if(( d3.event).keyCode == 16) { zoomToAdd = false } - + // s - if(d3.event.keyCode == 83) { + if(( d3.event).keyCode == 83) { simulate = !simulate if(simulate) { force.start() @@ -1308,38 +1308,38 @@ function forceDirectedVoronoi() { .on("keyup", function() { zoomToAdd = true }) - + var svg = d3.select("#chart") .append("svg") .attr("width", w) .attr("height", h) .call(zoom) - + var force = d3.layout.force() .charge(-300) .size([w, h]) .on("tick", update); - + force.nodes(vertices).start(); - + var circle = > svg.selectAll("circle"); var path = > svg.selectAll("path"); var link = > svg.selectAll("line"); - + function update() { path = path.data(d3_geom_voronoi(vertices)); path.enter().append("path") // drag node by dragging cell .call(d3.behavior.drag() .on("drag", function(d, i) { - vertices[i] = {x: vertices[i].x + ( d3.event).dx, y: vertices[i].y + ( d3.event).dy} + vertices[i] = {x: vertices[i].x + ( d3.event).dx, y: vertices[i].y + ( d3.event).dy} }) ) .style("fill", function(d, i) { return color(0) }) path.attr("d", function(d) { return "M" + d.join("L") + "Z"; }) .transition().duration(150).style("fill", function(d, i) { return color(d3.geom.polygon(d).area()) }) path.exit().remove(); - + circle = circle.data(vertices) circle.enter().append("circle") .attr("r", 0) @@ -1347,16 +1347,16 @@ function forceDirectedVoronoi() { circle.attr("cx", function(d) { return d.x; }) .attr("cy", function(d) { return d.y; }); circle.exit().transition().attr("r", 0).remove(); - + link = link.data(d3_geom_voronoi.links(vertices)) link.enter().append("line") link.attr("x1", function(d) { return d.source.x; }) .attr("y1", function(d) { return d.source.y; }) .attr("x2", function(d) { return d.target.x; }) .attr("y2", function(d) { return d.target.y; }) - + link.exit().remove() - + if(!simulate) force.stop() } } @@ -1521,7 +1521,7 @@ module hierarchicalEdgeBundling { .value(function (d) { return d.size; } ); var bundle = d3.layout.bundle(); - + var line = d3.svg.line.radial() .interpolate("bundle") .tension(.85) @@ -1851,7 +1851,7 @@ function chordDiagram() { [8010, 16145, 8090, 8045], [1013, 990, 940, 6907] ]; - + var chord = d3.layout.chord() .padding(.05) .sortSubgroups(d3.descending) @@ -2031,7 +2031,7 @@ function irisParallel() { } function drag(d: string) { - x.range()[i] = ( d3.event).x; + x.range()[i] = ( d3.event).x; traits.sort(function (a, b) { return x(a) - x(b); } ); g.attr("transform", function (d) { return "translate(" + x(d) + ")"; } ); foreground.attr("d", path); @@ -2085,14 +2085,14 @@ function healthAndWealth() { // The x & y axes. var xAxis = d3.svg.axis().orient("bottom").scale(xScale).ticks(12, d3.format(",d")), yAxis = d3.svg.axis().scale(yScale).orient("left"); - + // Create the SVG container and set the origin. var svg = d3.select("#chart").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - + // Add the x-axis. svg.append("g") .attr("class", "x axis") @@ -2152,7 +2152,7 @@ function healthAndWealth() { // Add an overlay for the year label. var box = (label.node()).getBBox(); - + var overlay = svg.append("rect") .attr("class", "overlay") .attr("x", box.x) @@ -2669,12 +2669,14 @@ function multiTest() { function testD3Events () { d3.select('svg') .on('click', () => { - var coords = [d3.event.pageX, d3.event.pageY]; - console.log("clicked", d3.event.target, "at " + coords); + let e = d3.event; + var coords = [e.pageX, e.pageY]; + console.log("clicked", e.target, "at " + coords); }) .on('keypress', () => { - if (d3.event.shiftKey) { - console.log('shift + ' + d3.event.which); + let e = d3.event; + if (e.shiftKey) { + console.log('shift + ' + e.which); } }); } @@ -2690,4 +2692,4 @@ function testD3MutlieTimeFormat() { ["%B", function(d) { return d.getMonth(); }], ["%Y", function() { return true; }] ]); -} \ No newline at end of file +} diff --git a/d3/d3.d.ts b/d3/d3.d.ts index ef3909e9fc..2d1b20c3bc 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -807,7 +807,7 @@ declare module d3 { interface Transition { transition(): Transition; - + delay(): number; delay(delay: number): Transition; delay(delay: (datum: Datum, index: number, outerIndex: number) => number): Transition; @@ -920,16 +920,33 @@ declare module d3 { export function flush(): void; } - /** - * Interface for any and all d3 events. - */ - interface Event extends KeyboardEvent, MouseEvent { - } + interface BaseEvent { + type: string; + sourceEvent?: Event; + } + + /** + * Define a D3-specific ZoomEvent per https://github.com/mbostock/d3/wiki/Zoom-Behavior#event + */ + interface ZoomEvent extends BaseEvent { + scale: number; + translate: [number, number]; + } + + /** + * Define a D3-specific DragEvent per https://github.com/mbostock/d3/wiki/Drag-Behavior#on + */ + interface DragEvent extends BaseEvent { + x: number; + y: number; + dx: number; + dy: number; + } /** * The current event's value. Use this variable in a handler registered with `selection.on`. */ - export var event: Event; + export var event: Event | BaseEvent; /** * Returns the x and y coordinates of the mouse relative to the provided container element, using d3.event for the mouse's position on the page. diff --git a/express/express.d.ts b/express/express.d.ts index 973d45fc72..e2f6d5df21 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -107,7 +107,7 @@ declare module "express" { use(path: string, ...handler: RequestHandler[]): T; use(path: string, handler: ErrorRequestHandler): T; use(path: string[], ...handler: RequestHandler[]): T; - use(path: string[], handler: ErrorRequestHandler[]): T; + use(path: string[], handler: ErrorRequestHandler): T; } export function Router(options?: any): Router; diff --git a/findup-sync/findup-sync-tests.ts b/findup-sync/findup-sync-tests.ts index f4aab395ae..55eab36177 100644 --- a/findup-sync/findup-sync-tests.ts +++ b/findup-sync/findup-sync-tests.ts @@ -11,3 +11,7 @@ str = findup(['foo', 'bar']); str = findup('foo', { debug: true }); + +str = findup('foo', { + cwd: "c:\\" +}); diff --git a/findup-sync/findup-sync.d.ts b/findup-sync/findup-sync.d.ts index a5bb5b49df..b7bf674e23 100644 --- a/findup-sync/findup-sync.d.ts +++ b/findup-sync/findup-sync.d.ts @@ -1,6 +1,6 @@ -// Type definitions for findup-sync v0.1.3 +// Type definitions for findup-sync v0.3.0 // Project: https://github.com/cowboy/node-findup-sync -// Definitions by: Bart van der Schoor +// Definitions by: Bart van der Schoor , Nathan Brown // Definitions: https://github.com/borisyankov/DefinitelyTyped /// @@ -8,8 +8,11 @@ declare module 'findup-sync' { import minimatch = require('minimatch'); - function mod(pattern: string, opts?: minimatch.IOptions): string; - function mod(pattern: string[], opts?: minimatch.IOptions): string; + interface IOptions extends minimatch.IOptions { + cwd?: string; + } + + function mod(pattern: string[] | string, opts?: IOptions): string; export = mod; } diff --git a/flowjs/flowjs-tests.ts b/flowjs/flowjs-tests.ts new file mode 100644 index 0000000000..8bedad0036 --- /dev/null +++ b/flowjs/flowjs-tests.ts @@ -0,0 +1,78 @@ +/// + +// flow object +var flowObject: flowjs.IFlow; +var bool: boolean = flowObject.support; +bool = flowObject.supportDirectory; +var obj: Object = flowObject.opts; +var flowFileArray: flowjs.IFlowFile[] = flowObject.files; + +flowObject.assignBrowse( [], false, false, {}); +flowObject.assignDrop( []); +flowObject.unAssignDrop( []); +flowObject.on("", () => {}); +flowObject.off("", () => {}); +flowObject.upload(); +flowObject.pause(); +flowObject.resume(); +flowObject.cancel(); +flowObject.progress(); +bool = flowObject.isUploading(); +flowObject.addFile( {}); +flowObject.removeFile( {}); +var flowFile: flowjs.IFlowFile = flowObject.getFromUniqueIdentifier(""); +var num: number = flowObject.getSize(); +num = flowObject.sizeUploaded(); +num = flowObject.timeRemaining(); + +// flow options +var flowOptions: flowjs.IFlowOptions = {}; +flowOptions.target = ""; +flowOptions.singleFile = true; +flowOptions.chunkSize= 0; +flowOptions.forceChunkSize = true; +flowOptions.simultaneousUploads= 0; +flowOptions.fileParameterName = ""; +flowOptions.query = {}; +flowOptions.headers = {}; +flowOptions.withCredentials = true; +flowOptions.method = ""; +flowOptions.testMethod = ""; +flowOptions.uploadMethod = ""; +flowOptions.allowDuplicateUploads = true; +flowOptions.prioritizeFirstAndLastChunk = true; +flowOptions.testchunks = true; +flowOptions.preprocess = () => {}; +flowOptions.initFileFn = () => {}; +flowOptions.generateUniqueIdentifier = () => {}; +flowOptions.maxChunkRetries= 0; +flowOptions.chunkRetryInterval= 0; +flowOptions.progressCallbacksInterval= 0; +flowOptions.speedSmoothingFactor= 0; +flowOptions.successStatuses = [""]; +flowOptions.permanentErrors = [""]; + +// flow file +flowObject = flowFile.flowObj; +var htmlFile: File = flowFile.file; +var str: string = flowFile.name; +str = flowFile.relativePath; +num = flowFile.size; +str = flowFile.uniqueIdentifier; +num = flowFile.averageSpeed; +num = flowFile.currentSpeed; +var anyArray: any[] = flowFile.chunks; +bool = flowFile.paused; +bool = flowFile.error; +num = flowFile.progress(true); +flowFile.pause(); +flowFile.resume(); +flowFile.cancel(); +flowFile.retry(); +flowFile.bootstrap(); +bool = flowFile.isUploading(); +bool = flowFile.isComplete; +num = flowFile.sizeUploaded; +num = flowFile.timeRemaining; +str = flowFile.getExtension; +str = flowFile.getType; diff --git a/flowjs/flowjs.d.ts b/flowjs/flowjs.d.ts new file mode 100644 index 0000000000..e9e90055b2 --- /dev/null +++ b/flowjs/flowjs.d.ts @@ -0,0 +1,85 @@ +// Type definitions for flowjs +// Project: https://github.com/flowjs/flow.js +// Definitions by: Ryan McNamara +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module flowjs { + interface IFlow { + support: boolean; + supportDirectory: boolean; + opts: Object; + files: IFlowFile[]; + + assignBrowse(domNodes: HTMLElement[], isDirectory: boolean, singleFile: boolean, attributes: Object): void; + assignDrop(domNodes: HTMLElement[]): void; + unAssignDrop(domNodes: HTMLElement[]): void; + on(event: string, callback: Function): void; + off(event?: string, callback?: Function): void; + upload(): void; + pause(): void; + resume(): void; + cancel(): void; + progress(): number; + isUploading(): boolean; + addFile(file: File): void; + removeFile(file: IFlowFile): void; + getFromUniqueIdentifier(uniqueIdentifier: string): IFlowFile; + getSize(): number; + sizeUploaded(): number; + timeRemaining(): number; + } + + interface IFlowOptions { + target?: string; + singleFile?: boolean; + chunkSize?: number; + forceChunkSize?: boolean; + simultaneousUploads?: number; + fileParameterName?: string; + query?: Object; + headers?: Object; + withCredentials?: boolean; + method?: string; + testMethod?: string; + uploadMethod?: string; + allowDuplicateUploads?: boolean; + prioritizeFirstAndLastChunk?: boolean; + testchunks?: boolean; + preprocess?: Function; + initFileFn?: Function; + generateUniqueIdentifier?: Function; + maxChunkRetries?: number; + chunkRetryInterval?: number; + progressCallbacksInterval?: number; + speedSmoothingFactor?: number; + successStatuses?: string[]; + permanentErrors?: string[]; + } + + interface IFlowFile { + flowObj: IFlow; + file: File; + name: string; + relativePath: string; + size: number; + uniqueIdentifier: string; + averageSpeed: number; + currentSpeed: number; + chunks: any[]; + paused: boolean; + error: boolean; + + progress(relative: boolean): number; + pause(): void; + resume(): void; + cancel(): void; + retry(): void; + bootstrap(): void; + isUploading(): boolean; + isComplete: boolean; + sizeUploaded: number; + timeRemaining: number; + getExtension: string; + getType: string; + } +} diff --git a/graphviz/graphviz-tests.ts b/graphviz/graphviz-tests.ts new file mode 100644 index 0000000000..01fa791502 --- /dev/null +++ b/graphviz/graphviz-tests.ts @@ -0,0 +1,26 @@ +/// + +import graphviz = require('graphviz'); + +// Create digraph G +var g: graphviz.Graph = graphviz.digraph("G"); + +// Add node (ID: Hello) +var n1: graphviz.Node = g.addNode( "Hello", {"color" : "blue"} ); +n1.set( "style", "filled" ); + +// Add node (ID: World) +g.addNode( "World" ); + +// Add edge between the two nodes +var e: graphviz.Edge = g.addEdge( n1, "World" ); +e.set( "color", "red" ); + +// Print the dot script +console.log( g.to_dot() ); + +// Set GraphViz path (if not in your path) +g.setGraphVizPath( "/usr/local/bin" ); + +// Generate a PNG output +g.output( "png", "test01.png" ); diff --git a/graphviz/graphviz.d.ts b/graphviz/graphviz.d.ts new file mode 100644 index 0000000000..42dc3877a0 --- /dev/null +++ b/graphviz/graphviz.d.ts @@ -0,0 +1,93 @@ +// Type definitions for Graphviz 0.0.8 +// Project: git://github.com/glejeune/node-graphviz.git +// Definitions by: Matt Frantz +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// graphviz.d.ts + +declare module 'graphviz' { + + export interface HasAttributes { + set(name: string, value: any): void; + get(name: string): any; + } + + export interface Node extends HasAttributes { + } + + export interface Edge extends HasAttributes { + } + + export interface OutputCallback { + (data: string): void; + } + + export interface ErrorCallback { + (code: number, stdout: string, stderr: string): void; + } + + export interface RenderOptions { + type: string; // output file type (png, jpeg, ps, ...) + use: string; // Graphviz command to use (dot, neato, ...) + path: string; // GraphViz path + G: any; // graph options + N: any; // node options + E: any; // edge options + } + + export interface Graph extends HasAttributes { + + addNode(id: string, attrs?: any): Node; + nodeCount(): number; + + // TODO: Use union types when we have TS 1.4 + addEdge(nodeOne: string, nodeTwo: string, attrs?: any): Edge; + addEdge(nodeOne: string, nodeTwo: Node, attrs?: any): Edge; + addEdge(nodeOne: Node, nodeTwo: string, attrs?: any): Edge; + addEdge(nodeOne: Node, nodeTwo: Node, attrs?: any): Edge; + + edgeCount(): number; + + // Subgraph (cluster) API + addCluster(id: string): Graph; + getCluster(id: string): Graph; + clusterCount(): number; + + setNodeAttribut(name: string, value: any): void; + getNodeAttribut(name: string): any; + + setEdgeAttribut(name: string, value: any): void; + getEdgeAttribut(name: string): any; + + to_dot(): string; + + // Graphviz command to use (dot, neato, ...) + use: string; + + // Path containing Graphviz binaries. + setGraphVizPath(directoryPath: string): void; + + // TODO: Use union types when we can have TS 1.4 + render(type: string, filename: string, errback?: ErrorCallback): void; + render(options: RenderOptions, filename: string, errback?: ErrorCallback): void; + render(type: string, callback: OutputCallback, errback?: ErrorCallback): void; + render(options: RenderOptions, callback: OutputCallback, errback?: ErrorCallback): void; + + // alias for render + output(type: string, filename: string, errback?: ErrorCallback): void; + output(options: RenderOptions, filename: string, errback?: ErrorCallback): void; + output(type: string, callback: OutputCallback, errback?: ErrorCallback): void; + output(options: RenderOptions, callback: OutputCallback, errback?: ErrorCallback): void; + } + + export function graph(id: string): Graph; + + export function digraph(id: string): Graph; + + interface ParseCallback { + (graph: Graph): void; + } + + export function parse(path: string, callback: ParseCallback, errback?: ErrorCallback): void; + +} diff --git a/gridstack/gridstack-tests.ts b/gridstack/gridstack-tests.ts new file mode 100644 index 0000000000..b3167ea5d6 --- /dev/null +++ b/gridstack/gridstack-tests.ts @@ -0,0 +1,20 @@ +/// +/// + + +// Type definitions for Gridstack +// Project: http://troolee.github.io/gridstack.js/ +// Definitions by: Pascal Senn +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +var options = { + float: true +}; +var gridstack:GridStack = $(document).gridstack(options); + +gridstack.add_widget("test", 1, 2, 3, 4, true); +gridstack.batch_update(); +gridstack.cell_height();; +gridstack.cell_height(2); +gridstack.cell_width(); +gridstack.get_cell_from_pixel({ left:20, top: 20 }); diff --git a/gridstack/gridstack.d.ts b/gridstack/gridstack.d.ts new file mode 100644 index 0000000000..4bb3794830 --- /dev/null +++ b/gridstack/gridstack.d.ts @@ -0,0 +1,241 @@ +// Type definitions for Gridstack +// Project: http://troolee.github.io/gridstack.js/ +// Definitions by: Pascal Senn +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface JQuery { + gridstack (options: IGridstackOptions):GridStack +} + +interface GridStack { + /** + * Creates new widget and returns it. + * + * Widget will be always placed even if result height is more than actual grid height. You need to use will_it_fit method before calling add_widget for additional check. + * + * @param {string} el widget to add + * @param {number} x widget position x + * @param {number} y widget position y + * @param {number} width widget dimension width + * @param {number} height widget dimension height + * @param {boolean} auto_position if true then x, y parameters will be ignored and widget will be places on the first available position + */ + add_widget(el: string, x: number, y: number, width: number, height: number, auto_position: boolean): JQuery + /** + * Initializes batch updates. You will see no changes until commit method is called. + */ + batch_update():void + /** + * Gets current cell height. + */ + cell_height():number + /** + * Update current cell height. This method rebuilds an internal CSS style sheet. Note: You can expect performance issues if call this method too often. + * @param {number} val the cell height + */ + cell_height(val:number):void + /** + * Gets current cell width. + */ + cell_width():number + /** + * Finishes batch updates. Updates DOM nodes. You must call it after batch_update. + */ + commit():void + /** + * Destroys a grid instance. + */ + destroy(): void + /* + * Disables widgets moving/resizing. + */ + disable(): void + /* + * Enables widgets moving/resizing. + */ + enable(): void + /* + * Get the position of the cell under a pixel on screen. + * @param {MousePosition} position the position of the pixel to resolve in absolute coordinates, as an object with top and leftproperties + */ + get_cell_from_pixel(position: MousePosition): CellPosition, + /* + * Checks if specified area is empty. + * @param {number} x the position x. + * @param {number} y the position y. + * @param {number} width the width of to check + * @param {number} height the height of to check + */ + is_area_empty(x: number, y: number, width: number, height: number): void + /* + * Locks/unlocks widget. + * @param {HTMLElement} el widget to modify. + * @param {boolean} val if true widget will be locked. + */ + locked(el: HTMLElement, val: boolean): void + /* + * Set the minWidth for a widget. + * @param {HTMLElement} el widget to modify. + * @param {number} val A numeric value of the number of columns + */ + min_width(el: HTMLElement, val: number): void + /* + * Set the minHeight for a widget. + * @param {HTMLElement} el widget to modify. + * @param {number} val A numeric value of the number of rows + */ + min_height(el: HTMLElement, val: number): void + /* + * Enables/Disables moving. + * @param {HTMLElement} el widget to modify. + * @param {number} val if true widget will be draggable. + */ + movable(el: HTMLElement, val: boolean): void + /** + * Changes widget position + * @param {HTMLElement} el widget to modify + * @param {number} x new position x. If value is null or undefined it will be ignored. + * @param {number} y new position y. If value is null or undefined it will be ignored. + * + */ + move(el: HTMLElement, x: number, y: number): void + /** + * Removes widget from the grid. + * @param {HTMLElement} el widget to modify + * @param {boolean} detach_node if false DOM node won't be removed from the tree (Optional. Default true). + */ + remove_widget(el: HTMLElement, detach_node?: boolean): void + /** + * Removes all widgets from the grid. + */ + remove_all(): void + /** + * Changes widget size + * @param {HTMLElement} el widget to modify + * @param {number} width new dimensions width. If value is null or undefined it will be ignored. + * @param {number} height new dimensions height. If value is null or undefined it will be ignored. + */ + resize(el: HTMLElement, width: number, height: number): void + /** + * Enables/Disables resizing. + * @param {HTMLElement} el widget to modify + * @param {boolean} val if true widget will be resizable. + */ + resizable(el: HTMLElement, val: boolean): void + /** + * Toggle the grid static state. Also toggle the grid-stack-static class. + * @param {boolean} static_value if true the grid become static. + */ + set_static(static_value: boolean): void + /** + * Updates widget position/size. + * @param {HTMLElement} el widget to modify + * @param {number} x new position x. If value is null or undefined it will be ignored. + * @param {number} y new position y. If value is null or undefined it will be ignored. + * @param {number} width new dimensions width. If value is null or undefined it will be ignored. + * @param {number} height new dimensions height. If value is null or undefined it will be ignored. + */ + update(el: HTMLElement, x: number, y: number, width: number, height: number): void + /** + * Returns true if the height of the grid will be less the vertical constraint. Always returns true if grid doesn't have height constraint. + * @param {number} x new position x. If value is null or undefined it will be ignored. + * @param {number} y new position y. If value is null or undefined it will be ignored. + * @param {number} width new dimensions width. If value is null or undefined it will be ignored. + * @param {number} height new dimensions height. If value is null or undefined it will be ignored. + * @param {boolean} auto_position if true then x, y parameters will be ignored and widget will be places on the first available position + */ + will_it_fit(x: number, y: number, width: number, height: number, auto_position:boolean):boolean + + +} +/** +* Defines the coordiantes of a object +*/ +interface MousePosition { + top: number, + left:number, +} +/** +* Defines the position of a cell inside the grid +*/ +interface CellPosition { + x: number, + y:number +} +declare module GridStackUI { + interface Utils { + /** + * Sorts array of nodes + *@param nodes array to sort + *@param dir 1 for asc, -1 for desc (optional) + *@param width width of the grid. If undefined the width will be calculated automatically (optional). + **/ + sort(nodes: HTMLElement[], dir: number, width: number): void + } +} +/** +* Gridstack Options +* Defines the options for a Gridstack +*/ +interface IGridstackOptions { + /** + * if true the resizing handles are shown even if the user is not hovering over the widget (default: false) + */ + always_show_resize_handle: boolean; + /** + * turns animation on (default: true) + */ + animate: boolean; + /** + * if false gridstack will not initialize existing items (default: true) + */ + auto: boolean; + /** + * one cell height (default: 60) + */ + cell_height: number; + /** + * allows to override jQuery UI draggable options. (default: { handle: '.grid-stack-item-content', scroll: true, appendTo: 'body' }) + */ + draggable: {}; + /** + * draggable handle selector (default: '.grid-stack-item-content') + */ + handle: string; + /** + * maximum rows amount.Default is 0 which means no maximum rows + */ + height: number; + /** + * enable floating widgets (default: false) See example + */ + float: boolean; + /** + * widget class (default: 'grid-stack-item') + */ + item_class: string; + /** + * minimal width.If window width is less, grid will be shown in one - column mode (default: 768) + */ + min_width: number; + /** + * class for placeholder (default: 'grid-stack-placeholder') + */ + placeholder_class: string; + /** + * allows to override jQuery UI resizable options. (default: { autoHide: true, handles: 'se' }) + */ + resizable: {}; + /** + * makes grid static (default false).If true widgets are not movable/ resizable.You don't even need jQueryUI draggable/resizable. A CSS class grid-stack-static is also added to the container. + */ + static_grid: boolean; + /** + * vertical gap size (default: 20) + */ + vertical_margin: number; + /** + * amount of columns (default: 12) + */ + width: number; +} diff --git a/gulp-svg-sprite/gulp-svg-sprite-tests.ts b/gulp-svg-sprite/gulp-svg-sprite-tests.ts new file mode 100644 index 0000000000..6c1ba71df9 --- /dev/null +++ b/gulp-svg-sprite/gulp-svg-sprite-tests.ts @@ -0,0 +1,51 @@ +/// +/// +/// + +import svgSprite = require('gulp-svg-sprite'); +import spriter = require('svg-sprite'); +import gulp = require('gulp') + +let config: spriter.Config; + +// Basic configuration example +config = { + mode : { + css : { // Activate the «css» mode + render : { + css : true // Activate CSS output (with default options) + } + } + } +}; + +gulp.src('**/*.svg', {cwd: 'path/to/assets'}) + .pipe(svgSprite(config)) + .pipe(gulp.dest('out')); + + +config = { + shape : { + dimension : { // Set maximum dimensions + maxWidth : 32, + maxHeight : 32 + }, + spacing : { // Add padding + padding : 10 + }, + dest : 'out/intermediate-svg' // Keep the intermediate files + }, + mode : { + view : { // Activate the «view» mode + bust : false, + render : { + scss : true // Activate Sass output (with default options) + } + }, + symbol : true // Activate the «symbol» mode + } +}; + +gulp.src('**/*.svg', {cwd: 'path/to/assets'}) + .pipe(svgSprite(config)) + .pipe(gulp.dest('out')); diff --git a/gulp-svg-sprite/gulp-svg-sprite.d.ts b/gulp-svg-sprite/gulp-svg-sprite.d.ts new file mode 100644 index 0000000000..50aa003627 --- /dev/null +++ b/gulp-svg-sprite/gulp-svg-sprite.d.ts @@ -0,0 +1,22 @@ +// Type definitions for gulp-svg-sprite 1.2.9 +// Project: https://github.com/jkphl/gulp-svg-sprite +// Definitions by: Qubo +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module "gulp-svg-sprite" { + import spriter = require('svg-sprite'); + + namespace svgSprite { + interface SvgSprite { + (options?: spriter.Config): NodeJS.ReadWriteStream; + } + } + + var svgSprite: svgSprite.SvgSprite; + + export = svgSprite; +} + diff --git a/gulp-typescript/gulp-typescript.d.ts b/gulp-typescript/gulp-typescript.d.ts index da517a511b..7b16d0a5a2 100644 --- a/gulp-typescript/gulp-typescript.d.ts +++ b/gulp-typescript/gulp-typescript.d.ts @@ -23,6 +23,7 @@ declare module "gulp-typescript" { sourceRoot?: string; sortOutput?: boolean; target?: string; + typescript?: any; } interface Project { diff --git a/hammerjs/hammerjs.d.ts b/hammerjs/hammerjs.d.ts index 84d4f94319..4d1091f68e 100644 --- a/hammerjs/hammerjs.d.ts +++ b/hammerjs/hammerjs.d.ts @@ -302,7 +302,7 @@ interface SwipeRecognizerStatic new( options?:any ):SwipeRecognizer; } -interface SwipeRecognizer +interface SwipeRecognizer extends AttrRecognizer { } diff --git a/jake/jake.d.ts b/jake/jake.d.ts index 904a8084bf..1812b818b7 100644 --- a/jake/jake.d.ts +++ b/jake/jake.d.ts @@ -122,6 +122,11 @@ declare module jake{ * stop execution on error, default true */ breakOnError?:boolean; + + /** + * + */ + windowsVerbatimArguments?: boolean } export function exec(cmds:string[], callback?:()=>void, opts?:ExecOptions):void; diff --git a/jasmine-es6-promise-matchers/jasmine-es6-promise-matchers-tests.ts b/jasmine-es6-promise-matchers/jasmine-es6-promise-matchers-tests.ts new file mode 100644 index 0000000000..d2917e7612 --- /dev/null +++ b/jasmine-es6-promise-matchers/jasmine-es6-promise-matchers-tests.ts @@ -0,0 +1,21 @@ +/// + +describe('specs', () => { + beforeEach(() => { + JasminePromiseMatchers.install + }); + + afterEach(() => { + JasminePromiseMatchers.uninstall + }); + + it('should have correct syntax', (done) => { + var foo = {}; + var bar = {}; + + expect(foo).toBeResolvedWith(bar, done); + expect(foo).toBeRejectedWith(bar, done); + expect(foo).toBeResolved(done); + expect(foo).toBeRejected(done); + }); +}) \ No newline at end of file diff --git a/jasmine-es6-promise-matchers/jasmine-es6-promise-matchers.d.ts b/jasmine-es6-promise-matchers/jasmine-es6-promise-matchers.d.ts new file mode 100644 index 0000000000..1735e51bcb --- /dev/null +++ b/jasmine-es6-promise-matchers/jasmine-es6-promise-matchers.d.ts @@ -0,0 +1,36 @@ +// Type definitions for jasmine-es6-promise-matchers +// Project: https://github.com/bvaughn/jasmine-es6-promise-matchers +// Definitions by: Stephen Lautier +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module JasminePromiseMatchers { + export function install():void; + export function uninstall():void; +} + +declare module jasmine { + + interface Matchers { + /** + * Verifies that a Promise is (or has been) rejected. + */ + toBeRejected(done?: () => void): boolean; + + /** + * Verifies that a Promise is (or has been) rejected with the specified parameter. + */ + toBeRejectedWith(value: any, done?: () => void): boolean; + + /** + * Verifies that a Promise is (or has been) resolved. + */ + toBeResolved(done?: () => void): boolean; + + /** + * Verifies that a Promise is (or has been) resolved with the specified parameter. + */ + toBeResolvedWith(value: any, done?: () => void): boolean; + } +} \ No newline at end of file diff --git a/java/java-tests.ts b/java/java-tests.ts new file mode 100644 index 0000000000..568bd35a8c --- /dev/null +++ b/java/java-tests.ts @@ -0,0 +1,34 @@ +/// +/// + +import java = require('java'); +import BluePromise = require('bluebird'); + +java.asyncOptions = { + syncSuffix: 'Sync', + asyncSuffix: '', + promiseSuffix: 'P', + promisify: BluePromise.promisify +}; + +java.registerClientP((): Promise => { + return BluePromise.resolve(); +}); + +interface ProxyFunctions { + [index: string]: Function; +} + +java.ensureJvm() + .then(() => { + + // java.d.ts does not declare any Java types. + // We can import a java class, but we don't know the shape of the class here, so must use any + var Boolean: any = java.import('java.lang.Boolean'); + + var functions: ProxyFunctions = { + accept: function(t: any): void { }, + andThen: function(after: any): any {} + }; + var proxy: any = java.newProxy('java.util.function.Consumer', functions); + }); diff --git a/java/java.d.ts b/java/java.d.ts new file mode 100644 index 0000000000..87125355da --- /dev/null +++ b/java/java.d.ts @@ -0,0 +1,64 @@ +// Type definitions for java 0.5.4 +// Project: https://github.com/joeferner/java +// Definitions by: Jim Lloyd +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +// This is the core API exposed by https://github.com/joeferner/java. +// To get the full power of Typescript with Java, see https://github.com/RedSeal-co/ts-java. + +declare module 'java' { + var NodeJavaCore: NodeJavaCore.NodeAPI; + export = NodeJavaCore; +} + +declare module NodeJavaCore { + export interface Callback { + (err?: Error, result?: T): void; + } + + interface Promisify { + (funct: Function, receiver?: any): Function; + } + + interface AsyncOptions { + syncSuffix: string; + asyncSuffix?: string; + promiseSuffix?: string; + promisify?: Promisify; + } + + interface ProxyFunctions { + [index: string]: Function; + } + + // *NodeAPI* declares methods & members exported by the node java module. + interface NodeAPI { + classpath: string[]; + asyncOptions: AsyncOptions; + callMethod(instance: any, className: string, methodName: string, args: any[], callback: Callback): void; + callMethodSync(instance: any, className: string, methodName: string, ...args: any[]): any; + callStaticMethodSync(className: string, methodName: string, ...args: any[]): any; + instanceOf(javaObject: any, className: string): boolean; + registerClient(before: (cb: Callback) => void, after?: (cb: Callback) => void): void; + registerClientP(beforeP: () => Promise, afterP?: () => Promise): void; + ensureJvm(done: Callback): void; + ensureJvm(): Promise; + + newShort(val: number): any; + newLong(val: number): any; + newFloat(val: number): any; + newDouble(val: number): any; + + import(className: string): any; + newInstance(className: string, ...args: any[]): void; + newInstanceSync(className: string, ...args: any[]): any; + newInstanceP(className: string, ...args: any[]): Promise; + newArray(className: string, arg: any[]): any; + getClassLoader(): any; + + newProxy(interfaceName: string, functions: ProxyFunctions): any; + } +} diff --git a/jquery.cookie/jquery.cookie-tests.ts b/jquery.cookie/jquery.cookie-tests.ts index 69a8c04120..ab9b8cb5a7 100644 --- a/jquery.cookie/jquery.cookie-tests.ts +++ b/jquery.cookie/jquery.cookie-tests.ts @@ -35,3 +35,5 @@ $.cookie("test", testObject, cookieOptions); var result = $.cookie("test"); console.log(result.text); + +$.cookie.defaults = cookieOptions; diff --git a/jquery.cookie/jquery.cookie.d.ts b/jquery.cookie/jquery.cookie.d.ts index 06380f999a..be88ca3638 100644 --- a/jquery.cookie/jquery.cookie.d.ts +++ b/jquery.cookie/jquery.cookie.d.ts @@ -1,34 +1,106 @@ -// Type definitions for jQuery Cookie Plugin 1.3 +// Type definitions for jQuery Cookie Plugin 1.4.1 // Project: https://github.com/carhartl/jquery-cookie -// Definitions by: Roy Goode +// Definitions by: Roy Goode , Ben Lorantfy // Definitions: https://github.com/borisyankov/DefinitelyTyped /// interface JQueryCookieOptions { + /** + * Define lifetime of the cookie. Value can be a Number which will be interpreted as days from time of creation or a Date object. If omitted, the cookie becomes a session cookie. + */ expires?: any; + /** + * Define the path where the cookie is valid. By default the path of the cookie is the path of the page where the cookie was created (standard browser behavior). If you want to make it available for instance across the entire domain use path: '/'. Default: path of page where the cookie was created. + */ path?: string; + /** + * Define the domain where the cookie is valid. Default: domain of page where the cookie was created. + */ domain?: string; + /** + * If true, the cookie transmission requires a secure protocol (https). Default: false. + */ secure?: boolean; } - +// +// The following jsdoc comments are used to add intellisense to editors that support it. Uses snippets +// of documentation from the Github repo when possible. +// +// The ordering here matters. For example, the read function with the converter parameter is purposefully after +// the set function. This is because the intellisense that shows up after you press comma should be the set first, +// since that is more common, then the conversion function if user starts typing a parameter with a function type interface JQueryCookieStatic { + /** + * By default the cookie value is encoded/decoded when writing/reading, using encodeURIComponent/decodeURIComponent. Bypass this by setting raw to true: + */ raw?: boolean; + /** + * Turn on automatic storage of JSON objects passed as the cookie value. Assumes JSON.stringify and JSON.parse + */ json?: boolean; - + /** + * Cookie attributes can be set globally by setting properties of the $.cookie.defaults object or individually for each call to $.cookie() by passing a plain object to the options argument. Per-call options override the default options. + */ + defaults?: JQueryCookieOptions; + /** + * Gets an object of cookies as key-value pairs + */ (): {[key:string]:string}; + /** + * Gets a cookie by name + * @param name The name of the cookie to get + */ (name: string): any; - (name: string, converter: (value: string) => any): any; + /** + * Sets a cookie + * @param name The name of the cookie to set + * @param value The value to set the cookie to + */ (name: string, value: string): void; + /** + * Gets a cookie by name after applying a conversion function to the value + * @param name The name of the cookie to get + * @param converter A conversion function to change the cookie's value to a different representation on the fly + */ + (name: string, converter: (value: string) => any): any; + /** + * Sets a cookie with some options + * @param name The name of the cookie to set + * @param value The value to set the cookie to + * @param options An object of options that change how the cookie is set + */ (name: string, value: string, options: JQueryCookieOptions): void; + /** + * Sets a cookie using .toString(), or if $.cookie.json is set to true using JSON.stringify() + * @param name The name of the cookie to set + * @param value The value to set the cookie to + */ (name: string, value: any): void; + /** + * Sets a cookie using .toString(), or if $.cookie.json is set to true using JSON.stringify() + * @param name The name of the cookie to set + * @param value The value to set the cookie to + * @param options An object of options that change how the cookie is set + */ (name: string, value: any, options: JQueryCookieOptions): void; } interface JQueryStatic { + /** + * A simple, lightweight jQuery plugin for reading, writing and deleting cookies. + */ cookie?: JQueryCookieStatic; - + /** + * Deletes a cookie + * @param name Name of cookie to delete + */ removeCookie(name: string): boolean; + /** + * Deletes a cookie + * @param name Name of cookie to delete + * @param options The same attributes (path, domain) as what the cookie was written with + */ removeCookie(name: string, options: JQueryCookieOptions): boolean; } diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index 1a9a6dd269..1f723fde32 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -3359,7 +3359,7 @@ function test_promise_then_change_type() { var def = $.Deferred(); var promise = def.promise(null); - def.rejectWith(this, new Error()); + def.rejectWith(this, [new Error()]); return promise; } diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index ad9e934551..d7688f1871 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -241,7 +241,7 @@ interface JQueryCallback { * @param context A reference to the context in which the callbacks in the list should be fired. * @param arguments An argument, or array of arguments, to pass to the callbacks in the list. */ - fireWith(context?: any, ...args: any[]): JQueryCallback; + fireWith(context?: any, args?: any[]): JQueryCallback; /** * Determine whether a supplied callback is in a list @@ -395,7 +395,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * @param context Context passed to the progressCallbacks as the this object. * @param args Optional arguments that are passed to the progressCallbacks. */ - notifyWith(context: any, value?: any, ...args: any[]): JQueryDeferred; + notifyWith(context: any, value?: any[]): JQueryDeferred; /** * Reject a Deferred object and call any failCallbacks with the given args. @@ -409,7 +409,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * @param context Context passed to the failCallbacks as the this object. * @param args An optional array of arguments that are passed to the failCallbacks. */ - rejectWith(context: any, value?: any, ...args: any[]): JQueryDeferred; + rejectWith(context: any, value?: any[]): JQueryDeferred; /** * Resolve a Deferred object and call any doneCallbacks with the given args. @@ -425,7 +425,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * @param context Context passed to the doneCallbacks as the this object. * @param args An optional array of arguments that are passed to the doneCallbacks. */ - resolveWith(context: any, value?: T, ...args: any[]): JQueryDeferred; + resolveWith(context: any, value?: T[]): JQueryDeferred; /** * Return a Deferred's Promise object. diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index a5f77eaded..a49a779e28 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -9,7 +9,7 @@ declare module JQueryUI { // Accordion ////////////////////////////////////////////////// - interface AccordionOptions { + interface AccordionOptions extends AccordionEvents { active?: any; // boolean or number animate?: any; // boolean, number, string or object collapsible?: boolean; @@ -37,7 +37,7 @@ declare module JQueryUI { create?: AccordionEvent; } - interface Accordion extends Widget, AccordionOptions, AccordionEvents { + interface Accordion extends Widget, AccordionOptions { } @@ -342,7 +342,7 @@ declare module JQueryUI { interface DialogOptions extends DialogEvents { autoOpen?: boolean; - buttons?: { [buttonText: string]: (event?: Event) => void } | ButtonOptions[]; + buttons?: { [buttonText: string]: (event?: Event) => void } | DialogButtonOptions[]; closeOnEscape?: boolean; closeText?: string; dialogClass?: string; @@ -366,6 +366,14 @@ declare module JQueryUI { close?: DialogEvent; } + interface DialogButtonOptions { + icons?: any; + showText?: string | boolean; + text?: string; + click?: (eventObject: JQueryEventObject) => any; + [attr: string]: any; // attributes for the