Skip to content

Commit d2c9aac

Browse files
committed
Fixes for TS0.9.5
1 parent a1bada0 commit d2c9aac

File tree

6 files changed

+68
-52
lines changed

6 files changed

+68
-52
lines changed

d3/d3-tests.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ function testPieChart() {
4848
}
4949

5050
//Example from http://bl.ocks.org/3887051
51+
interface GroupedData {
52+
State: string;
53+
ages: Array<{ name: string; value: number;}>;
54+
}
5155
function groupedBarChart() {
5256
var margin = { top: 20, right: 20, bottom: 30, left: 40 },
5357
width = 960 - margin.left - margin.right,
@@ -79,7 +83,7 @@ function groupedBarChart() {
7983
.append("g")
8084
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
8185

82-
d3.csv("data.csv", function (error, data) {
86+
d3.csv("data.csv", function (error, data: Array<GroupedData>) {
8387
var ageNames = d3.keys(data[0]).filter(function (key) { return key !== "State"; });
8488

8589
data.forEach(function (d) {
@@ -731,6 +735,11 @@ function chainedTransitions() {
731735
}
732736

733737
//Example from http://bl.ocks.org/mbostock/4062085
738+
interface PyramidData {
739+
people: number;
740+
year: number;
741+
age: number;
742+
}
734743
function populationPyramid() {
735744
var margin = { top: 20, right: 40, bottom: 30, left: 20 },
736745
width = 960 - margin.left - margin.right,
@@ -766,7 +775,7 @@ function populationPyramid() {
766775
.attr("dy", ".71em")
767776
.text(2000);
768777

769-
d3.csv("population.csv", function (error, data) {
778+
d3.csv("population.csv", function (error, data: Array<PyramidData>) {
770779

771780
// Convert strings to numbers.
772781
data.forEach(function (d) {
@@ -1470,8 +1479,8 @@ function streamGraph() {
14701479
var n = 20, // number of layers
14711480
m = 200, // number of samples per layer
14721481
stack = d3.layout.stack().offset("wiggle"),
1473-
layers0 = stack(d3.range(n).map(function () { return bumpLayer(m); } )),
1474-
layers1 = stack(d3.range(n).map(function () { return bumpLayer(m); } ));
1482+
layers0 = stack(d3.range(n).map(function () { return bumpLayer(m); })),
1483+
layers1 = stack(d3.range(n).map(function () { return bumpLayer(m); }));
14751484

14761485
var width = 960,
14771486
height = 500;
@@ -1481,16 +1490,16 @@ function streamGraph() {
14811490
.range([0, width]);
14821491

14831492
var y = d3.scale.linear()
1484-
.domain([0, d3.max(layers0.concat(layers1), function (layer) { return d3.max(layer, function (d) { return d.y0 + d.y; } ); } )])
1493+
.domain([0, d3.max(layers0.concat(layers1), function (layer) { return d3.max(layer, function (d) { return d.y0 + d.y; }); })])
14851494
.range([height, 0]);
14861495

14871496
var color = d3.scale.linear()
14881497
.range(["#aad", "#556"]);
14891498

14901499
var area = d3.svg.area()
1491-
.x(function (d) { return x(d.x); } )
1492-
.y0(function (d) { return y(d.y0); } )
1493-
.y1(function (d) { return y(d.y0 + d.y); } );
1500+
.x(function (d) { return x(d.x); })
1501+
.y0(function (d) { return y(d.y0); })
1502+
.y1(function (d) { return y(d.y0 + d.y); });
14941503

14951504
var svg = d3.select("body").append("svg")
14961505
.attr("width", width)
@@ -1500,22 +1509,22 @@ function streamGraph() {
15001509
.data(layers0)
15011510
.enter().append("path")
15021511
.attr("d", area)
1503-
.style("fill", function () { return color(Math.random()); } );
1512+
.style("fill", function () { return color(Math.random()); });
15041513

15051514
function transition() {
15061515
d3.selectAll("path")
15071516
.data(function () {
15081517
var d = layers1;
15091518
layers1 = layers0;
15101519
return layers0 = d;
1511-
} )
1520+
})
15121521
.transition()
15131522
.duration(2500)
15141523
.attr("d", area);
15151524
}
15161525

15171526
// Inspired by Lee Byron's test data generator.
1518-
function bumpLayer(n) {
1527+
function bumpLayer(n): Array<{x: number; y: number;y0?:number;}> {
15191528

15201529
function bump(a) {
15211530
var x = 1 / (.1 + Math.random()),
@@ -2123,7 +2132,7 @@ function nestTest () {
21232132

21242133
entries = d3.nest()
21252134
.key(function(d) { return d.foo; })
2126-
.rollup(function(values) { return d3.sum(values, function(d) { return d.bar; }); })
2135+
.rollup(function(values) { return d3.sum<any>(values, function(d) { return d.bar; }); })
21272136
.entries([{foo: 1, bar: 2}, {foo: 1, bar: 0}, {foo: 1, bar: 1}, {foo: 2}]);
21282137

21292138
entries = d3.nest()

d3/d3.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ declare module D3 {
200200
*
201201
* @param map Array of objects to get the key values from
202202
*/
203-
keys(map: any[]): any[];
203+
keys(map: any): string[];
204204
/**
205205
* List the values of an associative array.
206206
*
@@ -1032,7 +1032,7 @@ declare module D3 {
10321032
}
10331033

10341034
export interface StackLayout {
1035-
(layers: any[], index?: number): any[];
1035+
<T>(layers: T[], index?: number): T[];
10361036
values(accessor?: (d: any) => any): StackLayout;
10371037
offset(offset: string): StackLayout;
10381038
}

fullCalendar/fullCalendar-tests.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,13 @@ $('#calendar').fullCalendar({
669669
eventColor: '#378006'
670670
});
671671

672+
interface EventWithDescription extends FullCalendar.EventObject {
673+
description: string;
674+
}
675+
interface JQuery {
676+
qtip: any; // dummy plugin interface
677+
}
678+
672679
$('#calendar').fullCalendar({
673680
events: [
674681
{
@@ -678,7 +685,7 @@ $('#calendar').fullCalendar({
678685
}
679686
// more events here
680687
],
681-
eventRender: function (event, element) {
688+
eventRender: function (event: EventWithDescription, element) {
682689
element.qtip({
683690
content: event.description
684691
});

fullCalendar/fullCalendar.d.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ declare module FullCalendar {
6969
dayNamesShort?: Array<string>;
7070
weekNumberTitle?: number;
7171

72-
dayClick?: (date: Date, allDay: boolean, jsEvent: Event, view: View) => void;
73-
eventClick?: (event: EventObject, jsEvent: Event, view: View) => any; // return type boolean or void
74-
eventMouseover?: (event: EventObject, jsEvent: Event, view: View) => void;
75-
eventMouseout?: (event: EventObject, jsEvent: Event, view: View) => void;
72+
dayClick?: (date: Date, allDay: boolean, jsEvent: MouseEvent, view: View) => void;
73+
eventClick?: (event: EventObject, jsEvent: MouseEvent, view: View) => any; // return type boolean or void
74+
eventMouseover?: (event: EventObject, jsEvent: MouseEvent, view: View) => void;
75+
eventMouseout?: (event: EventObject, jsEvent: MouseEvent, view: View) => void;
7676

7777
selectable?: any; // Boolean/ViewOptionHash
7878
selectHelper?: any; // Boolean/Function
7979
unselectAuto?: boolean;
8080
unselectCancel?: string;
81-
select?: (startDate: Date, endDate: Date, allDay: boolean, jsEvent: Event, view: View) => void;
81+
select?: (startDate: Date, endDate: Date, allDay: boolean, jsEvent: MouseEvent, view: View) => void;
8282
unselect?: (view: View, jsEvent: Event) => void;
8383

8484
eventSources?: Array<EventSource>;
@@ -103,16 +103,16 @@ declare module FullCalendar {
103103
disableResizing?: boolean;
104104
dragRevertDuration?: number;
105105
dragOpacity?: any; // Float/ViewOptionHash
106-
eventDragStart?: (event: EventObject, jsEvent: Event, ui: any, view: View) => void;
107-
eventDragStop?: (event: EventObject, jsEvent: Event, ui: any, view: View) => void;
106+
eventDragStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void;
107+
eventDragStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void;
108108
eventDrop?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: View) => void;
109-
eventResizeStart?: (event: EventObject, jsEvent: Event, ui: any, view: View) => void;
110-
eventResizeStop?: (event: EventObject, jsEvent: Event, ui: any, view: View) => void;
109+
eventResizeStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void;
110+
eventResizeStop?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void;
111111
eventResize?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: View) => void;
112112

113113
droppable?: boolean;
114114
dropAccept?: any; // String/Function
115-
drop?: (date: Date, allDay: boolean, jsEvent: Event, ui: any) => void;
115+
drop?: (date: Date, allDay: boolean, jsEvent: MouseEvent, ui: any) => void;
116116
}
117117

118118
export interface View {
@@ -194,14 +194,6 @@ declare module FullCalendar {
194194
}
195195

196196
interface JQuery {
197-
/**
198-
* Create calendar object
199-
*/
200-
fullCalendar(options: FullCalendar.Options): JQuery;
201-
/**
202-
* Generic method function
203-
*/
204-
fullCalendar(method: string, arg1: any, arg2: any, arg3: any): void;
205197
/**
206198
* Get/Set option value
207199
*/
@@ -306,6 +298,14 @@ interface JQuery {
306298
* Rerenders all events on the calendar.
307299
*/
308300
fullCalendar(method: 'rerenderEvents'): void;
301+
/**
302+
* Create calendar object
303+
*/
304+
fullCalendar(options: FullCalendar.Options): JQuery;
305+
/**
306+
* Generic method function
307+
*/
308+
fullCalendar(method: string, arg1: any, arg2: any, arg3: any): void;
309309
}
310310

311311
interface JQueryStatic {

jquery.simplePagination/jquery.simplePagination.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ interface SimplePaginationOptions {
2424

2525
interface JQuery {
2626
pagination(options?: SimplePaginationOptions): JQuery;
27-
pagination(method: string): any;
28-
pagination(method: string, value: any): any;
2927
pagination(method: 'selectPage', pageNumber: number): void;
3028
pagination(method: 'prevPage'): void;
3129
pagination(method: 'nextPage'): void;
@@ -36,4 +34,6 @@ interface JQuery {
3634
pagination(method: 'destroy'): void;
3735
pagination(method: 'redraw'): void;
3836
pagination(method: 'updateItems', items: number): void;
37+
pagination(method: string): any;
38+
pagination(method: string, value: any): any;
3939
}

0 commit comments

Comments
 (0)