mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
Temporarily remove d3-collection and d3-force.
These two modules are temporarily removed from this branch so that, the pull-request for the other release candidate definitions cum tests can be submitted as a pull request. They will be resubmitted in a follow-up, once completed.
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
/**
|
||||
* Typescript definition tests for d3/d3-collection module
|
||||
*
|
||||
* Note: These tests are intended to test the definitions only
|
||||
* in the sense of typing and call signature consistency. They
|
||||
* are not intended as functional tests.
|
||||
*/
|
||||
|
||||
import * as d3Collection from 'd3-collection';
|
||||
|
||||
// Preparatory steps --------------------------------------------------------------
|
||||
|
||||
let keyValueObj = {
|
||||
a: 'test',
|
||||
b: 123,
|
||||
c: [true, true, false]
|
||||
};
|
||||
|
||||
let keyValueObj2 = {
|
||||
a: 'test',
|
||||
b: 'same',
|
||||
c: 'type'
|
||||
};
|
||||
|
||||
let stringArray: string[],
|
||||
anyArray: any[],
|
||||
stringKVArray: Array<{key: string, value: string}>,
|
||||
anyKVArray: Array<{key: string, value: any}>;
|
||||
|
||||
|
||||
// test keys(...) signatures ------------------------------------------------------
|
||||
|
||||
stringArray = d3Collection.keys(keyValueObj);
|
||||
|
||||
stringArray = d3Collection.keys(document); // purely for the fun of it
|
||||
|
||||
// test values(...) signatures ------------------------------------------------------
|
||||
|
||||
anyArray = d3Collection.values(keyValueObj);
|
||||
// stringArray = d3Collection.values(keyValueObj); // test fails, as values in keyValueObj are not all strings
|
||||
|
||||
stringArray = d3Collection.values(keyValueObj2);
|
||||
stringArray = d3Collection.values<string>(keyValueObj2);
|
||||
|
||||
anyArray = d3Collection.values(document); // purely for the fun of it
|
||||
|
||||
// test entries(...) signatures ------------------------------------------------------
|
||||
|
||||
anyKVArray = d3Collection.entries(keyValueObj);
|
||||
// stringKVArray = d3Collection.entres(keyValueObj); // test fails, as values in keyValueObj are not all strings
|
||||
|
||||
stringKVArray = d3Collection.entries(keyValueObj2);
|
||||
stringKVArray = d3Collection.entries<string>(keyValueObj2);
|
||||
|
||||
anyKVArray = d3Collection.entries(document); // purely for the fun of it
|
||||
|
||||
// test D3Map signatures ------------------------------------------------------------
|
||||
|
||||
let map1: d3Collection.D3Map<any>;
|
||||
Vendored
-75
@@ -1,75 +0,0 @@
|
||||
// Type definitions for D3JS d3-collection module
|
||||
// Project: https://github.com/d3/d3-collection/
|
||||
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Reference type things that can be coerced to string implicitely
|
||||
*/
|
||||
type Stringifiable = {
|
||||
toString(): string;
|
||||
};
|
||||
|
||||
|
||||
export function keys(object: { [key: string]: any }): Array<string>;
|
||||
export function keys(object: Object): Array<string>;
|
||||
|
||||
export function values<T>(object: { [key: string]: T }): Array<T>;
|
||||
export function values(object: Object): Array<any>;
|
||||
|
||||
export function entries<T>(object: { [key: string]: T }): Array<{ key: string, value: T }>;
|
||||
export function entries(object: Object): Array<{ key: string, value: any }>;
|
||||
|
||||
export interface D3Map<T> {
|
||||
has(key: string): boolean;
|
||||
get(key: string): any;
|
||||
set(key: string, value: T): D3Map<T>;
|
||||
remove(key: string): boolean;
|
||||
clear(): void;
|
||||
keys(): Array<string>;
|
||||
values(): Array<T>;
|
||||
entries(): Array<{ key: string, value: T }>;
|
||||
each(func: (value: T, key: string, map: D3Map<T>) => void): undefined;
|
||||
empty(): boolean;
|
||||
size(): number;
|
||||
}
|
||||
|
||||
export function map<T>(): D3Map<T>;
|
||||
export function map<T>(d3Map: D3Map<T>): D3Map<T>;
|
||||
export function map<T>(array: Array<T>, key?: (value: T, i?: number, array?: Array<T>) => string): D3Map<T>;
|
||||
export function map(object: Object): D3Map<any>;
|
||||
|
||||
|
||||
export interface D3Set<T extends Stringifiable> {
|
||||
has(value: T): boolean;
|
||||
add(value: T): D3Set<T>;
|
||||
remove(value: T): boolean;
|
||||
clear(): void;
|
||||
values(): Array<string>;
|
||||
/**
|
||||
* The first and second parameter of the function are both passed
|
||||
* the 'value' of the set entry for consistency with map.each(...)
|
||||
* signature
|
||||
*/
|
||||
each(func: (value: string, valueRepeat: string, set: D3Set<T>) => void): undefined;
|
||||
empty(): boolean;
|
||||
size(): number;
|
||||
}
|
||||
|
||||
|
||||
export function set<T extends Stringifiable>(): D3Set<T>;
|
||||
export function set<T extends Stringifiable>(d3Set: D3Set<T>): D3Set<T>;
|
||||
export function set<T extends Stringifiable>(array: Array<T>, key?: (value: T) => string): D3Set<T>;
|
||||
|
||||
|
||||
interface D3Nest<T> {
|
||||
key(func: (datum: T) => string): D3Nest<T>;
|
||||
sortKeys(comparator: (a: string, b: string) => number): D3Nest<T>;
|
||||
sortValues(comparator: (a: T, b: T) => number): D3Nest<T>;
|
||||
rollup<U>(func: (values: T[]) => U): D3Nest<T>;
|
||||
map(array: T[]): D3Map<any>;
|
||||
object(array: T[]): { [key: string]: any};
|
||||
entries(array: T[]): { key: string; values: any }[];
|
||||
}
|
||||
|
||||
export function nest<T>(): D3Nest<T>;
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"d3-collection-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -1,126 +0,0 @@
|
||||
// /**
|
||||
// * Typescript definition tests for d3/d3-force module
|
||||
// *
|
||||
// * Note: These tests are intended to test the definitions only
|
||||
// * in the sense of typing and call signature consistency. They
|
||||
// * are not intended as functional tests.
|
||||
// */
|
||||
|
||||
// import * as d3Select from 'd3-selection';
|
||||
// import {
|
||||
// forceCenter,
|
||||
// ForceCenter,
|
||||
// forceLink,
|
||||
// ForceLink,
|
||||
// forceManyBody,
|
||||
// ForceManyBody,
|
||||
// forceSimulation,
|
||||
// Simulation,
|
||||
// SimulationLinkDatum,
|
||||
// SimulationNodeDatum
|
||||
// } from 'd3-force';
|
||||
|
||||
// import * as d3Drag from 'd3-drag';
|
||||
|
||||
// interface SimNode extends SimulationNodeDatum {
|
||||
// id: string;
|
||||
// group: number;
|
||||
|
||||
// }
|
||||
|
||||
// interface SimLink extends SimulationLinkDatum<SimNode> {
|
||||
// value: number;
|
||||
// }
|
||||
|
||||
// interface Graph {
|
||||
// nodes: Array<SimNode>;
|
||||
// links: Array<SimLink>;
|
||||
// }
|
||||
|
||||
|
||||
// let canvas = document.querySelector("canvas"),
|
||||
// context = canvas.getContext("2d"),
|
||||
// width = canvas.width,
|
||||
// height = canvas.height;
|
||||
|
||||
// let simulation = forceSimulation<SimNode, SimLink>()
|
||||
// .force("link", forceLink().id(function (d) { return d.id; }))
|
||||
// .force("charge", forceManyBody())
|
||||
// .force("center", forceCenter(width / 2, height / 2));
|
||||
|
||||
|
||||
// let graph: Graph = {
|
||||
// nodes: [
|
||||
// { "id": "Myriel", "group": 1 },
|
||||
// { "id": "Napoleon", "group": 1 },
|
||||
// { "id": "Mlle.Baptistine", "group": 1 },
|
||||
// { "id": "Mme.Magloire", "group": 1 },
|
||||
// { "id": "CountessdeLo", "group": 1 }
|
||||
// ],
|
||||
// links: [
|
||||
// { "source": "Napoleon", "target": "Myriel", "value": 1 },
|
||||
// { "source": "Mlle.Baptistine", "target": "Myriel", "value": 8 },
|
||||
// { "source": "Mme.Magloire", "target": "Myriel", "value": 10 },
|
||||
// { "source": "Mme.Magloire", "target": "Mlle.Baptistine", "value": 6 }
|
||||
// ]
|
||||
// };
|
||||
|
||||
|
||||
// simulation
|
||||
// .nodes(graph.nodes)
|
||||
// .on("tick", function ticked() {
|
||||
// context.clearRect(0, 0, width, height);
|
||||
|
||||
// context.beginPath();
|
||||
// graph.links.forEach(drawLink);
|
||||
// context.strokeStyle = "#aaa";
|
||||
// context.stroke();
|
||||
|
||||
// context.beginPath();
|
||||
// graph.nodes.forEach(drawNode);
|
||||
// context.fill();
|
||||
// context.strokeStyle = "#fff";
|
||||
// context.stroke();
|
||||
// });
|
||||
|
||||
// (<ForceLink<SimNode, SimLink>>simulation.force("link"))
|
||||
// .links(graph.links);
|
||||
|
||||
// d3Select.select(canvas)
|
||||
// .call(d3Drag.drag()
|
||||
// .container(canvas)
|
||||
// .subject(dragsubject)
|
||||
// .on("start", dragstarted)
|
||||
// .on("drag", dragged)
|
||||
// .on("end", dragended)
|
||||
// );
|
||||
|
||||
|
||||
// function dragsubject() {
|
||||
// return simulation.find(d3Select.event.x, d3Select.event.y);
|
||||
// }
|
||||
|
||||
|
||||
// function dragstarted() {
|
||||
// if (!d3Select.event.active) simulation.alphaTarget(0.3).restart()
|
||||
// simulation.fix(d3.event.subject);
|
||||
// }
|
||||
|
||||
// function dragged() {
|
||||
// simulation.fix(d3.event.subject, d3Select.event.x, d3Select.event.y);
|
||||
// }
|
||||
|
||||
// function dragended() {
|
||||
// if (!d3Select.event.active) simulation.alphaTarget(0);
|
||||
// simulation.unfix(d3Select.event.subject);
|
||||
// }
|
||||
|
||||
// function drawLink(d: SimLink) {
|
||||
// context.moveTo(d.source.x, d.source.y);
|
||||
// context.lineTo(d.target.x, d.target.y);
|
||||
// }
|
||||
|
||||
// function drawNode(d: SimLink) {
|
||||
// context.moveTo(d.x + 3, d.y);
|
||||
// context.arc(d.x, d.y, 3, 0, 2 * Math.PI);
|
||||
// }
|
||||
Vendored
-158
@@ -1,158 +0,0 @@
|
||||
// Type definitions for D3JS d3-force module
|
||||
// Project: https://github.com/d3/d3-force/
|
||||
// Definitions by: Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>, Tom Wanzek <https://github.com/tomwanzek>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
// Force Simulation
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// TODO: Review below: fx and fy should be optional as a matter of principle. The other properties, are optional prior to initialization, but once the
|
||||
// the nodes array is passed into the simulation, will be initialized.
|
||||
export interface SimulationNodeDatum {
|
||||
// NB: index is assigned internally by simulation, once initialized it is defined
|
||||
index?: number;
|
||||
x?: number;
|
||||
y?: number;
|
||||
vx?: number;
|
||||
vy?: number;
|
||||
fx?: number;
|
||||
fy?: number;
|
||||
}
|
||||
|
||||
export interface SimulationLinkDatum<NodeDatum extends SimulationNodeDatum> {
|
||||
// TODO: Strictly speaking, the string or number typing of source and target is only used when (re)initializing links
|
||||
// Once initialized, links' source and target fields will be of type NodeDatum
|
||||
source: NodeDatum | string | number;
|
||||
target: NodeDatum | string | number;
|
||||
// NB: index is assigned internally by force, once initialized it is defined
|
||||
index?: number;
|
||||
}
|
||||
|
||||
export interface Simulation<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum>> {
|
||||
restart(): Simulation<NodeDatum, LinkDatum>;
|
||||
stop(): Simulation<NodeDatum, LinkDatum>;
|
||||
tick(): Simulation<NodeDatum, LinkDatum>;
|
||||
nodes(): Array<NodeDatum>;
|
||||
nodes(nodesData: Array<NodeDatum>): Simulation<NodeDatum, LinkDatum>;
|
||||
alpha(): number;
|
||||
alpha(alpha: number): Simulation<NodeDatum, LinkDatum>;
|
||||
alphaMin(): number;
|
||||
alphaMin(min: number): Simulation<NodeDatum, LinkDatum>;
|
||||
alphaDecay(): number;
|
||||
alphaDecay(decay: number): Simulation<NodeDatum, LinkDatum>;
|
||||
alphaTarget(): number;
|
||||
alphaTarget(target: number): Simulation<NodeDatum, LinkDatum>;
|
||||
velocityDecay(): number;
|
||||
velocityDecay(decay: number): Simulation<NodeDatum, LinkDatum>;
|
||||
force(name: string): Force<NodeDatum, LinkDatum>;
|
||||
force(name: string, force: Force<NodeDatum, LinkDatum>): Simulation<NodeDatum, LinkDatum>;
|
||||
find(x: number, y: number, radius?: number): NodeDatum | undefined;
|
||||
on(typenames: 'tick' | 'end' | string): (this: Simulation<NodeDatum, LinkDatum>) => void;
|
||||
on(typenames: 'tick' | 'end' | string, listener: null): Simulation<NodeDatum, LinkDatum>;
|
||||
on(typenames: 'tick' | 'end' | string, listener: (this: this) => void): Simulation<NodeDatum, LinkDatum>;
|
||||
}
|
||||
|
||||
export function forceSimulation<NodeDatum extends SimulationNodeDatum>(nodesData?: Array<NodeDatum>): Simulation<NodeDatum, undefined>;
|
||||
export function forceSimulation<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum>>(nodesData?: Array<NodeDatum>): Simulation<NodeDatum, LinkDatum>;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Forces
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
|
||||
export interface Force<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum>> {
|
||||
(alpha: number): void;
|
||||
initialize(nodes: Array<NodeDatum>): void;
|
||||
}
|
||||
|
||||
|
||||
// Centering ------------------------------------------------------------
|
||||
|
||||
export interface ForceCenter<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> {
|
||||
x(): number;
|
||||
x(x: number): ForceCenter<NodeDatum>;
|
||||
y(): number;
|
||||
y(y: number): ForceCenter<NodeDatum>;
|
||||
}
|
||||
|
||||
export function forceCenter<NodeDatum extends SimulationNodeDatum>(x?: number, y?: number): ForceCenter<NodeDatum>;
|
||||
|
||||
// Collision ------------------------------------------------------------
|
||||
|
||||
export interface ForceCollide<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> {
|
||||
radius(): (node: NodeDatum, i: number, nodes: Array<NodeDatum>) => number;
|
||||
radius(radius: number): ForceCollide<NodeDatum>;
|
||||
radius(radius: (node: NodeDatum, i?: number, nodes?: Array<NodeDatum>) => number): ForceCollide<NodeDatum>;
|
||||
strength(): number;
|
||||
strength(strength: number): ForceCollide<NodeDatum>;
|
||||
iterations(): number;
|
||||
iterations(iterations: number): ForceCollide<NodeDatum>;
|
||||
}
|
||||
|
||||
export function forceCollide<NodeDatum extends SimulationNodeDatum>(): ForceCollide<NodeDatum>;
|
||||
export function forceCollide<NodeDatum extends SimulationNodeDatum>(radius: number): ForceCollide<NodeDatum>;
|
||||
export function forceCollide<NodeDatum extends SimulationNodeDatum>(radius: (node: NodeDatum, i: number, nodes: Array<NodeDatum>) => number): ForceCollide<NodeDatum>;
|
||||
|
||||
// Link ----------------------------------------------------------------
|
||||
|
||||
export interface ForceLink<NodeDatum extends SimulationNodeDatum, LinkDatum extends SimulationLinkDatum<NodeDatum>> extends Force<NodeDatum, LinkDatum> {
|
||||
links(): Array<LinkDatum>;
|
||||
links(links: Array<LinkDatum>): ForceLink<NodeDatum, LinkDatum>;
|
||||
id(): (d: NodeDatum, i: number, nodesData: Array<NodeDatum>) => (string | number);
|
||||
id(id: (d: NodeDatum, i?: number, nodesData?: Array<NodeDatum>) => string): ForceLink<NodeDatum, LinkDatum>;
|
||||
distance(): (d: LinkDatum, i: number, linksData: Array<LinkDatum>) => number;
|
||||
distance(distance: (d: LinkDatum, i: number, linksData: Array<LinkDatum>) => number): ForceLink<NodeDatum, LinkDatum>;
|
||||
strength(): (d: LinkDatum, i: number, linksData: Array<LinkDatum>) => number;
|
||||
strength(strength: (d: LinkDatum, i: number, linksData: Array<LinkDatum>) => number): ForceLink<NodeDatum, LinkDatum>;
|
||||
iterations(): number;
|
||||
iterations(iterations: number): ForceLink<NodeDatum, LinkDatum>;
|
||||
}
|
||||
|
||||
export function forceLink<NodeDatum extends SimulationNodeDatum, LinksDatum extends SimulationLinkDatum<NodeDatum>>(): ForceLink<NodeDatum, LinksDatum>;
|
||||
export function forceLink<NodeDatum extends SimulationNodeDatum, LinksDatum extends SimulationLinkDatum<NodeDatum>>(linksData: Array<LinksDatum>): ForceLink<NodeDatum, LinksDatum>;
|
||||
|
||||
// Many Body ----------------------------------------------------------------
|
||||
|
||||
export interface ForceManyBody<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> {
|
||||
strength(): (d: NodeDatum, i: number, data: Array<NodeDatum>) => number;
|
||||
strength(strength: number): ForceManyBody<NodeDatum>;
|
||||
strength(strength: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): ForceManyBody<NodeDatum>;
|
||||
theta(): number;
|
||||
theta(theta: number): ForceManyBody<NodeDatum>;
|
||||
distanceMin(): number;
|
||||
distanceMin(distance: number): ForceManyBody<NodeDatum>;
|
||||
distanceMax(): number;
|
||||
distanceMax(distance: number): ForceManyBody<NodeDatum>;
|
||||
}
|
||||
|
||||
export function forceManyBody<NodeDatum extends SimulationNodeDatum>(): ForceManyBody<NodeDatum>;
|
||||
|
||||
// Positioning ----------------------------------------------------------------
|
||||
|
||||
export interface ForcePositionX<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> {
|
||||
strength(): (d: NodeDatum, i: number, data: Array<NodeDatum>) => number;
|
||||
strength(strength: number): ForcePositionX<NodeDatum>;
|
||||
strength(strength: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): ForcePositionX<NodeDatum>;
|
||||
x(): (d: NodeDatum, i: number, data: Array<NodeDatum>) => number;
|
||||
x(x: number): ForcePositionX<NodeDatum>;
|
||||
x(x: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): ForcePositionX<NodeDatum>;
|
||||
}
|
||||
|
||||
export function forceX<NodeDatum extends SimulationNodeDatum>(): ForcePositionX<NodeDatum>;
|
||||
export function forceX<NodeDatum extends SimulationNodeDatum>(x: number): ForcePositionX<NodeDatum>;
|
||||
export function forceX<NodeDatum extends SimulationNodeDatum>(x: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): ForcePositionX<NodeDatum>;
|
||||
|
||||
export interface ForcePositionY<NodeDatum extends SimulationNodeDatum> extends Force<NodeDatum, any> {
|
||||
strength(): (d: NodeDatum, i: number, data: Array<NodeDatum>) => number;
|
||||
strength(strength: number): ForcePositionY<NodeDatum>;
|
||||
strength(strength: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): ForcePositionY<NodeDatum>;
|
||||
y(): (d: NodeDatum, i: number, data: Array<NodeDatum>) => number;
|
||||
y(y: number): ForcePositionY<NodeDatum>;
|
||||
y(y: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): ForcePositionY<NodeDatum>;
|
||||
}
|
||||
|
||||
export function forceY<NodeDatum extends SimulationNodeDatum>(): ForcePositionY<NodeDatum>;
|
||||
export function forceY<NodeDatum extends SimulationNodeDatum>(y: number): ForcePositionY<NodeDatum>;
|
||||
export function forceY<NodeDatum extends SimulationNodeDatum>(y: (d: NodeDatum, i: number, data: Array<NodeDatum>) => number): ForcePositionY<NodeDatum>;
|
||||
@@ -1,19 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": false,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"d3-force-tests.ts"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user