From 7cdeddfc0dc5188cafde9f2ff2e97f574028030e Mon Sep 17 00:00:00 2001 From: anuti Date: Mon, 13 Jun 2016 19:26:06 +0200 Subject: [PATCH 001/279] Create chart2.d.ts Chart JS library has been updated to version 2.0 although no one has yet created the proper definitions files. For this reason I propose my file while being aware that still needs lots of work. In addition to the usual bug there are shortcomings in the definition of many functions, as the official guide does not specify the parameter's types. in the hope that this can help someone. --- chartjs/chart2.d.ts | 392 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 392 insertions(+) create mode 100644 chartjs/chart2.d.ts diff --git a/chartjs/chart2.d.ts b/chartjs/chart2.d.ts new file mode 100644 index 0000000000..7ae02a6ebf --- /dev/null +++ b/chartjs/chart2.d.ts @@ -0,0 +1,392 @@ +/* TYPES */ +declare enum ChartType { + line, bar, radar, doughnut, polarArea, bubble +} +declare enum TimeUnit { + millisecond, second, minute, + hour, day, week, + month, quarter, year +} +interface ChartLegendItem { + text?: string; + fillStyle?: string; + hidden?: boolean; + lineCap?: string; + lineDash?: number[]; + lineDashOffset?: number; + lineJoin?: string; + lineWidth?: number; + strokeStyle?: string; +} +interface ChartTooltipItem { + xLabel?: string; + yLabel?: string; + datasetIndex?: number; + index?: number; +} +interface ChartTooltipCallback { + beforeTitle?: (item?: ChartTooltipItem[], data?: any) => void; + title?: (item?: ChartTooltipItem[], data?: any) => void; + afterTitle?: (item?: ChartTooltipItem[], data?: any) => void; + beforeBody?: (item?: ChartTooltipItem[], data?: any) => void; + beforeLabel?: (tooltipItem?: ChartTooltipItem, data?: any) => void; + label?: (tooltipItem?: ChartTooltipItem, data?: any) => void; + afterLabel?: (tooltipItem?: ChartTooltipItem, data?: any) => void; + afterBody?: (item?: ChartTooltipItem[], data?: any) => void; + beforeFooter?: (item?: ChartTooltipItem[], data?: any) => void; + footer?: (item?: ChartTooltipItem[], data?: any) => void; + afterfooter?: (item?: ChartTooltipItem[], data?: any) => void; +} +interface ChartAnimationParameter { + chartInstance?: any; + animationObject?: any; +} +interface ChartPoint { + x?: number; + y?: number; +} + +/* END */ + +/* Configuration */ +interface ChartConfiguration { + type?: string; + data?: ChartData; + options?: ChartOptions; +} + +/* END */ + +/* DATA */ +interface ChartData { + +} + +interface LinearChartData extends ChartData { + labels?: string[]; + datasets?: ChartDataSets[]; +} + +/* END */ + +/* Options */ +interface ChartOptions { + responsive?: boolean; + responsiveAnimationDuration?: number; + maintainAspectRatio?: boolean; + events?: string[]; + onClick?: (any?: any) => any; + title?: ChartTitleOptions; + legend?: ChartLegendOptions; + tooltip?: ChartTooltipOptions; + hover?: ChartHoverOptions; + animation?: ChartAnimationOptions; + elements?: ChartElementsOptions; + scales?: ChartScales; +} + +interface ChartFontOptions { + defaultFontColor?: string; + defaultFontFamily?: string; + defaultFontSize?: number; + defaultFontStyle?: string; +} + +interface ChartTitleOptions { + display?: boolean; + position?: string; + fullWdith?: boolean; + fontSize?: number; + fontFamily?: string; + fontColor?: string; + fontStyle?: string; + padding?: number; + text?: string; +} + +interface ChartLegendOptions { + display?: boolean; + position?: string; + fullWidth?: boolean; + onClick?: (event, legendItem) => void; + labels?: ChartLegendLabelOptions; +} + +interface ChartLegendLabelOptions { + boxWidth?: number; + fontSize?: number; + fontStyle?: number; + fontColor?: string; + fontFamily?: string; + padding?: number; + generateLabels?: (chart) => any; +} + +interface ChartTooltipOptions { + enabled?: boolean; + custom?: (a) => void; + mode?: string; + backgroundColor?: string; + titleFontFamily?: string; + titleFontSize?: number; + titleFontStyle?: string; + titleFontColor?: string; + titleSpacing?: number; + titleMarginBottom?: number; + bodyFontFamily?: string; + bodyFontSize?: number; + bodyFontStyle?: string; + bodyFontColor?: string; + bodySpacing?: number; + footerFontFamily?: string; + footerFontSize?: number; + footerFontStyle?: string; + footerFontColor?: string; + footerSpacing?: number; + footerMarginTop?: number; + xPadding?: number; + yPadding?: number; + caretSize?: number; + cornerRadius?: number; + multiKeyBackground?: string; + callbacks?: ChartTooltipCallback; +} + +interface ChartHoverOptions { + mode?: string; + animationDuration?: number; + onHover?: (active) => void; +} + +interface ChartAnimationObject { + currentStep?: number; + numSteps?: number; + easing?: string; + render?: (arg) => void; + onAnimationProgress?: (arg) => void; + onAnimationComplete?: (arg) => void; +} + +interface ChartAnimationOptions { + duration?: number; + easing?: string; + onProgress?: (chart) => void; + onComplete?: (chart) => void; +} + +interface ChartElementsOptions { + point?: ChartPointOptions; + line?: ChartLineOptions; + arg?: ChartArcOtpions; + rectangle?: ChartRectangleOptions; +} + +interface ChartArcOtpions { + backgroundColor?: string; + borderColor?: string; + borderWidth?: number; +} + +interface ChartLineOptions { + tension?: number; + backgroundColor?: string; + borderWidth?: number; + borderColor?: string; + borderCapStyle?: string; + borderDash?: any[]; + borderDashOffset?: number; + borderJoinStyle?: string; +} + +interface ChartPointOptions { + radius?: number; + pointStyle?: string; + backgroundColor?: string; + borderWidth?: number; + borderColor?: string; + hitRadius?: number; + hoverRadius?: number; + hoverBorderWidth?: number; +} + +interface ChartRectangleOptions { + backgroundColor?: string; + borderWidth?: number; + borderColor?: string; + borderSkipped?: string; +} +interface GridLineOptions { + display?: boolean; + color?: string; + lineWidth?: number; + drawBorder?: boolean; + drawOnChartArea?: boolean; + drawticks?: boolean; + tickMarkLength?: number; + zeroLineWidth?: number; + zeroLineColor?: string; + offsetGridLines?: boolean; +} + +interface ScaleTitleOptions { + display?: boolean; + labelString?: string; + fontColor?: string; + fontFamily?: string; + fontSize?: number; + fontStyle?: string; +} + +interface TickOptions { + autoSkip?: boolean; + callback?: (value, index, values) => string; + display?: boolean; + fontColor?: string; + fontFamily?: string; + fontSize?: number; + fontStyle?: string; + labelOffset?: number; + maxRotation?: number; + minRotation?: number; + mirror?: boolean; + padding?: number; + reverse?: boolean; + min?: any; + max?: any; +} +interface AngleLineOptions { + display?: boolean; + color?: string; + lineWidth?: number; +} + +interface PointLabelOptions { + callback?: (arg) => any; + fontColor?: string; + fontFamily?: string; + fontSize?: number; + fontStyle?: string; +} + +interface TickOptions { + backdropColor?: string; + backdropPaddingX?: number; + backdropPaddingY?: number; + maxTicksLimit?: number; + showLabelBackdrop?: boolean; +} +interface LinearTickOptions extends TickOptions { + beginAtZero?: boolean; + min?: number; + max?: number; + maxTicksLimit?: number; + stepSize?: number; + suggestedMin?: number; + suggestedMax?: number; +} + +interface LogarithmicTickOptions extends TickOptions { + min?: number; + max?: number; +} +/* END */ + +/* DATASETS */ +interface ChartDataSets { + backgroundColor?: string[]; + borderWidth?: number; + borderColor?: string[]; + borderCapStyle?: string; + borderDash?: number[]; + borderDashOffset?: number; + borderJoinStyle?: string; + data?: number[] | ChartPoint[]; + fill?: boolean; + label?: string; + lineTension?: number; + pointBorderColor?: string | string[]; + pointBackgroundColor?: string | string[]; + pointBorderWidth?: number | number[]; + pointRadius?: number | number[]; + pointHoverRadius?: number | number[]; + pointHitRadius?: number | number[]; + pointHoverBackgroundColor?: string | string[]; + pointHoverBorderColor?: string | string[]; + pointHoverBorderWidth?: number | number[]; + pointStyle?: string | string[] | HTMLImageElement | HTMLImageElement[]; + xAxisID?: string; + yAxisID?: string; +} +/* END */ + +/* SCALES */ +interface ChartScales { + type?: string; + display?: boolean; + position?: string; + beforeUpdate?: (scale?: any) => void; + beforeSetDimension?: (scale?: any) => void; + beforeDataLimits?: (scale?: any) => void; + beforeBuildTicks?: (scale?: any) => void; + beforeTickToLabelConversion?: (scale?: any) => void; + beforeCalculateTickRotation?: (scale?: any) => void; + beforeFit?: (scale?: any) => void; + afterUpdate?: (scale?: any) => void; + afterSetDimension?: (scale?: any) => void; + afterDataLimits?: (scale?: any) => void; + afterBuildTicks?: (scale?: any) => void; + afterTickToLabelConversion?: (scale?: any) => void; + afterCalculateTickRotation?: (scale?: any) => void; + afterFit?: (scale?: any) => void; + gridLines?: GridLineOptions; + scaleLabel?: ScaleTitleOptions; + ticks?: TickOptions; +} + +interface LinearScale extends ChartScales { + ticks?: LinearTickOptions; +} + + +interface LogarithmicScale extends ChartScales { + ticks?: LogarithmicTickOptions; +} + +interface TimeScale extends ChartScales { + displayFormats?: string; + isoWeekday?: boolean; + max?: string; + min?: string; + parser?: string | ((arg) => moment.MomentDateObject); + round?: string; + tooltipFormat?: string; + unit?: TimeUnit; + unitStepSize?: number; +} + +interface RadialLinearScale { + lineArc?: boolean; + angleLines?: AngleLineOptions; + pointLabels?: PointLabelOptions; + ticks?: TickOptions; +} +/* END */ + +declare var Chart: { + new (context: CanvasRenderingContext2D, options: ChartConfiguration): {}; + destroy: () => {}; + update: (duration, lazy) => {}; + render: (duration, lazy) => {}; + stop: () => {}; + resize: () => {}; + clear: () => {}; + toBase64: () => string; + generateLegend: () => {}; + getElementAtEvent: (e) => {}; + getElementsAtEvent: (e) => {}[]; + getDatasetAtEvent: (e) => {}[]; + + defaults: { + global: ChartOptions; + } +}; From 160f9f51a0662505e1671e87492097db9aedd1c3 Mon Sep 17 00:00:00 2001 From: anuti Date: Mon, 13 Jun 2016 20:36:25 +0200 Subject: [PATCH 002/279] Update chart2.d.ts --- chartjs/chart2.d.ts | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/chartjs/chart2.d.ts b/chartjs/chart2.d.ts index 7ae02a6ebf..f80e8d9897 100644 --- a/chartjs/chart2.d.ts +++ b/chartjs/chart2.d.ts @@ -108,7 +108,7 @@ interface ChartLegendOptions { display?: boolean; position?: string; fullWidth?: boolean; - onClick?: (event, legendItem) => void; + onClick?: (event: any, legendItem: any) => void; labels?: ChartLegendLabelOptions; } @@ -119,12 +119,12 @@ interface ChartLegendLabelOptions { fontColor?: string; fontFamily?: string; padding?: number; - generateLabels?: (chart) => any; + generateLabels?: (chart: any) => any; } interface ChartTooltipOptions { enabled?: boolean; - custom?: (a) => void; + custom?: (a: any) => void; mode?: string; backgroundColor?: string; titleFontFamily?: string; @@ -155,23 +155,23 @@ interface ChartTooltipOptions { interface ChartHoverOptions { mode?: string; animationDuration?: number; - onHover?: (active) => void; + onHover?: (active: any) => void; } interface ChartAnimationObject { currentStep?: number; numSteps?: number; easing?: string; - render?: (arg) => void; - onAnimationProgress?: (arg) => void; - onAnimationComplete?: (arg) => void; + render?: (arg: any) => void; + onAnimationProgress?: (arg: any) => void; + onAnimationComplete?: (arg: any) => void; } interface ChartAnimationOptions { duration?: number; easing?: string; - onProgress?: (chart) => void; - onComplete?: (chart) => void; + onProgress?: (chart: any) => void; + onComplete?: (chart: any) => void; } interface ChartElementsOptions { @@ -239,7 +239,7 @@ interface ScaleTitleOptions { interface TickOptions { autoSkip?: boolean; - callback?: (value, index, values) => string; + callback?: (value: any, index: any, values: any) => string; display?: boolean; fontColor?: string; fontFamily?: string; @@ -261,7 +261,7 @@ interface AngleLineOptions { } interface PointLabelOptions { - callback?: (arg) => any; + callback?: (arg: any) => any; fontColor?: string; fontFamily?: string; fontSize?: number; @@ -357,7 +357,7 @@ interface TimeScale extends ChartScales { isoWeekday?: boolean; max?: string; min?: string; - parser?: string | ((arg) => moment.MomentDateObject); + parser?: string | ((arg: any) => moment.MomentDateObject); round?: string; tooltipFormat?: string; unit?: TimeUnit; @@ -375,16 +375,16 @@ interface RadialLinearScale { declare var Chart: { new (context: CanvasRenderingContext2D, options: ChartConfiguration): {}; destroy: () => {}; - update: (duration, lazy) => {}; - render: (duration, lazy) => {}; + update: (duration: any, lazy: any) => {}; + render: (duration: any, lazy: any) => {}; stop: () => {}; resize: () => {}; clear: () => {}; toBase64: () => string; generateLegend: () => {}; - getElementAtEvent: (e) => {}; - getElementsAtEvent: (e) => {}[]; - getDatasetAtEvent: (e) => {}[]; + getElementAtEvent: (e: any) => {}; + getElementsAtEvent: (e: any) => {}[]; + getDatasetAtEvent: (e: any) => {}[]; defaults: { global: ChartOptions; From cfafb5a2f70a744102cdc9b9ce6abaa9adfe4d7a Mon Sep 17 00:00:00 2001 From: anuti Date: Mon, 13 Jun 2016 20:40:02 +0200 Subject: [PATCH 003/279] Update chart2.d.ts --- chartjs/chart2.d.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/chartjs/chart2.d.ts b/chartjs/chart2.d.ts index f80e8d9897..b3ac83f33d 100644 --- a/chartjs/chart2.d.ts +++ b/chartjs/chart2.d.ts @@ -1,4 +1,4 @@ -/* TYPES */ +// TYPES declare enum ChartType { line, bar, radar, doughnut, polarArea, bubble } @@ -46,18 +46,18 @@ interface ChartPoint { y?: number; } -/* END */ +// END -/* Configuration */ +// Configuration interface ChartConfiguration { type?: string; data?: ChartData; options?: ChartOptions; } -/* END */ +// END -/* DATA */ +// DATA interface ChartData { } @@ -67,9 +67,9 @@ interface LinearChartData extends ChartData { datasets?: ChartDataSets[]; } -/* END */ +// END -/* Options */ +// Options interface ChartOptions { responsive?: boolean; responsiveAnimationDuration?: number; @@ -289,9 +289,9 @@ interface LogarithmicTickOptions extends TickOptions { min?: number; max?: number; } -/* END */ +// END -/* DATASETS */ +// DATASETS interface ChartDataSets { backgroundColor?: string[]; borderWidth?: number; @@ -317,9 +317,9 @@ interface ChartDataSets { xAxisID?: string; yAxisID?: string; } -/* END */ +// END -/* SCALES */ +// SCALES interface ChartScales { type?: string; display?: boolean; @@ -370,7 +370,7 @@ interface RadialLinearScale { pointLabels?: PointLabelOptions; ticks?: TickOptions; } -/* END */ +// END declare var Chart: { new (context: CanvasRenderingContext2D, options: ChartConfiguration): {}; From 17ce7262df05a11e4cd4642f31f312ba1580760b Mon Sep 17 00:00:00 2001 From: frogcjn Date: Tue, 28 Jun 2016 12:17:22 +0800 Subject: [PATCH 004/279] fix post function --- mongoose/mongoose.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mongoose/mongoose.d.ts b/mongoose/mongoose.d.ts index 6d74a0e4b1..7a4d33c522 100644 --- a/mongoose/mongoose.d.ts +++ b/mongoose/mongoose.d.ts @@ -276,8 +276,7 @@ declare module "mongoose" { pre(method: string, fn: HookSyncCallback, errorCb?: HookErrorCallback): Schema; pre(method: string, isAsync: boolean, fn: HookAsyncCallback, errorCb?: HookErrorCallback): Schema; - post(method: string, fn: HookSyncCallback, errorCb?: HookErrorCallback): Schema; - post(method: string, isAsync: boolean, fn: HookAsyncCallback, errorCb?: HookErrorCallback): Schema; + post(method: string, fn: (doc: Document, next?: HookNextFunction) => any ): Schema; requiredPaths(): string[]; set(key: string, value: any): void; From 60b5a415abb71c4f020ab8f2f148ae5360066cc1 Mon Sep 17 00:00:00 2001 From: frogcjn Date: Tue, 28 Jun 2016 12:56:56 +0800 Subject: [PATCH 005/279] fix tests --- mongoose/mongoose-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoose/mongoose-tests.ts b/mongoose/mongoose-tests.ts index cd5f53c4d9..2f6467437c 100644 --- a/mongoose/mongoose-tests.ts +++ b/mongoose/mongoose-tests.ts @@ -369,7 +369,7 @@ schema.path('name'); schema.path('name', Number); schema.pathType('name'); schema.plugin(function() {}); -schema.post('save', function(next: () => void, doc: IActor) {}); +schema.post('save', function(doc: IActor) {}); schema.pre('save', function(next: () => void) {}); schema.requiredPaths(); schema.static('findByName', function(name: string, callback: () => void) {}); From ed6c1cf4e4abaad3526ba1c2b07521f76f42a8ed Mon Sep 17 00:00:00 2001 From: frogcjn Date: Wed, 29 Jun 2016 09:49:20 +0800 Subject: [PATCH 006/279] enhence callback type --- express-jwt/express-jwt.d.ts | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/express-jwt/express-jwt.d.ts b/express-jwt/express-jwt.d.ts index 1aec6606fe..dadf833f67 100644 --- a/express-jwt/express-jwt.d.ts +++ b/express-jwt/express-jwt.d.ts @@ -12,21 +12,30 @@ declare module "express-jwt" { function jwt(options: jwt.Options): jwt.RequestHandler; - interface IDoneCallback { - (err: Error, result: T): void; - } - - type ICallback = (req: express.Request, payload: T, done: IDoneCallback) => void; - namespace jwt { + + export type secretType = string | Buffer + export interface SecretCallback { + (req: express.Request, header:any, payload: any, done: (err: any, secret?: boolean) => void): void; + (req: express.Request, payload: any, done: (err: any, secret?: secretType) => void):void; + } + + export interface IsRevokedCallback { + (req: express.Request, payload: any, done: (err: any, revoked?: boolean) => void): void; + } + + export interface GetTokenCallback { + (req: express.Request): any; + } + export interface Options { - secret: string|Buffer|ICallback; + secret: secretType|SecretCallback; userProperty?: string; skip?: string[]; credentialsRequired?: boolean; - isRevoked?: boolean; + isRevoked?: IsRevokedCallback; requestProperty?: string; - getToken?: ICallback; + getToken?: GetTokenCallback; [property: string]: any; } export interface RequestHandler extends express.RequestHandler { @@ -34,4 +43,4 @@ declare module "express-jwt" { } } export = jwt; -} +} \ No newline at end of file From 48d8146a89e891e512f3021ed5f3af03f39a006a Mon Sep 17 00:00:00 2001 From: Jan Zak Date: Wed, 29 Jun 2016 23:18:47 +0200 Subject: [PATCH 007/279] Fix i18next default export --- i18next/i18next.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/i18next/i18next.d.ts b/i18next/i18next.d.ts index 5e2f8dcd20..02efffbc87 100644 --- a/i18next/i18next.d.ts +++ b/i18next/i18next.d.ts @@ -125,5 +125,5 @@ declare namespace I18next { declare module 'i18next' { var i18n:I18next.I18n; - export = i18n; + export default i18n; } From 40a3ecb89d7dccb88b1dd65279fca6e635724d4b Mon Sep 17 00:00:00 2001 From: anuti Date: Fri, 1 Jul 2016 11:46:00 +0200 Subject: [PATCH 008/279] Update chart2.d.ts --- chartjs/chart2.d.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/chartjs/chart2.d.ts b/chartjs/chart2.d.ts index b3ac83f33d..7c30802074 100644 --- a/chartjs/chart2.d.ts +++ b/chartjs/chart2.d.ts @@ -1,4 +1,3 @@ -// TYPES declare enum ChartType { line, bar, radar, doughnut, polarArea, bubble } @@ -46,18 +45,12 @@ interface ChartPoint { y?: number; } -// END - -// Configuration interface ChartConfiguration { type?: string; data?: ChartData; options?: ChartOptions; } -// END - -// DATA interface ChartData { } @@ -67,9 +60,6 @@ interface LinearChartData extends ChartData { datasets?: ChartDataSets[]; } -// END - -// Options interface ChartOptions { responsive?: boolean; responsiveAnimationDuration?: number; @@ -289,9 +279,7 @@ interface LogarithmicTickOptions extends TickOptions { min?: number; max?: number; } -// END -// DATASETS interface ChartDataSets { backgroundColor?: string[]; borderWidth?: number; @@ -317,9 +305,7 @@ interface ChartDataSets { xAxisID?: string; yAxisID?: string; } -// END -// SCALES interface ChartScales { type?: string; display?: boolean; @@ -347,7 +333,6 @@ interface LinearScale extends ChartScales { ticks?: LinearTickOptions; } - interface LogarithmicScale extends ChartScales { ticks?: LogarithmicTickOptions; } @@ -370,7 +355,6 @@ interface RadialLinearScale { pointLabels?: PointLabelOptions; ticks?: TickOptions; } -// END declare var Chart: { new (context: CanvasRenderingContext2D, options: ChartConfiguration): {}; From 517371c47a937d9fb3859e9b694b9f60e17e5cba Mon Sep 17 00:00:00 2001 From: anuti Date: Fri, 1 Jul 2016 12:06:12 +0200 Subject: [PATCH 009/279] Update chart2.d.ts --- chartjs/chart2.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/chartjs/chart2.d.ts b/chartjs/chart2.d.ts index 7c30802074..5ea06e9ba6 100644 --- a/chartjs/chart2.d.ts +++ b/chartjs/chart2.d.ts @@ -1,3 +1,8 @@ +// Type definitions for Chart.js +// Project: https://github.com/nnnick/Chart.js +// Definitions by: Alberto Nuti +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + declare enum ChartType { line, bar, radar, doughnut, polarArea, bubble } From 02c79d8200ba886ffe4590a89e4ced8e29ee51ab Mon Sep 17 00:00:00 2001 From: anuti Date: Fri, 1 Jul 2016 12:08:22 +0200 Subject: [PATCH 010/279] Update chart2.d.ts --- chartjs/chart2.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chartjs/chart2.d.ts b/chartjs/chart2.d.ts index 5ea06e9ba6..2d77f4c502 100644 --- a/chartjs/chart2.d.ts +++ b/chartjs/chart2.d.ts @@ -347,7 +347,7 @@ interface TimeScale extends ChartScales { isoWeekday?: boolean; max?: string; min?: string; - parser?: string | ((arg: any) => moment.MomentDateObject); + parser?: string | ((arg: any) => any); round?: string; tooltipFormat?: string; unit?: TimeUnit; From 5c0c17c088bfe65bc04bc43099407a02c4c3a3b1 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Sat, 2 Jul 2016 11:15:14 +0200 Subject: [PATCH 011/279] Updated mathjs Added additional properties to interface `MathNode` --- mathjs/mathjs.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mathjs/mathjs.d.ts b/mathjs/mathjs.d.ts index 4bfbd89723..6311b5b7a7 100644 --- a/mathjs/mathjs.d.ts +++ b/mathjs/mathjs.d.ts @@ -1334,6 +1334,10 @@ declare namespace mathjs { export interface MathNode { isNode: boolean; isSymbolNode: boolean; + isConstantNode: boolean; + isOperatorNode: boolean; + op: string; + fn: string; type: string; name: string; value: any; From 6e1e76882a438a1ba0dec0add68e8cb9a78fff00 Mon Sep 17 00:00:00 2001 From: Matt Lewis Date: Sat, 2 Jul 2016 15:15:23 +0100 Subject: [PATCH 012/279] Add typings for chai-dom --- chai-dom/chai-dom-tests.ts | 27 +++++++++++++++++++++++++++ chai-dom/chai-dom.d.ts | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 chai-dom/chai-dom-tests.ts create mode 100644 chai-dom/chai-dom.d.ts diff --git a/chai-dom/chai-dom-tests.ts b/chai-dom/chai-dom-tests.ts new file mode 100644 index 0000000000..2fca54765e --- /dev/null +++ b/chai-dom/chai-dom-tests.ts @@ -0,0 +1,27 @@ +/// + +import * as chai from 'chai'; +import * as chaiDom from 'chai-dom'; + +chai.use(chaiDom); +var expect = chai.expect; + +function test() { + + var testElement = '
'; + expect(testElement).to.have.attribute('foo', 'bar'); + expect(testElement).to.have.attr('foo').match(/bar/); + expect(testElement).to.have.class('foo'); + expect(testElement).to.have.id('id'); + expect(testElement).to.have.html('foo'); + expect(testElement).to.have.text('foo'); + expect(testElement).to.have.text(['foo', 'bar']); + expect(testElement).to.have.value('foo'); + expect(testElement).to.be.empty; + expect(testElement).to.have.length(2); + expect(testElement).to.exist; + expect(testElement).to.match('foo'); + expect(testElement).to.contain('foo'); + expect(testElement).to.contain(document.body); + +} \ No newline at end of file diff --git a/chai-dom/chai-dom.d.ts b/chai-dom/chai-dom.d.ts new file mode 100644 index 0000000000..397bc17cb4 --- /dev/null +++ b/chai-dom/chai-dom.d.ts @@ -0,0 +1,38 @@ +// Type definitions for chai-dom +// Project: https://github.com/nathanboktae/chai-dom +// Definitions by: Matt Lewis +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace Chai { + + interface Assertion { + + attr(name: string, value?: string): Assertion; + + attribute(name: string, value?: string): Assertion; + + class(className: string): Assertion; + + id(id: string): Assertion; + + html(html: string): Assertion; + + text(text: string|string[]): Assertion; + + value(text: string): Assertion; + + } + +} + +declare module "chai-dom" { + + function chaiDom(chai: any, utils: any): void; + + namespace chaiDom { + } + + export = chaiDom; +} From 53347571e6f44ed9a961b569bb81893fde4789c1 Mon Sep 17 00:00:00 2001 From: spzSource Date: Sat, 2 Jul 2016 19:42:13 +0300 Subject: [PATCH 013/279] [adal-angular]: add postLogoutRedirectUri and code style fix --- adal-angular/adal.d.ts | 44 ++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/adal-angular/adal.d.ts b/adal-angular/adal.d.ts index 1c60cbf6ef..a896d687ec 100644 --- a/adal-angular/adal.d.ts +++ b/adal-angular/adal.d.ts @@ -13,29 +13,30 @@ declare module 'adal' { declare namespace adal { interface Config { - tenant?: string, - clientId: string, - redirectUri?: string, - cacheLocation?: string, - displayCall?: (urlNavigate: string) => any, - correlationId?: string, - loginResource?: string, - resource?: string - endpoints?: any // If you need to send CORS api requests. - extraQueryParameter?: string + tenant?: string; + clientId: string; + redirectUri?: string; + cacheLocation?: string; + displayCall?: (urlNavigate: string) => any; + correlationId?: string; + loginResource?: string; + resource?: string; + endpoints?: any; // If you need to send CORS api requests. + extraQueryParameter?: string; + postLogoutRedirectUri?: string; // redirect url after succesful logout operation } interface User { - userName: string, - profile: any + userName: string; + profile: any; } interface RequestInfo { - valid: boolean, - parameters: any, - stateMatch: boolean, - stateResponse: string, - requestType: string + valid: boolean; + parameters: any; + stateMatch: boolean; + stateResponse: string; + requestType: string; } interface Logging { @@ -64,6 +65,10 @@ declare namespace adal { * Saves the resulting Idtoken in localStorage. */ login(): void; + + /** + * Indicates whether login is in progress now or not. + */ loginInProgress(): boolean; /** @@ -147,6 +152,11 @@ declare namespace adal { */ getResourceForEndpoint(endpoint: string): string; + /** + * Handles redirection after login operation. + * Gets access token from url and saves token to the (local/session) storage + * or saves error in case unsuccessful login. + */ handleWindowCallback(): void; log(level: number, message: string, error: any): void; From 690e468d4951f629983b36c0970eafb25b2269c8 Mon Sep 17 00:00:00 2001 From: spzSource Date: Sat, 2 Jul 2016 19:48:51 +0300 Subject: [PATCH 014/279] [adal-angular]: add tests for a new properties --- adal-angular/adal-tests.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/adal-angular/adal-tests.ts b/adal-angular/adal-tests.ts index 3b9e46c961..db984d95ba 100644 --- a/adal-angular/adal-tests.ts +++ b/adal-angular/adal-tests.ts @@ -20,4 +20,6 @@ Logging.level = 4; auth.info("Logging message"); -var userName: string = auth.getCachedUser().userName; \ No newline at end of file +var userName: string = auth.getCachedUser().userName; +var postLogoutRedirectUrl = auth.config.postLogoutRedirectUri; +var isValidRequest = auth.getRequestInfo('hash').valid; \ No newline at end of file From 15ddcf312782faf9e7fdfe724a3a29382a5825d7 Mon Sep 17 00:00:00 2001 From: Kaur Kuut Date: Sun, 3 Jul 2016 12:27:28 +0300 Subject: [PATCH 015/279] Updated Redux definitions to v3.5.2. --- redux/redux-tests.ts | 400 +++++++++++++++++++++++++++++++++++++--- redux/redux.d.ts | 422 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 764 insertions(+), 58 deletions(-) diff --git a/redux/redux-tests.ts b/redux/redux-tests.ts index cc0c934997..108e2be326 100644 --- a/redux/redux-tests.ts +++ b/redux/redux-tests.ts @@ -1,32 +1,386 @@ /// -function counter(state: any, action: any) { - if (!state) { - state = 0; +// Simple counter test using the global Redux var + +(function() { + type State = number; + + function counter(state: State, action: R.Action) { + if (!state) { + state = 0; + } + switch (action.type) { + case 'INCREMENT': + return state + 1; + case 'DECREMENT': + return state - 1; + default: + return state; + } } - switch (action.type) { - case 'INCREMENT': - return state + 1; - case 'DECREMENT': - return state - 1; + + function loggingMiddleware() { + return (next: Redux.Dispatch) => (action: any) => { + console.log(action.type); + next(action); + }; + } + + let createStoreWithMiddleware = Redux.applyMiddleware(loggingMiddleware)(Redux.createStore); + let store = createStoreWithMiddleware(counter); + + + store.subscribe(() => + console.log(store.getState()) + ); + + store.dispatch({ type: 'INCREMENT' }); +}()); + +// Tests based on the TypeScript tests found in https://github.com/reactjs/redux/tree/master/test/typescript + +import * as R from "redux"; + +// actionCreators.ts + +declare const dispatch: R.Dispatch; + +(function() { + interface AddTodoAction extends R.Action { + text: string; + } + + const addTodo: R.ActionCreator = (text: string) => ({ + type: 'ADD_TODO', + text + }) + + const addTodoAction: AddTodoAction = addTodo('test'); + + type AddTodoThunk = (dispatch: R.Dispatch) => AddTodoAction; + + const addTodoViaThunk: R.ActionCreator = (text: string) => + (dispatch: R.Dispatch) => ({ + type: 'ADD_TODO', + text + }) + + const boundAddTodo = R.bindActionCreators(addTodo, dispatch); + + const dispatchedAddTodoAction: AddTodoAction = boundAddTodo('test'); + + + const boundAddTodoViaThunk = R.bindActionCreators< + R.ActionCreator, + R.ActionCreator + >(addTodoViaThunk, dispatch) + + const dispatchedAddTodoViaThunkAction: AddTodoAction = + boundAddTodoViaThunk('test'); + + + const boundActionCreators = R.bindActionCreators({addTodo}, dispatch); + + const otherDispatchedAddTodoAction: AddTodoAction = + boundActionCreators.addTodo('test'); + + + interface M extends R.ActionCreatorsMapObject { + addTodoViaThunk: R.ActionCreator + } + + interface N extends R.ActionCreatorsMapObject { + addTodoViaThunk: R.ActionCreator + } + + const boundActionCreators2 = R.bindActionCreators({ + addTodoViaThunk + }, dispatch) + + const otherDispatchedAddTodoAction2: AddTodoAction = + boundActionCreators2.addTodoViaThunk('test'); +}()); + +// actions.ts + +namespace FSA { + interface Action

extends R.Action { + payload: P; + } + + const action: Action = { + type: 'ACTION_TYPE', + payload: 'test', + } + + const payload: string = action.payload; +} + + +namespace FreeShapeAction { + interface Action extends R.Action { + [key: string]: any; + } + + const action: Action = { + type: 'ACTION_TYPE', + text: 'test', + } + + const text: string = action['text']; +} + + +namespace StringLiteralTypeAction { + type ActionType = 'A' | 'B' | 'C'; + + interface Action extends R.Action { + type: ActionType; + } + + const action: Action = { + type: 'A' + } + + const type: ActionType = action.type; +} + + +namespace EnumTypeAction { + enum ActionType { + A, B, C + } + + interface Action extends R.Action { + type: ActionType; + } + + const action: Action = { + type: ActionType.A + } + + const type: ActionType = action.type; +} + +// compose.ts + +(function() { + const numberToNumber = (a: number): number => a + 2; + const numberToString = (a: number): string => "foo"; + const stringToNumber = (a: string): number => 5; + + const t1: number = R.compose(numberToNumber, numberToNumber)(5); + const t2: string = R.compose(numberToString, numberToNumber)(5); + const t3: string = R.compose(numberToString, stringToNumber)("f"); + const t4: (a: string) => number = R.compose( + (f: (a: string) => number) => ((p: string) => 5), + (f: (a: number) => string) => ((p: string) => 4) + )(numberToString); + + + const t5: number = R.compose(stringToNumber, numberToString, numberToNumber)(5); + const t6: string = R.compose(numberToString, stringToNumber, numberToString, numberToNumber)(5); + + const t7: string = R.compose( + numberToString, numberToNumber, stringToNumber, numberToString, stringToNumber)("fo"); +}()); + +// dispatch.ts + +// thunk +declare module "redux" { + export interface Dispatch { + (asyncAction: (dispatch: Dispatch, getState: () => S) => R): R; + } +} + +(function() { + const dispatchResult: R.Action = dispatch({type: 'TYPE'}); + + const dispatchThunkResult: number = dispatch(() => 42); + const dispatchedTimerId: number = dispatch(d => setTimeout(() => d({type: 'TYPE'}), 1000)); +}()); + +// middleware.ts + +declare module "redux" { + export interface Dispatch { + (asyncAction: (dispatch: Dispatch, getState: () => S) => R): R; + } +} + +(function() { + type Thunk = (dispatch: R.Dispatch, getState: () => S) => O; + + const thunkMiddleware: R.Middleware = + ({dispatch, getState}: R.MiddlewareAPI) => + (next: R.Dispatch) => + (action: A | Thunk): B|R.Action => + typeof action === 'function' ? + (>action)(dispatch, getState) : + next(action) + + + const loggerMiddleware: R.Middleware = + ({getState}: R.MiddlewareAPI) => + (next: R.Dispatch) => + (action: any): any => { + console.log('will dispatch', action) + + // Call the next dispatch method in the middleware chain. + const returnValue = next(action) + + console.log('state after dispatch', getState()) + + // This will likely be the action itself, unless + // a middleware further in chain changed it. + return returnValue + } + + + + type State = { + todos: string[]; + } + + const reducer: R.Reducer = (state: State, action: R.Action): State => { + return state; + } + + const storeWithThunkMiddleware = R.createStore( + reducer, + R.applyMiddleware(thunkMiddleware) + ); + + storeWithThunkMiddleware.dispatch( + (dispatch, getState) => { + const todos: string[] = getState().todos; + dispatch({type: 'ADD_TODO'}) + } + ) + + + const storeWithMultipleMiddleware = R.createStore( + reducer, + R.applyMiddleware(loggerMiddleware, thunkMiddleware) + ) +}()); + +// reducers.ts + +(function() { + type TodosState = string[]; + + interface AddTodoAction extends R.Action { + text: string; + } + + const todosReducer: R.Reducer = (state: TodosState, + action: R.Action): TodosState => { + switch (action.type) { + case 'ADD_TODO': + return [...state, (action).text] default: - return state; + return state + } } -} -function loggingMiddleware() { - return (next: Redux.Dispatch) => (action: any) => { - console.log(action.type); - next(action); - }; -} - -let createStoreWithMiddleware = Redux.applyMiddleware(loggingMiddleware)(Redux.createStore); -let store = createStoreWithMiddleware(counter); + const todosState: TodosState = todosReducer([], { + type: 'ADD_TODO', + text: 'test', + }); -store.subscribe(() => - console.log(store.getState()) -); + type CounterState = number; -store.dispatch({ type: 'INCREMENT' }); + + const counterReducer: R.Reducer = ( + state: CounterState, action: R.Action + ): CounterState => { + switch (action.type) { + case 'INCREMENT': + return state + 1 + default: + return state + } + } + + + type RootState = { + todos: TodosState; + counter: CounterState; + } + + + const rootReducer: R.Reducer = R.combineReducers({ + todos: todosReducer, + counter: counterReducer, + }) + + const rootState: RootState = rootReducer(undefined, { + type: 'ADD_TODO', + text: 'test', + }) +}()); + +// store.ts + +(function() { + type State = { + todos: string[]; + } + + const reducer: R.Reducer = (state: State, action: R.Action): State => { + return state; + } + + + /* createStore */ + + const store: R.Store = R.createStore(reducer); + + const storeWithPreloadedState: R.Store = R.createStore(reducer, { + todos: [] + }); + + const genericEnhancer: R.GenericStoreEnhancer = (next: R.StoreEnhancerStoreCreator) => next; + const specificEnhencer: R.StoreEnhancer = next => next; + + const storeWithGenericEnhancer: R.Store = R.createStore(reducer, genericEnhancer); + const storeWithSpecificEnhancer: R.Store = R.createStore(reducer, specificEnhencer); + + const storeWithPreloadedStateAndEnhancer: R.Store = R.createStore(reducer, { + todos: [] + }, genericEnhancer); + + + /* dispatch */ + + store.dispatch({ + type: 'ADD_TODO', + text: 'test' + }) + + + /* getState */ + + const state: State = store.getState(); + + + /* subscribe / unsubscribe */ + + const unsubscribe: R.Unsubscribe = store.subscribe(() => { + console.log('Current state:', store.getState()) + }) + + unsubscribe(); + + + /* replaceReducer */ + + const newReducer: R.Reducer = (state: State, action: R.Action): State => { + return state; + } + + store.replaceReducer(newReducer); +}()); \ No newline at end of file diff --git a/redux/redux.d.ts b/redux/redux.d.ts index 3327236c14..16df551cd4 100644 --- a/redux/redux.d.ts +++ b/redux/redux.d.ts @@ -1,50 +1,402 @@ -// Type definitions for Redux v3.3.1 -// Project: https://github.com/rackt/redux -// Definitions by: William Buchwalter , Vincent Prouillet +// Type definitions for Redux v3.5.2 +// Project: https://github.com/reactjs/redux +// Definitions by: William Buchwalter , Vincent Prouillet , Kaur Kuut // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace Redux { - - interface ActionCreator extends Function { - (...args: any[]): any; - } - - interface Reducer extends Function { - (state: any, action: any): any; - } - - interface Dispatch extends Function { - (action: any): any; - } - - interface StoreMethods { - dispatch: Dispatch; - getState(): any; + /** + * An *action* is a plain object that represents an intention to change the + * state. Actions are the only way to get data into the store. Any data, + * whether from UI events, network callbacks, or other sources such as + * WebSockets needs to eventually be dispatched as actions. + * + * Actions must have a `type` field that indicates the type of action being + * performed. Types can be defined as constants and imported from another + * module. It’s better to use strings for `type` than Symbols because strings + * are serializable. + * + * Other than `type`, the structure of an action object is really up to you. + * If you’re interested, check out Flux Standard Action for recommendations on + * how actions should be constructed. + */ + interface Action { + type: any; } - interface MiddlewareArg { - dispatch: Dispatch; - getState: Function; + /* reducers */ + + /** + * A *reducer* (also called a *reducing function*) is a function that accepts + * an accumulation and a value and returns a new accumulation. They are used + * to reduce a collection of values down to a single value + * + * Reducers are not unique to Redux—they are a fundamental concept in + * functional programming. Even most non-functional languages, like + * JavaScript, have a built-in API for reducing. In JavaScript, it's + * `Array.prototype.reduce()`. + * + * In Redux, the accumulated value is the state object, and the values being + * accumulated are actions. Reducers calculate a new state given the previous + * state and an action. They must be *pure functions*—functions that return + * the exact same output for given inputs. They should also be free of + * side-effects. This is what enables exciting features like hot reloading and + * time travel. + * + * Reducers are the most important concept in Redux. + * + * *Do not put API calls into reducers.* + * + * @template S State object type. + */ + type Reducer = (state: S, action: A) => S; + + /** + * Object whose values correspond to different reducer functions. + */ + interface ReducersMapObject { + [key: string]: Reducer; } - interface Middleware extends Function { - (obj: MiddlewareArg): Function; + /** + * Turns an object whose values are different reducer functions, into a single + * reducer function. It will call every child reducer, and gather their results + * into a single state object, whose keys correspond to the keys of the passed + * reducer functions. + * + * @template S Combined state object type. + * + * @param reducers An object whose values correspond to different reducer + * functions that need to be combined into one. One handy way to obtain it + * is to use ES6 `import * as reducers` syntax. The reducers may never + * return undefined for any action. Instead, they should return their + * initial state if the state passed to them was undefined, and the current + * state for any unrecognized action. + * + * @returns A reducer function that invokes every reducer inside the passed + * object, and builds a state object with the same shape. + */ + function combineReducers(reducers: ReducersMapObject): Reducer; + + + /* store */ + + /** + * A *dispatching function* (or simply *dispatch function*) is a function that + * accepts an action or an async action; it then may or may not dispatch one + * or more actions to the store. + * + * We must distinguish between dispatching functions in general and the base + * `dispatch` function provided by the store instance without any middleware. + * + * The base dispatch function *always* synchronously sends an action to the + * store’s reducer, along with the previous state returned by the store, to + * calculate a new state. It expects actions to be plain objects ready to be + * consumed by the reducer. + * + * Middleware wraps the base dispatch function. It allows the dispatch + * function to handle async actions in addition to actions. Middleware may + * transform, delay, ignore, or otherwise interpret actions or async actions + * before passing them to the next middleware. + */ + interface Dispatch { + (action: A): A; } - class Store { - getReducer(): Reducer; - replaceReducer(nextReducer: Reducer): void; - dispatch(action: any): any; - getState(): any; - subscribe(listener: Function): Function; + /** + * Function to remove listener added by `Store.subscribe()`. + */ + interface Unsubscribe { + (): void; } - function createStore(reducer: Reducer, initialState?: any, enhancer?: Function): Store; - function bindActionCreators(actionCreators: T, dispatch: Dispatch): T; - function combineReducers(reducers: any): Reducer; - function applyMiddleware(...middlewares: Middleware[]): Function; - function compose(...functions: Function[]): T; + /** + * A store is an object that holds the application’s state tree. + * There should only be a single store in a Redux app, as the composition + * happens on the reducer level. + * + * @template S State object type. + */ + interface Store { + /** + * Dispatches an action. It is the only way to trigger a state change. + * + * The `reducer` function, used to create the store, will be called with the + * current state tree and the given `action`. Its return value will be + * considered the **next** state of the tree, and the change listeners will + * be notified. + * + * The base implementation only supports plain object actions. If you want + * to dispatch a Promise, an Observable, a thunk, or something else, you + * need to wrap your store creating function into the corresponding + * middleware. For example, see the documentation for the `redux-thunk` + * package. Even the middleware will eventually dispatch plain object + * actions using this method. + * + * @param action A plain object representing “what changed”. It is a good + * idea to keep actions serializable so you can record and replay user + * sessions, or use the time travelling `redux-devtools`. An action must + * have a `type` property which may not be `undefined`. It is a good idea + * to use string constants for action types. + * + * @returns For convenience, the same action object you dispatched. + * + * Note that, if you use a custom middleware, it may wrap `dispatch()` to + * return something else (for example, a Promise you can await). + */ + dispatch: Dispatch; + + /** + * Reads the state tree managed by the store. + * + * @returns The current state tree of your application. + */ + getState(): S; + + /** + * Adds a change listener. It will be called any time an action is + * dispatched, and some part of the state tree may potentially have changed. + * You may then call `getState()` to read the current state tree inside the + * callback. + * + * You may call `dispatch()` from a change listener, with the following + * caveats: + * + * 1. The subscriptions are snapshotted just before every `dispatch()` call. + * If you subscribe or unsubscribe while the listeners are being invoked, + * this will not have any effect on the `dispatch()` that is currently in + * progress. However, the next `dispatch()` call, whether nested or not, + * will use a more recent snapshot of the subscription list. + * + * 2. The listener should not expect to see all states changes, as the state + * might have been updated multiple times during a nested `dispatch()` before + * the listener is called. It is, however, guaranteed that all subscribers + * registered before the `dispatch()` started will be called with the latest + * state by the time it exits. + * + * @param listener A callback to be invoked on every dispatch. + * @returns A function to remove this change listener. + */ + subscribe(listener: () => void): Unsubscribe; + + /** + * Replaces the reducer currently used by the store to calculate the state. + * + * You might need this if your app implements code splitting and you want to + * load some of the reducers dynamically. You might also need this if you + * implement a hot reloading mechanism for Redux. + * + * @param nextReducer The reducer for the store to use instead. + */ + replaceReducer(nextReducer: Reducer): void; + } + + /** + * A store creator is a function that creates a Redux store. Like with + * dispatching function, we must distinguish the base store creator, + * `createStore(reducer, preloadedState)` exported from the Redux package, from + * store creators that are returned from the store enhancers. + * + * @template S State object type. + */ + interface StoreCreator { + (reducer: Reducer, enhancer?: StoreEnhancer): Store; + (reducer: Reducer, preloadedState: S, enhancer?: StoreEnhancer): Store; + } + + /** + * A store enhancer is a higher-order function that composes a store creator + * to return a new, enhanced store creator. This is similar to middleware in + * that it allows you to alter the store interface in a composable way. + * + * Store enhancers are much the same concept as higher-order components in + * React, which are also occasionally called “component enhancers”. + * + * Because a store is not an instance, but rather a plain-object collection of + * functions, copies can be easily created and modified without mutating the + * original store. There is an example in `compose` documentation + * demonstrating that. + * + * Most likely you’ll never write a store enhancer, but you may use the one + * provided by the developer tools. It is what makes time travel possible + * without the app being aware it is happening. Amusingly, the Redux + * middleware implementation is itself a store enhancer. + */ + type StoreEnhancer = (next: StoreEnhancerStoreCreator) => StoreEnhancerStoreCreator; + type GenericStoreEnhancer = (next: StoreEnhancerStoreCreator) => StoreEnhancerStoreCreator; + type StoreEnhancerStoreCreator = (reducer: Reducer, preloadedState?: S) => Store; + + /** + * Creates a Redux store that holds the state tree. + * The only way to change the data in the store is to call `dispatch()` on it. + * + * There should only be a single store in your app. To specify how different + * parts of the state tree respond to actions, you may combine several + * reducers + * into a single reducer function by using `combineReducers`. + * + * @template S State object type. + * + * @param reducer A function that returns the next state tree, given the + * current state tree and the action to handle. + * + * @param [preloadedState] The initial state. You may optionally specify it to + * hydrate the state from the server in universal apps, or to restore a + * previously serialized user session. If you use `combineReducers` to + * produce the root reducer function, this must be an object with the same + * shape as `combineReducers` keys. + * + * @param [enhancer] The store enhancer. You may optionally specify it to + * enhance the store with third-party capabilities such as middleware, time + * travel, persistence, etc. The only store enhancer that ships with Redux + * is `applyMiddleware()`. + * + * @returns A Redux store that lets you read the state, dispatch actions and + * subscribe to changes. + */ + const createStore: StoreCreator; + + + /* middleware */ + + interface MiddlewareAPI { + dispatch: Dispatch; + getState(): S; + } + + /** + * A middleware is a higher-order function that composes a dispatch function + * to return a new dispatch function. It often turns async actions into + * actions. + * + * Middleware is composable using function composition. It is useful for + * logging actions, performing side effects like routing, or turning an + * asynchronous API call into a series of synchronous actions. + */ + interface Middleware { + (api: MiddlewareAPI): (next: Dispatch) => Dispatch; + } + + /** + * Creates a store enhancer that applies middleware to the dispatch method + * of the Redux store. This is handy for a variety of tasks, such as + * expressing asynchronous actions in a concise manner, or logging every + * action payload. + * + * See `redux-thunk` package as an example of the Redux middleware. + * + * Because middleware is potentially asynchronous, this should be the first + * store enhancer in the composition chain. + * + * Note that each middleware will be given the `dispatch` and `getState` + * functions as named arguments. + * + * @param middlewares The middleware chain to be applied. + * @returns A store enhancer applying the middleware. + */ + function applyMiddleware(...middlewares: Middleware[]): GenericStoreEnhancer; + + + /* action creators */ + + /** + * An *action creator* is, quite simply, a function that creates an action. Do + * not confuse the two terms—again, an action is a payload of information, and + * an action creator is a factory that creates an action. + * + * Calling an action creator only produces an action, but does not dispatch + * it. You need to call the store’s `dispatch` function to actually cause the + * mutation. Sometimes we say *bound action creators* to mean functions that + * call an action creator and immediately dispatch its result to a specific + * store instance. + * + * If an action creator needs to read the current state, perform an API call, + * or cause a side effect, like a routing transition, it should return an + * async action instead of an action. + * + * @template A Returned action type. + */ + interface ActionCreator { + (...args: any[]): A; + } + + /** + * Object whose values are action creator functions. + */ + interface ActionCreatorsMapObject { + [key: string]: ActionCreator; + } + + /** + * Turns an object whose values are action creators, into an object with the + * same keys, but with every function wrapped into a `dispatch` call so they + * may be invoked directly. This is just a convenience method, as you can call + * `store.dispatch(MyActionCreators.doSomething())` yourself just fine. + * + * For convenience, you can also pass a single function as the first argument, + * and get a function in return. + * + * @param actionCreator An object whose values are action creator functions. + * One handy way to obtain it is to use ES6 `import * as` syntax. You may + * also pass a single function. + * + * @param dispatch The `dispatch` function available on your Redux store. + * + * @returns The object mimicking the original object, but with every action + * creator wrapped into the `dispatch` call. If you passed a function as + * `actionCreator`, the return value will also be a single function. + */ + function bindActionCreators>(actionCreator: A, dispatch: Dispatch): A; + + function bindActionCreators< + A extends ActionCreator, + B extends ActionCreator + >(actionCreator: A, dispatch: Dispatch): B; + + function bindActionCreators(actionCreators: M, dispatch: Dispatch): M; + + function bindActionCreators< + M extends ActionCreatorsMapObject, + N extends ActionCreatorsMapObject + >(actionCreators: M, dispatch: Dispatch): N; + + + /* compose */ + + /** + * Composes single-argument functions from right to left. The rightmost + * function can take multiple arguments as it provides the signature for the + * resulting composite function. + * + * @param funcs The functions to compose. + * @returns R function obtained by composing the argument functions from right + * to left. For example, `compose(f, g, h)` is identical to doing + * `(...args) => f(g(h(...args)))`. + */ + function compose(): (a: R, ...args: any[]) => R; + + function compose( + f1: (b: A) => R, + f2: (...args: any[]) => A + ): (...args: any[]) => R; + + function compose( + f1: (b: B) => R, + f2: (a: A) => B, + f3: (...args: any[]) => A + ): (...args: any[]) => R; + + function compose( + f1: (b: C) => R, + f2: (a: B) => C, + f3: (a: A) => B, + f4: (...args: any[]) => A + ): (...args: any[]) => R; + + function compose( + f1: (a: any) => R, + ...funcs: Function[] + ): (...args: any[]) => R; } declare module "redux" { From d417f687ab0c81ed72bffbc5dace5f643369bb70 Mon Sep 17 00:00:00 2001 From: Kaur Kuut Date: Sun, 3 Jul 2016 15:09:21 +0300 Subject: [PATCH 016/279] Fixed redux dependent definitions. --- react-redux/react-redux-2.1.2-tests.tsx | 14 +++++------ react-redux/react-redux-2.1.2.d.ts | 6 ++--- react-redux/react-redux-tests.tsx | 16 ++++++------- react-redux/react-redux.d.ts | 6 ++--- .../react-router-redux-2.x.d.ts | 4 ++-- react-router-redux/react-router-redux.d.ts | 4 ++-- redux-bootstrap/redux-bootstrap-tests.tsx | 4 ++-- redux-bootstrap/redux-bootstrap.d.ts | 4 ++-- redux-devtools/redux-devtools-2.1.4-tests.tsx | 2 +- redux-devtools/redux-devtools.d.ts | 4 ++-- redux-form/redux-form.d.ts | 14 +++++------ redux-immutable/redux-immutable.d.ts | 2 +- redux-mock-store/redux-mock-store-tests.ts | 2 +- .../redux-promise-middleware-tests.ts | 6 ++--- redux-promise/redux-promise-tests.ts | 7 ++---- redux-promise/redux-promise.d.ts | 19 +++++++++------ redux-saga/redux-saga.d.ts | 2 +- redux-thunk/redux-thunk-tests.ts | 15 ++++++------ redux-thunk/redux-thunk.d.ts | 24 ++++++++++++------- 19 files changed, 81 insertions(+), 74 deletions(-) diff --git a/react-redux/react-redux-2.1.2-tests.tsx b/react-redux/react-redux-2.1.2-tests.tsx index cb791a3d8e..ab32609c01 100644 --- a/react-redux/react-redux-2.1.2-tests.tsx +++ b/react-redux/react-redux-2.1.2-tests.tsx @@ -41,7 +41,7 @@ function mapStateToProps(state: CounterState) { } // Which action creators does it want to receive by props? -function mapDispatchToProps(dispatch: Dispatch) { +function mapDispatchToProps(dispatch: Dispatch) { return { onIncrement: () => dispatch(increment()) }; @@ -78,7 +78,7 @@ ReactDOM.render(( // https://github.com/rackt/react-redux/blob/master/docs/api.md // declare var routes: Route; -declare var store: Store; +declare var store: Store; declare var routerState: RouterState; class MyRootComponent extends Component { @@ -160,7 +160,7 @@ connect(mapStateToProps2, actionCreators)(TodoApp); // return { todos: state.todos }; //} -function mapDispatchToProps2(dispatch: Dispatch) { +function mapDispatchToProps2(dispatch: Dispatch) { return { actions: bindActionCreators(actionCreators, dispatch) }; } @@ -172,7 +172,7 @@ connect(mapStateToProps2, mapDispatchToProps2)(TodoApp); // return { todos: state.todos }; //} -function mapDispatchToProps3(dispatch: Dispatch) { +function mapDispatchToProps3(dispatch: Dispatch) { return bindActionCreators({ addTodo }, dispatch); } @@ -184,7 +184,7 @@ connect(mapStateToProps2, mapDispatchToProps3)(TodoApp); // return { todos: state.todos }; //} -function mapDispatchToProps4(dispatch: Dispatch) { +function mapDispatchToProps4(dispatch: Dispatch) { return { todoActions: bindActionCreators(todoActionCreators, dispatch), counterActions: bindActionCreators(counterActionCreators, dispatch) @@ -199,7 +199,7 @@ connect(mapStateToProps2, mapDispatchToProps4)(TodoApp); // return { todos: state.todos }; //} -function mapDispatchToProps5(dispatch: Dispatch) { +function mapDispatchToProps5(dispatch: Dispatch) { return { actions: bindActionCreators(objectAssign({}, todoActionCreators, counterActionCreators), dispatch) }; @@ -213,7 +213,7 @@ connect(mapStateToProps2, mapDispatchToProps5)(TodoApp); // return { todos: state.todos }; //} -function mapDispatchToProps6(dispatch: Dispatch) { +function mapDispatchToProps6(dispatch: Dispatch) { return bindActionCreators(objectAssign({}, todoActionCreators, counterActionCreators), dispatch); } diff --git a/react-redux/react-redux-2.1.2.d.ts b/react-redux/react-redux-2.1.2.d.ts index fa67b1b2e9..717d831e0e 100644 --- a/react-redux/react-redux-2.1.2.d.ts +++ b/react-redux/react-redux-2.1.2.d.ts @@ -32,11 +32,11 @@ declare module "react-redux" { } interface MapDispatchToPropsFunction { - (dispatch: Dispatch, ownProps?: any): any; + (dispatch: Dispatch, ownProps?: any): any; } interface MapDispatchToPropsObject { - [name: string]: ActionCreator; + [name: string]: ActionCreator; } interface MergeProps { @@ -58,7 +58,7 @@ declare module "react-redux" { /** * The single Redux store in your application. */ - store?: Store; + store?: Store; children?: Function; } diff --git a/react-redux/react-redux-tests.tsx b/react-redux/react-redux-tests.tsx index d22f3aef46..646cdb44a7 100644 --- a/react-redux/react-redux-tests.tsx +++ b/react-redux/react-redux-tests.tsx @@ -41,7 +41,7 @@ function mapStateToProps(state: CounterState) { } // Which action creators does it want to receive by props? -function mapDispatchToProps(dispatch: Dispatch) { +function mapDispatchToProps(dispatch: Dispatch) { return { onIncrement: () => dispatch(increment()) }; @@ -77,7 +77,7 @@ ReactDOM.render(( // API // https://github.com/rackt/react-redux/blob/master/docs/api.md // -declare var store: Store; +declare var store: Store; declare var routerState: RouterState; declare var history: HistoryModule.History; class MyRootComponent extends Component { @@ -165,7 +165,7 @@ connect(mapStateToProps2, actionCreators)(TodoApp); // return { todos: state.todos }; //} -function mapDispatchToProps2(dispatch: Dispatch) { +function mapDispatchToProps2(dispatch: Dispatch) { return { actions: bindActionCreators(actionCreators, dispatch) }; } @@ -177,7 +177,7 @@ connect(mapStateToProps2, mapDispatchToProps2)(TodoApp); // return { todos: state.todos }; //} -function mapDispatchToProps3(dispatch: Dispatch) { +function mapDispatchToProps3(dispatch: Dispatch) { return bindActionCreators({ addTodo }, dispatch); } @@ -189,7 +189,7 @@ connect(mapStateToProps2, mapDispatchToProps3)(TodoApp); // return { todos: state.todos }; //} -function mapDispatchToProps4(dispatch: Dispatch) { +function mapDispatchToProps4(dispatch: Dispatch) { return { todoActions: bindActionCreators(todoActionCreators, dispatch), counterActions: bindActionCreators(counterActionCreators, dispatch) @@ -204,7 +204,7 @@ connect(mapStateToProps2, mapDispatchToProps4)(TodoApp); // return { todos: state.todos }; //} -function mapDispatchToProps5(dispatch: Dispatch) { +function mapDispatchToProps5(dispatch: Dispatch) { return { actions: bindActionCreators(objectAssign({}, todoActionCreators, counterActionCreators), dispatch) }; @@ -218,7 +218,7 @@ connect(mapStateToProps2, mapDispatchToProps5)(TodoApp); // return { todos: state.todos }; //} -function mapDispatchToProps6(dispatch: Dispatch) { +function mapDispatchToProps6(dispatch: Dispatch) { return bindActionCreators(objectAssign({}, todoActionCreators, counterActionCreators), dispatch); } @@ -302,7 +302,7 @@ namespace TestStatelessFunctionWithMapArguments { }; }; - const mapDispatchToProps = (dispatch: Dispatch, ownProps: GreetingProps) => { + const mapDispatchToProps = (dispatch: Dispatch, ownProps: GreetingProps) => { return { onClick: () => { dispatch({ type: 'GREETING', name: ownProps.name }); diff --git a/react-redux/react-redux.d.ts b/react-redux/react-redux.d.ts index 6f05a17b6e..e522264a4a 100644 --- a/react-redux/react-redux.d.ts +++ b/react-redux/react-redux.d.ts @@ -61,11 +61,11 @@ declare module "react-redux" { } interface MapDispatchToPropsFunction { - (dispatch: Dispatch, ownProps?: TOwnProps): TDispatchProps; + (dispatch: Dispatch, ownProps?: TOwnProps): TDispatchProps; } interface MapDispatchToPropsObject { - [name: string]: ActionCreator; + [name: string]: ActionCreator; } interface MergeProps { @@ -92,7 +92,7 @@ declare module "react-redux" { /** * The single Redux store in your application. */ - store?: Store; + store?: Store; children?: ReactNode; } diff --git a/react-router-redux/react-router-redux-2.x.d.ts b/react-router-redux/react-router-redux-2.x.d.ts index a526208612..5e38fe4bee 100644 --- a/react-router-redux/react-router-redux-2.x.d.ts +++ b/react-router-redux/react-router-redux-2.x.d.ts @@ -35,11 +35,11 @@ declare namespace ReactRouterRedux { goBack: GoBackAction; } interface HistoryMiddleware extends R.Middleware { - listenForReplays(store: R.Store, selectLocationState?: Function): void; + listenForReplays(store: R.Store, selectLocationState?: Function): void; unsubscribe(): void; } - function routeReducer(state?: any, options?: any): R.Reducer; + function routeReducer(state?: any, options?: any): R.Reducer; function syncHistory(history: H.History): HistoryMiddleware; } diff --git a/react-router-redux/react-router-redux.d.ts b/react-router-redux/react-router-redux.d.ts index b2c993132a..d91f1ad4e1 100644 --- a/react-router-redux/react-router-redux.d.ts +++ b/react-router-redux/react-router-redux.d.ts @@ -52,8 +52,8 @@ declare namespace ReactRouterRedux { adjustUrlOnReplay?: boolean; } - function routerReducer(state?: any, options?: any): R.Reducer; - function syncHistoryWithStore(history: H.History, store: R.Store, options?: SyncHistoryWithStoreOptions): ReactRouterReduxHistory; + function routerReducer(state?: any, options?: any): R.Reducer; + function syncHistoryWithStore(history: H.History, store: R.Store, options?: SyncHistoryWithStoreOptions): ReactRouterReduxHistory; function routerMiddleware(history: H.History): R.Middleware; } diff --git a/redux-bootstrap/redux-bootstrap-tests.tsx b/redux-bootstrap/redux-bootstrap-tests.tsx index ae6d8063aa..b769063e3e 100644 --- a/redux-bootstrap/redux-bootstrap-tests.tsx +++ b/redux-bootstrap/redux-bootstrap-tests.tsx @@ -9,8 +9,8 @@ let result = bootstrap({ initialState: {}, middlewares: [], reducers: { - reposReducer: (previousState: any, action: any) => { return null; }, - usersReducer: (previousState: any, action: any) => { return null; } + reposReducer: (previousState: any, action: any): any => { return null; }, + usersReducer: (previousState: any, action: any): any => { return null; } }, routes: routes }); diff --git a/redux-bootstrap/redux-bootstrap.d.ts b/redux-bootstrap/redux-bootstrap.d.ts index 933fa988a7..2bfdc53f31 100644 --- a/redux-bootstrap/redux-bootstrap.d.ts +++ b/redux-bootstrap/redux-bootstrap.d.ts @@ -18,13 +18,13 @@ declare module "redux-bootstrap" { } interface BootstrapResult { - store: Redux.Store; + store: Redux.Store; history: ReactRouterRedux.ReactRouterReduxHistory; root: JSX.Element; } interface ReducersOption { - [index: string]: Redux.Reducer; + [index: string]: Redux.Reducer; } export default function bootstrap(options: BootstrapOptions): BootstrapResult; diff --git a/redux-devtools/redux-devtools-2.1.4-tests.tsx b/redux-devtools/redux-devtools-2.1.4-tests.tsx index a57811f16b..6968468315 100644 --- a/redux-devtools/redux-devtools-2.1.4-tests.tsx +++ b/redux-devtools/redux-devtools-2.1.4-tests.tsx @@ -11,7 +11,7 @@ import { Component } from 'react'; declare var m1: Middleware; declare var m2: Middleware; declare var m3: Middleware; -declare var reducer: Reducer; +declare var reducer: Reducer; class CounterApp extends Component { }; class Provider extends Component<{ store: any }, any> { }; diff --git a/redux-devtools/redux-devtools.d.ts b/redux-devtools/redux-devtools.d.ts index 47ad2198d9..e2afe1e160 100644 --- a/redux-devtools/redux-devtools.d.ts +++ b/redux-devtools/redux-devtools.d.ts @@ -10,13 +10,13 @@ declare module "redux-devtools" { interface IDevTools { new (): JSX.ElementClass - instrument(): Function + instrument(): (opts: any) => any; } export function createDevTools(el: React.ReactElement): IDevTools export function persistState(debugSessionKey: string): Function - var factory: { instrument(): Function } + var factory: { instrument(): (opts: any) => any } export default factory; } \ No newline at end of file diff --git a/redux-form/redux-form.d.ts b/redux-form/redux-form.d.ts index dfc2df43a9..edcf9c2c71 100644 --- a/redux-form/redux-form.d.ts +++ b/redux-form/redux-form.d.ts @@ -192,7 +192,7 @@ declare module 'redux-form' { */ handleSubmit?(event:SyntheticEvent):void; - handleSubmit?(submit:(data:FormData, dispatch?:Dispatch) + handleSubmit?(submit:(data:FormData, dispatch?:Dispatch) => Promise|void):FormEventHandler; /** @@ -285,11 +285,11 @@ declare module 'redux-form' { } interface MapDispatchToPropsFunction { - (dispatch:Dispatch, ownProps?:any): any; + (dispatch:Dispatch, ownProps?:any): any; } interface MapDispatchToPropsObject { - [name: string]: ActionCreator; + [name: string]: ActionCreator; } export function reduxForm(config:ReduxFormConfig, @@ -337,7 +337,7 @@ declare module 'redux-form' { * * See Asynchronous Blur Validation Example for more details. */ - asyncValidate?(values:FormData, dispatch:Dispatch, props:Object): + asyncValidate?(values:FormData, dispatch:Dispatch, props:Object): Promise; /** @@ -377,7 +377,7 @@ declare module 'redux-form' { * you must pass it as a parameter to handleSubmit() inside your form * component. */ - onSubmit?(values:FormData, dispatch?:Dispatch): any; + onSubmit?(values:FormData, dispatch?:Dispatch): any; /** * If true, the form values will be overwritten whenever the initialValues @@ -466,7 +466,7 @@ declare module 'redux-form' { [formName:string]: { [fieldName:string]: Normalizer } - }):Reducer; + }):Reducer; /** * Returns a form reducer that will also pass each action through @@ -475,6 +475,6 @@ declare module 'redux-form' { * passed to each reducer will only be the slice that pertains to that * form. */ - plugin(reducers:{[formName:string]: Reducer}):Reducer; + plugin(reducers:{[formName:string]: Reducer}):Reducer; } } diff --git a/redux-immutable/redux-immutable.d.ts b/redux-immutable/redux-immutable.d.ts index df0f3745af..8d235b9338 100644 --- a/redux-immutable/redux-immutable.d.ts +++ b/redux-immutable/redux-immutable.d.ts @@ -6,5 +6,5 @@ /// declare module "redux-immutable" { - export function combineReducers(reducers : Object): Redux.Reducer; + export function combineReducers(reducers: Object): Redux.Reducer; } diff --git a/redux-mock-store/redux-mock-store-tests.ts b/redux-mock-store/redux-mock-store-tests.ts index 1b0a53968b..4a6045c288 100644 --- a/redux-mock-store/redux-mock-store-tests.ts +++ b/redux-mock-store/redux-mock-store-tests.ts @@ -19,7 +19,7 @@ function counter(state: any, action: any) { } function loggingMiddleware() { - return (next: Redux.Dispatch) => (action: any) => { + return (next: Redux.Dispatch) => (action: any) => { console.log(action.type); next(action); }; diff --git a/redux-promise-middleware/redux-promise-middleware-tests.ts b/redux-promise-middleware/redux-promise-middleware-tests.ts index ef7e7d82de..64fde63170 100644 --- a/redux-promise-middleware/redux-promise-middleware-tests.ts +++ b/redux-promise-middleware/redux-promise-middleware-tests.ts @@ -4,7 +4,7 @@ import { createStore, applyMiddleware, Store, Dispatch } from "redux"; import promiseMiddleware from "redux-promise-middleware"; -declare var rootReducer: Function; +declare var rootReducer: (state: any, action: any) => any; declare var Promise: any; declare var doSomethingAsyncAndReturnPromise: any; declare var someActionCreator: any; @@ -13,7 +13,7 @@ const createStoreWithMiddleware = applyMiddleware( promiseMiddleware() )(createStore); -const store: Store = createStoreWithMiddleware(rootReducer); +const store: Store = createStoreWithMiddleware(rootReducer); export function myAsyncActionCreator(data: any) { return { @@ -38,7 +38,7 @@ const actionCreator1 = () => ({ const actionCreator2 = () => ({ type: "FIRST_ACTION_TYPE", payload: { - promise: Promise.resolve((action: string, dispatch: Redux.Dispatch, getState: Function) => { + promise: Promise.resolve((action: string, dispatch: Redux.Dispatch, getState: Function) => { dispatch({ type: "SECEOND_ACTION_TYPE", payload: "..." }); dispatch(someActionCreator()); }) diff --git a/redux-promise/redux-promise-tests.ts b/redux-promise/redux-promise-tests.ts index 8859eaac52..724f695261 100644 --- a/redux-promise/redux-promise-tests.ts +++ b/redux-promise/redux-promise-tests.ts @@ -3,9 +3,8 @@ /// import {createAction} from 'redux-actions'; -import { createStore, applyMiddleware } from 'redux'; +import { createStore, applyMiddleware, PromiseAction } from 'redux'; import promise from 'redux-promise'; -import PromiseInterface = ReduxPromise.PromiseInterface; declare var userReducer: any; @@ -18,11 +17,9 @@ appStore.dispatch( listUsers() ); -function listUsers(): PromiseInterface { +function listUsers(): PromiseAction { return createAction('LIST_USERS', () => { return Promise.resolve([{ email: 'me@definitely.typed' }]); }); } - - diff --git a/redux-promise/redux-promise.d.ts b/redux-promise/redux-promise.d.ts index 58b6d712a6..f3fbea7240 100644 --- a/redux-promise/redux-promise.d.ts +++ b/redux-promise/redux-promise.d.ts @@ -1,18 +1,23 @@ // Type definitions for redux-promise v0.5.3 // Project: https://github.com/acdlite/redux-promise -// Definitions by: Rogelio Morrell Caballero +// Definitions by: Rogelio Morrell Caballero , Kaur Kuut // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// +declare namespace Redux { + type PromiseAction = (dispatch: Redux.Dispatch, getState?: () => S) => any; + + interface Dispatch { + (asyncAction: PromiseAction): R; + } +} + declare namespace ReduxPromise { - export interface Promise extends Redux.Middleware {} - export interface PromiseInterface { - (dispatch: Redux.Dispatch, getState?: () => T): any; - } + export interface Promise extends Redux.Middleware {} } declare module "redux-promise" { - var promise: ReduxPromise.Promise; - export default promise; + var promise: ReduxPromise.Promise; + export default promise; } \ No newline at end of file diff --git a/redux-saga/redux-saga.d.ts b/redux-saga/redux-saga.d.ts index 8df9f63a9c..638099f6c6 100644 --- a/redux-saga/redux-saga.d.ts +++ b/redux-saga/redux-saga.d.ts @@ -118,7 +118,7 @@ declare module 'redux-saga/lib/runSaga' { subscribe: (cb: Function) => Function; } - export function storeIO(store: Store): IO; + export function storeIO(store: Store): IO; export function runSaga(iterator: Iterable, io: IO, diff --git a/redux-thunk/redux-thunk-tests.ts b/redux-thunk/redux-thunk-tests.ts index f1283bf53c..a900c799ed 100644 --- a/redux-thunk/redux-thunk-tests.ts +++ b/redux-thunk/redux-thunk-tests.ts @@ -2,11 +2,10 @@ /// /// -import { createStore, applyMiddleware, Store, Dispatch } from 'redux'; +import { createStore, applyMiddleware, Store, Dispatch, ThunkAction } from 'redux'; import thunk from 'redux-thunk'; -import ThunkInterface = ReduxThunk.ThunkInterface; -declare var rootReducer: Function; +declare var rootReducer: (state: any, action: any) => any; declare var fetch: any; // create a store that has redux-thunk middleware enabled @@ -14,7 +13,7 @@ const createStoreWithMiddleware = applyMiddleware( thunk )(createStore); -const store: Store = createStoreWithMiddleware(rootReducer); +const store: Store = createStoreWithMiddleware(rootReducer); function fetchSecretSauce() { return fetch('https://www.google.com/search?q=secret+sauce'); @@ -58,13 +57,13 @@ store.dispatch(withdrawMoney(100)); // A thunk is a function that returns a function. // This is a thunk. -function makeASandwichWithSecretSauce(forPerson: any): ThunkInterface { +function makeASandwichWithSecretSauce(forPerson: any): ThunkAction { // Invert control! // Return a function that accepts `dispatch` so we can dispatch later. // Thunk middleware knows how to turn thunk async actions into actions. - return function (dispatch: Dispatch): any { + return function (dispatch: Dispatch): any { return fetchSecretSauce().then( (sauce: any) => dispatch(makeASandwich(forPerson, sauce)), (error: any) => dispatch(apologize('The Sandwich Shop', forPerson, error)) @@ -92,8 +91,8 @@ store.dispatch( // actions and async actions from other action creators, // and I can build my control flow with Promises. -function makeSandwichesForEverybody(): ThunkInterface { - return function (dispatch: Dispatch, getState: () => any): any { +function makeSandwichesForEverybody(): ThunkAction { + return function (dispatch: Dispatch, getState: () => any): any { if (!getState().sandwiches.isShopOpen) { // You don’t have to return Promises, but it’s a handy convention diff --git a/redux-thunk/redux-thunk.d.ts b/redux-thunk/redux-thunk.d.ts index d19d2a2d0c..08f62bc99e 100644 --- a/redux-thunk/redux-thunk.d.ts +++ b/redux-thunk/redux-thunk.d.ts @@ -1,18 +1,24 @@ -// Type definitions for redux-thunk v2.0.1 +// Type definitions for redux-thunk v2.1.0 // Project: https://github.com/gaearon/redux-thunk -// Definitions by: Qubo +// Definitions by: Qubo , Kaur Kuut // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -declare namespace ReduxThunk { - export interface Thunk extends Redux.Middleware {} - export interface ThunkInterface { - (dispatch: Redux.Dispatch, getState?: () => T): any; - } +declare namespace Redux { + type ThunkAction = (dispatch: Dispatch, getState: () => S, extraArgument: E) => R; + + interface Dispatch { + (asyncAction: ThunkAction): R; + } } declare module "redux-thunk" { - var thunk: ReduxThunk.Thunk; - export default thunk; + import { Middleware } from "redux"; + + const thunk: Middleware & { + withExtraArgument(extraArgument: any): Middleware; + }; + + export default thunk; } From dd026f6afd9aca2e170f6c7f8302a8135b07a7a9 Mon Sep 17 00:00:00 2001 From: Dan Marshall Date: Sun, 3 Jul 2016 13:31:28 -0700 Subject: [PATCH 017/279] added curveIntersectionThreshold --- bezier-js/bezier-js.d.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/bezier-js/bezier-js.d.ts b/bezier-js/bezier-js.d.ts index 8256f4ce99..dfc699bc15 100644 --- a/bezier-js/bezier-js.d.ts +++ b/bezier-js/bezier-js.d.ts @@ -57,6 +57,7 @@ declare module BezierJs { back: Bezier; endcap: BezierCap; bbox: BBox; + intersections: (shape: Shape) => string[][] | number[][]; } interface ABC { A: Point; @@ -76,8 +77,8 @@ declare module BezierJs { * */ class Bezier { - clockwise: boolean; private _linear; + clockwise: boolean; _3d: boolean; _t1: number; _t2: number; @@ -128,12 +129,12 @@ declare module BezierJs { scale(d: Function): Bezier; scale(d: number): Bezier; outline(d1: number, d2?: number, d3?: number, d4?: number): PolyBezier; - outlineshapes(d1: number, d2: number): Shape[]; - intersects(curve: Bezier): string[] | number[]; + outlineshapes(d1: number, d2: number, curveIntersectionThreshold?: number): Shape[]; + intersects(curve: Bezier, curveIntersectionThreshold?: number): string[] | number[]; intersects(curve: Line): string[] | number[]; lineIntersects(line: Line): number[]; - selfintersects(): string[]; - curveintersects(c1: Bezier[], c2: Bezier[]): string[]; + selfintersects(curveIntersectionThreshold?: number): string[]; + curveintersects(c1: Bezier[], c2: Bezier[], curveIntersectionThreshold?: number): string[]; arcs(errorThreshold?: number): Arc[]; private _error(pc, np1, s, e); private _iterate(errorThreshold, circles); @@ -165,8 +166,8 @@ declare module BezierJs.utils { function lli(v1: Offset, v2: Offset): Point; function makeline(p1: Point, p2: Point): Bezier; function findbbox(sections: Bezier[]): BBox; - function shapeintersections(s1: Shape, bbox1: BBox, s2: Shape, bbox2: BBox): string[][] | number[][]; - function makeshape(forward: Bezier, back: Bezier): Shape; + function shapeintersections(s1: Shape, bbox1: BBox, s2: Shape, bbox2: BBox, curveIntersectionThreshold?: number): string[][] | number[][]; + function makeshape(forward: Bezier, back: Bezier, curveIntersectionThreshold?: number): Shape; function getminmax(curve: Bezier, d: string, list: number[]): MinMax; function align(points: Point[], line: Line): Point[]; function roots(points: Point[], line: Line): number[]; @@ -174,7 +175,7 @@ declare module BezierJs.utils { function inflections(points: Point[]): number[]; function bboxoverlap(b1: BBox, b2: BBox): boolean; function expandbox(bbox: BBox, _bbox: BBox): void; - function pairiteration(c1: Bezier, c2: Bezier): string[]; + function pairiteration(c1: Bezier, c2: Bezier, curveIntersectionThreshold?: number): string[]; function getccenter(p1: Point, p2: Point, p3: Point): Arc; } declare module BezierJs { From 197e8047fcfbfef9120202d2322b5f7cdc292732 Mon Sep 17 00:00:00 2001 From: Dan Marshall Date: Sun, 3 Jul 2016 13:41:48 -0700 Subject: [PATCH 018/279] add intersections to Shape --- bezier-js/bezier-js-tests.ts | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/bezier-js/bezier-js-tests.ts b/bezier-js/bezier-js-tests.ts index 54c629d11b..2f9f2685a2 100644 --- a/bezier-js/bezier-js-tests.ts +++ b/bezier-js/bezier-js-tests.ts @@ -1,27 +1,29 @@ /// function test() { - + var bezierjs: typeof BezierJs; - - var bezier = new bezierjs.Bezier([1,2,3,4]); + + var bezier = new bezierjs.Bezier([1, 2, 3, 4]); var cap = new bezierjs.BezierCap([]); var point: BezierJs.Point = { x: 0, y: 0 }; var utils = bezier.getUtils(); - var line: BezierJs.Line = { p1: { x:0, y: 0}, p2: {x:1, y: 1}}; + var line: BezierJs.Line = { p1: { x: 0, y: 0 }, p2: { x: 1, y: 1 } }; var abc: BezierJs.ABC = { A: null, B: null, C: null }; var arc: BezierJs.Arc = { e: 0, s: 0, x: 0, y: 0, r: 1 }; var bbox: BezierJs.BBox = bezier.bbox(); - var closest: BezierJs.Closest = { mdist: 1, mpos: 0 }; - var inflection: BezierJs.Inflection = { values: null, x: [0], y: [0], z:[0] }; + var closest: BezierJs.Closest = { mdist: 1, mpos: 0 }; + var inflection: BezierJs.Inflection = { values: null, x: [0], y: [0], z: [0] }; var minmax: BezierJs.MinMax = { min: 0, max: 0 }; var offset: BezierJs.Offset = { x: 0, y: 0, c: point, n: point }; var pair: BezierJs.Pair = { left: bezier, right: bezier }; var poly: BezierJs.PolyBezier = bezier.outline(1); var projection: BezierJs.Projection = { x: 0, y: 0, t: 9, d: 4 }; - var shape: BezierJs.Shape = { startcap: cap, endcap: cap, forward: bezier, back: bezier, bbox: bbox }; + var shape: BezierJs.Shape = { + startcap: cap, endcap: cap, forward: bezier, back: bezier, bbox: bbox, intersections: function (shape) { return [[0]]; } + }; var split: BezierJs.Split = { left: bezier, right: bezier, span: [point] }; - + bezier.arcs(); bezier.clockwise; bezier.compute(.5); @@ -36,10 +38,10 @@ function test() { bezier.length(); bezier.lineIntersects(line); bezier.normal(0); - bezier.offset(1,2); + bezier.offset(1, 2); bezier.on(point, 0); bezier.order = 5; - bezier.outlineshapes(1,3); + bezier.outlineshapes(1, 3); bezier.overlaps(bezier); bezier.point(9); bezier.project(point); @@ -52,9 +54,9 @@ function test() { bezier.split(0.5).left; bezier.toSVG(); bezier.update(); - + cap.virtual = true; - + poly.addCurve(bezier); poly.bbox(); poly.curve(7); @@ -62,12 +64,12 @@ function test() { poly.length(); poly.offset(9).points[0].y; poly.points[0]; - + utils.abcratio(0, 1); utils.align([point], line); utils.angle(point, point, point); utils.approximately(5, 7, .001); - utils.arcfn(1, function(){}); + utils.arcfn(1, function () { }); utils.bboxoverlap(bbox, bbox); utils.between(0, 0, 1); utils.closest([point], point); @@ -78,7 +80,7 @@ function test() { utils.findbbox([bezier]); utils.getccenter(point, point, point); utils.getminmax(bezier, 'x', [0]); - utils.length(function(){}); + utils.length(function () { }); utils.lerp(1, point, point); utils.lli(offset, offset); utils.lli4(point, point, point, point); @@ -92,5 +94,5 @@ function test() { utils.roots([point], line); utils.round(.999, .001); utils.shapeintersections(shape, bbox, shape, bbox); - + } \ No newline at end of file From 55a25048a85c50e52c46706154dc3144d378dd9a Mon Sep 17 00:00:00 2001 From: Kasidit Iamthong Date: Mon, 4 Jul 2016 04:05:48 +0700 Subject: [PATCH 019/279] Fix THREE.FirstPersonControls and THREE.OrbitControls definition. --- threejs/three-FirstPersonControls.d.ts | 9 +++++---- threejs/three-orbitcontrols.d.ts | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/threejs/three-FirstPersonControls.d.ts b/threejs/three-FirstPersonControls.d.ts index fc13ca8ed9..3bc4f65237 100644 --- a/threejs/three-FirstPersonControls.d.ts +++ b/threejs/three-FirstPersonControls.d.ts @@ -11,6 +11,7 @@ declare namespace THREE { object: THREE.Object3D; target: THREE.Vector3; domElement: HTMLCanvasElement; + enabled: boolean; movementSpeed: number; lookSpeed: number; noFly: boolean; @@ -18,14 +19,13 @@ declare namespace THREE { autoForward: boolean; activeLook: boolean; heightSpeed: boolean; - heightCoef: boolean; - heightMin: boolean; + heightCoef: number; + heightMin: number; + heightMax: number; constrainVertical: boolean; verticalMin: number; verticalMax: number; autoSpeedFactor: number; - mouseX: number; - mouseY: number; lat: number; lon: number; phi: number; @@ -37,5 +37,6 @@ declare namespace THREE { freeze: boolean; mouseDragOn: boolean; update(delta?: number): void; + dispose(): void; } } diff --git a/threejs/three-orbitcontrols.d.ts b/threejs/three-orbitcontrols.d.ts index 910a658334..2813c615db 100644 --- a/threejs/three-orbitcontrols.d.ts +++ b/threejs/three-orbitcontrols.d.ts @@ -49,6 +49,7 @@ declare namespace THREE { dollyOut(dollyScale: number): void; update(): void; reset(): void; + dispose(): void; getPolarAngle(): number; getAzimuthalAngle(): number; From 4d586d46ce710874d7a6a12caf8d985eb2ff8c4c Mon Sep 17 00:00:00 2001 From: Kasidit Iamthong Date: Mon, 4 Jul 2016 08:07:34 +0700 Subject: [PATCH 020/279] Revert removal of `mouseX` and `mouseY`. Correct `domElement` type and `update` parameter. --- threejs/three-FirstPersonControls.d.ts | 6 ++++-- threejs/three-orbitcontrols.d.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/threejs/three-FirstPersonControls.d.ts b/threejs/three-FirstPersonControls.d.ts index 3bc4f65237..9f6db3ec6c 100644 --- a/threejs/three-FirstPersonControls.d.ts +++ b/threejs/three-FirstPersonControls.d.ts @@ -10,7 +10,7 @@ declare namespace THREE { constructor(object: Camera, domElement?: HTMLElement); object: THREE.Object3D; target: THREE.Vector3; - domElement: HTMLCanvasElement; + domElement: HTMLCanvasElement | HTMLDocument; enabled: boolean; movementSpeed: number; lookSpeed: number; @@ -26,6 +26,8 @@ declare namespace THREE { verticalMin: number; verticalMax: number; autoSpeedFactor: number; + mouseX: number; + mouseY: number; lat: number; lon: number; phi: number; @@ -36,7 +38,7 @@ declare namespace THREE { moveRight: boolean; freeze: boolean; mouseDragOn: boolean; - update(delta?: number): void; + update(delta: number): void; dispose(): void; } } diff --git a/threejs/three-orbitcontrols.d.ts b/threejs/three-orbitcontrols.d.ts index 2813c615db..cb1ffd21d5 100644 --- a/threejs/three-orbitcontrols.d.ts +++ b/threejs/three-orbitcontrols.d.ts @@ -10,7 +10,7 @@ declare namespace THREE { constructor(object: Camera, domElement?: HTMLElement); object: Camera; - domElement: HTMLElement; + domElement: HTMLElement | HTMLDocument; // API enabled: boolean; From a36840d981199ebc8622ac1af16ffe638c44b9ab Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Mon, 4 Jul 2016 11:39:46 +0900 Subject: [PATCH 021/279] feat: update samlp definition file --- samlp/samlp.d.ts | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/samlp/samlp.d.ts b/samlp/samlp.d.ts index 2993951545..5d0ffef0d5 100644 --- a/samlp/samlp.d.ts +++ b/samlp/samlp.d.ts @@ -13,11 +13,15 @@ declare module "samlp" { export function auth(options: IdPOptions): express.Handler; export function logout(options: IdPOptions): express.Handler; - export function parseRequest(req: express.Request, callback: (err: any, data: any) => void): void; - export function getSamlResponse(options: IdPOptions, user: any, callback: (err: any, samlResponse: any) => void): void; + export function parseRequest(req: express.Request, callback: (err: any, data: SamlRequest) => void): void; + export function getSamlResponse(options: IdPOptions, user: any, callback: (err: any, samlResponse: string) => void): void; export function sendError(options: IdPOptions): express.Handler; export function metadata(options: IdPMetadataOptions): express.Handler; + + export type DigestAlgorithmType = 'sha1' | 'sha256'; + export type SignatureAlgorithmType = 'rsa-sha1' | 'rsa-sha256'; + export interface IdPOptions { issuer: string; cert: string | Buffer; @@ -26,8 +30,8 @@ declare module "samlp" { recipient?: string; destination?: string; RelayState?: string; - digestAlgorithm?: 'sha1' | 'sha256'; - signatureAlgorithm?: 'rsa-sha1' | 'rsa-sha256'; + digestAlgorithm?: DigestAlgorithmType; + signatureAlgorithm?: SignatureAlgorithmType; signResponse?: boolean; encryptionCert?: string | Buffer; encryptionPublicKey?: string | Buffer; @@ -35,14 +39,16 @@ declare module "samlp" { keyEncryptionAlgorighm?: string; lifetimeInSeconds?: number; authnContextClassRef?: string; - profileMapper?: PassportProfileMapper; + inResponseTo?: string; + profileMapper?: ProfileMapperConstructor; getUserFromRequest?: (req: express.Request) => any; getPostURL: (audience: string, authnRequestDom: any, req: express.Request, callback: (err: any, url: string) => void) => void; } + export interface IdPMetadataOptions { issuer: string; cert: string | Buffer; - profileMapper?: PassportProfileMapper; + profileMapper?: ProfileMapperConstructor; redirectEndpointPath?: string; postEndpointPath?: string; logoutEndpointPaths?: { @@ -51,12 +57,26 @@ declare module "samlp" { }; } - export class PassportProfileMapper { - constructor(pu: passport.Profile); + export interface SamlRequest { + id?: string; + issuer?: string; + assertionConsumerServiceURL?: string; + destination?: string; + forceAuthn?: string; + } + + + export interface ProfileMapper { metadata: MetadataItem[]; getClaims(): any; getNameIdentifier(): any; } + export interface ProfileMapperConstructor { + (pu: passport.Profile): ProfileMapper; + prototype: ProfileMapper; + } + export var PassportProfileMapper: ProfileMapperConstructor; + export interface MetadataItem { id: string; optional: boolean; From d1d106602ad25e1e70728cbd2f3a376ace2d6cde Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Mon, 4 Jul 2016 11:46:19 +0900 Subject: [PATCH 022/279] feat: update `csurf` type definition --- csurf/csurf.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/csurf/csurf.d.ts b/csurf/csurf.d.ts index ed2b2e68ed..3d213c76cd 100644 --- a/csurf/csurf.d.ts +++ b/csurf/csurf.d.ts @@ -1,4 +1,4 @@ -// Type definitions for csurf +// Type definitions for csurf 1.9.0 // Project: https://www.npmjs.org/package/csurf // Definitions by: Hiroki Horiuchi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -17,6 +17,8 @@ declare module "csurf" { function csurf(options?: { value?: (req: express.Request) => string; cookie?: csurf.CookieOptions | boolean; + ignoreMethods?: string[]; + sessionKey?: string; }): express.RequestHandler; namespace csurf { From abe7af3825830f38e559cb79ae20eb033d7a7d99 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Mon, 4 Jul 2016 10:27:08 +0200 Subject: [PATCH 023/279] The subclasses property are now optional --- mathjs/mathjs.d.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mathjs/mathjs.d.ts b/mathjs/mathjs.d.ts index 6311b5b7a7..9671dd8005 100644 --- a/mathjs/mathjs.d.ts +++ b/mathjs/mathjs.d.ts @@ -1333,14 +1333,15 @@ declare namespace mathjs { export interface MathNode { isNode: boolean; - isSymbolNode: boolean; - isConstantNode: boolean; - isOperatorNode: boolean; - op: string; - fn: string; + isSymbolNode?: boolean; + isConstantNode?: boolean; + isOperatorNode?: boolean; + op?: string; + fn?: string; + args?: MathNode[]; type: string; - name: string; - value: any; + name?: string; + value?: any; compile(): EvalFunction; eval(): any; From 31a80af9134bf7fc6d08f036ea62d8a281f04f2d Mon Sep 17 00:00:00 2001 From: Jan Zak Date: Mon, 4 Jul 2016 11:34:41 +0200 Subject: [PATCH 024/279] Fix i18next import --- .../i18next-sprintf-postprocessor-tests.ts | 2 +- i18next/i18next-tests.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/i18next-sprintf-postprocessor/i18next-sprintf-postprocessor-tests.ts b/i18next-sprintf-postprocessor/i18next-sprintf-postprocessor-tests.ts index 36a948d620..b251acba91 100644 --- a/i18next-sprintf-postprocessor/i18next-sprintf-postprocessor-tests.ts +++ b/i18next-sprintf-postprocessor/i18next-sprintf-postprocessor-tests.ts @@ -1,6 +1,6 @@ /// -import * as i18next from "i18next"; +import i18next from "i18next"; import * as sprintfA from "i18next-sprintf-postprocessor"; import sprintfB from "i18next-sprintf-postprocessor/dist/commonjs"; diff --git a/i18next/i18next-tests.ts b/i18next/i18next-tests.ts index 373b7394b4..81c1c214b0 100644 --- a/i18next/i18next-tests.ts +++ b/i18next/i18next-tests.ts @@ -5,7 +5,7 @@ /// /// -import * as i18n from 'i18next'; +import i18n from 'i18next'; i18n.init({ debug: true, From 79a7fad499369ce70e79e909c0706f391c01336c Mon Sep 17 00:00:00 2001 From: oizie Date: Mon, 4 Jul 2016 11:40:03 +0100 Subject: [PATCH 025/279] Added type definitions for react-dnd-html5-backend --- .../react-dnd-html5-backend-tests.ts | 301 ++++++++++++++++++ .../react-dnd-html5-backend.d.ts | 15 + 2 files changed, 316 insertions(+) create mode 100644 react-dnd-html5-backend/react-dnd-html5-backend-tests.ts create mode 100644 react-dnd-html5-backend/react-dnd-html5-backend.d.ts diff --git a/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts b/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts new file mode 100644 index 0000000000..031c778653 --- /dev/null +++ b/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts @@ -0,0 +1,301 @@ +/// +"use strict"; + +// Test adapted from the ReactDnD chess game tutorial: +// http://gaearon.github.io/react-dnd/docs-tutorial.html + +import React = require("react"); +import ReactDnd = require("react-dnd"); + +var r = React.DOM; + +import DragSource = ReactDnd.DragSource; +import DropTarget = ReactDnd.DropTarget; +import DragLayer = ReactDnd.DragLayer; +import DragDropContext = ReactDnd.DragDropContext; +import HTML5Backend, { getEmptyImage } from 'react-dnd-html5-backend'; +import TestBackend = require('react-dnd/modules/backends/Test'); + +// Game Component +// ---------------------------------------------------------------------- + +namespace Game { + var knightPosition = [0, 0]; + var observer: any = null; + + function emitChange() { + observer(knightPosition); + } + + export function observe(o: any) { + if (observer) { + throw new Error("Multiple observers not implemented."); + } + + observer = o; + emitChange(); + } + + export function moveKnight(toX: number, toY: number) { + knightPosition = [toX, toY]; + emitChange(); + } + + export function canMoveKnight(toX: number, toY: number) { + const x = knightPosition[0]; + const y = knightPosition[1]; + const dx = toX - x; + const dy = toY - y; + + return (Math.abs(dx) === 2 && Math.abs(dy) === 1) || + (Math.abs(dx) === 1 && Math.abs(dy) === 2); + } +} + +var ItemTypes = { + KNIGHT: "knight" +}; + +// Knight Component +// ---------------------------------------------------------------------- + +namespace Knight { + interface KnightP extends React.Props { + connectDragSource: ReactDnd.ConnectDragSource; + connectDragPreview: ReactDnd.ConnectDragPreview; + isDragging: boolean; + } + + var knightSource: ReactDnd.DragSourceSpec = { + beginDrag: (props) => { + return {}; + } + }; + + function knightCollect(connect: ReactDnd.DragSourceConnector, monitor: ReactDnd.DragSourceMonitor) { + return { + connectDragSource: connect.dragSource(), + connectDragPreview: connect.dragPreview(), + isDragging: monitor.isDragging() + }; + } + + export class Knight extends React.Component { + static defaultProps: KnightP; + + static create = React.createFactory(Knight); + + componentDidMount() { + var img = getEmptyImage(); + img.onload = () => this.props.connectDragPreview(img); + } + + render() { + return this.props.connectDragSource( + r.div({ + style: { + opacity: this.props.isDragging ? 0.5 : 1, + fontSize: 25, + fontWeight: 'bold', + cursor: 'move' + } + }, "♘") + ); + } + } + + export var DndKnight = DragSource(ItemTypes.KNIGHT, knightSource, knightCollect)(Knight); + export var create = React.createFactory(DndKnight); +} + +// Square Component +// ---------------------------------------------------------------------- + +namespace Square { + interface SquareP extends React.Props { + black: boolean; + } + + export class Square extends React.Component { + render() { + var fill = this.props.black ? 'black' : 'white'; + return r.div({ + style: { + backgroundColor: fill + } + }) + } + } + + export var create = React.createFactory(Square); +} + +// BoardSquare Component +// ---------------------------------------------------------------------- + +namespace BoardSquare { + interface BoardSquareP extends React.Props { + x: number; + y: number; + connectDropTarget?: ReactDnd.ConnectDropTarget; + isOver?: boolean; + canDrop?: boolean; + } + + var boardSquareTarget: ReactDnd.DropTargetSpec = { + canDrop: (props) => Game.canMoveKnight(props.x, props.y), + drop: (props) => Game.moveKnight(props.x, props.y) + }; + + function boardSquareCollect(connect: ReactDnd.DropTargetConnector, monitor: ReactDnd.DropTargetMonitor) { + return { + connectDropTarget: connect.dropTarget(), + isOver: monitor.isOver(), + canDrop: monitor.canDrop() + }; + } + + export class BoardSquare extends React.Component { + static defaultProps: BoardSquareP; + + private _renderOverlay = (color: string) => { + return r.div({ + style: { + position: 'absolute', + top: 0, + left: 0, + height: '100%', + width: '100%', + zIndex: 1, + opacity: 0.5, + backgroundColor: color + } + }); + }; + + render() { + var black = (this.props.x + this.props.y) % 2 === 1; + var isOver = this.props.isOver; + var canDrop = this.props.canDrop; + + return this.props.connectDropTarget( + r.div({ + style: { + position: 'relative', + width: '100%', + height: '100%' + }, + children: [ + Square.create({ + black: black + }), + isOver && !canDrop ? this._renderOverlay('red') : null, + !isOver && canDrop ? this._renderOverlay('yellow') : null, + isOver && canDrop ? this._renderOverlay('green') : null + ] + }) + ); + } + } + + export var DndBoardSquare = DropTarget(ItemTypes.KNIGHT, boardSquareTarget, boardSquareCollect)(BoardSquare); + export var create = React.createFactory(DndBoardSquare); +} + +// Custom Drag Layer Component +// ---------------------------------------------------------------------- +namespace CustomDragLayer { + interface CustomDragLayerP extends React.Props { + isDragging?: boolean; + item?: Object; + } + + function dragLayerCollect(monitor: ReactDnd.DragLayerMonitor) { + return { + isDragging: monitor.isDragging(), + item: monitor.getItem(), + }; + } + + export class CustomDragLayer extends React.Component { + render() { + return r.div(null, this.props.isDragging ? this.props.item : null); + } + } + + export var dragLayer = DragLayer(dragLayerCollect)(CustomDragLayer); + + export var create = React.createFactory(dragLayer); +} + +// Board Component +// ---------------------------------------------------------------------- + +namespace Board { + interface BoardP extends React.Props { + knightPosition: number[]; + } + + export class Board extends React.Component { + private _renderPiece = (x: number, y: number) => { + var knightX = this.props.knightPosition[0]; + var knightY = this.props.knightPosition[1]; + return x === knightX && y === knightY ? + Knight.create() : + null; + }; + + private _renderSquare = (i: number) => { + var x = i % 8; + var y = Math.floor(i / 8); + + return r.div({ + key: i, + style: { + width: '12.5%', + height: '12.5%' + } + }, BoardSquare.create({ + x: x, + y: y + }, this._renderPiece(x, y))); + }; + + render() { + var squares: React.ReactHTMLElement[] = []; + for (let i = 0; i < 64; i++) { + squares.push(this._renderSquare(i)); + } + + return r.div({ + children: [ + CustomDragLayer.create(), + r.div({ + style: { + width: '100%', + height: '100%', + display: 'flex', + flexWrap: 'wrap' + }, + children: squares + }) + ] + }); + } + } + + export var createWithHTMLBackend = React.createFactory(DragDropContext(HTML5Backend)(Board)); + export var createWithTestBackend = React.createFactory(DragDropContext(TestBackend)(Board)); +} + +// Render the Board Component +// ---------------------------------------------------------------------- + +Board.createWithHTMLBackend({ + knightPosition: [0, 0] +}); + + +Board.createWithTestBackend({ + knightPosition: [0, 0] +}); diff --git a/react-dnd-html5-backend/react-dnd-html5-backend.d.ts b/react-dnd-html5-backend/react-dnd-html5-backend.d.ts new file mode 100644 index 0000000000..a635814842 --- /dev/null +++ b/react-dnd-html5-backend/react-dnd-html5-backend.d.ts @@ -0,0 +1,15 @@ +// Type definitions for React DnD Html5 Backend v2.1.2 +// Project: https://github.com/gaearon/react-dnd +// Definitions by: Pedro Pereira +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare module "react-dnd-html5-backend" { + import ReactDnd = __ReactDnd; + + export enum NativeTypes { FILE, URL, TEXT } + export function getEmptyImage(): any; // Image + export default class HTML5Backend implements __ReactDnd.Backend {} +} \ No newline at end of file From 2d8104f6f9c5ea09fc79e99eb60e679766872f08 Mon Sep 17 00:00:00 2001 From: oizie Date: Mon, 4 Jul 2016 11:47:20 +0100 Subject: [PATCH 026/279] Fixed test for react-dnd-html5-backend --- react-dnd-html5-backend/react-dnd-html5-backend-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts b/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts index 031c778653..c67f4b9ef5 100644 --- a/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts +++ b/react-dnd-html5-backend/react-dnd-html5-backend-tests.ts @@ -1,4 +1,4 @@ -/// +/// "use strict"; // Test adapted from the ReactDnD chess game tutorial: From db7290eda1a0e746c1542e012bd363ddf98b0cfe Mon Sep 17 00:00:00 2001 From: "yuichi.watanabe" Date: Mon, 4 Jul 2016 23:30:36 +0900 Subject: [PATCH 027/279] add type definitions of tinycopy --- tinycopy/tinycopy-tests.ts | 17 +++++++++++++++++ tinycopy/tinycopy.d.ts | 14 ++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tinycopy/tinycopy-tests.ts create mode 100644 tinycopy/tinycopy.d.ts diff --git a/tinycopy/tinycopy-tests.ts b/tinycopy/tinycopy-tests.ts new file mode 100644 index 0000000000..f695ebf19e --- /dev/null +++ b/tinycopy/tinycopy-tests.ts @@ -0,0 +1,17 @@ +/// + +import TinyCopy from 'tinycopy'; + +TinyCopy.exec('test', (err, data) => {}); + +var trigger_1 = document.getElementById('trigger_1'); +var target_1 = document.getElementById('target'); +new TinyCopy(trigger_1, target_1) + .on('success', function(data) {}) + .on('error', function(err) {}); + +var trigger_2 = document.getElementById('trigger_2'); +var target_2 = 'test'; +new TinyCopy(trigger_2, target_2) + .on('success', function(data) {}) + .on('error', function(err) {}); diff --git a/tinycopy/tinycopy.d.ts b/tinycopy/tinycopy.d.ts new file mode 100644 index 0000000000..33b7ae217c --- /dev/null +++ b/tinycopy/tinycopy.d.ts @@ -0,0 +1,14 @@ +// Type definitions for tinycopy 2.1.2 +// Project: https://github.com/vvatanabe/tinycopy +// Definitions by: Yuichi Watanabe +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "tinycopy" { + export default class TinyCopy { + constructor(trigger: Element, target: (string | Element | NodeListOf)); + on(type: "success", action: (data: string) => void): this; + on(type: "error", action: (err: Error) => void): this; + on(type: string, action: (e: (string | Error)) => void): this; + static exec(value: string, callback: (err?: Error, data?: string) => void): void; + } +} From d63782563fcbcb4e545b9abeaa6b0483101ef21d Mon Sep 17 00:00:00 2001 From: Jean-Philippe HAUTIN Date: Mon, 4 Jul 2016 18:01:59 +0200 Subject: [PATCH 028/279] update to use static methods. add missing Date.create(number) --- sugar/sugar.d.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sugar/sugar.d.ts b/sugar/sugar.d.ts index 217ffb110e..8f56fbff0a 100644 --- a/sugar/sugar.d.ts +++ b/sugar/sugar.d.ts @@ -907,7 +907,7 @@ interface String { } // Todo: fix when TypeScript supports adding static functions to native types. -interface NumberStatic { +interface NumberConstructor { /** * Returns a random integer between [n1] and [n2]. @@ -1963,8 +1963,8 @@ interface Number { upto(num: number, fn?: Function, step?: number): number[]; } -// Todo: Fix when TypeScript supports static members on native types. -interface ArrayStatic { +//Static members on native types. +interface ArrayConstructor { /** * Alternate array constructor. @@ -2918,7 +2918,7 @@ interface Array { //zip(...arrays: T[]): T[][]; } -interface ObjectStatic { +interface ObjectConstructor { /** * Creates a new object, equivalent to %new Object()% or %{}%, but with extended methods. @@ -4003,7 +4003,7 @@ interface Function { throttle(ms: number): Function; } -interface RegExpStatic { +interface RegExpConstructor { /** * Escapes all RegExp tokens in a string. @@ -4080,7 +4080,7 @@ interface Locale { timeParse: string[]; } -interface DateStatic { +interface DateConstructor { /** * Adds a locale to the locales understood by Sugar. @@ -4125,6 +4125,11 @@ interface DateStatic { **/ create(d: string, locale?: string): Date; + /** + * @see create + * @param timestamp + create(timestamp:number): Date; + /** * @see create * @param year Year YYYY From 6e54cb627506cf64d6effba1fe49b5a091ac4297 Mon Sep 17 00:00:00 2001 From: JodiWarren Date: Mon, 4 Jul 2016 17:20:08 +0100 Subject: [PATCH 029/279] Add missing currentTarget event property Closes #9899 --- jquery/jquery.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 5dc88bf795..0f72c709cf 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -442,6 +442,7 @@ interface JQueryDeferred extends JQueryGenericPromise { * Interface of the JQuery extension of the W3C event object */ interface BaseJQueryEventObject extends Event { + currentTarget: Element; data: any; delegateTarget: Element; isDefaultPrevented(): boolean; From 6dc5684fc878403ec7e65e7471fb6c16b6e56a61 Mon Sep 17 00:00:00 2001 From: Jean-Philippe HAUTIN Date: Mon, 4 Jul 2016 18:29:59 +0200 Subject: [PATCH 030/279] add posibility to create a date with no parameters ( 'now' ) --- sugar/sugar.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sugar/sugar.d.ts b/sugar/sugar.d.ts index 8f56fbff0a..6270ed2330 100644 --- a/sugar/sugar.d.ts +++ b/sugar/sugar.d.ts @@ -4128,7 +4128,7 @@ interface DateConstructor { /** * @see create * @param timestamp - create(timestamp:number): Date; + create(timestamp?: number): Date; /** * @see create From a1bc94c2570c279710f7a3f8cb6a3070ddf18336 Mon Sep 17 00:00:00 2001 From: jodi Warren Date: Mon, 4 Jul 2016 17:42:40 +0100 Subject: [PATCH 031/279] add test --- jquery/jquery-tests.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jquery/jquery-tests.ts b/jquery/jquery-tests.ts index a06c251b84..d031535184 100644 --- a/jquery/jquery-tests.ts +++ b/jquery/jquery-tests.ts @@ -1525,6 +1525,9 @@ function test_eventParams() { $(window).on('mousewheel', (e) => { var delta = (e.originalEvent).deltaY; }); + $( "p" ).click(function( event ) { + alert( event.currentTarget === this ); // true + }); } function test_extend() { From 41563f5421f08fdc9c194b943c5ec8780377c51c Mon Sep 17 00:00:00 2001 From: gentoo90 Date: Tue, 5 Jul 2016 10:12:47 +0300 Subject: [PATCH 032/279] Add host field to Dialog interface It should be set by DialogContext.addHost() according to durandals documentation. --- durandal/durandal.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/durandal/durandal.d.ts b/durandal/durandal.d.ts index c5ec79ae61..97e1307a0b 100644 --- a/durandal/durandal.d.ts +++ b/durandal/durandal.d.ts @@ -693,6 +693,7 @@ declare module 'plugins/dialog' { } interface Dialog { + host: HTMLElement; owner: any; context: DialogContext; activator: DurandalActivator; From 44bee9f24c14f22a57d897fce80c0ec42748ea52 Mon Sep 17 00:00:00 2001 From: Jonathon T Date: Tue, 5 Jul 2016 17:18:57 +1000 Subject: [PATCH 033/279] Added basic methods for angular-xeditable editable-form --- angular-xeditable/angular-xeditable.d.ts | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/angular-xeditable/angular-xeditable.d.ts b/angular-xeditable/angular-xeditable.d.ts index eaa1296886..01a19707e1 100644 --- a/angular-xeditable/angular-xeditable.d.ts +++ b/angular-xeditable/angular-xeditable.d.ts @@ -53,4 +53,46 @@ declare namespace angular.xeditable { */ activationEvent: string; } + + interface IEditableFormController extends angular.IFormController { + + /** + * Shows form with editable controls. + */ + $show(); + + /** + * Hides form with editable controls without saving. + */ + $hide(); + + /** + * Sets focus on form field specified by `name`.
+ * When trying to set the focus on a form field of a new row in the editable table, the `$activate` call needs to be wrapped in a `$timeout` call so that the form is rendered before the `$activate` function is called. + * + * @param name name of field + */ + $activate(name: string); + + /** + * Triggers `oncancel` event and calls `$hide()`. + */ + $cancel(); + + $setWaiting(value: boolean); + + /** + * Shows error message for particular field. + * + * @param name name of field + * @param msg error message + */ + $setError(name: string, msg: string); + + $submit(); + + $save(); + + } + } From 3255e07bcd49d146848f3ad36e521a5d6289533c Mon Sep 17 00:00:00 2001 From: Jonathon T Date: Tue, 5 Jul 2016 17:26:27 +1000 Subject: [PATCH 034/279] Added return types for angular-xeditable editable-form methods --- angular-xeditable/angular-xeditable.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/angular-xeditable/angular-xeditable.d.ts b/angular-xeditable/angular-xeditable.d.ts index 01a19707e1..026fc5d2fb 100644 --- a/angular-xeditable/angular-xeditable.d.ts +++ b/angular-xeditable/angular-xeditable.d.ts @@ -59,12 +59,12 @@ declare namespace angular.xeditable { /** * Shows form with editable controls. */ - $show(); + $show(): void; /** * Hides form with editable controls without saving. */ - $hide(); + $hide(): void; /** * Sets focus on form field specified by `name`.
@@ -72,14 +72,14 @@ declare namespace angular.xeditable { * * @param name name of field */ - $activate(name: string); + $activate(name: string): void; /** * Triggers `oncancel` event and calls `$hide()`. */ - $cancel(); + $cancel(): void; - $setWaiting(value: boolean); + $setWaiting(value: boolean): void; /** * Shows error message for particular field. @@ -87,11 +87,11 @@ declare namespace angular.xeditable { * @param name name of field * @param msg error message */ - $setError(name: string, msg: string); + $setError(name: string, msg: string): void; - $submit(); + $submit(): void; - $save(); + $save(): void; } From 834e9452c2d89cc64e39c1d9ec281f653c35415d Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Tue, 5 Jul 2016 09:48:53 +0200 Subject: [PATCH 035/279] second argument of `EventEmitter#off` is optional See https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/eventemitter3/eventemitter3.d.ts#L97 --- pixi.js/pixi.js.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pixi.js/pixi.js.d.ts b/pixi.js/pixi.js.d.ts index 2b1565f7d6..68384fa9ec 100644 --- a/pixi.js/pixi.js.d.ts +++ b/pixi.js/pixi.js.d.ts @@ -90,7 +90,7 @@ declare namespace PIXI { removeListener(event: string, fn: Function, context?: any, once?: boolean): EventEmitter; removeAllListeners(event: string): EventEmitter; - off(event: string, fn: Function, context?: any, once?: boolean): EventEmitter; + off(event: string, fn?: Function, context?: any, once?: boolean): EventEmitter; addListener(event: string, fn: Function, context?: any): EventEmitter; } From 46c35115c9e8b1dcc54159b09fd815beb5592fa4 Mon Sep 17 00:00:00 2001 From: york yao Date: Tue, 5 Jul 2016 19:23:07 +0800 Subject: [PATCH 036/279] add missing pexpire and pexpireat --- ioredis/ioredis.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ioredis/ioredis.d.ts b/ioredis/ioredis.d.ts index 42a498addc..a3769fee6c 100644 --- a/ioredis/ioredis.d.ts +++ b/ioredis/ioredis.d.ts @@ -230,8 +230,12 @@ declare module IORedis { renamenx(...args: any[]): any; expire(args: any[], callback?: ResCallbackT): any; expire(...args: any[]): any; + pexpire(args: any[], callback?: ResCallbackT): any; + pexpire(...args: any[]): any; expireat(args: any[], callback?: ResCallbackT): any; expireat(...args: any[]): any; + pexpireat(args: any[], callback?: ResCallbackT): any; + pexpireat(...args: any[]): any; keys(args: any[], callback?: ResCallbackT): any; keys(...args: any[]): any; dbsize(args: any[], callback?: ResCallbackT): any; @@ -507,8 +511,12 @@ declare module IORedis { renamenx(...args: any[]): Pipeline; expire(args: any[], callback?: ResCallbackT): Pipeline; expire(...args: any[]): Pipeline; + pexpire(args: any[], callback?: ResCallbackT): Pipeline; + pexpire(...args: any[]): Pipeline; expireat(args: any[], callback?: ResCallbackT): Pipeline; expireat(...args: any[]): Pipeline; + pexpireat(args: any[], callback?: ResCallbackT): Pipeline; + pexpireat(...args: any[]): Pipeline; keys(args: any[], callback?: ResCallbackT): Pipeline; keys(...args: any[]): Pipeline; dbsize(args: any[], callback?: ResCallbackT): Pipeline; From 37e93445986a98b9be57680de1e102ca384e0531 Mon Sep 17 00:00:00 2001 From: Endel Dreyer Date: Tue, 5 Jul 2016 13:45:40 +0200 Subject: [PATCH 037/279] optional `event` parameter when removing listeners --- pixi.js/pixi.js.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pixi.js/pixi.js.d.ts b/pixi.js/pixi.js.d.ts index 68384fa9ec..dfccd33431 100644 --- a/pixi.js/pixi.js.d.ts +++ b/pixi.js/pixi.js.d.ts @@ -87,8 +87,8 @@ declare namespace PIXI { emit(event: string, ...args: any[]): boolean; on(event: string, fn: Function, context?: any): EventEmitter; once(event: string, fn: Function, context?: any): EventEmitter; - removeListener(event: string, fn: Function, context?: any, once?: boolean): EventEmitter; - removeAllListeners(event: string): EventEmitter; + removeListener(event: string, fn?: Function, context?: any, once?: boolean): EventEmitter; + removeAllListeners(event?: string): EventEmitter; off(event: string, fn?: Function, context?: any, once?: boolean): EventEmitter; addListener(event: string, fn: Function, context?: any): EventEmitter; From e111a97d1524dd6ca4f1af002d1b0b4da654af25 Mon Sep 17 00:00:00 2001 From: ziv Date: Tue, 5 Jul 2016 14:46:08 +0300 Subject: [PATCH 038/279] adding typing for scroll-into-view --- scroll-into-view/scroll-into-view-tests.ts | 24 +++++++++++++++ scroll-into-view/scroll-into-view.d.ts | 36 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 scroll-into-view/scroll-into-view-tests.ts create mode 100644 scroll-into-view/scroll-into-view.d.ts diff --git a/scroll-into-view/scroll-into-view-tests.ts b/scroll-into-view/scroll-into-view-tests.ts new file mode 100644 index 0000000000..b3b771835c --- /dev/null +++ b/scroll-into-view/scroll-into-view-tests.ts @@ -0,0 +1,24 @@ +/// +import * as scrollIntoView from "scroll-into-view" + +var someElement: HTMLElement +scrollIntoView(someElement); + +scrollIntoView(someElement, { + time: 500, // half a second + ease: function(value){ + return Math.pow(value,2) - value); // Do something weird. + }, + validTarget: function(target, parentsScrolled){ + return parentsScrolled < 2 && !target.matches('.dontScroll'); + }, + align:{ + top: 0, + left: 1 + } +}); + +scrollIntoView(someElement, function(type){ + // Scrolling done. + // type will be 'complete' if the scroll completed or 'canceled' if the current scroll was canceled by a new scroll +}) \ No newline at end of file diff --git a/scroll-into-view/scroll-into-view.d.ts b/scroll-into-view/scroll-into-view.d.ts new file mode 100644 index 0000000000..b587f36142 --- /dev/null +++ b/scroll-into-view/scroll-into-view.d.ts @@ -0,0 +1,36 @@ +// Type definitions for scroll-into-view 1.6.0 +// Project: https://github.com/KoryNunn/scroll-into-view +// Definitions by: zivni https://github.com/zivni +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module __ScrollIntoView { + + interface Settings { + time?: number + ease?: (value: number) => number + validTarget?: (target: HTMLElement, parentsScrolled: number) => boolean + align?: Alignment + } + + interface Alignment { + /** 0 to 1, default 0.5 (center) */ + top?: number + /** 0 to 1, default 0.5 (center) */ + left?: number + } + + /** type will be 'complete' if the scroll completed or 'canceled' if the current scroll was canceled by a new scroll */ + type callbackParamterType = "complete" | "canceled" + type Callback = (type: callbackParamterType) => void + + interface ScrollIntoView { + (target: HTMLElement, callback?: __ScrollIntoView.Callback) : void + (target: HTMLElement, settings: __ScrollIntoView.Settings, callback?: __ScrollIntoView.Callback) : void + } + +} + +declare module "scroll-into-view" { + var scrollIntoView: __ScrollIntoView.ScrollIntoView + export = scrollIntoView; +} From 674fdd2fc9658005fe7aebca9a552beb1205aa2a Mon Sep 17 00:00:00 2001 From: Alex Kozack Date: Tue, 5 Jul 2016 16:09:18 +0300 Subject: [PATCH 039/279] Add chrome.app.getDetails() function --- chrome/chrome-app.d.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/chrome/chrome-app.d.ts b/chrome/chrome-app.d.ts index 3b63357986..1019f4066c 100644 --- a/chrome/chrome-app.d.ts +++ b/chrome/chrome-app.d.ts @@ -6,6 +6,17 @@ /// /// +//////////////////// +// App +//////////////////// +declare namespace chrome.app { + interface AppDetails extends chrome.runtime.Manifest { + id: string; + } + + export function getDetails(): AppDetails; +} + //////////////////// // App Runtime //////////////////// From 18396bd284b6608e80e2de56ad042fcc6815b625 Mon Sep 17 00:00:00 2001 From: Travis Hill Date: Tue, 5 Jul 2016 09:40:51 -0400 Subject: [PATCH 040/279] Added missing methods to JoinClause object --- knex/knex.d.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/knex/knex.d.ts b/knex/knex.d.ts index 74ea935911..771cc39cbf 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -179,6 +179,20 @@ declare module "knex" { on(column1: string, column2: string): JoinClause; on(column1: string, raw: Raw): JoinClause; on(column1: string, operator: string, column2: string): JoinClause; + andOn(raw: Raw): JoinClause; + andOn(callback: Function): JoinClause; + andOn(columns: {[key: string]: string|Raw}): JoinClause; + andOn(column1: string, column2: string): JoinClause; + andOn(column1: string, raw: Raw): JoinClause; + andOn(column1: string, operator: string, column2: string): JoinClause; + orOn(raw: Raw): JoinClause; + orOn(callback: Function): JoinClause; + orOn(columns: {[key: string]: string|Raw}): JoinClause; + orOn(column1: string, column2: string): JoinClause; + orOn(column1: string, raw: Raw): JoinClause; + orOn(column1: string, operator: string, column2: string): JoinClause; + using(column: string|string[]|Raw|{[key: string]: string|Raw}): JoinClause; + type(type: string): JoinClause; } interface JoinRaw { From 19cc1c2dda796a2488db1d97bd86cf6d48b10421 Mon Sep 17 00:00:00 2001 From: Travis Hill Date: Tue, 5 Jul 2016 09:42:23 -0400 Subject: [PATCH 041/279] Fixed formatting --- knex/knex.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/knex/knex.d.ts b/knex/knex.d.ts index 771cc39cbf..24020b0083 100644 --- a/knex/knex.d.ts +++ b/knex/knex.d.ts @@ -192,7 +192,7 @@ declare module "knex" { orOn(column1: string, raw: Raw): JoinClause; orOn(column1: string, operator: string, column2: string): JoinClause; using(column: string|string[]|Raw|{[key: string]: string|Raw}): JoinClause; - type(type: string): JoinClause; + type(type: string): JoinClause; } interface JoinRaw { From 69408e5daf3669fac2120d3298abc1948dd0463b Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Tue, 5 Jul 2016 17:33:50 +0200 Subject: [PATCH 042/279] Added missing itemClickEvent option --- jquery.contextMenu/jquery.contextMenu.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/jquery.contextMenu/jquery.contextMenu.d.ts b/jquery.contextMenu/jquery.contextMenu.d.ts index 030a83f9f6..4b52a0ed84 100644 --- a/jquery.contextMenu/jquery.contextMenu.d.ts +++ b/jquery.contextMenu/jquery.contextMenu.d.ts @@ -28,6 +28,7 @@ interface JQueryContextMenuOptions { items: any; reposition?: boolean; className?: string; + itemClickEvent?: string; } interface JQueryStatic { From 663c838a5805b3032c46302cca7841a3eef0e545 Mon Sep 17 00:00:00 2001 From: Ian Grayson Date: Tue, 5 Jul 2016 10:27:30 -0700 Subject: [PATCH 043/279] Create ssh2-sftp-client.d.ts --- ssh2-sftp-client/ssh2-sftp-client-tests.ts | 27 +++++++++++++ ssh2-sftp-client/ssh2-sftp-client.d.ts | 47 ++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 ssh2-sftp-client/ssh2-sftp-client-tests.ts create mode 100644 ssh2-sftp-client/ssh2-sftp-client.d.ts diff --git a/ssh2-sftp-client/ssh2-sftp-client-tests.ts b/ssh2-sftp-client/ssh2-sftp-client-tests.ts new file mode 100644 index 0000000000..0c2709bf61 --- /dev/null +++ b/ssh2-sftp-client/ssh2-sftp-client-tests.ts @@ -0,0 +1,27 @@ +/// + +import * as Client from 'ssh2-sftp-client'; +var client = new Client(); + +client.connect({ + host: 'asdb', + port: 1234, + privateKey: 'my private key rsa in openssh format', + readyTimeout: 1000, +}).then(() => null); + +client.list('/remote/path').then(() => null); + +client.get('/remote/path').then(stream => stream.read(0)); + +client.put('/local/path', '/remote/path').then(() => null); + +client.put(new Buffer('content'), '/remote/path').then(() => null); + +client.mkdir('/remote/path/dir', true).then(() => null); + +client.delete('remote/path').then(() => null); + +client.remove('/remote/from', '/remote/to').then(() => null); + +client.end().then(() => null); \ No newline at end of file diff --git a/ssh2-sftp-client/ssh2-sftp-client.d.ts b/ssh2-sftp-client/ssh2-sftp-client.d.ts new file mode 100644 index 0000000000..1676ad0077 --- /dev/null +++ b/ssh2-sftp-client/ssh2-sftp-client.d.ts @@ -0,0 +1,47 @@ +// Type definitions for ssh2-sftp-client v1.0.5 +// Project: https://www.npmjs.com/package/ssh2-sftp-client +// Definitions by: igrayson +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "ssh2-sftp-client" { + import * as ssh2 from 'ssh2'; + + namespace sftp { + + interface FileInfo { + type:string; + name:string; + size:number; + modifyTime:number; + accessTime:number; + rights:{ + user:string; + group:string; + other:string; + }; + owner:number; + group:number; + } + + interface Client { + new():Client; + connect(options:ssh2.ConnectConfig):Promise; + list(remoteFilePath:string):Promise>; + get(remoteFilePath:string, useCompression?:boolean):Promise; + put(localFilePath:string, remoteFilePath:string, useCompression?:boolean):Promise; + put(buffer:Buffer, remoteFilePath:string, useCompression?:boolean):Promise; + put(stream:NodeJS.ReadableStream, remoteFilePath:string, useCompression?:boolean):Promise; + mkdir(remoteFilePath:string, recursive?:boolean):Promise; + delete(remoteFilePath:string):Promise; + remove(remoteSourcePath:string, remoteDestPath:string):Promise; + end():Promise; + } + } + + var sftp:sftp.Client; + + export = sftp; +} + From 566e3c0f7cec844ce3ad52f582dc922d306fe501 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Tue, 5 Jul 2016 21:32:26 +0200 Subject: [PATCH 044/279] React motion update --- react-motion/react-motion-tests.tsx | 87 ++++++++++++++++++++++- react-motion/react-motion.d.ts | 105 +++++++++++++++++++++++----- 2 files changed, 174 insertions(+), 18 deletions(-) diff --git a/react-motion/react-motion-tests.tsx b/react-motion/react-motion-tests.tsx index 0ff53dae4a..db7a28c921 100644 --- a/react-motion/react-motion-tests.tsx +++ b/react-motion/react-motion-tests.tsx @@ -3,7 +3,7 @@ /// import * as React from 'react'; -import {Motion, spring} from 'react-motion'; +import {StaggeredMotion, Motion, spring, TransitionMotion, TransitionPlainStyle, TransitionStyle, Style, PlainStyle} from 'react-motion'; class Root extends React.Component<{}, {}> { @@ -15,3 +15,88 @@ class Root extends React.Component<{}, {}> { ); } } + +class TransitionTest extends React.Component<{}, {}> { + render() { + return ( + + {this.renderItems.bind(this)} + + ); + } + + getDefaultStyles(): TransitionPlainStyle[] { + return [1, 2, 3].map(num => { + const style: PlainStyle = { + height: 0 + }; + return { + key: `${num}`, + data: num, + style: style + }; + }) + } + + getStyles(): TransitionStyle[] { + return [1, 2, 3].map(num => { + const style: Style = { + height: spring(10) + }; + return { + key: `${num}`, + data: num, + style: style + } + }); + } + + renderItems(interpolatedItems: TransitionStyle[]): JSX.Element { + return ( +

+ ) + } +} + +class StaggeredTest extends React.Component<{}, {}> { + render() { + return ( + + + ) + } + + getStyles(prevInterpolatedStyles: PlainStyle[]): Style[] { + return prevInterpolatedStyles.map((prevStyle, index) => { + const style: Style = {}; + style['h'] = (index === 0) ? spring(100) : spring(prevInterpolatedStyles[index - 1]['h']); + return style; + }) + } + + renderItems(interpolatedItems: PlainStyle[]): JSX.Element { + return ( +
+ {interpolatedItems.map((style, index) => { + return ( +
+ ) + })} +
+ ) + } +} diff --git a/react-motion/react-motion.d.ts b/react-motion/react-motion.d.ts index f868d084d2..627717d118 100644 --- a/react-motion/react-motion.d.ts +++ b/react-motion/react-motion.d.ts @@ -1,12 +1,13 @@ // Type definitions for react-motion // Project: https://github.com/chenglou/react-motion -// Definitions by: Stepan Mikhaylyuk +// Definitions by: Stepan Mikhaylyuk , Alexey Svetliakov // Definitions: https://github.com/borisyankov/DefinitelyTyped /// declare module "react-motion" { - import { Component } from 'react'; + import { Component, ReactElement } from 'react'; + // your typical style object given in props. Maps to a number or a spring config export type Style = { [key: string]: number | OpaqueConfig }; @@ -16,37 +17,82 @@ declare module "react-motion" { // internal velocity object. Similar to PlainStyle, but whose numbers represent // speed. Might be exposed one day. export type Velocity = { [key: string]: number }; + + /** + * Spring additional configuration + */ interface SpringHelperConfig { - stiffness: number; - damping: number; /** - * Specifies both the rounding of the interpolated value and the speed (internal). - */ + * Specified stiffness + * @defaults 170 + */ + stiffness?: number; + /** + * Specifies damping + * @defaults 26 + */ + damping?: number; + /** + * Specifies both the rounding of the interpolated value and the speed (internal). + * @defaults 0.01 + */ precision?: number; - // TODO: add onRest. Not public yet } + export interface OpaqueConfig { val: number; stiffness: number; damping: number; precision: number; - // TODO: add onRest. Not public yet } + /** + * properties + */ interface MotionProps { - defaultStyle?: any; - style: any; + /** + * The default style. Being ignored on subsequent renders + * @default Object with same keys as in style whose values are the initial numbers you're interpolating on + */ + defaultStyle?: PlainStyle; + /** + * Object that maps to either number or opaque config returned by spring(). + * Must keep same keys throughout component's existence + */ + style: Style; + /** + * Callback with your interpolated styles. Must return one react element to render + * @param interpolatedStyle + */ + children?: (interpolatedStyle: PlainStyle) => ReactElement; + /** + * The callback that fires when the animation comes to a rest. + */ + onRest?: () => void; } export class Motion extends Component { } // === TransitionMotion === interface TransitionStyle { - key: any; // unique ID to identify component across render animations - data?: any; // optional data you want to carry along the style, e.g. itemText + /** + * The ID that TransitionMotion uses to track which configuration is which across renders, even when things are reordered. + * Typically reused as the component key when you map over the interpolated styles. + */ + key: string; + /** + * Anything you'd like to carry along. Will be preserved on re-renders until key off + */ + data?: any; + /** + * Actual starting style configuration + */ style: Style; // actual style you're passing } + /** + * Default style for transition + */ interface TransitionPlainStyle { key: any; data?: any; @@ -54,18 +100,43 @@ declare module "react-motion" { style: PlainStyle; } type InterpolateFunction = (previousInterpolatedStyles?: Array) => Array; - type Styles = Array | InterpolateFunction; + /** + * Transition properties + */ interface TransitionProps { + /** + * Default styles on first render + */ defaultStyles?: Array; - styles: Styles; - children: (interpolatedStyles: Array) => __React.ReactElement; + /** + * Styles to interpolate. Accepts array of TransitionStyle objects or interpolated function similar as for + * + */ + styles: Array | InterpolateFunction; + children?: (interpolatedStyles: Array) => ReactElement; + /** + * Triggers when new elements appears + * @param styleThatEntered + */ willEnter?: (styleThatEntered: TransitionStyle) => PlainStyle; - willLeave?: (styleThatLeft: TransitionStyle) => Style; + /** + * Triggers when new element disappears + * @param styleThatLeft + */ + willLeave?: (styleThatLeft: TransitionStyle) => Style | void; } - export class TransitionMotion extends Component { } + export class TransitionMotion extends Component { } + interface StaggeredMotionProps { + /** + * Default styles + */ defaultStyles?: Array; + /** + * Styles to interpolate + * @param previousInterpolatedStyles The previously interpolating (array of) styles (undefined at first render, unless defaultStyles is provided). + */ styles: (previousInterpolatedStyles?: Array) => Array + +
+ ) + } +} + + +Radium.TestMode.enable(); diff --git a/radium/radium.d.ts b/radium/radium.d.ts index 2e931c6e01..1989156877 100644 --- a/radium/radium.d.ts +++ b/radium/radium.d.ts @@ -112,7 +112,7 @@ declare module 'radium' { } // @Radium decorator function Radium(component: TElement): TElement; - function Radium(config: Radium.RadiumConfig): (component?: TElement) => TElement; + function Radium(config: Radium.RadiumConfig): (component?: any) => any; export = Radium; } From 1a9041ce005862fc52306f32f13ff7191719077f Mon Sep 17 00:00:00 2001 From: Dasa Paddock Date: Tue, 5 Jul 2016 15:43:36 -0700 Subject: [PATCH 049/279] Update for ArcGIS API for JavaScript version 3.17 --- arcgis-js-api/arcgis-js-api.d.ts | 206 ++++++++++++++++++++++++------- 1 file changed, 162 insertions(+), 44 deletions(-) diff --git a/arcgis-js-api/arcgis-js-api.d.ts b/arcgis-js-api/arcgis-js-api.d.ts index 01d8a02c12..65765fbb09 100644 --- a/arcgis-js-api/arcgis-js-api.d.ts +++ b/arcgis-js-api/arcgis-js-api.d.ts @@ -1,4 +1,4 @@ -// Type definitions for ArcGIS API for JavaScript v3.16 +// Type definitions for ArcGIS API for JavaScript v3.17 // Project: http://js.arcgis.com // Definitions by: Esri // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -18,7 +18,6 @@ declare module "esri" { import BasemapLayer = require("esri/dijit/BasemapLayer"); import Symbol = require("esri/symbols/Symbol"); import BookmarkItem = require("esri/dijit/BookmarkItem"); - import Units = require("esri/units"); import Color = require("esri/Color"); import LocationProviderBase = require("esri/tasks/locationproviders/LocationProviderBase"); import PictureMarkerSymbol = require("esri/symbols/PictureMarkerSymbol"); @@ -45,6 +44,7 @@ declare module "esri" { import QueryTask = require("esri/tasks/QueryTask"); import TextSymbol = require("esri/symbols/TextSymbol"); import StandardGeographyQueryTask = require("esri/tasks/geoenrichment/StandardGeographyQueryTask"); + import WMSLayerInfo = require("esri/layers/WMSLayerInfo"); import WMTSLayerInfo = require("esri/layers/WMTSLayerInfo"); export interface AGSMouseEvent extends MouseEvent { @@ -354,7 +354,7 @@ declare module "esri" { /** Radius of the circle. */ radius?: number; /** Unit of the radius. */ - radiusUnit?: Units; + radiusUnit?: string; } export interface CircleOptions2 { /** The center point of the circle. */ @@ -366,7 +366,7 @@ declare module "esri" { /** The radius of the circle. */ radius?: number; /** Unit of the radius. */ - radiusUnit?: Units; + radiusUnit?: string; } export interface ClassedColorSliderOptions { /** Data map containing renderer information. */ @@ -643,6 +643,8 @@ declare module "esri" { minStops?: number; /** When true, stops on the route are re-ordered to provide an optimal route. */ optimalRoute?: boolean; + /** If specified, this specifies the portal where the produced route layers are going to be stored and accessed. */ + portalUrl?: string; /** URL link to a custom print page. */ printPage?: string; /** If available, this print task is used to display an overview map of the route on the directions print page (Added at v3.11). */ @@ -677,6 +679,8 @@ declare module "esri" { showReturnToStartOption?: boolean; /** Display the 'Show Reverse Stops' button. */ showReverseStopsButton?: boolean; + /** Applicable if the widget works with a Network Analyst Server federated with ArcGIS Online or Portal. */ + showSaveButton?: boolean; /** Highlight the route segment when a directions step is clicked. */ showSegmentHighlight?: boolean; /** Display a popup with segment details when a direction step is clicked. */ @@ -911,6 +915,8 @@ declare module "esri" { layer: FeatureLayer; } export interface FeatureTableOptions { + /** The number of features a service will try to fetch. */ + batchCount?: number; /** Object defining the date options specifically for formatting date and time editors. */ dateOptions?: any; /** Sets the editing state for the FeatureTable. */ @@ -931,12 +937,18 @@ declare module "esri" { menuFunctions?: any[]; /** Attribute fields to include in the FeatureTable. */ outFields?: string[]; + /** Displays or hides the attachment column. */ + showAttachments?: boolean; /** Displays the data type of the field right under the field label. */ showDataTypes?: boolean; + /** Displays or hides total number of features and selected number of features in the grid header. */ + showFeatureCount?: boolean; /** Displays or hides the FeatureTable header. */ showGridHeader?: boolean; /** Displays or hides 'Options' drop-down menu of the FeatureTable. */ showGridMenu?: boolean; + /** Displays or hides the 'Statistics' option in column menus for numeric fields. */ + showStatistics?: boolean; /** Enables an interaction between the map and the feature table. */ syncSelection?: boolean; /** Enables pan/zoom to selected features on the map when the table in 'sync selection' mode. */ @@ -1187,10 +1199,20 @@ declare module "esri" { gdbVersion?: string; } export interface ImageServiceMeasureOptions { + /** The angular unit in which directions of line segments will be calculated. */ + angularUnit?: string; + /** The area unit in which areas of polygons will be calculated. */ + areaUnit?: string; + /** Defines whether to show the widget result in a popup or in the widget's result area when the widget has 'toolbar' layout. */ + displayMeasureResultInPopup?: boolean; /** Symbol to be used when drawing a polygon or extent. */ fillSymbol?: SimpleFillSymbol; /** Image service layer with which the toolbar is associated. */ layer: ArcGISImageServiceLayer; + /** Defines the layout of the widget. */ + layout?: string; + /** The linear unit in which height, length, or perimeters will be calculated. */ + linearUnit?: string; /** Symbol to be used when drawing a line. */ lineSymbol?: SimpleLineSymbol; /** Map instance with which the toolbar is associate. */ @@ -1402,9 +1424,9 @@ declare module "esri" { /** Flag for showing full list of units in the Location tool. */ advancedLocationUnits?: boolean; /** The default area unit for the measure area tool. */ - defaultAreaUnit?: Units; + defaultAreaUnit?: string; /** The default length unit for the measure distance tool. */ - defaultLengthUnit?: Units; + defaultLengthUnit?: string; /** Allows the user to immediately measure previously-created geometry on dijit creation. */ geometry?: Point | Polyline | Polygon; /** Line symbol used to draw the lines for the measure line and measure distance tools. */ @@ -2190,6 +2212,28 @@ declare module "esri" { /** The well-known ID of the spatial reference used by the WFSLayer. */ wkid?: string; } + export interface WMSLayerInfoOptions { + /** All the bounding extents defined for this layer. */ + allExtents?: Extent[]; + /** A description of the WMS layer. */ + description?: string; + /** The extent of the WMS Layer. */ + extent?: Extent; + /** The URL to the legend image. */ + legendURL?: string; + /** The name of the WMS layer. */ + name: string; + /** Returns true if the layer can be queried and the service supports GetFeatureInfo with either text/html or text/plain formats. */ + queryable?: boolean; + /** Indicates if this layer should be included in the popup. */ + showPopup?: boolean; + /** All the spatial references defined for this layer. */ + spatialReferences?: SpatialReference[]; + /** WMSLayerInfos of the layer's sub layers. */ + subLayers?: WMSLayerInfo[]; + /** The title of the WMS layer. */ + title?: string; + } export interface WMSLayerOptions { /** Specify the map image format, valid options are png,jpg,bmp,gif,svg. */ format?: string; @@ -3732,6 +3776,8 @@ declare module "esri/dijit/Directions" { maxStopsReached: boolean; /** Read-only: The graphic for the calculated route. */ mergedRouteGraphic: Graphic; + /** If specified, this specifies the portal where the produced route layers are going to be stored and accessed. */ + portalUrl: string; /** Routing parameters for the widget. */ routeParams: RouteParameters; /** Routing task for the widget. */ @@ -3744,6 +3790,8 @@ declare module "esri/dijit/Directions" { showClearButton: boolean; /** If true, the toggle button group allowing user to choose between Miles and Kilometers is shown. */ showMilesKilometersOption: boolean; + /** Applicable if the widget works with a Network Analyst Server federated with ArcGIS Online or Portal. */ + showSaveButton: boolean; /** If true, and supported by the service, then two toggle button groups are shown: one to allow user to choose between driving a car, a truck, or walking, and one more group to choose between fastest or shortest routes. */ showTravelModesOption: boolean; /** An array of graphics that define the stop locations along the route. */ @@ -3792,6 +3840,11 @@ declare module "esri/dijit/Directions" { * @param index The index of the route segment to highlight. */ highlightSegment(index: number): void; + /** + * Loads a stored route layer from either ArcGIS Online or Portal + * @param itemId The itemId of the stored route layer from either ArcGIS Online or Portal. + */ + loadRoute(itemId: string): any; /** * Remove the stop at the specified index. * @param index The index of the stop to remove. @@ -3801,6 +3854,16 @@ declare module "esri/dijit/Directions" { removeStops(): any; /** Resets the directions widget removing any directions, stops and map graphics. */ reset(): any; + /** + * Specify the language used for the directions. + * @param locale The locale used for the directions. + */ + setDirectionsLanguage(locale: string): any; + /** + * Specify the length units used for the directions widget. + * @param units The length units used for the directions widget. + */ + setDirectionsLengthUnits(units: string): any; /** * If widget runs with Travel Modes enabled, call this method to switch to particular Travel mode programmatically. * @param travelModeName Travel mode. @@ -3843,10 +3906,16 @@ declare module "esri/dijit/Directions" { on(type: "directions-finish", listener: (event: { result: RouteResult; target: Directions }) => void): esri.Handle; /** Fires when the route services starts to calculate the route. */ on(type: "directions-start", listener: (event: { target: Directions }) => void): esri.Handle; + /** Fires after a user clicks the Save or Save as New button and subsequently does not have permission to create an item in ArcGIS Online or Portal. */ + on(type: "feature-collection-created", listener: (event: { target: Directions }) => void): esri.Handle; /** Fires when the directions widget has fully loaded. */ on(type: "load", listener: (event: { target: Directions }) => void): esri.Handle; /** Fires when the widget starts or stops listening for map clicks. */ on(type: "map-click-active", listener: (event: { mapClickActive: boolean; target: Directions }) => void): esri.Handle; + /** Fires after a user clicks the Save or Save as New button for the first time in order to store a new route in either ArcGIS Online or Portal. */ + on(type: "route-item-created", listener: (event: { target: Directions }) => void): esri.Handle; + /** Fires when a existing route layer item is successfully updated in ArcGIS Online or Portal after user clicks the Save button. */ + on(type: "route-item-updated", listener: (event: { target: Directions }) => void): esri.Handle; /** Fired when you hover over a route segment in the directions display. */ on(type: "segment-highlight", listener: (event: { graphic: Graphic; target: Directions }) => void): esri.Handle; /** Fires when a route segment is selected in the directions display. */ @@ -3901,6 +3970,8 @@ declare module "esri/dijit/FeatureTable" { /** Creates an instance of the FeatureTable widget within the provided DOM node. */ class FeatureTable { + /** The number of features a service will try to fetch. */ + batchCount: number; /** Read-only: A reference to the column objects and their parameters. */ columns: any[]; /** Read-only: Reference to the dataStore used by the dGrid. */ @@ -3909,6 +3980,8 @@ declare module "esri/dijit/FeatureTable" { dateOptions: any; /** Sets the editing state for the FeatureTable. */ editable: boolean; + /** Event trigger(s) used to display editing interface for an individual cell. */ + editOn: string | any; /** Read-only: Number of records displayed in FeatureTable. */ featureCount: number; /** The featureLayer that the table is associated with. */ @@ -3937,12 +4010,18 @@ declare module "esri/dijit/FeatureTable" { selectedRowIds: number[]; /** Read-only: Each element in the array is an object that contains name-value pair of fields and field values associated with the selected rows. */ selectedRows: any[]; - /** Displays the data type of the field right under the field label in the column header. */ + /** Displays or hides the attachment column. */ + showAttachments: boolean; + /** Displays or hides the data type of the field right under the field label in the column header. */ showDataTypes: boolean; + /** Displays or hides total number of features and selected number of features in the grid header. */ + showFeatureCount: boolean; /** Displays or hides the FeatureTable header. */ showGridHeader: boolean; /** Displays or hides 'Options' drop-down menu of the FeatureTable. */ showGridMenu: boolean; + /** Displays or hides the 'Statistics' option in column menus for numeric fields. */ + showStatistics: boolean; /** Enables an interaction between the map and the feature table. */ syncSelection: boolean; /** Enables pans to selected features on the map when the table in 'sync selection' mode. */ @@ -3953,6 +4032,29 @@ declare module "esri/dijit/FeatureTable" { * @param srcNodeRef Reference or id of a HTML element that this dijit is rendered into. */ constructor(params: esri.FeatureTableOptions, srcNodeRef: Node | string); + /** Removes all current selections including subsets from filterSelectedRecords(). */ + clearSelection(): void; + /** Destroys the FeatureTable widget. */ + destroy(): void; + /** + * Allows users to see the sub-set of currently selected records (uses dGrid.query). + * @param toggle When true only a subset of currently selected features will be displayed in the FeatureTable. + */ + filterSelectedRecords(toggle: boolean): void; + /** + * Queries and gets selected features from the FeatureLayer instead of the store. + * @param id Array of row ids + */ + getFeatureDataById(id: number[]): any; + /** + * Gets row object by the row ID. + * @param id row ID + */ + getRowDataById(id: number): any; + /** Refreshes the data in the grid. */ + refresh(): void; + /** Resizes the grid's container. */ + resize(): void; /** Finalizes the creation of the widget. */ startup(): void; /** Fires when the grid column is resized. */ @@ -4286,8 +4388,13 @@ declare module "esri/dijit/ImageServiceMeasure" { /** * Creates an instance of the ImageServiceMeasure widget. * @param params An Object containing constructor options. + * @param srcNode Reference or id of the HTML element where the widget should be rendered. */ - constructor(params: esri.ImageServiceMeasureOptions); + constructor(params: esri.ImageServiceMeasureOptions, srcNode: Node | string); + /** Destroys the ImageServiceMeasure widget. */ + destroy(): void; + /** Finalizes the creation of the widget. */ + startup(): void; } export = ImageServiceMeasure; } @@ -4528,9 +4635,14 @@ declare module "esri/dijit/LayerSwipe" { declare module "esri/dijit/Legend" { import esri = require("esri"); + import Map = require("esri/map"); /** The legend dijit displays a label and symbol for some or all of the layers in the map. */ class Legend { + /** Specify a subset of the layers in the map to display in the legend. */ + layerInfos: any[]; + /** Reference to the map. */ + map: Map; /** * Creates a new Legend dijit. * @param params Parameters used to configure the dijit. @@ -4555,7 +4667,7 @@ declare module "esri/dijit/LocateButton" { import Symbol = require("esri/symbols/Symbol"); import Graphic = require("esri/graphic"); - /** LocateButton provides a simple button to locate and zoom to the users current location. */ + /** LocateButton provides a simple button to locate and zoom to the user's location. */ class LocateButton { /** Centers the map to the location when a new position is returned. */ centerAt: boolean; @@ -6767,7 +6879,7 @@ declare module "esri/dijit/editing/Add" { import esri = require("esri"); import OperationBase = require("esri/OperationBase"); - /** The esri/dijit/editing namespace contains editing related operations that inherit from OperationBase. */ + /** This class is used with the UndoManager to provide undo/redo functionality of Add operations when editing. */ class Add extends OperationBase { /** * Create a new Add operation. @@ -6810,7 +6922,7 @@ declare module "esri/dijit/editing/Cut" { import esri = require("esri"); import OperationBase = require("esri/OperationBase"); - /** The esri/dijit/editing namespace contains editing related operations that inherit from OperationBase. */ + /** This class is used with the UndoManager to provide undo/redo functionality of Cut operations when editing. */ class Cut extends OperationBase { /** * Create a new Cut operation. @@ -6829,7 +6941,7 @@ declare module "esri/dijit/editing/Delete" { import esri = require("esri"); import OperationBase = require("esri/OperationBase"); - /** The esri/dijit/editing namespace contains editing related operations that inherit from OperationBase. */ + /** This class is used with the UndoManager to provide undo/redo functionality of Delete operations when editing. */ class Delete extends OperationBase { /** * Create a new Delete operation. @@ -6929,7 +7041,7 @@ declare module "esri/dijit/editing/Union" { import esri = require("esri"); import OperationBase = require("esri/OperationBase"); - /** The esri/dijit/editing namespace contains editing related operations that inherit from OperationBase. */ + /** This class is used with the UndoManager to provide undo/redo functionality of Union operations when editing. */ class Union extends OperationBase { /** * Create a new Union operation. @@ -6948,7 +7060,7 @@ declare module "esri/dijit/editing/Update" { import esri = require("esri"); import OperationBase = require("esri/OperationBase"); - /** The esri/dijit/editing namespace contains editing related operations that inherit from OperationBase. */ + /** This class is used with the UndoManager to provide undo/redo functionality of Update operations when editing. */ class Update extends OperationBase { /** * Create a new Update operation. @@ -8353,8 +8465,9 @@ declare module "esri/geometry/webMercatorUtils" { /** * Converts geometry from Web Mercator units to geographic units. * @param geometry The geometry to convert. + * @param isLinear Indicates whether to work with linear values, i.e., do not normalize. */ - webMercatorToGeographic(geometry: Geometry): Geometry; + webMercatorToGeographic(geometry: Geometry, isLinear?: boolean): Geometry; /** * Translates the given Web Mercator coordinates to Longitude and Latitude. * @param x The x coordinate value to convert. @@ -10809,8 +10922,6 @@ declare module "esri/layers/VectorTileLayer" { initialExtent: Extent; /** The spatial reference of the layer. */ spatialReference: SpatialReference; - /** The style object of the service with fully qualified URLs for glyphs and sprite. */ - style: any; /** Contains information about the tiling scheme for the layer. */ tileInfo: TileInfo; /** The URL to the vector tile service or style JSON that will be used to draw the layer. */ @@ -10821,6 +10932,8 @@ declare module "esri/layers/VectorTileLayer" { * @param options Optional parameters. */ constructor(url: string | any, options?: esri.VectorTileLayerOptions); + /** Returns an object that contains the current style information for the layer. */ + getStyle(): any; /** * Changes the style properties used to render the layers. * @param styleUrl A url to a JSON file containing the stylesheet information to render the layer. @@ -10835,14 +10948,15 @@ declare module "esri/layers/VectorTileLayer" { declare module "esri/layers/WFSLayer" { import esri = require("esri"); + import GraphicsLayer = require("esri/layers/GraphicsLayer"); import Field = require("esri/layers/Field"); import Extent = require("esri/geometry/Extent"); import Graphic = require("esri/graphic"); import InfoTemplate = require("esri/InfoTemplate"); import Renderer = require("esri/renderers/Renderer"); - /** (Currently in beta) A layer for OGC Web Feature Services (WFS). */ - class WFSLayer { + /** (Currently in beta) A layer for OGC Web Feature Services (WFS). */ + class WFSLayer extends GraphicsLayer { /** An array of fields in the layer. */ fields: Field[]; /** The full extent of the layer. */ @@ -10864,17 +10978,11 @@ declare module "esri/layers/WFSLayer" { * @param options See options table below for full descriptions of the properties needed for this object. */ constructor(options: esri.WFSLayerOptions); - /** Creates the getFeature parameter based on the version, nsLayerName, nsGeometryFieldName, mode, wkid, inverseFilter, maxFeatures constructor parameters. */ - buildRequest(): string; /** - * Gets the WFS layer capabilities. - * @param callback An array of WFS layers in JSON format. + * Creates a WFSLayer using the provided JSON object. + * @param json The input JSON. */ - getCapabilities(callback?: Function): void; - /** Performs the getFeature request. */ - getFeature(): void; - /** Returns a JSON Object containing all of the WFS parameters. */ - getWFSParameters(): any; + fromJson(json: Object): void; /** Redraws all the graphics in the layer. */ redraw(): void; /** Refreshes the features in the WFS layer. */ @@ -10885,8 +10993,8 @@ declare module "esri/layers/WFSLayer" { setPointSymbol(): void; /** Sets the default polygon symbol to be used if no renderer is specified. */ setPolygonSymbol(): void; - /** Sets the WFS parameters using the provided JSON Object. */ - setWFSParameters(): void; + /** Converts the WFSLayer instance to a JSON object. */ + toJson(): any; } export = WFSLayer; } @@ -10952,6 +11060,7 @@ declare module "esri/layers/WMSLayer" { } declare module "esri/layers/WMSLayerInfo" { + import esri = require("esri"); import Extent = require("esri/geometry/Extent"); /** The WMSLayerInfo class defines and provides information about layers in a WMS service. */ @@ -10966,6 +11075,10 @@ declare module "esri/layers/WMSLayerInfo" { legendURL: string; /** The layer name. */ name: string; + /** Returns true if the layer can be queried and the service supports GetFeatureInfo with either text/html or text/plain formats */ + queryable: boolean; + /** Indicates if this layer should be included in the popup. */ + showPopup: boolean; /** An array of WKIDs of all spatial references defined for the layer. */ spatialReferences: number[]; /** WMSLayerInfos of the layer's sub layers. */ @@ -10974,9 +11087,9 @@ declare module "esri/layers/WMSLayerInfo" { title: string; /** * Creates a new WMSLayerInfo object. - * @param layer WMSLayerInfo layer object. + * @param options See options list for parameters. */ - constructor(layer: any); + constructor(options?: esri.WMSLayerInfoOptions); } export = WMSLayerInfo; } @@ -11584,7 +11697,7 @@ declare module "esri/opsdashboard/DataSourceProxy" { displayFieldName: string; /** Read-only: The collection of fields. */ fields: Field[]; - /** The geometry type. */ + /** Read-only: The geometry type. */ geometryType: string; /** Read-only: The id of the data source. */ id: string; @@ -11611,8 +11724,8 @@ declare module "esri/opsdashboard/DataSourceProxy" { executeQuery(query: Query): any; /** An object that contains service level metadata about whether or not the layer supports queries using statistics, order by fields, DISTINCT, pagination, query with distance, and returning queries with extents. */ getAdvancedQueryCapabilities(): any; - /** Retrieve the associated data source that supports selection. */ - getAssociatedSelectionDataSourceProxy(): any; + /** Retrieve the associated id of the data source that supports selection. */ + getAssociatedSelectionDataSourceId(): any; /** Get the associated popupInfo for the data source if any available. */ getPopupInfo(): any; /** Get the associated render object for the data source if any available. */ @@ -11666,12 +11779,17 @@ declare module "esri/opsdashboard/ExtensionBase" { static POLYLINE: any; /** Read-only: Indicates if the host application is the Windows Operations Dashboard. */ isNative: boolean; + /** Read Only: It will list all of the Portal helper services. */ + portalHelperServices: string; /** Read-only: The URL to the ArcGIS.com site or in-house portal that you are currently signed in to. */ portalUrl: string; /** Get the collection of data sources from the host application. */ getDataSourceProxies(): any; - /** Get the data source corresponding to the data source id from the host application. */ - getDataSourceProxy(): any; + /** + * Get the data source corresponding to the data source id from the host application. + * @param dataSourceId The data source id + */ + getDataSourceProxy(dataSourceId: string): any; /** Get the collection of map widgets from the host application. */ getMapWidgetProxies(): any; /** @@ -11791,7 +11909,7 @@ declare module "esri/opsdashboard/GraphicsLayerProxy" { minScale: number; /** Read-only: The current host graphics layer opacity ratio. */ opacity: number; - /** The current renderer used by the host graphics layer. */ + /** Read-only: The current renderer used by the host graphics layer. */ renderer: Renderer; /** Read-only: The current host graphics layer visibility. */ visible: boolean; @@ -11928,8 +12046,6 @@ declare module "esri/opsdashboard/MapWidgetProxy" { destroyGraphicsLayerProxy(graphicsLayerProxy: GraphicsLayerProxy): void; /** Gets the current host map extent. */ getMapExtent(): any; - /** Called by the host application when the extent of the host map has changed. */ - mapExtentChanged(): void; /** * Pans the map to a new location. * @param mapPoint A new location with the same spatial reference as the host map. @@ -14088,7 +14204,7 @@ declare module "esri/tasks/FindTask" { url: string; /** * Creates a new FindTask object. - * @param url URL to the ArcGIS Server REST resource that represents a layer in a service. + * @param url URL to the ArcGIS Server REST resource that represents a map service. * @param options Optional parameters. */ constructor(url: string, options?: esri.FindTaskOptions); @@ -15343,6 +15459,8 @@ declare module "esri/tasks/RouteParameters" { startTimeIsUTC: boolean; /** The set of stops loaded as network locations during analysis. */ stops: any; + /** If true , the TimeWindowStart and TimeWindowEnd attributes of a stop are in UTC time (milliseconds). */ + timeWindowsAreUTC: boolean; /** Travel modes define how a pedestrian, car, truck or other medium of transportation moves through the street network. */ travelMode: any; /** If true, the hierarchy attribute for the network should be used in analysis. */ @@ -16696,7 +16814,7 @@ declare module "esri/tasks/query" { static SPATIAL_REL_TOUCHES: any; /** The feature from feature class 1 is completely enclosed by the feature from feature class 2. */ static SPATIAL_REL_WITHIN: any; - /** Distance to buffer input geometry. */ + /** Buffer distance for input geometries. */ distance: number; /** The geometry to apply to the spatial filter. */ geometry: Geometry; @@ -16738,7 +16856,7 @@ declare module "esri/tasks/query" { text: string; /** Specify a time extent for the query. */ timeExtent: TimeExtent; - /** Distance unit. */ + /** The unit for calculating the buffer distance. */ units: string; /** A where clause for the query. */ where: string; @@ -17055,7 +17173,7 @@ declare module "esri/toolbars/navigation" { * @param symbol The SimpleFillSymbol used for the rubber band zoom. */ setZoomSymbol(symbol: Symbol): void; - /** Zoom to full extent of base layer. */ + /** Zoom to initial extent of base layer. */ zoomToFullExtent(): void; /** Zoom to next extent in extent history. */ zoomToNextExtent(): void; From fee05fe77c32aabd3f7dea136796d6dfb2284bfb Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Wed, 6 Jul 2016 01:01:17 +0200 Subject: [PATCH 050/279] Chai-enzyme --- chai-enzyme/chai-enzyme-tests.tsx | 45 +++++++++ chai-enzyme/chai-enzyme.d.ts | 153 ++++++++++++++++++++++++++++++ 2 files changed, 198 insertions(+) create mode 100644 chai-enzyme/chai-enzyme-tests.tsx create mode 100644 chai-enzyme/chai-enzyme.d.ts diff --git a/chai-enzyme/chai-enzyme-tests.tsx b/chai-enzyme/chai-enzyme-tests.tsx new file mode 100644 index 0000000000..f85320cee0 --- /dev/null +++ b/chai-enzyme/chai-enzyme-tests.tsx @@ -0,0 +1,45 @@ +/// +/// +/// +/// + +import * as React from "react"; +import * as chaiEnzyme from "chai-enzyme"; +import { expect } from "chai"; +import { shallow } from "enzyme"; + +const Test = () =>
; + +class Test2 extends React.Component<{}, {}> { + render() { + return
; + } +} + +chai.use(chaiEnzyme()); + +const wrapper = shallow(); + +expect(wrapper).to.be.checked(); +expect(wrapper).to.have.className("test"); +expect(wrapper).to.have.descendants({ a: "b" }); +expect(wrapper).to.have.descendants(Test); +expect(wrapper).to.have.exactly(1).descendants(Test2); +expect(wrapper).to.have.descendants("div"); +expect(wrapper).to.be.disabled(); +expect(wrapper).to.be.blank(); +expect(wrapper).to.be.present(); +expect(wrapper).to.have.html("
"); +expect(wrapper).to.have.id("test"); +expect(wrapper).to.have.ref("test"); +expect(wrapper).to.be.selected(); +expect(wrapper).to.have.tagName("div"); +expect(wrapper).to.have.text(""); +expect(wrapper).to.have.value("test"); +expect(wrapper).to.have.attr("test", "test"); +expect(wrapper).to.have.data("test", "Test"); +expect(wrapper).to.have.style("background", "green"); +expect(wrapper).to.have.state("test", "test"); +expect(wrapper).to.have.prop("test", 5); +expect(wrapper).to.contain(); +expect(wrapper).to.match(); diff --git a/chai-enzyme/chai-enzyme.d.ts b/chai-enzyme/chai-enzyme.d.ts new file mode 100644 index 0000000000..21e463dac5 --- /dev/null +++ b/chai-enzyme/chai-enzyme.d.ts @@ -0,0 +1,153 @@ +// Type definitions for chai-enzyme 0.5.0 +// Project: https://github.com/producthunt/chai-enzyme +// Definitions by: Alexey Svetliakov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + + +/// +/// +/// + +declare namespace Chai { + type EnzymeSelector = string | __React.StatelessComponent | __React.ComponentClass | { [key: string]: any }; + + interface Match { + /** + * Assert that the wrapper matches given selector: + * @param selector + */ + (selector: EnzymeSelector): Assertion; + } + interface Include { + /** + * Assert that the wrapper contains a given node: + * @param code + */ + (selector: EnzymeSelector): Assertion; + } + interface Assertion { + /** + * Assert that the given wrapper is checked: + */ + checked(): Assertion; + + /** + * Assert that the wrapper has a given class: + * @param name + */ + className(name: string): Assertion; + + /** + * Assert that the wrapper contains a descendant matching the given selector: + * @param selector + */ + descendants(selector?: EnzymeSelector): Assertion; + + /** + * Assert that the wrapper contains an exact amount of descendants matching the given selector: + */ + exactly(count?: number): Assertion; + + /** + * Assert that the given wrapper is disabled: + */ + disabled(): Assertion; + + /** + * Assert that the given wrapper is empty: + */ + blank(): Assertion; + + /** + * Assert that the given wrapper exists: + */ + present(): Assertion; + + /** + * Assert that the wrapper has given html: + * @param str + */ + html(str?: string): Assertion; + + /** + * Assert that the wrapper has given ID attribute: + * @param str + */ + id(str: string): Assertion; + + /** + * Assert that the wrapper has a given ref + * @param key + */ + ref(key: string): Assertion; + + /** + * Assert that the given wrapper is selected: + */ + selected(): Assertion; + + /** + * Assert that the given wrapper has the tag name: + * @param str + */ + tagName(str: string): Assertion; + + /** + * Assert that the given wrapper has the supplied text: + * @param str + */ + text(str?: string): Assertion; + + /** + * Assert that the given wrapper has given value: + * @param str + */ + value(str: string): Assertion; + + /** + * Assert that the wrapper has given attribute [with value]: + * @param key + * @param val + */ + attr(key: string, val?: string): Assertion; + + /** + * Assert that the wrapper has a given data attribute [with value]: + * @param key + * @param val + */ + data(key: string, val?: string): Assertion; + + /** + * Assert that the wrapper has given style: + * @param key + * @param val + */ + style(key: string, val?: string): Assertion; + + /** + * Assert that the wrapper has given state [with value]: + * @param key + * @param val + */ + state(key: string, val?: any): Assertion; + + /** + * Assert that the wrapper has given prop [with value]: + * @param key + * @param val + */ + prop(key: string, val?: any): Assertion; + } +} + +declare module "chai-enzyme" { + import { ShallowWrapper, ReactWrapper, CheerioWrapper } from "enzyme"; + + type DebugWrapper = ShallowWrapper | CheerioWrapper | ReactWrapper; + function chaiEnzyMe(wrapper?: (debugWrapper: DebugWrapper) => string): (chai: any) => void; + + module chaiEnzyMe { + } + export = chaiEnzyMe; +} From b09f8bf76eaea1503df5b50480a0228adeb26fe8 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Wed, 6 Jul 2016 01:09:51 +0200 Subject: [PATCH 051/279] react-textarea-autosize --- .../react-textarea-autosize-tests.tsx | 17 ++++++ .../react-textarea-autosize.d.ts | 58 +++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 react-textarea-autosize/react-textarea-autosize-tests.tsx create mode 100644 react-textarea-autosize/react-textarea-autosize.d.ts diff --git a/react-textarea-autosize/react-textarea-autosize-tests.tsx b/react-textarea-autosize/react-textarea-autosize-tests.tsx new file mode 100644 index 0000000000..d87117fa44 --- /dev/null +++ b/react-textarea-autosize/react-textarea-autosize-tests.tsx @@ -0,0 +1,17 @@ +/// +/// + +import * as React from "react"; +import Textarea from "react-textarea-autosize"; + +class Test extends React.Component<{}, {}> { + public render() { + return ( +