From d0d8d7887c4edcd4da73b55ecfffe2651360cddd Mon Sep 17 00:00:00 2001 From: Roland Zwaga Date: Tue, 29 Jul 2014 11:35:42 +0200 Subject: [PATCH 01/23] Fixed: D3.Layout.TreeLayout.nodes() returns Array instead of TreeLayout --- d3/d3.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 598cd9f34..80de53804 100755 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -1128,7 +1128,7 @@ declare module D3 { /** * Runs the tree layout */ - nodes(root: GraphNode): TreeLayout; + nodes(root: GraphNode): Array; /** * Given the specified array of nodes, such as those returned by nodes, returns an array of objects representing the links from parent to child for each node */ From 59ccd2392f65b87ce679f824bc291a8ada657e19 Mon Sep 17 00:00:00 2001 From: damianog Date: Sun, 17 Aug 2014 11:09:59 +0200 Subject: [PATCH 02/23] Update express.d.ts deprecate res.sendfile deprecate `res.sendfile` -- use `res.sendFile` instead --- express/express.d.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/express/express.d.ts b/express/express.d.ts index d9551e22b..735e6db0e 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -490,9 +490,9 @@ declare module "express" { * * Examples: * - * The following example illustrates how `res.sendfile()` may + * The following example illustrates how `res.sendFile()` may * be used as an alternative for the `static()` middleware for - * dynamic situations. The code backing `res.sendfile()` is actually + * dynamic situations. The code backing `res.sendFile()` is actually * the same code, so HTTP cache support etc is identical. * * app.get('/user/:uid/photos/:file', function(req, res){ @@ -501,13 +501,18 @@ declare module "express" { * * req.user.mayViewFilesFrom(uid, function(yes){ * if (yes) { - * res.sendfile('/uploads/' + uid + '/' + file); + * res.sendFile('/uploads/' + uid + '/' + file); * } else { * res.send(403, 'Sorry! you cant see that.'); * } * }); * }); */ + sendFile(path: string): void; + sendFile(path: string, options: any): void; + sendFile(path: string, fn: Errback): void; + sendFile(path: string, options: any, fn: Errback): void; + sendfile(path: string): void; sendfile(path: string, options: any): void; sendfile(path: string, fn: Errback): void; From 8c5eb7a46fdc787376cd9f6987a9c1d6d0c2086b Mon Sep 17 00:00:00 2001 From: Sergey Zarouski Date: Sun, 17 Aug 2014 22:08:46 -0400 Subject: [PATCH 03/23] add _.create to LoDashStatic Something is better then nothing, adding _.create method --- lodash/lodash.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index a4de09279..3e3fd43d7 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -6210,6 +6210,16 @@ declare module _ { noop(): void; } + //_.create + interface LoDashStatic { + /** + * Creates an object that inherits from the given prototype object. If a properties object is provided its own enumerable properties are assigned to the created object. + * @param prototype The object to inherit from. + * @param properties The properties to assign to the object. + */ + create(prototype: Object, properties?: Object): Object; + } + interface ListIterator { (value: T, index: number, list: T[]): TResult; } From 87004e74a559a7aa160d0bafce50a28da1caf176 Mon Sep 17 00:00:00 2001 From: dinesh Date: Mon, 18 Aug 2014 12:00:16 +0800 Subject: [PATCH 04/23] Made the functions once, debounce, throttle, after to accept function with generics signature. The function returened from these functions will have signature as the functions passed into them, compiler should be made aware of this. --- underscore/underscore-tests.ts | 10 ++-- underscore/underscore.d.ts | 94 +++++++++++++++++----------------- 2 files changed, 52 insertions(+), 52 deletions(-) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 8b638ee50..2e550ee82 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -140,18 +140,18 @@ _.delay(log, 1000, 'logged later'); _.defer(function () { alert('deferred'); }); -var updatePosition = () => alert('updating position...'); +var updatePosition = (param:string) => alert('updating position... Param: ' + param); var throttled = _.throttle(updatePosition, 100); $(window).scroll(throttled); -var calculateLayout = () => alert('calculating layout...'); +var calculateLayout = (param:string) => alert('calculating layout... Param: ' + param); var lazyLayout = _.debounce(calculateLayout, 300); $(window).resize(lazyLayout); -var createApplication = () => alert('creating application...'); +var createApplication = (param:string) => alert('creating application... Param: ' + param); var initialize = _.once(createApplication); -initialize(); -initialize(); +initialize("me"); +initialize("me"); var notes: any[]; var render = () => alert("rendering..."); diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 9736c2879..e17c6b662 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -1033,62 +1033,62 @@ interface UnderscoreStatic { ...arguments: any[]): void; /** - * Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly, - * will only actually call the original function at most once per every wait milliseconds. Useful for - * rate-limiting events that occur faster than you can keep up with. - * By default, throttle will execute the function as soon as you call it for the first time, and, - * if you call it again any number of times during the wait period, as soon as that period is over. - * If you'd like to disable the leading-edge call, pass {leading: false}, and if you'd like to disable - * the execution on the trailing-edge, pass {trailing: false}. - * @param func Function to throttle `waitMS` ms. - * @param wait The number of milliseconds to wait before `fn` can be invoked again. - * @param options Allows for disabling execution of the throttled function on either the leading or trailing edge. - * @return `fn` with a throttle of `wait`. - **/ - throttle( - func: any, + * Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly, + * will only actually call the original function at most once per every wait milliseconds. Useful for + * rate-limiting events that occur faster than you can keep up with. + * By default, throttle will execute the function as soon as you call it for the first time, and, + * if you call it again any number of times during the wait period, as soon as that period is over. + * If you'd like to disable the leading-edge call, pass {leading: false}, and if you'd like to disable + * the execution on the trailing-edge, pass {trailing: false}. + * @param func Function to throttle `waitMS` ms. + * @param wait The number of milliseconds to wait before `fn` can be invoked again. + * @param options Allows for disabling execution of the throttled function on either the leading or trailing edge. + * @return `fn` with a throttle of `wait`. + **/ + throttle( + func: T, wait: number, - options?: _.ThrottleSettings): Function; + options?: _.ThrottleSettings): T; /** - * Creates and returns a new debounced version of the passed function that will postpone its execution - * until after wait milliseconds have elapsed since the last time it was invoked. Useful for implementing - * behavior that should only happen after the input has stopped arriving. For example: rendering a preview - * of a Markdown comment, recalculating a layout after the window has stopped being resized, and so on. - * - * Pass true for the immediate parameter to cause debounce to trigger the function on the leading instead - * of the trailing edge of the wait interval. Useful in circumstances like preventing accidental double - *-clicks on a "submit" button from firing a second time. - * @param fn Function to debounce `waitMS` ms. - * @param wait The number of milliseconds to wait before `fn` can be invoked again. - * @param immediate True if `fn` should be invoked on the leading edge of `waitMS` instead of the trailing edge. - * @return Debounced version of `fn` that waits `wait` ms when invoked. - **/ - debounce( - fn: Function, + * Creates and returns a new debounced version of the passed function that will postpone its execution + * until after wait milliseconds have elapsed since the last time it was invoked. Useful for implementing + * behavior that should only happen after the input has stopped arriving. For example: rendering a preview + * of a Markdown comment, recalculating a layout after the window has stopped being resized, and so on. + * + * Pass true for the immediate parameter to cause debounce to trigger the function on the leading instead + * of the trailing edge of the wait interval. Useful in circumstances like preventing accidental double + *-clicks on a "submit" button from firing a second time. + * @param fn Function to debounce `waitMS` ms. + * @param wait The number of milliseconds to wait before `fn` can be invoked again. + * @param immediate True if `fn` should be invoked on the leading edge of `waitMS` instead of the trailing edge. + * @return Debounced version of `fn` that waits `wait` ms when invoked. + **/ + debounce( + fn: T, wait: number, - immediate?: boolean): Function; + immediate?: boolean): T; /** - * Creates a version of the function that can only be called one time. Repeated calls to the modified - * function will have no effect, returning the value from the original call. Useful for initialization - * functions, instead of having to set a boolean flag and then check it later. - * @param fn Function to only execute once. - * @return Copy of `fn` that can only be invoked once. - **/ - once(fn: Function): Function; + * Creates a version of the function that can only be called one time. Repeated calls to the modified + * function will have no effect, returning the value from the original call. Useful for initialization + * functions, instead of having to set a boolean flag and then check it later. + * @param fn Function to only execute once. + * @return Copy of `fn` that can only be invoked once. + **/ + once(fn: T): T; /** - * Creates a version of the function that will only be run after first being called count times. Useful - * for grouping asynchronous responses, where you want to be sure that all the async calls have finished, - * before proceeding. - * @param count Number of times to be called before actually executing. - * @fn The function to defer execution `count` times. - * @return Copy of `fn` that will not execute until it is invoked `count` times. - **/ - after( + * Creates a version of the function that will only be run after first being called count times. Useful + * for grouping asynchronous responses, where you want to be sure that all the async calls have finished, + * before proceeding. + * @param count Number of times to be called before actually executing. + * @fn The function to defer execution `count` times. + * @return Copy of `fn` that will not execute until it is invoked `count` times. + **/ + after( count: number, - fn: Function): Function; + fn: T): T; /** * Wraps the first function inside of the wrapper function, passing it as the first argument. This allows From 5ee094dbae985fdcf91afb63a91cce59bdf7558a Mon Sep 17 00:00:00 2001 From: dinesh Date: Mon, 18 Aug 2014 12:02:47 +0800 Subject: [PATCH 05/23] Corrected the auto spacing created by WebStorm IDE --- underscore/underscore.d.ts | 76 +++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index e17c6b662..2d7361dda 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -1033,59 +1033,59 @@ interface UnderscoreStatic { ...arguments: any[]): void; /** - * Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly, - * will only actually call the original function at most once per every wait milliseconds. Useful for - * rate-limiting events that occur faster than you can keep up with. - * By default, throttle will execute the function as soon as you call it for the first time, and, - * if you call it again any number of times during the wait period, as soon as that period is over. - * If you'd like to disable the leading-edge call, pass {leading: false}, and if you'd like to disable - * the execution on the trailing-edge, pass {trailing: false}. - * @param func Function to throttle `waitMS` ms. - * @param wait The number of milliseconds to wait before `fn` can be invoked again. - * @param options Allows for disabling execution of the throttled function on either the leading or trailing edge. - * @return `fn` with a throttle of `wait`. - **/ + * Creates and returns a new, throttled version of the passed function, that, when invoked repeatedly, + * will only actually call the original function at most once per every wait milliseconds. Useful for + * rate-limiting events that occur faster than you can keep up with. + * By default, throttle will execute the function as soon as you call it for the first time, and, + * if you call it again any number of times during the wait period, as soon as that period is over. + * If you'd like to disable the leading-edge call, pass {leading: false}, and if you'd like to disable + * the execution on the trailing-edge, pass {trailing: false}. + * @param func Function to throttle `waitMS` ms. + * @param wait The number of milliseconds to wait before `fn` can be invoked again. + * @param options Allows for disabling execution of the throttled function on either the leading or trailing edge. + * @return `fn` with a throttle of `wait`. + **/ throttle( func: T, wait: number, options?: _.ThrottleSettings): T; /** - * Creates and returns a new debounced version of the passed function that will postpone its execution - * until after wait milliseconds have elapsed since the last time it was invoked. Useful for implementing - * behavior that should only happen after the input has stopped arriving. For example: rendering a preview - * of a Markdown comment, recalculating a layout after the window has stopped being resized, and so on. - * - * Pass true for the immediate parameter to cause debounce to trigger the function on the leading instead - * of the trailing edge of the wait interval. Useful in circumstances like preventing accidental double - *-clicks on a "submit" button from firing a second time. - * @param fn Function to debounce `waitMS` ms. - * @param wait The number of milliseconds to wait before `fn` can be invoked again. - * @param immediate True if `fn` should be invoked on the leading edge of `waitMS` instead of the trailing edge. - * @return Debounced version of `fn` that waits `wait` ms when invoked. - **/ + * Creates and returns a new debounced version of the passed function that will postpone its execution + * until after wait milliseconds have elapsed since the last time it was invoked. Useful for implementing + * behavior that should only happen after the input has stopped arriving. For example: rendering a preview + * of a Markdown comment, recalculating a layout after the window has stopped being resized, and so on. + * + * Pass true for the immediate parameter to cause debounce to trigger the function on the leading instead + * of the trailing edge of the wait interval. Useful in circumstances like preventing accidental double + *-clicks on a "submit" button from firing a second time. + * @param fn Function to debounce `waitMS` ms. + * @param wait The number of milliseconds to wait before `fn` can be invoked again. + * @param immediate True if `fn` should be invoked on the leading edge of `waitMS` instead of the trailing edge. + * @return Debounced version of `fn` that waits `wait` ms when invoked. + **/ debounce( fn: T, wait: number, immediate?: boolean): T; /** - * Creates a version of the function that can only be called one time. Repeated calls to the modified - * function will have no effect, returning the value from the original call. Useful for initialization - * functions, instead of having to set a boolean flag and then check it later. - * @param fn Function to only execute once. - * @return Copy of `fn` that can only be invoked once. - **/ + * Creates a version of the function that can only be called one time. Repeated calls to the modified + * function will have no effect, returning the value from the original call. Useful for initialization + * functions, instead of having to set a boolean flag and then check it later. + * @param fn Function to only execute once. + * @return Copy of `fn` that can only be invoked once. + **/ once(fn: T): T; /** - * Creates a version of the function that will only be run after first being called count times. Useful - * for grouping asynchronous responses, where you want to be sure that all the async calls have finished, - * before proceeding. - * @param count Number of times to be called before actually executing. - * @fn The function to defer execution `count` times. - * @return Copy of `fn` that will not execute until it is invoked `count` times. - **/ + * Creates a version of the function that will only be run after first being called count times. Useful + * for grouping asynchronous responses, where you want to be sure that all the async calls have finished, + * before proceeding. + * @param count Number of times to be called before actually executing. + * @fn The function to defer execution `count` times. + * @return Copy of `fn` that will not execute until it is invoked `count` times. + **/ after( count: number, fn: T): T; From 3f2d6b33b1ad83a4dc44bb0734fe38a30958144e Mon Sep 17 00:00:00 2001 From: froginvasion Date: Mon, 18 Aug 2014 10:51:24 +0200 Subject: [PATCH 06/23] Removed two missing properties from kineticjs Both `Polygon` and `Transition` dont seem to be present anymore in the current version of KineticJS. I'm not an expert of KineticJS, which means I could be wrong of course. --- kineticjs/kineticjs.d.ts | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/kineticjs/kineticjs.d.ts b/kineticjs/kineticjs.d.ts index b5d56e846..1bdd79c61 100644 --- a/kineticjs/kineticjs.d.ts +++ b/kineticjs/kineticjs.d.ts @@ -300,15 +300,6 @@ declare module Kinetic { setData(SVG: string): any; } - var Polygon: { - new (config: PolygonConfig): IPolygon; - } - - interface IPolygon extends IShape { - getPoints(): any; - setPoints(points: any): any; - } - var RegularPolygon: { new (config: RegularPolygonConfig): IRegularPolygon; } @@ -405,14 +396,6 @@ declare module Kinetic { setTextStrokeWidth(textStrokeWidth: number): any; } - var Transition: { - new (node: Node, config: any): ITransition; - } - interface ITransition { - start(): any; - stop(): any; - } - var Animation: { new (...args: any[]): IAnimation; } @@ -485,10 +468,6 @@ declare module Kinetic { dash?: number[]; } - interface PolygonConfig extends DrawOptionsConfig, ObjectOptionsConfig { - points: any; - } - interface RegularPolygonConfig extends DrawOptionsConfig, ObjectOptionsConfig { sides: number; radius: number; From 094c4b575002b60d09c010259f71e19e949d3a9c Mon Sep 17 00:00:00 2001 From: Morten Houston Ludvigsen Date: Mon, 18 Aug 2014 15:33:03 +0200 Subject: [PATCH 07/23] Added definitions for source-map --- CONTRIBUTORS.md | 1 + source-map/source-map-tests.ts | 165 +++++++++++++++++++++++++++++++++ source-map/source-map.d.ts | 90 ++++++++++++++++++ 3 files changed, 256 insertions(+) create mode 100644 source-map/source-map-tests.ts create mode 100644 source-map/source-map.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index b8aecd835..cd95442e8 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -325,6 +325,7 @@ All definitions files include a header with the author and editors, so at some p * [SockJS](https://github.com/sockjs/sockjs-client) (by [Emil Ivanov](https://github.com/vladev)) * [sockjs-node](https://github.com/sockjs/sockjs-node) (by [Phil McCloghry-Laing](https://github.com/pmccloghrylaing)) * [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) +* [source-map](https://github.com/mozilla/source-map) (by [Morten Houston Ludvigsen](https://github.com/MortenHoustonLudvigsen)) * [Spin](http://fgnass.github.com/spin.js/) (by [Boris Yankov](https://github.com/borisyankov)) * [sqlite3](https://github.com/mapbox/node-sqlite3) (by [Nick Malaguti](https://github.com/nmalaguti)) * [status-bar](https://github.com/atom/status-bar) (by [vvakame](https://github.com/vvakame)) diff --git a/source-map/source-map-tests.ts b/source-map/source-map-tests.ts new file mode 100644 index 000000000..f7ad78e85 --- /dev/null +++ b/source-map/source-map-tests.ts @@ -0,0 +1,165 @@ +import SourceMap = require('source-map'); + +function testSourceMapConsumer() { + function testConstructor() { + var scm: SourceMap.SourceMapConsumer; + + // create with full RawSourceMap + scm = new SourceMap.SourceMapConsumer({ + version: 'foo', + sources: ['foo', 'bar'], + names: ['foo', 'bar'], + sourcesContent: 'foo', + mappings: 'foo' + }); + + // create with partial RawSourceMap + scm = new SourceMap.SourceMapConsumer({ + version: 'foo', + sources: ['foo', 'bar'], + names: ['foo', 'bar'], + mappings: 'foo' + }); + } + + function testOriginalPositionFor(scm: SourceMap.SourceMapConsumer) { + var origPos: SourceMap.MappedPosition; + origPos = scm.originalPositionFor({ line: 42, column: 42 }); + } + + function testGeneratedPositionFor(scm: SourceMap.SourceMapConsumer) { + var genPos: SourceMap.Position; + genPos = scm.generatedPositionFor({ line: 42, column: 42, source: 'foo' }); + genPos = scm.generatedPositionFor({ line: 42, column: 42, source: 'foo', name: 'bar' }); + } + + function testSourceContentFor(scm: SourceMap.SourceMapConsumer) { + var content: string; + content = scm.sourceContentFor('foo'); + } + + function testEachMapping(scm: SourceMap.SourceMapConsumer) { + var x: SourceMap.MappingItem; + var context: {}; + + scm.eachMapping(mapping => { x = mapping; }); + scm.eachMapping(mapping => { x = mapping; }, context); + scm.eachMapping(mapping => { x = mapping; }, context, SourceMap.SourceMapConsumer.GENERATED_ORDER); + scm.eachMapping(mapping => { x = mapping; }, context, SourceMap.SourceMapConsumer.ORIGINAL_ORDER); + } +} + +function testSourceMapGenerator() { + function testConstructor() { + var generator: SourceMap.SourceMapGenerator; + + generator = new SourceMap.SourceMapGenerator(); + generator = new SourceMap.SourceMapGenerator({ + file: 'foo' + }); + generator = new SourceMap.SourceMapGenerator({ + sourceRoot: 'foo' + }); + generator = new SourceMap.SourceMapGenerator({ + file: 'foo', + sourceRoot: 'bar' + }); + } + + function testFromSourceMap(generator: SourceMap.SourceMapGenerator, scm: SourceMap.SourceMapConsumer) { + generator = SourceMap.SourceMapGenerator.fromSourceMap(scm); + } + + function testAddMapping(generator: SourceMap.SourceMapGenerator) { + generator.addMapping({ + generated: { line: 42, column: 42 }, + original: { line: 42, column: 42 }, + source: 'foo', + name: 'foo' + }); + + generator.addMapping({ + generated: { line: 42, column: 42 }, + original: { line: 42, column: 42 }, + source: 'foo' + }); + } + + function testSetSourceContent(generator: SourceMap.SourceMapGenerator) { + generator.setSourceContent('foo', 'bar'); + } + + function testApplySourceMap(generator: SourceMap.SourceMapGenerator, scm: SourceMap.SourceMapConsumer) { + generator.applySourceMap(scm); + generator.applySourceMap(scm, 'foo'); + generator.applySourceMap(scm, 'foo', 'bar'); + } + + function testToString(generator: SourceMap.SourceMapGenerator) { + var str: string; + str = generator.toString(); + } +} + +function testSourceNode() { + function testConstructor() { + var node: SourceMap.SourceNode; + + node = new SourceMap.SourceNode(); + node = new SourceMap.SourceNode(42, 42, 'foo'); + node = new SourceMap.SourceNode(42, 42, 'foo', 'bar'); + node = new SourceMap.SourceNode(42, 42, 'foo', 'bar', 'slam'); + } + + function testFromStringWithSourceMap(scm: SourceMap.SourceMapConsumer) { + var node: SourceMap.SourceNode; + + node = SourceMap.SourceNode.fromStringWithSourceMap('foo', scm); + node = SourceMap.SourceNode.fromStringWithSourceMap('foo', scm, 'bar'); + } + + function testAdd(node: SourceMap.SourceNode) { + node.add('foo'); + } + + function testPrepend(node: SourceMap.SourceNode) { + node.prepend('foo'); + } + + function testSetSourceContent(node: SourceMap.SourceNode) { + node.setSourceContent('foo', 'bar'); + } + + function testWalk(node: SourceMap.SourceNode) { + var chunk: string; + var mapping: SourceMap.MappedPosition; + + node.walk((c, m) => { chunk = c; mapping = m; }); + } + + function testWalkSourceContents(node: SourceMap.SourceNode) { + var file: string; + var content: string; + + node.walkSourceContents((f, c) => { file = f; content = c; }); + } + + function testJoin(node: SourceMap.SourceNode) { + node = node.join('foo'); + } + + function testReplaceRight(node: SourceMap.SourceNode) { + node = node.replaceRight('foo', 'bar'); + } + + function testToString(node: SourceMap.SourceNode) { + var str: string; + str = node.toString(); + } + + function testToStringWithSourceMap(node: SourceMap.SourceNode, sos: SourceMap.StartOfSourceMap) { + var result: SourceMap.CodeWithSourceMap; + result = node.toStringWithSourceMap(); + result = node.toStringWithSourceMap(sos); + } +} \ No newline at end of file diff --git a/source-map/source-map.d.ts b/source-map/source-map.d.ts new file mode 100644 index 000000000..a1d8e208b --- /dev/null +++ b/source-map/source-map.d.ts @@ -0,0 +1,90 @@ +// Type definitions for source-map v0.1.38 +// Project: https://github.com/mozilla/source-map +// Definitions by: Morten Houston Ludvigsen +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module SourceMap { + interface StartOfSourceMap { + file?: string; + sourceRoot?: string; + } + + interface RawSourceMap extends StartOfSourceMap { + version: string; + sources: Array; + names: Array; + sourcesContent?: string; + mappings: string; + } + + interface Position { + line: number; + column: number; + } + + interface MappedPosition extends Position { + source: string; + name?: string; + } + + interface MappingItem { + source: string; + generatedLine: number; + generatedColumn: number; + originalLine: number; + originalColumn: number; + name: string; + } + + interface Mapping { + generated: Position; + original: Position; + source: string; + name?: string; + } + + interface CodeWithSourceMap { + code: string; + map: SourceMapGenerator; + } + + class SourceMapConsumer { + public static GENERATED_ORDER: number; + public static ORIGINAL_ORDER: number; + + constructor(rawSourceMap: RawSourceMap); + public originalPositionFor(generatedPosition: Position): MappedPosition; + public generatedPositionFor(originalPosition: MappedPosition): Position; + public sourceContentFor(source: string): string; + public eachMapping(callback: (mapping: MappingItem) => void, context?: any, order?: number): void; + } + + class SourceMapGenerator { + constructor(startOfSourceMap?: StartOfSourceMap); + public static fromSourceMap(sourceMapConsumer: SourceMapConsumer): SourceMapGenerator; + public addMapping(mapping: Mapping): void; + public setSourceContent(sourceFile: string, sourceContent: string): void; + public applySourceMap(sourceMapConsumer: SourceMapConsumer, sourceFile?: string, sourceMapPath?: string): void; + public toString(): string; + } + + class SourceNode { + constructor(); + constructor(line: number, column: number, source: string); + constructor(line: number, column: number, source: string, chunk?: string, name?: string); + public static fromStringWithSourceMap(code: string, sourceMapConsumer: SourceMapConsumer, relativePath?: string): SourceNode; + public add(chunk: string): void; + public prepend(chunk: string): void; + public setSourceContent(sourceFile: string, sourceContent: string): void; + public walk(fn: (chunk: string, mapping: MappedPosition) => void): void; + public walkSourceContents(fn: (file: string, content: string) => void): void; + public join(sep: string): SourceNode; + public replaceRight(pattern: string, replacement: string): SourceNode; + public toString(): string; + public toStringWithSourceMap(startOfSourceMap?: StartOfSourceMap): CodeWithSourceMap; + } +} + +declare module 'source-map' { + export = SourceMap; +} From f8002652941e2d05285bfbe550efaf07697c9162 Mon Sep 17 00:00:00 2001 From: Kevin Weeks Date: Mon, 18 Aug 2014 14:39:59 -0700 Subject: [PATCH 08/23] Reduced type severity of templateProvider in IState interface templateProvider can be an annotated function (any[]) like controllerProvider, so any is a more appropriate typing. --- angular-ui/angular-ui-router.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-ui/angular-ui-router.d.ts b/angular-ui/angular-ui-router.d.ts index 0f8eb5c57..005bf8b90 100644 --- a/angular-ui/angular-ui-router.d.ts +++ b/angular-ui/angular-ui-router.d.ts @@ -11,7 +11,7 @@ declare module ng.ui { name?: string; template?: any; templateUrl?: any; - templateProvider?: () => string; + templateProvider?: any; controller?: any; controllerAs?: string; controllerProvider?: any; From 76463ce678b1751ad4e197823248ffdbd686f6bd Mon Sep 17 00:00:00 2001 From: ZauberNerd Date: Tue, 19 Aug 2014 10:50:30 +0200 Subject: [PATCH 09/23] Corrected type annotations and method signatures for ZyngaScroller --- scroller/scroller.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scroller/scroller.d.ts b/scroller/scroller.d.ts index 09cbbc291..b1312ff35 100644 --- a/scroller/scroller.d.ts +++ b/scroller/scroller.d.ts @@ -38,10 +38,10 @@ declare class Scroller { finishPullToRefresh(): void; getValues(): ScrollValuesWithZoom; getScrollMax(): ScrollValues; - zoomTo(level: number, animate?: boolean, originLeft?: boolean, originTop?: boolean): void; - zoomBy(factor: number, animate?: boolean, originLeft?: boolean, originTop?: boolean): void; - scrollTo(left?: number, top?: number, animate?: number, zoom?: number): void; - scrollBy(left?: number, top?: number, animate?: number): void; + zoomTo(level: number, animate?: boolean, originLeft?: number, originTop?: number, callback?: Function): void; + zoomBy(factor: number, animate?: boolean, originLeft?: number, originTop?: number, callback?: Function): void; + scrollTo(left?: number, top?: number, animate?: boolean, zoom?: number): void; + scrollBy(left?: number, top?: number, animate?: boolean): void; doMouseZoom(wheelDelta: number, timeStamp: number, pageX: number, pageY: number): void; doTouchStart(touches: any[], timeStamp: number): void; From a422e8fc073c5adee3ac7796d63d9d0815a4e394 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Tue, 19 Aug 2014 19:35:30 +0900 Subject: [PATCH 10/23] add csurf type file --- csurf/csurf.d.ts | 30 ++++++++++++++++++++++++++++++ passport/passport.d.ts | 29 ++++++++++++----------------- 2 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 csurf/csurf.d.ts diff --git a/csurf/csurf.d.ts b/csurf/csurf.d.ts new file mode 100644 index 000000000..3a95435d7 --- /dev/null +++ b/csurf/csurf.d.ts @@ -0,0 +1,30 @@ +// Type definitions for csurf +// Project: http://expressjs.com +// Definitions by: Hiroki Horiuchi +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Express { + export interface Request { + csrfToken(): string; + } +} + +declare module "csurf" { + import express = require('express'); + + function csurf(options?: { + value?: (req: express.Request) => string; + cookie?: csurf.CookieOptions; + }): express.RequestHandler; + + module csurf { + export interface CookieOptions extends express.CookieOptions { + key: string; + } + } + + export = csurf; +} + diff --git a/passport/passport.d.ts b/passport/passport.d.ts index fc3dd786f..6d03093eb 100644 --- a/passport/passport.d.ts +++ b/passport/passport.d.ts @@ -8,6 +8,18 @@ declare module Express { export interface Request { session?: any; + + // These declarations are merged into express's Request type + login(user: any, done: (err: any) => void): void; + login(user: any, options: Object, done: (err: any) => void): void; + logIn(user: any, done: (err: any) => void): void; + logIn(user: any, options: Object, done: (err: any) => void): void; + + logout(): void; + logOut(): void; + + isAuthenticated(): boolean; + isUnauthenticated(): boolean; } } @@ -68,20 +80,3 @@ declare module 'passport' { } } -declare module Express { - export interface Request { - - // These declarations are merged into express's Request type - login(user: any, done: (err: any) => void): void; - login(user: any, options: Object, done: (err: any) => void): void; - logIn(user: any, done: (err: any) => void): void; - logIn(user: any, options: Object, done: (err: any) => void): void; - - logout(): void; - logOut(): void; - - isAuthenticated(): boolean; - isUnauthenticated(): boolean; - } -} - From 688f734b69f454c90191f0f1caad0b05610ff446 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Tue, 19 Aug 2014 19:37:13 +0900 Subject: [PATCH 11/23] add semicolon --- express/express.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/express/express.d.ts b/express/express.d.ts index d9551e22b..9d5d3d33a 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -821,7 +821,7 @@ declare module "express" { (name: string): string; // Getter (name: string, ...handlers: RequestHandler[]): Application; (name: RegExp, ...handlers: RequestHandler[]): Application; - } + }; /** * Return the app's absolute pathname From 451f712613ab0effc1318a5d55e047764d1c53ac Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Wed, 20 Aug 2014 00:27:36 +0900 Subject: [PATCH 12/23] change Project URL --- csurf/csurf.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/csurf/csurf.d.ts b/csurf/csurf.d.ts index 3a95435d7..cc78f9599 100644 --- a/csurf/csurf.d.ts +++ b/csurf/csurf.d.ts @@ -1,5 +1,5 @@ // Type definitions for csurf -// Project: http://expressjs.com +// Project: https://www.npmjs.org/package/csurf // Definitions by: Hiroki Horiuchi // Definitions: https://github.com/borisyankov/DefinitelyTyped From 10ba3e4655afc34a46ec7fd648b505def74ba982 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Bru=CC=88ckner?= Date: Tue, 19 Aug 2014 16:41:08 -0400 Subject: [PATCH 13/23] Added Chroma.js definitions --- CONTRIBUTORS.md | 1 + chroma-js/chroma-js-tests.ts | 120 +++++++++++++ chroma-js/chroma-js.d.ts | 317 +++++++++++++++++++++++++++++++++++ 3 files changed, 438 insertions(+) create mode 100644 chroma-js/chroma-js-tests.ts create mode 100644 chroma-js/chroma-js.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index b8aecd835..d7a87dd49 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -46,6 +46,7 @@ All definitions files include a header with the author and editors, so at some p * [CasperJS](http://casperjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker)) * [Cheerio](https://github.com/MatthewMueller/cheerio) (by [Bret Little](https://github.com/blittle)) * [Chosen](http://harvesthq.github.com/chosen/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Chroma.js](https://github.com/gka/chroma.js) (by [Sebastian Brückner](https://github.com/invliD)) * [Chrome](http://developer.chrome.com/extensions/) (by [Matthew Kimber](https://github.com/matthewkimber) and [otiai10](https://github.com/otiai10)) * [Chrome App](http://developer.chrome.com/apps/) (by [Adam Lay](https://github.com/AdamLay)) * [CKEditor](https://github.com/ckeditor/ckeditor-dev) (by [Ondrej Sevcik](https://github.com/ondrejsevcik)) diff --git a/chroma-js/chroma-js-tests.ts b/chroma-js/chroma-js-tests.ts new file mode 100644 index 000000000..3240ac11f --- /dev/null +++ b/chroma-js/chroma-js-tests.ts @@ -0,0 +1,120 @@ +/// + +function test_chroma() { + chroma("red"); + chroma("#ff0000"); + chroma("#f00"); + chroma("FF0000"); + chroma(255, 0, 0); + chroma([255, 0, 0]); + chroma(0, 1, 0.5, 'hsl'); + chroma([0, 1, 0.5], 'hsl'); + chroma(0, 1, 1, 'hsv'); + chroma("rgb(255,0,0)"); + chroma("rgb(100%,0%,0%)"); + chroma("hsl(0,100%,50%)"); + chroma(53.24, 80.09, 67.20, 'lab'); + chroma(53.24, 104.55, 40, 'lch'); + chroma(1, 0, 0, 'gl'); + + chroma.hex("#ff0000"); + chroma.hex("red"); + chroma.hex("rgb(255, 0, 0)"); + + chroma.rgb(255, 0, 0); + chroma.hsl(0, 1, 0.5); + chroma.hsv(120, 0.5, 0.5); + chroma.lab(53.24, 80.09, 67.20); + chroma.lch(53.24, 104.55, 40); + chroma.gl(1, 0, 0); + + chroma.interpolate('white', 'black', 0) // #ffffff + chroma.interpolate('white', 'black', 1) // #000000 + chroma.interpolate('white', 'black', 0.5) // #7f7f7f + chroma.interpolate('white', 'black', 0.5, 'hsv') // #808080 + chroma.interpolate('white', 'black', 0.5, 'lab') // #777777 + + chroma.interpolate('rgba(0,0,0,0)', 'rgba(255,0,0,1)', 0.5).css() //"rgba(127.5,0,0,0.5)" + + var bezInterpolator = chroma.interpolate.bezier(['white', 'yellow', 'red', 'black']); + bezInterpolator(0).hex() // #ffffff + bezInterpolator(0.33).hex() // #ffcc67 + bezInterpolator(0.66).hex() // #b65f1a + bezInterpolator(1).hex() // #000000 + + chroma.luminance('black') // 0 + chroma.luminance('white') // 1 + chroma.luminance('#ff0000') // 0.2126 + + chroma.contrast('white', 'navy') // 16.00 – ok + chroma.contrast('white', 'yellow') // 1.07 – not ok! +} + +function test_color() { + chroma('red').hex() // "#FF0000"" + chroma('red').rgb() // [255, 0, 0] + chroma('red').hsv() // [0, 1, 1] + chroma('red').hsl() // [0, 1, 0.5] + chroma('red').lab() // [53.2407, 80.0924, 67.2031] + chroma('red').lch() // [53.2407, 104.5517, 39.9990] + chroma('red').rgba() // [255, 0, 0, 1] + chroma('red').css() // "rgb(255,0,0)" + chroma('red').alpha(0.7).css() // "rgba(255,0,0,0.7)" + chroma('red').css('hsl') // "hsl(0,100%,50%)" + chroma('red').alpha(0.7).css('hsl') // "hsla(0,100%,50%,0.7)" + chroma('blue').css('hsla') // "hsla(240,100%,50%,1)" + + var red = chroma('red'); + red.alpha(0.5); + red.css(); // rgba(255,0,0,0.5); + + chroma('red').darken().hex() // #BC0000 + chroma('red').brighten().hex() // #FF603B + chroma('#eecc99').saturate().hex() // #fcc973 + chroma('red').desaturate().hex() // #ec3d23 + + chroma('black').luminance() // 0 + chroma('white').luminance() // 1 + chroma('red').luminance() // 0.2126 +} + +function test_scale() { + var scale = chroma.scale(['lightyellow', 'navy']); + scale(0.5); // #7F7FB0 + + chroma.scale('RdYlBu'); + + var col = scale(0.5); + col.hex(); // #7F7FB0 + col.rgb(); // [127.5, 127.5, 176] + + scale = chroma.scale(['lightyellow', 'navy']).out('hex'); + scale(0.5); // "#7F7FB0" + + var scale = chroma.scale(['lightyellow', 'navy']); + scale.mode('hsv')(0.5); // #54C08A + scale.mode('hsl')(0.5); // #31FF98 + scale.mode('lab')(0.5); // #967CB2 + scale.mode('lch')(0.5); // #D26662 + + var scale = chroma.scale(['lightyellow', 'navy']).domain([0, 400]); + scale(200); // #7F7FB0 + + var scale = chroma.scale(['lightyellow', 'navy']).domain([0, 100, 200, 300, 400]); + scale(98); // #7F7FB0 + scale(99); // #7F7FB0 + scale(100); // #AAAAC0 + scale(101); // #AAAAC0 + + chroma.scale(['#eee', '#900']).domain([0, 400], 7); + chroma.scale(['#eee', '#900']).domain([1, 1000000], 7, 'log'); + chroma.scale(['#eee', '#900']).domain([1, 1000000], 5, 'quantiles'); + chroma.scale(['#eee', '#900']).domain([1, 1000000], 5, 'k-means'); + chroma.scale(['white', 'red']).domain([0, 100], 4).domain() // [0, 25, 50, 75, 100] + + chroma.scale().range(['lightyellow', 'navy']); + + chroma.scale(['lightyellow', 'navy']).correctLightness(true); + + chroma.scale('RdYlGn').domain([0,1], 5).colors() +} diff --git a/chroma-js/chroma-js.d.ts b/chroma-js/chroma-js.d.ts new file mode 100644 index 000000000..94b32ae81 --- /dev/null +++ b/chroma-js/chroma-js.d.ts @@ -0,0 +1,317 @@ +// Type definitions for Chroma.js v0.5.6 +// Project: https://github.com/gka/chroma.js +// Definitions by: Sebastian Brückner +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** + * Chroma.js is a tiny library for all kinds of color conversions and color scales. + */ +declare module Chroma { + + export interface ChromaStatic { + /** + * Creates a color from a string representation (as supported in CSS). + * + * @param color The string to convert to a color. + * @return the color object. + */ + (color: string): Color; + + /** + * Create a color in the specified color space using a, b and c as values. + * + * @param a + * @param b + * @param c + * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". + * @return the color object. + */ + (a: number, b: number, c: number, colorSpace?: string): Color; + + /** + * Create a color in the specified color space using values. + * + * @param values An array of values (e.g. [r, g, b, a?]). + * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". + * @return the color object. + */ + (values: number[], colorSpace?: string): Color; + + /** + * Create a color in the specified color space using a, b and c as values. + * + * @param a + * @param b + * @param c + * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". + * @return the color object. + */ + color(a: number, b: number, c: number, colorSpace?: string): Color; + + /** + * Calculate the contrast ratio of two colors. + * + * @param color1 The first color. + * @param color2 The second color. + * @return the contrast ratio. + */ + contrast(color1: Color, color2: Color): number; + /** + * Calculate the contrast ratio of two colors. + * + * @param color1 The first color. + * @param color2 The second color. + * @return the contrast ratio. + */ + contrast(color1: Color, color2: string): number; + /** + * Calculate the contrast ratio of two colors. + * + * @param color1 The first color. + * @param color2 The second color. + * @return the contrast ratio. + */ + contrast(color1: string, color2: Color): number; + /** + * Calculate the contrast ratio of two colors. + * + * @param color1 The first color. + * @param color2 The second color. + * @return the contrast ratio. + */ + contrast(color1: string, color2: string): number; + + /** + * Create a color from a hex or string representation (as supported in CSS). + * + * This is an alias of chroma.hex(). + * + * @param color The string to convert to a color. + * @return the color object. + */ + css(color: string): Color; + + /** + * Create a color from a hex or string representation (as supported in CSS). + * + * This is an alias of chroma.css(). + * + * @param color The string to convert to a color. + * @return the color object. + */ + hex(color: string): Color; + + rgb(red: number, green: number, blue: number, alpha?: number): Color; + hsl(hue: number, saturation: number, lightness: number, alpha?: number): Color; + hsv(hue: number, saturation: number, value: number, alpha?: number): Color; + lab(lightness: number, a: number, b: number, alpha?: number): Color; + lch(lightness: number, chroma: number, hue: number, alpha?: number): Color; + gl(red: number, green: number, blue: number, alpha?: number): Color; + + interpolate: InterpolateFunction; + mix: InterpolateFunction; + + luminance(color: Color): number; + luminance(color: string): number; + + /** + * Creates a color scale using a pre-defined color scale. + * + * @param name The name of the color scale. + * @return the resulting color scale. + */ + scale(name: string): Scale; + + /** + * Creates a color scale function from the given set of colors. + * + * @param colors An Array of at least two color names or hex values. + * @return the resulting color scale. + */ + scale(colors?: string[]): Scale; + + scales: PredefinedScales; + } + + interface InterpolateFunction { + (color1: Color, color2: Color, f: number, mode?: string): Color; + (color1: Color, color2: string, f: number, mode?: string): Color; + (color1: string, color2: Color, f: number, mode?: string): Color; + (color1: string, color2: string, f: number, mode?: string): Color; + + bezier(colors: any[]): (t: number) => Color; + } + + interface PredefinedScales { + [key: string]: Scale; + + cool: Scale; + hot: Scale; + } + + export interface Color { + /** + * Creates a color from a string representation (as supported in CSS). + * + * @param color The string to convert to a color. + */ + new(color: string): Color; + + /** + * Create a color in the specified color space using a, b and c as values. + * + * @param a + * @param b + * @param c + * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". + */ + new(a: number, b: number, c: number, colorSpace?: string): Color; + + /** + * Create a color in the specified color space using a, b and c as color values and alpha as the alpha value. + * + * @param a + * @param b + * @param c + * @param alpha The alpha value of the color. + * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". + */ + new(a: number, b: number, c: number, alpha: number, colorSpace?: string): Color; + + /** + * Create a color in the specified color space using values. + * + * @param values An array of values (e.g. [r, g, b, a?]). + * @param colorSpace The color space to use (one of "rgb", "hsl", "hsv", "lab", "lch", "gl"). Defaults to "rgb". + */ + new(values: number[], colorSpace: string): Color; + + /** + * Convert this color to CSS hex representation. + * + * @return this color's hex representation. + */ + hex(): string; + + /** + * @return the relative luminance of the color, which is a value between 0 (black) and 1 (white). + */ + luminance(): number; + + /** + * @return the X11 name of this color or its hex value if it does not have a name. + */ + name(): string; + + /** + * @return the alpha value of the color. + */ + alpha(): number; + + /** + * Set the alpha value. + * + * @param alpha The alpha value. + * @return this + */ + alpha(alpha: number): Color; + + css(mode?: string): string; + + interpolate(color: Color, f: number, mode?: string): Color; + interpolate(color: string, f: number, mode?: string): Color; + + premultiply(): Color; + + rgb(): number[]; + rgba(): number[]; + hsl(): number[]; + hsv(): number[]; + lab(): number[]; + lch(): number[]; + hsi(): number[]; + gl(): number[]; + + darken(amount?: number): Color; + darker(amount: number): Color; + brighten(amount?: number): Color; + brighter(amount: number): Color; + saturate(amount?: number): Color; + desaturate(amount?: number): Color; + + toString(): string; + } + + export interface Scale { + /** + * Interpolate a color using the currently set range and domain. + * + * @param value The value to use for interpolation. + * @return the interpolated hex color OR a Color object (depending on the mode set on this Scale). + */ + (value: number): any; + + /** + * Retreive all possible colors generated by this scale if it has distinct classes. + * + * @param mode The output mode to use. Must be one of Color's getters. Defaults to "hex". + * @return an array of colors in the type specified by mode. + */ + colors(mode?: string): any[]; + + correctLightness(): boolean; + + /** + * Enable or disable automatic lightness correction of this scale. + * + * @param Whether to enable or disable automatic lightness correction. + * @return this + */ + correctLightness(enable: boolean): Scale; + + /** + * Get the current domain. + * + * @return The current domain. + */ + domain(): number[]; + + /** + * Set the domain. + * + * @param domain An Array of at least two numbers (min and max). + * @param classes The number of fixed classes to create between min and max. + * @param mode The scale to use. Examples: log, quantiles, k-means. + * @return this + */ + domain(domain: number[], classes?: number, mode?: string): Scale; + + /** + * Specify in which color space the colors should be interpolated. Defaults to "rgb". + * You can use any of the following spaces: rgb, hsv, hsl, lab, lch + * + * @param colorSpace The color space to use for interpolation. + * @return this + */ + mode(colorSpace: string): Scale; + + /** + * Set the output mode of this Scale. + * + * @param mode The output mode to use. Must be one of Color's getters. + * @return this + */ + out(mode: string): Scale; + + /** + * Set the color range after initialization. + * + * @param colors An Array of at least two color names or hex values. + * @return this + */ + range(colors: string[]): Scale; + } + +} + +declare var chroma: Chroma.ChromaStatic; From 376e27131e3ec6a2336bbd2fe3dae2809a213458 Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Wed, 20 Aug 2014 10:22:05 +1000 Subject: [PATCH 14/23] Adding promises to GAPI --- gapi/gapi.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gapi/gapi.d.ts b/gapi/gapi.d.ts index 8a9206663..d9d6fb90b 100644 --- a/gapi/gapi.d.ts +++ b/gapi/gapi.d.ts @@ -141,6 +141,23 @@ declare module gapi.client { statusText: string; } ) => any):void; + /** + * HttpRequest supports promises. + */ + then(success:(response:{ + result:T; + body:string; + headers?: any[]; + status?: number; + statusText?: string + })=>void, + failure:(response:{ + result:T; + body:string; + headers?: any[]; + status?: number; + statusText?: string + })=>void): void; } /** * Represents an HTTP Batch operation. Individual HTTP requests are added with the add method and the batch is executed using execute. From 0e86e57b2374deb2f910ff3836db2fc4b83ad105 Mon Sep 17 00:00:00 2001 From: WojciechKrysiak Date: Wed, 20 Aug 2014 09:52:46 +0200 Subject: [PATCH 15/23] Update knockout.d.ts According to the documents $index is an observable. --- knockout/knockout.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 8b26c50b9..b8db00e3c 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -118,7 +118,7 @@ interface KnockoutBindingContext { $parents: any[]; $root: any; $data: any; - $index?: number; + $index?: KnockoutObservable; $parentContext?: KnockoutBindingContext; extend(properties: any): any; From fd019eed8b83a77dd7daf0c1a08db18cbabde0dd Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Wed, 20 Aug 2014 13:17:24 +0200 Subject: [PATCH 16/23] Add typings for version 1.5.1 --- .../timezonecomplete-1.4.6-tests.ts | 183 +++ timezonecomplete/timezonecomplete-1.4.6.d.ts | 1004 +++++++++++++++++ timezonecomplete/timezonecomplete-tests.ts | 12 + timezonecomplete/timezonecomplete.d.ts | 141 ++- 4 files changed, 1331 insertions(+), 9 deletions(-) create mode 100644 timezonecomplete/timezonecomplete-1.4.6-tests.ts create mode 100644 timezonecomplete/timezonecomplete-1.4.6.d.ts diff --git a/timezonecomplete/timezonecomplete-1.4.6-tests.ts b/timezonecomplete/timezonecomplete-1.4.6-tests.ts new file mode 100644 index 000000000..de0b73048 --- /dev/null +++ b/timezonecomplete/timezonecomplete-1.4.6-tests.ts @@ -0,0 +1,183 @@ +/// + +import tc = require("timezonecomplete-1.4.6"); + +var b: boolean; +var n: number; +var s: string; +var w: tc.WeekDay; + +b = tc.isLeapYear(2014); +n = tc.daysInMonth(2014, 10); +n = tc.daysInYear(2014); +n = tc.dayOfYear(2014, 1, 2); +w = tc.lastWeekDayOfMonth(2014, 1, tc.WeekDay.Sunday); +n = tc.weekDayOnOrAfter(2014, 1, 14, tc.WeekDay.Monday); +n = tc.weekDayOnOrBefore(2014, 1, 14, tc.WeekDay.Monday); + +// DURATION + +var d: tc.Duration; +var d1: tc.Duration = tc.Duration.hours(24); +var d2: tc.Duration = tc.Duration.minutes(24); +var d3: tc.Duration = tc.Duration.seconds(24); +var d4: tc.Duration = tc.Duration.milliseconds(24); +var d5: tc.Duration = new tc.Duration(24); +var d6: tc.Duration = new tc.Duration("00:01"); +var d7: tc.Duration = d6.clone(); + +n = d7.wholeHours(); +n = d7.hours(); +n = d7.minutes(); +n = d7.minute(); +n = d7.seconds(); +n = d7.second(); +n = d7.milliseconds(); +n = d7.millisecond(); +s = d7.sign(); +b = d7.lessThan(d6); +b = d7.greaterThan(d6); +d = d7.min(d6); +d = d7.max(d6); +d = d7.multiply(3); +d = d7.divide(0.3); +d = d7.add(d6); +d = d7.sub(d6); +s = d7.toString(); + +// TIMEZONE + +var t: tc.TimeZone; +var k: tc.TimeZoneKind; + +t = tc.TimeZone.local(); +t = tc.TimeZone.utc(); +t = tc.TimeZone.zone(2); +t = tc.TimeZone.zone("+01:00"); +s = t.name(); +k = t.kind(); +b = t.equals(t); +b = t.isUtc(); +n = t.offsetForUtc(2014, 1, 1, 13, 0, 5, 123); +n = t.offsetForZone(2014, 1, 1, 13, 0, 5, 123); +n = t.offsetForUtcDate(new Date(2014, 1, 1, 13, 0, 5, 123), tc.DateFunctions.Get); +n = t.offsetForZoneDate(new Date(2014, 1, 1, 13, 0, 5, 123), tc.DateFunctions.GetUTC); +s = t.toString(); +s = tc.TimeZone.offsetToString(2); +n = tc.TimeZone.stringToOffset("+00:01"); + +// REALTIMESOURCE + +var date: Date = (new tc.RealTimeSource()).now(); + +// DATETIME + +var dt: tc.DateTime; + +var ts: tc.TimeSource = tc.DateTime.timeSource; + +dt = tc.DateTime.nowLocal(); +dt = tc.DateTime.nowUtc(); +dt = tc.DateTime.now(tc.TimeZone.local()); +dt = new tc.DateTime(); +dt = new tc.DateTime("2014-01-01T13:05:01.123 UTC"); +dt = new tc.DateTime("2014-01-01T13:05:01.123", tc.TimeZone.utc()); +dt = new tc.DateTime(date, tc.DateFunctions.Get); +dt = new tc.DateTime(date, tc.DateFunctions.Get, tc.TimeZone.utc()); +dt = new tc.DateTime(2014, 1, 1, 13, 5, 1, 123); +dt = new tc.DateTime(2014, 1, 1, 13, 5, 1, 123, tc.TimeZone.utc()); +dt = new tc.DateTime(89949284); +dt = new tc.DateTime(89949284, tc.TimeZone.utc()); +dt = dt.clone(); +t = dt.zone(); +n = dt.offset(); +n = dt.year(); +n = dt.month(); +n = dt.day(); +n = dt.hour(); +n = dt.minute(); +n = dt.second(); +n = dt.millisecond(); +n = dt.unixUtcMillis(); +n = dt.utcYear(); +n = dt.utcMonth(); +n = dt.utcDay(); +n = dt.utcHour(); +n = dt.utcMinute(); +n = dt.utcSecond(); +n = dt.utcMillisecond(); +dt.convert(tc.TimeZone.local()); +dt = dt.toZone(tc.TimeZone.utc()); +date = dt.toDate(); +dt = dt.add(tc.Duration.seconds(2)); +dt = dt.add(2, tc.TimeUnit.Year); +dt = dt.add(2, tc.TimeUnit.Month); +dt = dt.add(2, tc.TimeUnit.Week); +dt = dt.add(2, tc.TimeUnit.Day); +dt = dt.add(2, tc.TimeUnit.Hour); +dt = dt.add(2, tc.TimeUnit.Minute); +dt = dt.add(2, tc.TimeUnit.Second); +dt = dt.addLocal(2, tc.TimeUnit.Second); +dt = dt.sub(tc.Duration.seconds(2)); +dt = dt.sub(2, tc.TimeUnit.Year); +dt = dt.sub(2, tc.TimeUnit.Month); +dt = dt.sub(2, tc.TimeUnit.Week); +dt = dt.sub(2, tc.TimeUnit.Day); +dt = dt.sub(2, tc.TimeUnit.Hour); +dt = dt.sub(2, tc.TimeUnit.Minute); +dt = dt.sub(2, tc.TimeUnit.Second); +dt = dt.subLocal(2, tc.TimeUnit.Second); +d = dt.diff(new tc.DateTime(9289234, tc.TimeZone.local())); +b = dt.lessThan(new tc.DateTime(9289234, tc.TimeZone.local())); +b = dt.lessEqual(new tc.DateTime(9289234, tc.TimeZone.local())); +b = dt.greaterThan(new tc.DateTime(9289234, tc.TimeZone.local())); +b = dt.greaterEqual(new tc.DateTime(9289234, tc.TimeZone.local())); +s = dt.toIsoString(); +s = dt.toString(); +s = dt.toUtcString(); + +var wd: tc.WeekDay; +wd = dt.weekDay(); +wd = dt.utcWeekDay(); + +// PERIOD + +s = tc.periodDstToString(tc.PeriodDst.RegularIntervals); +s = tc.periodDstToString(tc.PeriodDst.RegularLocalTime); + +var p: tc.Period; + +p = new tc.Period(tc.DateTime.nowLocal(), 1, tc.TimeUnit.Hour, tc.PeriodDst.RegularLocalTime); +dt = p.start(); +n = p.amount(); +var tu: tc.TimeUnit = p.unit(); +var pd: tc.PeriodDst = p.dst(); +dt = p.findFirst(tc.DateTime.nowLocal()); +dt = p.findNext(dt); +s = p.toIsoString(); +s = p.toString(); + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/timezonecomplete/timezonecomplete-1.4.6.d.ts b/timezonecomplete/timezonecomplete-1.4.6.d.ts new file mode 100644 index 000000000..bd70278d5 --- /dev/null +++ b/timezonecomplete/timezonecomplete-1.4.6.d.ts @@ -0,0 +1,1004 @@ +// Type definitions for timezonecomplete 1.4.6 +// Project: https://github.com/SpiritIT/timezonecomplete +// Definitions by: Rogier Schouten +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Generated by dts-bundle v0.2.0 + +declare module 'timezonecomplete-1.4.6' { + import basics = require("__timezonecomplete/basics"); + export import TimeUnit = basics.TimeUnit; + export import WeekDay = basics.WeekDay; + export import isLeapYear = basics.isLeapYear; + export import daysInMonth = basics.daysInMonth; + export import daysInYear = basics.daysInYear; + export import dayOfYear = basics.dayOfYear; + export import lastWeekDayOfMonth = basics.lastWeekDayOfMonth; + export import weekDayOnOrAfter = basics.weekDayOnOrAfter; + export import weekDayOnOrBefore = basics.weekDayOnOrBefore; + import datetime = require("__timezonecomplete/datetime"); + export import DateTime = datetime.DateTime; + import duration = require("__timezonecomplete/duration"); + export import Duration = duration.Duration; + import javascript = require("__timezonecomplete/javascript"); + export import DateFunctions = javascript.DateFunctions; + import period = require("__timezonecomplete/period"); + export import Period = period.Period; + export import PeriodDst = period.PeriodDst; + export import periodDstToString = period.periodDstToString; + import timesource = require("__timezonecomplete/timesource"); + export import TimeSource = timesource.TimeSource; + export import RealTimeSource = timesource.RealTimeSource; + import timezone = require("__timezonecomplete/timezone"); + export import NormalizeOption = timezone.NormalizeOption; + export import TimeZoneKind = timezone.TimeZoneKind; + export import TimeZone = timezone.TimeZone; +} + +declare module '__timezonecomplete/basics' { + import javascript = require("__timezonecomplete/javascript"); + /** + * Day-of-week. Note the enum values correspond to JavaScript day-of-week: + * Sunday = 0, Monday = 1 etc + */ + export enum WeekDay { + Sunday = 0, + Monday = 1, + Tuesday = 2, + Wednesday = 3, + Thursday = 4, + Friday = 5, + Saturday = 6, + } + /** + * Time units + */ + export enum TimeUnit { + Second = 0, + Minute = 1, + Hour = 2, + Day = 3, + Week = 4, + Month = 5, + Year = 6, + } + /** + * @return True iff the given year is a leap year. + */ + export function isLeapYear(year: number): boolean; + /** + * The days in a given year + */ + export function daysInYear(year: number): number; + /** + * @param year The full year + * @param month The month 1-12 + * @return The number of days in the given month + */ + export function daysInMonth(year: number, month: number): number; + /** + * Returns the day of the year of the given date [0..365]. January first is 0. + * + * @param year The year e.g. 1986 + * @param month Month 1-12 + * @param day Day of month 1-31 + */ + export function dayOfYear(year: number, month: number, day: number): number; + /** + * Returns the last instance of the given weekday in the given month + * + * @param year The year + * @param month the month 1-12 + * @param weekDay the desired week day + * + * @return the last occurrence of the week day in the month + */ + export function lastWeekDayOfMonth(year: number, month: number, weekDay: WeekDay): number; + /** + * Returns the day-of-month that is on the given weekday and which is >= the given day. + * Throws if the month has no such day. + */ + export function weekDayOnOrAfter(year: number, month: number, day: number, weekDay: WeekDay): number; + /** + * Returns the day-of-month that is on the given weekday and which is <= the given day. + * Throws if the month has no such day. + */ + export function weekDayOnOrBefore(year: number, month: number, day: number, weekDay: WeekDay): number; + /** + * Convert a unix milli timestamp into a TimeT structure. + * This does NOT take leap seconds into account. + */ + export function unixToTimeNoLeapSecs(unixMillis: number): TimeStruct; + /** + * Convert a year, month, day etc into a unix milli timestamp. + * This does NOT take leap seconds into account. + * + * @param year Year e.g. 1970 + * @param month Month 1-12 + * @param day Day 1-31 + * @param hour Hour 0-23 + * @param minute Minute 0-59 + * @param second Second 0-59 (no leap seconds) + * @param milli Millisecond 0-999 + */ + export function timeToUnixNoLeapSecs(year?: number, month?: number, day?: number, hour?: number, minute?: number, second?: number, milli?: number): number; + /** + * Convert a TimeT structure into a unix milli timestamp. + * This does NOT take leap seconds into account. + */ + export function timeToUnixNoLeapSecs(tm: TimeStruct): number; + /** + * Return the day-of-week. + * This does NOT take leap seconds into account. + */ + export function weekDayNoLeapSecs(unixMillis: number): WeekDay; + /** + * Basic representation of a date and time + */ + export class TimeStruct { + /** + * Year, 1970-... + */ + year: number; + /** + * Month 1-12 + */ + month: number; + /** + * Day of month, 1-31 + */ + day: number; + /** + * Hour 0-23 + */ + hour: number; + /** + * Minute 0-59 + */ + minute: number; + /** + * Seconds, 0-59 + */ + second: number; + /** + * Milliseconds 0-999 + */ + milli: number; + /** + * Create a TimeStruct from a number of unix milliseconds + */ + static fromUnix(unixMillis: number): TimeStruct; + /** + * Create a TimeStruct from a JavaScript date + * + * @param d The date + * @param df Which functions to take (getX() or getUTCX()) + */ + static fromDate(d: Date, df: javascript.DateFunctions): TimeStruct; + /** + * Returns a TimeStruct from an ISO 8601 string WITHOUT time zone + */ + static fromString(s: string): TimeStruct; + /** + * Constructor + * + * @param year Year e.g. 1970 + * @param month Month 1-12 + * @param day Day 1-31 + * @param hour Hour 0-23 + * @param minute Minute 0-59 + * @param second Second 0-59 (no leap seconds) + * @param milli Millisecond 0-999 + */ + constructor(/** + * Year, 1970-... + */ + year?: number, /** + * Month 1-12 + */ + month?: number, /** + * Day of month, 1-31 + */ + day?: number, /** + * Hour 0-23 + */ + hour?: number, /** + * Minute 0-59 + */ + minute?: number, /** + * Seconds, 0-59 + */ + second?: number, /** + * Milliseconds 0-999 + */ + milli?: number); + /** + * Validate a TimeStruct, returns false if invalid. + */ + validate(): boolean; + /** + * The day-of-year 0-365 + */ + yearDay(): number; + /** + * Returns this time as a unix millisecond timestamp + * Does NOT take leap seconds into account. + */ + toUnixNoLeapSecs(): number; + /** + * Deep equals + */ + equals(other: TimeStruct): boolean; + /** + * < operator + */ + lessThan(other: TimeStruct): boolean; + clone(): TimeStruct; + valueOf(): number; + /** + * ISO 8601 string YYYY-MM-DDThh:mm:ss.nnn + */ + toString(): string; + inspect(): string; + } +} + +declare module '__timezonecomplete/datetime' { + import basics = require("__timezonecomplete/basics"); + import duration = require("__timezonecomplete/duration"); + import javascript = require("__timezonecomplete/javascript"); + import timesource = require("__timezonecomplete/timesource"); + import timezone = require("__timezonecomplete/timezone"); + /** + * DateTime class which is time zone-aware + * and which can be mocked for testing purposes. + */ + export class DateTime { + /** + * Actual time source in use. Setting this property allows to + * fake time in tests. DateTime.nowLocal() and DateTime.nowUtc() + * use this property for obtaining the current time. + */ + static timeSource: timesource.TimeSource; + /** + * Current date+time in local time (derived from DateTime.timeSource.now()). + */ + static nowLocal(): DateTime; + /** + * Current date+time in UTC time (derived from DateTime.timeSource.now()). + */ + static nowUtc(): DateTime; + /** + * Current date+time in the given time zone (derived from DateTime.timeSource.now()). + * @param timeZone The desired time zone. + */ + static now(timeZone: timezone.TimeZone): DateTime; + /** + * Constructor. Creates current time in local timezone. + */ + constructor(); + /** + * Constructor + * Non-existing local times are normalized by rounding up to the next DST offset. + * + * @param isoString String in ISO 8601 format. Instead of ISO time zone, + * it may include a space and then and IANA time zone. + * e.g. "2007-04-05T12:30:40.500" (no time zone, naive date) + * e.g. "2007-04-05T12:30:40.500+01:00" (UTC offset without daylight saving time) + * or "2007-04-05T12:30:40.500Z" (UTC) + * or "2007-04-05T12:30:40.500 Europe/Amsterdam" (IANA time zone, with daylight saving time if applicable) + * @param timeZone if given, the date in the string is assumed to be in this time zone. + * Note that it is NOT CONVERTED to the time zone. Useful + * for strings without a time zone + */ + constructor(isoString: string, timeZone?: timezone.TimeZone); + /** + * Constructor. You provide a date, then you say whether to take the + * date.getYear()/getXxx methods or the date.getUTCYear()/date.getUTCXxx methods, + * and then you state which time zone that date is in. + * Non-existing local times are normalized by rounding up to the next DST offset. + * Note that the Date class has bugs and inconsistencies when constructing them with times around + * DST changes. + * + * @param date A date object. + * @param getters Specifies which set of Date getters contains the date in the given time zone: the + * Date.getXxx() methods or the Date.getUTCXxx() methods. + * @param timeZone The time zone that the given date is assumed to be in (may be null for unaware dates) + */ + constructor(date: Date, getFuncs: javascript.DateFunctions, timeZone?: timezone.TimeZone); + /** + * Constructor. Note that unlike JavaScript dates we require fields to be in normal ranges. + * Use the add(duration) or sub(duration) for arithmetic. + * @param year The full year (e.g. 2014) + * @param month The month [1-12] (note this deviates from JavaScript Date) + * @param day The day of the month [1-31] + * @param hour The hour of the day [0-24) + * @param minute The minute of the hour [0-59] + * @param second The second of the minute [0-59] + * @param millisecond The millisecond of the second [0-999] + * @param timeZone The time zone, or null (for unaware dates) + */ + constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, timeZone?: timezone.TimeZone); + /** + * Constructor + * @param unixTimestamp milliseconds since 1970-01-01T00:00:00.000 + * @param timeZone the time zone that the timestamp is assumed to be in (usually UTC). + */ + constructor(unixTimestamp: number, timeZone?: timezone.TimeZone); + /** + * @return a copy of this object + */ + clone(): DateTime; + /** + * @return The time zone that the date is in. May be null for unaware dates. + */ + zone(): timezone.TimeZone; + /** + * @return the offset w.r.t. UTC in minutes. Returns 0 for unaware dates and for UTC dates. + */ + offset(): number; + /** + * @return The full year e.g. 2014 + */ + year(): number; + /** + * @return The month 1-12 (note this deviates from JavaScript Date) + */ + month(): number; + /** + * @return The day of the month 1-31 + */ + day(): number; + /** + * @return The hour 0-23 + */ + hour(): number; + /** + * @return the minutes 0-59 + */ + minute(): number; + /** + * @return the seconds 0-59 + */ + second(): number; + /** + * @return the milliseconds 0-999 + */ + millisecond(): number; + /** + * @return the day-of-week (the enum values correspond to JavaScript + * week day numbers) + */ + weekDay(): basics.WeekDay; + /** + * @return Milliseconds since 1970-01-01T00:00:00.000Z + */ + unixUtcMillis(): number; + /** + * @return The full year e.g. 2014 + */ + utcYear(): number; + /** + * @return The UTC month 1-12 (note this deviates from JavaScript Date) + */ + utcMonth(): number; + /** + * @return The UTC day of the month 1-31 + */ + utcDay(): number; + /** + * @return The UTC hour 0-23 + */ + utcHour(): number; + /** + * @return The UTC minutes 0-59 + */ + utcMinute(): number; + /** + * @return The UTC seconds 0-59 + */ + utcSecond(): number; + /** + * @return The UTC milliseconds 0-999 + */ + utcMillisecond(): number; + /** + * @return the UTC day-of-week (the enum values correspond to JavaScript + * week day numbers) + */ + utcWeekDay(): basics.WeekDay; + /** + * Convert this date to the given time zone (in-place). + * Throws if this date does not have a time zone. + * @return this (for chaining) + */ + convert(zone?: timezone.TimeZone): DateTime; + /** + * Returns this date converted to the given time zone. + * Unaware dates can only be converted to unaware dates (clone) + * Converting an unaware date to an aware date throws an exception. Use the constructor + * if you really need to do that. + * + * @param zone The new time zone. This may be null to create unaware date. + * @return The converted date + */ + toZone(zone?: timezone.TimeZone): DateTime; + /** + * Convert to JavaScript date with the zone time in the getX() methods. + * Unless the timezone is local, the Date.getUTCX() methods will NOT be correct. + * This is because Date calculates getUTCX() from getX() applying local time zone. + */ + toDate(): Date; + /** + * Add a time duration relative to UTC. Note that this simply adds a number + * of milliseconds to UTC and converts back to zone(), + * There is not DST handling. + * @return this + duration + */ + add(duration: duration.Duration): DateTime; + /** + * Add an amount of time relative to UTC, as regularly as possible. + * + * Adding e.g. 1 hour will increment the utcHour() field, adding 1 month + * increments the utcMonth() field. + * Adding an amount of units leaves lower units intact. E.g. + * adding a month will leave the day() field untouched if possible. + * + * Note adding Months or Years will clamp the date to the end-of-month if + * the start date was at the end of a month, i.e. contrary to JavaScript + * Date#setUTCMonth() it will not overflow into the next month + * + * In case of DST changes, the utc time fields are still untouched but local + * time fields may shift. + */ + add(amount: number, unit: basics.TimeUnit): DateTime; + /** + * Add an amount of time to the zone time, as regularly as possible. + * + * Adding e.g. 1 hour will increment the hour() field of the zone + * date by one. In case of DST changes, the time fields may additionally + * increase by the DST offset, if a non-existing local time would + * be reached otherwise. + * + * Adding a unit of time will leave lower-unit fields intact, unless the result + * would be a non-existing time. Then an extra DST offset is added. + * + * Note adding Months or Years will clamp the date to the end-of-month if + * the start date was at the end of a month, i.e. contrary to JavaScript + * Date#setUTCMonth() it will not overflow into the next month + */ + addLocal(amount: number, unit: basics.TimeUnit): DateTime; + /** + * Same as add(-1*duration); + */ + sub(duration: duration.Duration): DateTime; + /** + * Same as add(-1*amount, unit); + */ + sub(amount: number, unit: basics.TimeUnit): DateTime; + /** + * Same as addLocal(-1*amount, unit); + */ + subLocal(amount: number, unit: basics.TimeUnit): DateTime; + /** + * Time difference between two DateTimes + * @return this - other + */ + diff(other: DateTime): duration.Duration; + /** + * @return True iff (this < other) + */ + lessThan(other: DateTime): boolean; + /** + * @return True iff (this <= other) + */ + lessEqual(other: DateTime): boolean; + /** + * @return True iff this and other represent the same time in UTC + */ + equals(other: DateTime): boolean; + /** + * @return True iff this and other represent the same time and + * have the same zone + */ + identical(other: DateTime): boolean; + /** + * @return True iff this > other + */ + greaterThan(other: DateTime): boolean; + /** + * @return True iff this >= other + */ + greaterEqual(other: DateTime): boolean; + /** + * Proper ISO 8601 format string with any IANA zone converted to ISO offset + * E.g. "2014-01-01T23:15:33+01:00" for Europe/Amsterdam + */ + toIsoString(): string; + /** + * Modified ISO 8601 format string with IANA name if applicable. + * E.g. "2014-01-01T23:15:33.000 Europe/Amsterdam" + */ + toString(): string; + /** + * Used by util.inspect() + */ + inspect(): string; + /** + * Modified ISO 8601 format string in UTC without time zone info + */ + toUtcString(): string; + } +} + +declare module '__timezonecomplete/duration' { + /** + * Time duration. Create one e.g. like this: var d = Duration.hours(1). + * Note that time durations do not take leap seconds etc. into account: + * one hour is simply represented as 3600000 milliseconds. + */ + export class Duration { + /** + * Construct a time duration + * @param n Number of hours + * @return A duration of n hours + */ + static hours(n: number): Duration; + /** + * Construct a time duration + * @param n Number of minutes + * @return A duration of n minutes + */ + static minutes(n: number): Duration; + /** + * Construct a time duration + * @param n Number of seconds + * @return A duration of n seconds + */ + static seconds(n: number): Duration; + /** + * Construct a time duration + * @param n Number of milliseconds + * @return A duration of n milliseconds + */ + static milliseconds(n: number): Duration; + /** + * Construct a time duration of 0 + */ + constructor(); + /** + * Construct a time duration from a number of milliseconds + */ + constructor(milliseconds: number); + /** + * Construct a time duration from a string in format + * [-]h[:m[:s[.n]]] e.g. -01:00:30.501 + */ + constructor(input: string); + /** + * @return another instance of Duration with the same value. + */ + clone(): Duration; + /** + * The entire duration in milliseconds (negative or positive) + */ + milliseconds(): number; + /** + * The millisecond part of the duration (always positive) + * @return e.g. 400 for a -01:02:03.400 duration + */ + millisecond(): number; + /** + * The entire duration in seconds (negative or positive, fractional) + * @return e.g. 1.5 for a 1500 milliseconds duration + */ + seconds(): number; + /** + * The second part of the duration (always positive) + * @return e.g. 3 for a -01:02:03.400 duration + */ + second(): number; + /** + * The entire duration in minutes (negative or positive, fractional) + * @return e.g. 1.5 for a 90000 milliseconds duration + */ + minutes(): number; + /** + * The minute part of the duration (always positive) + * @return e.g. 2 for a -01:02:03.400 duration + */ + minute(): number; + /** + * The entire duration in hours (negative or positive, fractional) + * @return e.g. 1.5 for a 5400000 milliseconds duration + */ + hours(): number; + /** + * The hour part of the duration (always positive). + * Note that this part can exceed 23 hours, because for + * now, we do not have a days() function + * @return e.g. 25 for a -25:02:03.400 duration + */ + wholeHours(): number; + /** + * Sign + * @return "-" if the duration is negative + */ + sign(): string; + /** + * @return True iff (this < other) + */ + lessThan(other: Duration): boolean; + /** + * @return True iff this and other represent the same time duration + */ + equals(other: Duration): boolean; + /** + * @return True iff this > other + */ + greaterThan(other: Duration): boolean; + /** + * @return The minimum (most negative) of this and other + */ + min(other: Duration): Duration; + /** + * @return The maximum (most positive) of this and other + */ + max(other: Duration): Duration; + /** + * Multiply with a fixed number. + * @return a new Duration of (this * value) + */ + multiply(value: number): Duration; + /** + * Divide by a fixed number. + * @return a new Duration of (this / value) + */ + divide(value: number): Duration; + /** + * Add a duration. + * @return a new Duration of (this + value) + */ + add(value: Duration): Duration; + /** + * Subtract a duration. + * @return a new Duration of (this - value) + */ + sub(value: Duration): Duration; + /** + * String in [-]hh:mm:ss.nnn notation. All fields are + * always present except the sign. + */ + toFullString(): string; + /** + * String in [-]hh[:mm[:ss[.nnn]]] notation. Fields are + * added as necessary + */ + toString(): string; + /** + * Used by util.inspect() + */ + inspect(): string; + } +} + +declare module '__timezonecomplete/javascript' { + /** + * Indicates how a Date object should be interpreted. + * Either we can take getYear(), getMonth() etc for our field + * values, or we can take getUTCYear(), getUtcMonth() etc to do that. + */ + export enum DateFunctions { + /** + * Use the Date.getFullYear(), Date.getMonth(), ... functions. + */ + Get = 0, + /** + * Use the Date.getUTCFullYear(), Date.getUTCMonth(), ... functions. + */ + GetUTC = 1, + } +} + +declare module '__timezonecomplete/period' { + import basics = require("__timezonecomplete/basics"); + import datetime = require("__timezonecomplete/datetime"); + /** + * Specifies how the period should repeat across the day + * during DST changes. + */ + export enum PeriodDst { + /** + * Keep repeating in similar intervals measured in UTC, + * unaffected by Daylight Saving Time. + * E.g. a repetition of one hour will take one real hour + * every time, even in a time zone with DST. + * Leap seconds, leap days and month length + * differences will still make the intervals different. + */ + RegularIntervals = 0, + /** + * Ensure that the time at which the intervals occur stay + * at the same place in the day, local time. So e.g. + * a period of one day, starting at 8:05AM Europe/Amsterdam time + * will always start at 8:05 Europe/Amsterdam. This means that + * in UTC time, some intervals will be 25 hours and some + * 23 hours during DST changes. + * Another example: an hourly interval will be hourly in local time, + * skipping an hour in UTC for a DST backward change. + */ + RegularLocalTime = 1, + } + /** + * Convert a PeriodDst to a string: "regular intervals" or "regular local time" + */ + export function periodDstToString(p: PeriodDst): string; + /** + * Repeating time period: consists of a starting point and + * a time length. This class accounts for leap seconds and leap days. + */ + export class Period { + /** + * Constructor + * LIMITATION: if dst equals RegularLocalTime, and unit is Second, Minute or Hour, + * then the amount must be a factor of 24. So 120 seconds is allowed while 121 seconds is not. + * This is due to the enormous processing power required by these cases. They are not + * implemented and you will get an assert. + * + * @param start The start of the period. If the period is in Months or Years, and + * the day is 29 or 30 or 31, the results are maximised to end-of-month. + * @param amount The amount of units. + * @param unit The unit. + * @param dst Specifies how to handle Daylight Saving Time. Not relevant + * if the time zone of the start datetime does not have DST. + */ + constructor(start: datetime.DateTime, amount: number, unit: basics.TimeUnit, dst: PeriodDst); + /** + * The start date + */ + start(): datetime.DateTime; + /** + * The amount of units + */ + amount(): number; + /** + * The unit + */ + unit(): basics.TimeUnit; + /** + * The dst handling mode + */ + dst(): PeriodDst; + /** + * The first occurrence of the period greater than + * the given date. The given date need not be at a period boundary. + * Pre: the fromdate and startdate must either both have timezones or not + * @param fromDate: the date after which to return the next date + * @return the first date matching the period after fromDate, given + * in the same zone as the fromDate. + */ + findFirst(fromDate: datetime.DateTime): datetime.DateTime; + /** + * Returns the next timestamp in the period. The given timestamp must + * be at a period boundary, otherwise the answer is incorrect. + * This function has MUCH better performance than findFirst. + * Returns the datetime "count" times away from the given datetime. + * @param prev Boundary date. Must have a time zone (any time zone) iff the period start date has one. + * @param count Optional, must be >= 1 and whole. + * @return (prev + count * period), in the same timezone as prev. + */ + findNext(prev: datetime.DateTime, count?: number): datetime.DateTime; + /** + * Returns an ISO duration string e.g. + * 2014-01-01T12:00:00.000+01:00/P1H + * 2014-01-01T12:00:00.000+01:00/PT1M (one minute) + * 2014-01-01T12:00:00.000+01:00/P1M (one month) + */ + toIsoString(): string; + /** + * A string representation e.g. + * "10 years, starting at 2014-03-01T12:00:00 Europe/Amsterdam, keeping regular intervals". + */ + toString(): string; + /** + * Used by util.inspect() + */ + inspect(): string; + } +} + +declare module '__timezonecomplete/timesource' { + /** + * For testing purposes, we often need to manipulate what the current + * time is. This is an interface for a custom time source object + * so in tests you can use a custom time source. + */ + export interface TimeSource { + /** + * Return the current date+time as a javascript Date object + */ + now(): Date; + } + /** + * Default time source, returns actual time + */ + export class RealTimeSource implements TimeSource { + now(): Date; + } +} + +declare module '__timezonecomplete/timezone' { + import javascript = require("__timezonecomplete/javascript"); + /** + * The type of time zone + */ + export enum TimeZoneKind { + /** + * Local time offset as determined by JavaScript Date class. + */ + Local = 0, + /** + * Fixed offset from UTC, without DST. + */ + Offset = 1, + /** + * IANA timezone managed through Olsen TZ database. Includes + * DST if applicable. + */ + Proper = 2, + } + /** + * Option for TimeZone#normalizeLocal() + */ + export enum NormalizeOption { + /** + * Normalize non-existing times by ADDING the DST offset + */ + Up = 0, + /** + * Normalize non-existing times by SUBTRACTING the DST offset + */ + Down = 1, + } + /** + * Time zone. The object is immutable because it is cached: + * requesting a time zone twice yields the very same object. + * Note that we use time zone offsets inverted w.r.t. JavaScript Date.getTimezoneOffset(), + * i.e. offset 90 means +01:30. + * + * Time zones come in three flavors: the local time zone, as calculated by JavaScript Date, + * a fixed offset ("+01:30") without DST, or a IANA timezone ("Europe/Amsterdam") with DST + * applied depending on the time zone rules. + */ + export class TimeZone { + /** + * The local time zone for a given date. Note that + * the time zone varies with the date: amsterdam time for + * 2014-01-01 is +01:00 and amsterdam time for 2014-07-01 is +02:00 + */ + static local(): TimeZone; + /** + * The UTC time zone. + */ + static utc(): TimeZone; + /** + * Returns a time zone object from the cache. If it does not exist, it is created. + * @return The time zone with the given offset w.r.t. UTC in minutes, e.g. 90 for +01:30 + */ + static zone(offset: number): TimeZone; + /** + * Returns a time zone object from the cache. If it does not exist, it is created. + * @param s: Empty string for local time, a TZ database time zone name (e.g. Europe/Amsterdam) + * or an offset string (either +01:30, +0130, +01, Z). For a full list of names, see: + * https://en.wikipedia.org/wiki/List_of_tz_database_time_zones + */ + static zone(s: string): TimeZone; + /** + * Do not use this constructor, use the static + * TimeZone.zone() method instead. + * @param name NORMALIZED name, assumed to be correct + */ + constructor(name: string); + /** + * The time zone identifier. Can be an offset "-01:30" or an + * IANA time zone name "Europe/Amsterdam", or "localtime" for + * the local time zone. + */ + name(): string; + /** + * The kind of time zone (Local/Offset/Proper) + */ + kind(): TimeZoneKind; + /** + * Equality operator. Maps zero offsets and different names for UTC onto + * each other. Other time zones are not mapped onto each other. + */ + equals(other: TimeZone): boolean; + /** + * Is this zone equivalent to UTC? + */ + isUtc(): boolean; + /** + * Does this zone have Daylight Saving Time at all? + */ + hasDst(): boolean; + /** + * Calculate timezone offset from a UTC time. + * @param year local full year + * @param month local month 1-12 (note this deviates from JavaScript date) + * @param day local day of month 1-31 + * @param hour local hour 0-23 + * @param minute local minute 0-59 + * @param second local second 0-59 + * @param millisecond local millisecond 0-999 + * @return the offset of this time zone with respect to UTC at the given time, in minutes. + */ + offsetForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number; + /** + * Calculate timezone offset from a zone-local time (NOT a UTC time). + * @param year local full year + * @param month local month 1-12 (note this deviates from JavaScript date) + * @param day local day of month 1-31 + * @param hour local hour 0-23 + * @param minute local minute 0-59 + * @param second local second 0-59 + * @param millisecond local millisecond 0-999 + * @return the offset of this time zone with respect to UTC at the given time, in minutes. + */ + offsetForZone(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number; + /** + * Note: will be removed in version 2.0.0 + * + * Convenience function, takes values from a Javascript Date + * Calls offsetForUtc() with the contents of the date + * + * @param date: the date + * @param funcs: the set of functions to use: get() or getUTC() + */ + offsetForUtcDate(date: Date, funcs: javascript.DateFunctions): number; + /** + * Note: will be removed in version 2.0.0 + * + * Convenience function, takes values from a Javascript Date + * Calls offsetForUtc() with the contents of the date + * + * @param date: the date + * @param funcs: the set of functions to use: get() or getUTC() + */ + offsetForZoneDate(date: Date, funcs: javascript.DateFunctions): number; + /** + * Normalizes non-existing local times by adding a forward offset change. + * During a forward standard offset change or DST offset change, some amount of + * local time is skipped. Therefore, this amount of local time does not exist. + * This function adds the amount of forward change to any non-existing time. After all, + * this is probably what the user meant. + * + * @param localUnixMillis Unix timestamp in zone time + * @param opt (optional) Round up or down? Default: up + * + * @returns Unix timestamp in zone time, normalized. + */ + normalizeZoneTime(localUnixMillis: number, opt?: NormalizeOption): number; + /** + * The time zone identifier (normalized). + * Either "localtime", IANA name, or "+hh:mm" offset. + */ + toString(): string; + /** + * Used by util.inspect() + */ + inspect(): string; + /** + * Convert an offset number into an offset string + * @param offset The offset in minutes from UTC e.g. 90 minutes + * @return the offset in ISO notation "+01:30" for +90 minutes + */ + static offsetToString(offset: number): string; + /** + * String to offset conversion. + * @param s Formats: "-01:00", "-0100", "-01", "Z" + * @return offset w.r.t. UTC in minutes + */ + static stringToOffset(s: string): number; + } +} + diff --git a/timezonecomplete/timezonecomplete-tests.ts b/timezonecomplete/timezonecomplete-tests.ts index 9f3833f71..86c3a9986 100644 --- a/timezonecomplete/timezonecomplete-tests.ts +++ b/timezonecomplete/timezonecomplete-tests.ts @@ -11,9 +11,12 @@ b = tc.isLeapYear(2014); n = tc.daysInMonth(2014, 10); n = tc.daysInYear(2014); n = tc.dayOfYear(2014, 1, 2); +w = tc.firstWeekDayOfMonth(2014, 1, tc.WeekDay.Sunday); w = tc.lastWeekDayOfMonth(2014, 1, tc.WeekDay.Sunday); n = tc.weekDayOnOrAfter(2014, 1, 14, tc.WeekDay.Monday); n = tc.weekDayOnOrBefore(2014, 1, 14, tc.WeekDay.Monday); +n = tc.secondOfDay(13, 59, 59); +n = tc.weekOfMonth(2014, 1, 1); // DURATION @@ -97,6 +100,10 @@ n = dt.day(); n = dt.hour(); n = dt.minute(); n = dt.second(); +n = dt.weekNumber(); +n = dt.weekOfMonth(); +n = dt.secondOfDay(); +n = dt.dayOfYear(); n = dt.millisecond(); n = dt.unixUtcMillis(); n = dt.utcYear(); @@ -106,6 +113,11 @@ n = dt.utcHour(); n = dt.utcMinute(); n = dt.utcSecond(); n = dt.utcMillisecond(); +n = dt.utcWeekNumber(); +n = dt.utcWeekOfMonth(); +n = dt.utcSecondOfDay(); +n = dt.utcDayOfYear(); +s = dt.format("%Y-%m-%d"); dt.convert(tc.TimeZone.local()); dt = dt.toZone(tc.TimeZone.utc()); date = dt.toDate(); diff --git a/timezonecomplete/timezonecomplete.d.ts b/timezonecomplete/timezonecomplete.d.ts index 46b202e8f..8cad4a35e 100644 --- a/timezonecomplete/timezonecomplete.d.ts +++ b/timezonecomplete/timezonecomplete.d.ts @@ -1,4 +1,4 @@ -// Type definitions for timezonecomplete 1.4.6 +// Type definitions for timezonecomplete 1.5.1 // Project: https://github.com/SpiritIT/timezonecomplete // Definitions by: Rogier Schouten // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -11,10 +11,14 @@ declare module 'timezonecomplete' { export import isLeapYear = basics.isLeapYear; export import daysInMonth = basics.daysInMonth; export import daysInYear = basics.daysInYear; - export import dayOfYear = basics.dayOfYear; + export import firstWeekDayOfMonth = basics.firstWeekDayOfMonth; export import lastWeekDayOfMonth = basics.lastWeekDayOfMonth; export import weekDayOnOrAfter = basics.weekDayOnOrAfter; export import weekDayOnOrBefore = basics.weekDayOnOrBefore; + export import weekNumber = basics.weekNumber; + export import weekOfMonth = basics.weekOfMonth; + export import dayOfYear = basics.dayOfYear; + export import secondOfDay = basics.secondOfDay; import datetime = require("__timezonecomplete/datetime"); export import DateTime = datetime.DateTime; import duration = require("__timezonecomplete/duration"); @@ -93,6 +97,16 @@ declare module '__timezonecomplete/basics' { * @return the last occurrence of the week day in the month */ export function lastWeekDayOfMonth(year: number, month: number, weekDay: WeekDay): number; + /** + * Returns the first instance of the given weekday in the given month + * + * @param year The year + * @param month the month 1-12 + * @param weekDay the desired week day + * + * @return the first occurrence of the week day in the month + */ + export function firstWeekDayOfMonth(year: number, month: number, weekDay: WeekDay): number; /** * Returns the day-of-month that is on the given weekday and which is >= the given day. * Throws if the month has no such day. @@ -103,6 +117,19 @@ declare module '__timezonecomplete/basics' { * Throws if the month has no such day. */ export function weekDayOnOrBefore(year: number, month: number, day: number, weekDay: WeekDay): number; + export function weekOfMonth(year: number, month: number, day: number): number; + /** + * The ISO 8601 week number for the given date. Week 1 is the week + * that has January 4th in it, and it starts on Monday. + * See https://en.wikipedia.org/wiki/ISO_week_date + * + * @param year Year e.g. 1988 + * @param month Month 1-12 + * @param day Day of month 1-31 + * + * @return Week number 1-53 + */ + export function weekNumber(year: number, month: number, day: number): number; /** * Convert a unix milli timestamp into a TimeT structure. * This does NOT take leap seconds into account. @@ -131,6 +158,10 @@ declare module '__timezonecomplete/basics' { * This does NOT take leap seconds into account. */ export function weekDayNoLeapSecs(unixMillis: number): WeekDay; + /** + * N-th second in the day, counting from 0 + */ + export function secondOfDay(hour: number, minute: number, second: number): number; /** * Basic representation of a date and time */ @@ -332,6 +363,12 @@ declare module '__timezonecomplete/datetime' { * @return The time zone that the date is in. May be null for unaware dates. */ zone(): timezone.TimeZone; + /** + * Zone name abbreviation at this time + * @param dstDependent (default true) set to false for a DST-agnostic abbreviation + * @return The abbreviation + */ + zoneAbbreviation(dstDependent?: boolean): string; /** * @return the offset w.r.t. UTC in minutes. Returns 0 for unaware dates and for UTC dates. */ @@ -369,6 +406,36 @@ declare module '__timezonecomplete/datetime' { * week day numbers) */ weekDay(): basics.WeekDay; + /** + * Returns the day number within the year: Jan 1st has number 0, + * Jan 2nd has number 1 etc. + * + * @return the day-of-year [0-366] + */ + dayOfYear(): number; + /** + * The ISO 8601 week number. Week 1 is the week + * that has January 4th in it, and it starts on Monday. + * See https://en.wikipedia.org/wiki/ISO_week_date + * + * @return Week number [1-53] + */ + weekNumber(): number; + /** + * The week of this month. There is no official standard for this, + * but we assume the same rules for the weekNumber (i.e. + * week 1 is the week that has the 4th day of the month in it) + * + * @return Week number [1-5] + */ + weekOfMonth(): number; + /** + * Returns the number of seconds that have passed on the current day + * Does not consider leap seconds + * + * @return seconds [0-86399] + */ + secondOfDay(): number; /** * @return Milliseconds since 1970-01-01T00:00:00.000Z */ @@ -397,6 +464,13 @@ declare module '__timezonecomplete/datetime' { * @return The UTC seconds 0-59 */ utcSecond(): number; + /** + * Returns the UTC day number within the year: Jan 1st has number 0, + * Jan 2nd has number 1 etc. + * + * @return the day-of-year [0-366] + */ + utcDayOfYear(): number; /** * @return The UTC milliseconds 0-999 */ @@ -406,6 +480,29 @@ declare module '__timezonecomplete/datetime' { * week day numbers) */ utcWeekDay(): basics.WeekDay; + /** + * The ISO 8601 UTC week number. Week 1 is the week + * that has January 4th in it, and it starts on Monday. + * See https://en.wikipedia.org/wiki/ISO_week_date + * + * @return Week number [1-53] + */ + utcWeekNumber(): number; + /** + * The week of this month. There is no official standard for this, + * but we assume the same rules for the weekNumber (i.e. + * week 1 is the week that has the 4th day of the month in it) + * + * @return Week number [1-5] + */ + utcWeekOfMonth(): number; + /** + * Returns the number of seconds that have passed on the current day + * Does not consider leap seconds + * + * @return seconds [0-86399] + */ + utcSecondOfDay(): number; /** * Convert this date to the given time zone (in-place). * Throws if this date does not have a time zone. @@ -514,6 +611,7 @@ declare module '__timezonecomplete/datetime' { * E.g. "2014-01-01T23:15:33+01:00" for Europe/Amsterdam */ toIsoString(): string; + format(formatString: string): string; /** * Modified ISO 8601 format string with IANA name if applicable. * E.g. "2014-01-01T23:15:33.000 Europe/Amsterdam" @@ -523,6 +621,10 @@ declare module '__timezonecomplete/datetime' { * Used by util.inspect() */ inspect(): string; + /** + * The valueOf() method returns the primitive value of the specified object. + */ + valueOf(): any; /** * Modified ISO 8601 format string in UTC without time zone info */ @@ -678,6 +780,10 @@ declare module '__timezonecomplete/duration' { * Used by util.inspect() */ inspect(): string; + /** + * The valueOf() method returns the primitive value of the specified object. + */ + valueOf(): any; } } @@ -923,13 +1029,15 @@ declare module '__timezonecomplete/timezone' { hasDst(): boolean; /** * Calculate timezone offset from a UTC time. - * @param year local full year - * @param month local month 1-12 (note this deviates from JavaScript date) - * @param day local day of month 1-31 - * @param hour local hour 0-23 - * @param minute local minute 0-59 - * @param second local second 0-59 - * @param millisecond local millisecond 0-999 + * + * @param year Full year + * @param month Month 1-12 (note this deviates from JavaScript date) + * @param day Day of month 1-31 + * @param hour Hour 0-23 + * @param minute Minute 0-59 + * @param second Second 0-59 + * @param millisecond Millisecond 0-999 + * * @return the offset of this time zone with respect to UTC at the given time, in minutes. */ offsetForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number): number; @@ -965,6 +1073,21 @@ declare module '__timezonecomplete/timezone' { * @param funcs: the set of functions to use: get() or getUTC() */ offsetForZoneDate(date: Date, funcs: javascript.DateFunctions): number; + /** + * Zone abbreviation at given UTC timestamp e.g. CEST for Central European Summer Time. + * + * @param year Full year + * @param month Month 1-12 (note this deviates from JavaScript date) + * @param day Day of month 1-31 + * @param hour Hour 0-23 + * @param minute Minute 0-59 + * @param second Second 0-59 + * @param millisecond Millisecond 0-999 + * @param dstDependent (default true) set to false for a DST-agnostic abbreviation + * + * @return "local" for local timezone, the offset for an offset zone, or the abbreviation for a proper zone. + */ + abbreviationForUtc(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, millisecond?: number, dstDependent?: boolean): string; /** * Normalizes non-existing local times by adding a forward offset change. * During a forward standard offset change or DST offset change, some amount of From 63d0061afb26fa84d0d7aa5c4f4ea08da9cf357c Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Thu, 21 Aug 2014 20:43:33 +0900 Subject: [PATCH 17/23] modify method signature --- node/node.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/node.d.ts b/node/node.d.ts index 282120dc6..be3813ade 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1110,7 +1110,7 @@ declare module "crypto" { setPrivateKey(public_key: string, encoding?: string): void; } export function getDiffieHellman(group_name: string): DiffieHellman; - export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void; + export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: Buffer) => any): void; export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; export function randomBytes(size: number): Buffer; export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; From d5bf84fdb8538633c241b3b300545e8b98eb30ed Mon Sep 17 00:00:00 2001 From: Andrey Kurdyumov Date: Thu, 21 Aug 2014 17:43:47 +0600 Subject: [PATCH 18/23] Updated definition for the Duration.humanize See the docs there http://momentjs.com/docs/#/durations/humanize/ --- moment/moment.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moment/moment.d.ts b/moment/moment.d.ts index 20e921c32..0ec575fd8 100644 --- a/moment/moment.d.ts +++ b/moment/moment.d.ts @@ -28,7 +28,7 @@ interface MomentInput { interface Duration { - humanize(): string; + humanize(withSuffix?: boolean): string; milliseconds(): number; asMilliseconds(): number; From 0446dc4b625840653b894d10b4c9b0586709e167 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Thu, 21 Aug 2014 20:44:04 +0900 Subject: [PATCH 19/23] add optional variable --- passport/passport.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/passport/passport.d.ts b/passport/passport.d.ts index 6d03093eb..977323140 100644 --- a/passport/passport.d.ts +++ b/passport/passport.d.ts @@ -8,6 +8,7 @@ declare module Express { export interface Request { session?: any; + authInfo?: any; // These declarations are merged into express's Request type login(user: any, done: (err: any) => void): void; From aa8615f8f29ee2ea8cd7969a41718331667b1be8 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Thu, 21 Aug 2014 20:44:20 +0900 Subject: [PATCH 20/23] fix bug --- request/request-tests.ts | 3 ++- request/request.d.ts | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/request/request-tests.ts b/request/request-tests.ts index d422c3abc..986702c27 100644 --- a/request/request-tests.ts +++ b/request/request-tests.ts @@ -114,7 +114,8 @@ req = req.oauth(oauth); req = req.jar(jar); write = req.pipe(write); write = req.pipe(write, value); -req.write(); +req.pipe(req); +req.write(value); req.end(str); req.end(buffer); req.pause(); diff --git a/request/request.d.ts b/request/request.d.ts index e6a1d100e..5331fbd17 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -91,7 +91,7 @@ declare module 'request' { body: any; } - export interface Request { + export interface Request extends http.ClientRequest { getAgent(): http.Agent; //start(): void; //abort(): void; @@ -108,12 +108,8 @@ declare module 'request' { jar(jar: CookieJar): Request; pipe(dest: stream.Writable, opts?: any): stream.Writable; - write(): void; - end(chunk: string): void; - end(chunk: NodeBuffer): void; pause(): void; resume(): void; - abort(): void; destroy(): void; toJSON(): string; } From 777cfd5f3097370bb862ff270e15fc88c4b9b6c0 Mon Sep 17 00:00:00 2001 From: Andrey Kurdyumov Date: Thu, 21 Aug 2014 18:02:22 +0600 Subject: [PATCH 21/23] Added state field for the SignalR object --- signalr/signalr.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/signalr/signalr.d.ts b/signalr/signalr.d.ts index 7d1e64b74..4a503a84c 100644 --- a/signalr/signalr.d.ts +++ b/signalr/signalr.d.ts @@ -37,6 +37,7 @@ interface SignalR { messageId: string; url: string; qs: any; + state: number; (url: string, queryString?: any, logging?: boolean): SignalR; hubConnection(url?: string): SignalR; From 19e6407072a93eea6adbe6548a575329b680ef38 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Thu, 21 Aug 2014 21:09:38 +0900 Subject: [PATCH 22/23] modify exnteds interface --- request/request.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/request/request.d.ts b/request/request.d.ts index 5331fbd17..b204920a8 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -91,7 +91,7 @@ declare module 'request' { body: any; } - export interface Request extends http.ClientRequest { + export interface Request extends stream.Writable { getAgent(): http.Agent; //start(): void; //abort(): void; @@ -110,6 +110,7 @@ declare module 'request' { pipe(dest: stream.Writable, opts?: any): stream.Writable; pause(): void; resume(): void; + abort(): void; destroy(): void; toJSON(): string; } From a38d60a3dd5d36a14f7d76f9d25f994b92595b77 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Fri, 22 Aug 2014 12:37:27 +0900 Subject: [PATCH 23/23] add stream.Stream type --- node/node.d.ts | 4 ++++ request/request.d.ts | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/node/node.d.ts b/node/node.d.ts index be3813ade..4140a8c4b 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1121,6 +1121,10 @@ declare module "crypto" { declare module "stream" { import events = require("events"); + export interface Stream extends events.EventEmitter { + pipe(destination: T, options?: { end?: boolean; }): T; + } + export interface ReadableOptions { highWaterMark?: number; encoding?: string; diff --git a/request/request.d.ts b/request/request.d.ts index b204920a8..fc03a7e19 100644 --- a/request/request.d.ts +++ b/request/request.d.ts @@ -91,7 +91,10 @@ declare module 'request' { body: any; } - export interface Request extends stream.Writable { + export interface Request extends stream.Stream { + readable: boolean; + writable: boolean; + getAgent(): http.Agent; //start(): void; //abort(): void; @@ -107,7 +110,14 @@ declare module 'request' { oauth(oauth: OAuthOptions): Request; jar(jar: CookieJar): Request; - pipe(dest: stream.Writable, opts?: any): stream.Writable; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding: string, cb?: Function): boolean; + write(str: string, encoding?: string, fd?: string): boolean; + end(): void; + end(chunk: Buffer, cb?: Function): void; + end(chunk: string, cb?: Function): void; + end(chunk: string, encoding: string, cb?: Function): void; pause(): void; resume(): void; abort(): void;