Merge remote-tracking branch 'refs/remotes/DefinitelyTyped/master' into yog2-defininations

This commit is contained in:
ssddi456
2017-06-15 16:59:49 +08:00
55 changed files with 1303 additions and 558 deletions
@@ -2,3 +2,9 @@ import * as connectRedis from "connect-redis";
import * as session from "express-session";
let RedisStore = connectRedis(session);
const store = new RedisStore({
host: 'localhost',
port: 6379,
logErrors: error => console.warn(error),
scanCount: 80,
});
+3
View File
@@ -1,6 +1,7 @@
// Type definitions for connect-redis
// Project: https://npmjs.com/package/connect-redis
// Definitions by: Xavier Stouder <https://github.com/xstoudi>
// Albert Kurniawan <https://github.com/morcerf>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="express" />
@@ -32,6 +33,8 @@ declare module "connect-redis" {
prefix?: string;
unref?: boolean;
serializer?: Serializer | JSON;
logErrors?: boolean | ((error: string) => void);
scanCount?: number;
}
interface Serializer {
stringify: Function;
@@ -1,5 +1,29 @@
window.addEventListener('batterystatus',
(ev: BatteryStatusEvent) => { console.log('Battery level is ' + ev.level); });
function eventCallBack(ev: BatteryStatusEvent) {
console.log('Battery level is ' + ev.level);
}
window.addEventListener('batterystatus', (ev: BatteryStatusEvent) => { console.log('Battery level is ' + ev.level); });
window.addEventListener('batterystatus', (ev) => { console.log('Battery level is ' + ev.level); });
window.addEventListener('batterycritical', (ev) => { console.log('Battery is critical: ' + ev.level); });
window.addEventListener('batterylow', (ev) => { console.log('Battery is low: ' + ev.level); });
window.addEventListener('batterycritical',
() => { alert('Battery is critical low!'); });
window.addEventListener('baterystatus', eventCallBack);
window.addEventListener('batterycritical', eventCallBack);
window.addEventListener('batterylow', eventCallBack);
window.removeEventListener('batterystatus', eventCallBack);
window.removeEventListener('batterycritical', eventCallBack);
window.removeEventListener('batterylow', eventCallBack);
window.addEventListener('batterycritical', () => { alert('Battery is critical low!'); });
window.addEventListener('batterylow', () => { alert('Battery is low!'); });
function batteryCriticalCallback() {
alert('Battery is critical low!');
}
function batteryLowCallback() {
alert('Battery is critical low!');
}
window.addEventListener('batterycritical', batteryCriticalCallback);
window.addEventListener('batterylow', batteryLowCallback);
+17 -105
View File
@@ -4,116 +4,28 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
//
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
// Licensed under the MIT license.
// TypeScript Version: 2.3
interface WindowEventMap {
/**
* batterystatus: event fires when the percentage of battery charge changes by at least 1 percent, or if the device is plugged in or unplugged.
*/
"batterystatus" : BatteryStatusEvent;
/**
* batterycritical: event fires when the percentage of battery charge has reached the critical battery threshold. The value is device-specific.
*/
"batterycritical": BatteryStatusEvent;
/**
* batterylow: event fires when the percentage of battery charge has reached the low battery threshold, device-specific value.
*/
"batterylow": BatteryStatusEvent;
}
interface Window {
onbatterystatus: (type: BatteryStatusEvent) => void;
onbatterycritical: (type: BatteryStatusEvent) => void;
onbatterylow: (type: BatteryStatusEvent) => void;
/**
* Adds a listener for an event from the BatteryStatus plugin.
* @param type the event to listen for
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param listener the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
addEventListener(type: "batterystatus", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
/**
* Adds a listener for an event from the BatteryStatus plugin.
* @param type the event to listen for
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param listener the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
addEventListener(type: "batterycritical", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
/**
* Adds a listener for an event from the BatteryStatus plugin.
* @param type the event to listen for
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param listener the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
addEventListener(type: "batterylow", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
/**
* Adds a listener for an event from the BatteryStatus plugin.
* @param type the event to listen for
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param listener the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
addEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void;
/**
* Removes a listener for an event from the BatteryStatus plugin.
* @param type The event to stop listening for.
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param callback the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
removeEventListener(type: "batterystatus", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
/**
* Removes a listener for an event from the BatteryStatus plugin.
* @param type The event to stop listening for.
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param callback the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
removeEventListener(type: "batterycritical", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
/**
* Removes a listener for an event from the BatteryStatus plugin.
* @param type The event to stop listening for.
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param callback the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
removeEventListener(type: "batterylow", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void;
/**
* Removes a listener for an event from the BatteryStatus plugin.
* @param type The event to stop listening for.
* batterystatus: event fires when the percentage of battery charge
* changes by at least 1 percent, or if the device is plugged in or unplugged.
* batterycritical: event fires when the percentage of battery charge has reached
* the critical battery threshold. The value is device-specific.
* batterylow: event fires when the percentage of battery charge has
* reached the low battery threshold, device-specific value.
* @param callback the function that executes when the event fires. The function is
* passed an BatteryStatusEvent object as a parameter.
*/
removeEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void;
}
/** Object, that passed into battery event listener */
@@ -5,7 +5,28 @@
// is similar to native window.open signature, so the compiler can's
// select proper overload, but we cast result to InAppBrowser manually.
var iab = <InAppBrowser>window.open('google.com', '_self');
iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); });
iab.addEventListener('loadstart', (ev) => { console.log('loadstart' + ev.url); });
iab.addEventListener('loadstop', (ev) => { console.log('loadstop' + ev.code); });
iab.addEventListener('loaderror', (ev) => { console.log('loaderror' + ev.code); });
iab.addEventListener('exit', (ev) => { console.log('exit' + ev.code); });
function inAppBrowserCallBack(ev: InAppBrowserEvent) {
console.log('InAppBrowser callback ' + ev.url);
}
iab.addEventListener('loadstart', inAppBrowserCallBack);
iab.addEventListener('loadstart', inAppBrowserCallBack);
iab.addEventListener('loadstop', inAppBrowserCallBack);
iab.addEventListener('loaderror', inAppBrowserCallBack);
iab.addEventListener('exit', inAppBrowserCallBack);
iab.removeEventListener('loadstart', inAppBrowserCallBack);
iab.removeEventListener('loadstop', inAppBrowserCallBack);
iab.removeEventListener('loaderror', inAppBrowserCallBack);
iab.removeEventListener('exit', inAppBrowserCallBack);
iab.show();
iab.executeScript(
{ code: "console.log('Injected script in action')" },
+4 -92
View File
@@ -5,6 +5,7 @@
//
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
// TypeScript Version: 2.3
interface Window {
/**
@@ -57,59 +58,14 @@ interface InAppBrowser extends Window {
// addEventListener overloads
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* @param type loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: "loadstart", callback: (event: InAppBrowserEvent) => void): void;
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) => void): void;
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: "loaderror", callback: (event: InAppBrowserEvent) => void): void;
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: "exit", callback: (event: InAppBrowserEvent) => void): void;
/**
* Adds a listener for an event from the InAppBrowser.
* @param type the event to listen for
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an Event object as a parameter.
*/
addEventListener(type: string, callback: (event: Event) => void): void;
addEventListener(type: "loadstart" | "loadstop" | "loaderror" | "exit", callback: (event: InAppBrowserEvent) => void): void;
// removeEventListener overloads
/**
* Removes a listener for an event from the InAppBrowser.
@@ -121,51 +77,7 @@ interface InAppBrowser extends Window {
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: "loadstart", callback: (event: InAppBrowserEvent) => void): void;
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) => void): void;
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: "loaderror", callback: (event: InAppBrowserEvent) => void): void;
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
removeEventListener(type: "exit", callback: (event: InAppBrowserEvent) => void): void;
/**
* Removes a listener for an event from the InAppBrowser.
* @param type The event to stop listening for.
* loadstart: event fires when the InAppBrowser starts to load a URL.
* loadstop: event fires when the InAppBrowser finishes loading a URL.
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
* exit: event fires when the InAppBrowser window is closed.
* @param callback the function that executes when the event fires. The function is
* passed an Event object as a parameter.
*/
removeEventListener(type: string, callback: (event: Event) => void): void;
removeEventListener(type: "loadstart" | "loadstop" | "loaderror" | "exit", callback: (event: InAppBrowserEvent) => void): void;
/** Closes the InAppBrowser window. */
close(): void;
/** Hides the InAppBrowser window. Calling this has no effect if the InAppBrowser was already hidden. */
+130 -20
View File
@@ -7,7 +7,7 @@
*/
import * as d3Sankey from 'd3-sankey';
import {select, Selection} from 'd3-selection';
import { select, Selection } from 'd3-selection';
import { Link } from 'd3-shape';
// ---------------------------------------------------------------------------
@@ -18,38 +18,44 @@ import { Link } from 'd3-shape';
// the Sankey layout generator. The latter are reflected in the SankeyNode and SankeyLink interfaces provided
// by the definitions file
interface SNodeExtra {
nodeId: number;
name: string;
name: string;
}
interface SNodeExtraCustomId {
nodeId: string;
name: string;
}
interface SLinkExtra {
uom: string;
uom: string;
}
// For convenience
type SNode = d3Sankey.SankeyNode<SNodeExtra, SLinkExtra>;
type SNodeCustomId = d3Sankey.SankeyNode<SNodeExtraCustomId, SLinkExtra>;
type SLink = d3Sankey.SankeyLink<SNodeExtra, SLinkExtra>;
type SLinkCustomId = d3Sankey.SankeyLink<SNodeExtraCustomId, SLinkExtra>;
interface DAG {
customNodes: SNode[];
customLinks: SLink[];
customNodes: SNode[];
customLinks: SLink[];
}
const graph: DAG = {
interface DAGCustomId {
customNodes: SNodeCustomId[];
customLinks: SLinkCustomId[];
}
const graphDefault: DAG = {
customNodes: [{
nodeId: 0,
name: "node0"
}, {
nodeId: 1,
name: "node1"
}, {
nodeId: 2,
name: "node2"
}, {
nodeId: 3,
name: "node3"
}, {
nodeId: 4,
name: "node4"
}],
customLinks: [{
@@ -90,6 +96,61 @@ const graph: DAG = {
}]
};
const graphCustomId: DAGCustomId = {
customNodes: [{
nodeId: "n0",
name: "node0"
}, {
nodeId: "n1",
name: "node1"
}, {
nodeId: "n2",
name: "node2"
}, {
nodeId: "n3",
name: "node3"
}, {
nodeId: "n4",
name: "node4"
}],
customLinks: [{
source: "n0",
target: "n2",
value: 2,
uom: 'Widget(s)'
}, {
source: "n1",
target: "n2",
value: 2,
uom: 'Widget(s)'
}, {
source: "n1",
target: "n3",
value: 2,
uom: 'Widget(s)'
}, {
source: "n0",
target: "n4",
value: 2,
uom: 'Widget(s)'
}, {
source: "n2",
target: "n3",
value: 2,
uom: 'Widget(s)'
}, {
source: "n2",
target: "n4",
value: 2,
uom: 'Widget(s)'
}, {
source: "n3",
target: "n4",
value: 4,
uom: 'Widget(s)'
}]
};
let sNodes: SNode[];
let sLinks: SLink[];
@@ -109,6 +170,7 @@ let sGraph: d3Sankey.SankeyGraph<SNodeExtra, SLinkExtra>;
let slgDefault: d3Sankey.SankeyLayout<d3Sankey.SankeyGraph<{}, {}>, {}, {}> = d3Sankey.sankey();
let slgDAG: d3Sankey.SankeyLayout<DAG, SNodeExtra, SLinkExtra> = d3Sankey.sankey<DAG, SNodeExtra, SLinkExtra>();
let slgDAGCustomId: d3Sankey.SankeyLayout<DAGCustomId, SNodeExtraCustomId, SLinkExtra> = d3Sankey.sankey<DAGCustomId, SNodeExtraCustomId, SLinkExtra>();
// ---------------------------------------------------------------------------
// NodeWidth
@@ -175,6 +237,54 @@ slgDAG = slgDAG.iterations(40);
num = slgDAG.iterations();
// ---------------------------------------------------------------------------
// Node Id
// ---------------------------------------------------------------------------
// Set -----------------------------------------------------------------------
slgDAGCustomId = slgDAGCustomId.nodeId((d) => {
const node: SNodeCustomId = d;
return d.nodeId;
});
// Get -----------------------------------------------------------------------
let nodeIdAccessor: (d: SNodeCustomId) => string | number;
nodeIdAccessor = slgDAGCustomId.nodeId();
// ---------------------------------------------------------------------------
// Node Alignment
// ---------------------------------------------------------------------------
// Set -----------------------------------------------------------------------
declare const testNode: SNode;
// Test pre-defined alignment functions
slgDAG = slgDAG.nodeAlign(d3Sankey.sankeyLeft);
num = d3Sankey.sankeyLeft(testNode, 10);
slgDAG = slgDAG.nodeAlign(d3Sankey.sankeyRight);
num = d3Sankey.sankeyRight(testNode, 10);
slgDAG = slgDAG.nodeAlign(d3Sankey.sankeyCenter);
num = d3Sankey.sankeyCenter(testNode, 10);
slgDAG = slgDAG.nodeAlign(d3Sankey.sankeyJustify);
num = d3Sankey.sankeyJustify(testNode, 10);
// Test custom
slgDAG = slgDAG.nodeAlign((node, maxN) => {
const n: SNode = node;
const mN: number = maxN;
return node.depth || 0;
});
// Get -----------------------------------------------------------------------
let nodeAlignmentFn: (d: SNode, n: number) => number;
nodeAlignmentFn = slgDAG.nodeAlign();
// ---------------------------------------------------------------------------
// Nodes
// ---------------------------------------------------------------------------
@@ -182,7 +292,7 @@ num = slgDAG.iterations();
// Set -----------------------------------------------------------------------
// Use array and test return type for chainability
slgDAG = slgDAG.nodes(graph.customNodes);
slgDAG = slgDAG.nodes(graphDefault.customNodes);
// Use accessor function and test return type for chainability
slgDAG = slgDAG.nodes(d => d.customNodes);
@@ -198,7 +308,7 @@ let nodesAccessor: (d: DAG) => SNode[] = slgDAG.nodes();
// Set -----------------------------------------------------------------------
// test return type for chainability
slgDAG = slgDAG.links(graph.customLinks);
slgDAG = slgDAG.links(graphDefault.customLinks);
// Use accessor function and test return type for chainability
slgDAG = slgDAG.links(d => d.customLinks);
@@ -211,9 +321,9 @@ let linksAccessor: (d: DAG) => SLink[] = slgDAG.links();
// Compute Initial Layout
// ---------------------------------------------------------------------------
sGraph = slgDAG(graph);
sGraph = slgDAG(graphDefault);
// With additional arguments, although here unused.
sGraph = slgDAG(graph, "foo", 50);
sGraph = slgDAG(graphDefault, "foo", 50);
// ---------------------------------------------------------------------------
// Update Layout
@@ -255,7 +365,6 @@ let sNode = sNodes[0];
// User-specified extra properties:
num = sNode.nodeId;
str = sNode.name;
// Sankey Layout calculated (if layout has been run, otherwise undefined):
@@ -267,6 +376,7 @@ numMaybe = sNode.y1;
numMaybe = sNode.value;
numMaybe = sNode.index;
numMaybe = sNode.depth;
numMaybe = sNode.height;
let linksArrMaybe: SLink[] | undefined;
@@ -290,10 +400,10 @@ num = sLink.value;
// layout(...) was invoked, the source and target nodes may be numbers
// objects without the Sankey layout coordinates, or objects with calculated
// information
let numOrSankeyNode: number | SNode;
let numStringOrSankeyNode: number | string | SNode;
numOrSankeyNode = sLink.source;
numOrSankeyNode = sLink.target;
numStringOrSankeyNode = sLink.source;
numStringOrSankeyNode = sLink.target;
// Sankey Layout calculated (if layout has been run, otherwise undefined):
+80 -8
View File
@@ -1,9 +1,9 @@
// Type definitions for D3JS d3-sankey module 0.6
// Type definitions for D3JS d3-sankey module 0.7
// Project: https://github.com/d3/d3-sankey/
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Last module patch version validated against: 0.6
// Last module patch version validated against: 0.7
import { Link } from 'd3-shape';
@@ -50,6 +50,10 @@ export interface SankeyNodeMinimal<N extends SankeyExtraProperties, L extends Sa
* Node’s zero-based graph depth, derived from the graph topology calculated by Sankey layout generator.
*/
depth?: number;
/**
* Node’s zero-based graph height, derived from the graph topology calculated by Sankey layout generator.
*/
height?: number;
/**
* Node's minimum horizontal position (derived from the node.depth) calculated by Sankey layout generator.
*/
@@ -96,23 +100,25 @@ export type SankeyNode<N extends SankeyExtraProperties, L extends SankeyExtraPro
*/
export interface SankeyLinkMinimal<N extends SankeyExtraProperties, L extends SankeyExtraProperties> {
/**
* Link's source node. For convenience, when initializing a Sankey layout,
* Link's source node. For convenience, when initializing a Sankey layout using the default node id accessor,
* source may be the zero-based index of the corresponding node in the nodes array
* returned by the nodes accessor of the Sankey layout generator rather than object references.
* returned by the nodes accessor of the Sankey layout generator rather than object references. Alternatively,
* the Sankey layout can be configured with a custom node ID accessor to resolve the source node of the link upon initialization.
*
* Once the Sankey generator is invoked to return the Sankey graph object,
* the numeric index will be replaced with the corresponding source node object.
*/
source: number | SankeyNode<N, L>;
source: number | string | SankeyNode<N, L>;
/**
* Link's target node. For convenience, when initializing a Sankey layout,
* Link's target node. For convenience, when initializing a Sankey layout using the default node id accessor,
* target may be the zero-based index of the corresponding node in the nodes array
* returned by the nodes accessor of the Sankey layout generator rather than object references.
* returned by the nodes accessor of the Sankey layout generator rather than object references. Alternatively,
* the Sankey layout can be configured with a custom node ID accessor to resolve the target node of the link upon initialization.
*
* Once the Sankey generator is invoked to return the Sankey graph object,
* the numeric index will be replaced with the corresponding target node object.
*/
target: number | SankeyNode<N, L>;
target: number | string | SankeyNode<N, L>;
/**
* Link's numeric value
*/
@@ -244,6 +250,34 @@ export interface SankeyLayout<Data, N extends SankeyExtraProperties, L extends S
*/
links(links: (data: Data, ...args: any[]) => Array<SankeyLink<N, L>>): this;
/**
* Return the current node id accessor.
* The default accessor is a function being passed in a Sankey layout node and returning its numeric node.index.
*/
nodeId(): (node: SankeyNode<N, L>) => string | number;
/**
* Set the node id accessor to the specified function and return this Sankey layout generator.
*
* The default accessor is a function being passed in a Sankey layout node and returning its numeric node.index.
* The default id accessor allows each link’s source and target to be specified as a zero-based index into the nodes array.
*
* @param nodeId A node id accessor function being passed a node in the Sankey graph and returning its id.
*/
nodeId(nodeId: (node: SankeyNode<N, L>) => string | number): this;
/**
* Return the current node alignment method, which defaults to d3.sankeyLeft.
*/
nodeAlign(): (node: SankeyNode<N, L>, n: number) => number;
/**
* Set the node alignment method the specified function and return this Sankey layout generator.
*
* @param nodeAlign A node alignment function which is evaluated for each input node in order,
* being passed the current node and the total depth n of the graph (one plus the maximum node.depth),
* and must return an integer between 0 and n - 1 that indicates the desired horizontal position of the node in the generated Sankey diagram.
*/
nodeAlign(nodeAlign: (node: SankeyNode<N, L>, n: number) => number): this;
/**
* Return the current node width, which defaults to 24.
*/
@@ -346,6 +380,44 @@ export function sankey<N extends SankeyExtraProperties, L extends SankeyExtraPro
*/
export function sankey<Data, N extends SankeyExtraProperties, L extends SankeyExtraProperties>(): SankeyLayout<Data, N, L>;
/**
* Compute the horizontal node position of a node in a Sankey layout with left alignment.
* Returns (node.depth) to indicate the desired horizontal position of the node in the generated Sankey diagram.
*
* @param node Sankey node for which to calculate the horizontal node position.
* @param n Total depth n of the graph (one plus the maximum node.depth)
*/
export function sankeyLeft(node: SankeyNode<{}, {}>, n: number): number;
/**
* Compute the horizontal node position of a node in a Sankey layout with right alignment.
* Returns (n - 1 - node.height) to indicate the desired horizontal position of the node in the generated Sankey diagram.
*
* @param node Sankey node for which to calculate the horizontal node position.
* @param n Total depth n of the graph (one plus the maximum node.depth)
*/
export function sankeyRight(node: SankeyNode<{}, {}>, n: number): number;
/**
* Compute the horizontal node position of a node in a Sankey layout with center alignment.
* Like d3.sankeyLeft, except that nodes without any incoming links are moved as right as possible.
* Returns an integer between 0 and n - 1 that indicates the desired horizontal position of the node in the generated Sankey diagram.
*
* @param node Sankey node for which to calculate the horizontal node position.
* @param n Total depth n of the graph (one plus the maximum node.depth)
*/
export function sankeyCenter(node: SankeyNode<{}, {}>, n: number): number;
/**
* Compute the horizontal node position of a node in a Sankey layout with justified alignment.
* Like d3.sankeyLeft, except that nodes without any outgoing links are moved to the far right.
* Returns an integer between 0 and n - 1 that indicates the desired horizontal position of the node in the generated Sankey diagram.
*
* @param node Sankey node for which to calculate the horizontal node position.
* @param n Total depth n of the graph (one plus the maximum node.depth)
*/
export function sankeyJustify(node: SankeyNode<{}, {}>, n: number): number;
/**
* Get a horizontal link shape suitable for a Sankey diagram.
* Source and target accessors are pre-configured and work with the
+1 -4
View File
@@ -622,9 +622,6 @@ $('#calendar').fullCalendar({
eventColor: '#378006'
});
interface EventWithDescription extends FullCalendar.EventObject {
description: string;
}
interface JQueryQTip extends JQuery {
qtip(options: Object): JQuery; // dummy plugin interface
}
@@ -638,7 +635,7 @@ $('#calendar').fullCalendar({
}
// more events here
],
eventRender(event: EventWithDescription, element: JQueryQTip, view: FullCalendar.ViewObject) {
eventRender(event: FullCalendar.EventObject, element: JQueryQTip, view: FullCalendar.ViewObject) {
element.qtip({
content: event.description
});
+3
View File
@@ -2,6 +2,7 @@
// Project: http://fullcalendar.io/
// Definitions by: Neil Stalker <https://github.com/nestalk>, Marcelo Camargo <https://github.com/hasellcamargo>, Patrick Niemann <https://github.com/panic175>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
/// <reference types="jquery"/>
@@ -229,6 +230,8 @@ export interface EventObject extends Timespan {
backgroundColor?: string;
borderColor?: string;
textColor?: string;
// non-standard fields, see https://fullcalendar.io/docs/event_data/Event_Object/ and https://fullcalendar.io/docs/event_rendering/eventRender/
[x: string]: any;
}
export interface ViewObject extends Timespan {
+14
View File
@@ -0,0 +1,14 @@
import * as Hubot from "hubot";
const brain = new Hubot.Brain();
brain; // $ExpectType Brain
brain.userForName('someone'); // $ExpectType any
const robot = new Hubot.Robot(
'src/adapters',
'slack',
false,
'hubot',
);
robot; // $ExpectType Robot
robot.hear(/hello/, () => null); // $ExpectType void
+49
View File
@@ -0,0 +1,49 @@
// Type definitions for hubot 2.19
// Project: https://github.com/github/hubot
// Definitions by: Dirk Gadsden <https://github.com/dirk>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace Hubot {
class Brain {
userForId(id: any): any;
userForName(name: string): any;
}
class User {
id: any;
name: string;
}
class Message {
user: User;
text: string;
id: string;
}
class Response {
match: RegExpMatchArray;
message: Message;
constructor(robot: Robot, message: Message, match: RegExpMatchArray);
send(...strings: string[]): void;
reply(...strings: string[]): void;
random<T>(items: T[]): T;
}
type ListenerCallback = (response: Response) => void;
class Robot {
brain: Brain;
constructor(adapterPath: string, adapter: string, httpd: boolean, name: string, alias?: string);
hear(regex: RegExp, callback: ListenerCallback): void;
hear(regex: RegExp, options: any, callback: ListenerCallback): void;
respond(regex: RegExp, callback: ListenerCallback): void;
respond(regex: RegExp, options: any, callback: ListenerCallback): void;
}
}
// Compatibility with CommonJS syntax exported by Hubot's CoffeeScript.
// tslint:disable-next-line export-just-namespace
export = Hubot;
export as namespace Hubot;
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"hubot-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+5
View File
@@ -1,6 +1,7 @@
// Type definitions for Inquirer.js
// Project: https://github.com/SBoudrias/Inquirer.js
// Definitions by: Qubo <https://github.com/tkQubo>
// Parvez <https://github.com/ppathan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="rx" />
@@ -110,6 +111,10 @@ declare namespace inquirer {
* Change the number of lines that will be rendered when using list, rawList, expand or checkbox.
*/
pageSize?: number;
/**
* Add a mask when password will entered
*/
mask?: string;
}
/**
+10
View File
@@ -0,0 +1,10 @@
// Type definitions for jasmine-given 2.6
// Project: https://github.com/searls/jasmine-given
// Definitions by: Shai Reznik <https://github.com/shairez>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function Given(func: () => void): void;
declare function When(func: () => void): void;
declare function Then(func: () => void): void;
declare function And(func: () => void): void;
declare function Invariant(func: () => void): void;
@@ -0,0 +1,9 @@
Given(() => { });
When(() => { });
Then(() => { });
And(() => { });
Invariant(() => {});
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jasmine-given-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+2 -2
View File
@@ -137,8 +137,8 @@ declare namespace jasmine {
function objectContaining<T>(sample: Partial<T>): ObjectContaining<T>;
function createSpy(name: string, originalFn?: Function): Spy;
function createSpyObj(baseName: string, methodNames: any[]): any;
function createSpyObj<T>(baseName: string, methodNames: any[]): SpyObj<T>;
function createSpyObj(baseName: string, methodNames: any[] | {[methodName: string]: any}): any;
function createSpyObj<T>(baseName: string, methodNames: any[] | {[methodName: string]: any}): SpyObj<T>;
function createSpyObj(baseName: string, methodNames: any): any;
function createSpyObj(methodNames: any[]): any;
+1
View File
@@ -390,6 +390,7 @@ declare namespace L {
interface LayerOptions {
pane?: string;
attribution?: string;
}
interface InteractiveLayerOptions extends LayerOptions {
+35 -5
View File
@@ -10486,6 +10486,36 @@ declare namespace _ {
(t1: T1, t2: T2, t3: T3, t4: T4): CurriedFunction1<T5, R>;
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): R;
}
interface RightCurriedFunction1<T1, R>{
():RightCurriedFunction1<T1, R>
(t1:T1):R
}
interface RightCurriedFunction2<T1,T2, R>{
():RightCurriedFunction2<T1,T2, R>
(t2:T2):RightCurriedFunction1<T1, R>
(t1:T1,t2:T2):R
}
interface RightCurriedFunction3<T1,T2,T3, R>{
():RightCurriedFunction3<T1,T2,T3, R>
(t3:T3):RightCurriedFunction2<T1,T2, R>
(t2:T2,t3:T3):RightCurriedFunction1<T1, R>
(t1:T1,t2:T2,t3:T3):R
}
interface RightCurriedFunction4<T1,T2,T3,T4, R>{
():RightCurriedFunction4<T1,T2,T3,T4, R>
(t4:T4):RightCurriedFunction3<T1,T2,T3, R>
(t3:T3,t4:T4):RightCurriedFunction2<T1,T2, R>
(t2:T2,t3:T3,t4:T4):RightCurriedFunction1<T1, R>
(t1:T1,t2:T2,t3:T3,t4:T4):R
}
interface RightCurriedFunction5<T1,T2,T3,T4,T5, R>{
():RightCurriedFunction5<T1,T2,T3,T4,T5, R>
(t5:T5):RightCurriedFunction4<T1,T2,T3,T4, R>
(t4:T4,t5:T5):RightCurriedFunction3<T1,T2,T3, R>
(t3:T3,t4:T4,t5:T5):RightCurriedFunction2<T1,T2, R>
(t2:T2,t3:T3,t4:T4,t5:T5):RightCurriedFunction1<T1, R>
(t1:T1,t2:T2,t3:T3,t4:T4,t5:T5):R
}
interface LoDashImplicitObjectWrapper<T> {
/**
@@ -10503,7 +10533,7 @@ declare namespace _ {
* @return Returns the new curried function.
*/
curryRight<T1, R>(func: (t1: T1) => R):
CurriedFunction1<T1, R>;
RightCurriedFunction1<T1, R>;
/**
* This method is like _.curry except that arguments are applied to func in the manner of _.partialRight
* instead of _.partial.
@@ -10511,7 +10541,7 @@ declare namespace _ {
* @return Returns the new curried function.
*/
curryRight<T1, T2, R>(func: (t1: T1, t2: T2) => R):
CurriedFunction2<T2, T1, R>;
RightCurriedFunction2<T1, T2, R>;
/**
* This method is like _.curry except that arguments are applied to func in the manner of _.partialRight
* instead of _.partial.
@@ -10519,7 +10549,7 @@ declare namespace _ {
* @return Returns the new curried function.
*/
curryRight<T1, T2, T3, R>(func: (t1: T1, t2: T2, t3: T3) => R):
CurriedFunction3<T3, T2, T1, R>;
RightCurriedFunction3<T1, T2, T3, R>;
/**
* This method is like _.curry except that arguments are applied to func in the manner of _.partialRight
* instead of _.partial.
@@ -10527,7 +10557,7 @@ declare namespace _ {
* @return Returns the new curried function.
*/
curryRight<T1, T2, T3, T4, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4) => R):
CurriedFunction4<T4, T3, T2, T1, R>;
RightCurriedFunction4<T1, T2, T3, T4, R>;
/**
* This method is like _.curry except that arguments are applied to func in the manner of _.partialRight
* instead of _.partial.
@@ -10535,7 +10565,7 @@ declare namespace _ {
* @return Returns the new curried function.
*/
curryRight<T1, T2, T3, T4, T5, R>(func: (t1: T1, t2: T2, t3: T3, t4: T4, t5: T5) => R):
CurriedFunction5<T5, T4, T3, T2, T1, R>;
RightCurriedFunction5<T1, T2, T3, T4, T5, R>;
/**
* This method is like _.curry except that arguments are applied to func in the manner of _.partialRight
* instead of _.partial.
+7 -8
View File
@@ -5923,15 +5923,14 @@ curryResult0 = _.curryRight(testCurryRightFn)(1, 2, 3);
curryResult2 = _.curryRight(testCurryRightFn)(1);
curryResult0 = _(testCurryRightFn).curryRight().value()(1, 2, 3);
curryResult2 = _(testCurryRightFn).curryRight().value()(1);
let curryResult7: _.CurriedFunction1<string, [string, number, boolean]>;
let curryResult8: _.CurriedFunction2<number, string, [string, number, boolean]>;
let curryResult9: _.CurriedFunction3<boolean, number, string, [string, number, boolean]>;
curryResult3 = _.curryRight(testCurry2)(true, 2, "1");
curryResult3 = _.curryRight(testCurry2)(true, 2)("1");
curryResult3 = _.curryRight(testCurry2)(true)(2, "1");
let curryResult7: _.RightCurriedFunction1<string, [string, number, boolean]>;
let curryResult8: _.RightCurriedFunction2<string,number , [string, number, boolean]>;
let curryResult9: _.RightCurriedFunction3<string, number, boolean, [string, number, boolean]>;
curryResult3 = _.curryRight(testCurry2)("1", 2, true);
curryResult3 = _.curryRight(testCurry2)( 2,true)("1");
curryResult3 = _.curryRight(testCurry2)(true)( "1",2);
curryResult3 = _.curryRight(testCurry2)(true)(2)("1");
curryResult7 = _.curryRight(testCurry2)(true, 2);
curryResult7 = _.curryRight(testCurry2)(2,true);
curryResult7 = _.curryRight(testCurry2)(true)(2);
curryResult8 = _.curryRight(testCurry2)(true);
curryResult9 = _.curryRight(testCurry2);
+42 -4
View File
@@ -1,4 +1,4 @@
// Type definitions for massive 3.x
// Type definitions for massive 3.0
// Project: https://github.com/dmfay/massive-js.git
// Definitions by: Pascal Birchler <https://github.com/swissspidy>
// Clarence Ho <https://github.com/clarenceh>
@@ -10,7 +10,7 @@
export = massive;
declare function massive(
connection: object | string,
connection: massive.ConnectionInfo | string,
loaderConfig?: object,
driverConfig?: object): Promise<massive.Database>;
@@ -26,17 +26,55 @@ declare namespace massive {
fallback_application_name?: boolean;
}
interface QueryOptions {
columns?: string[];
limit?: number;
offset?: number;
only?: boolean;
order?: string[];
orderBody?: boolean;
build?: boolean;
document?: boolean;
single?: boolean;
stream?: boolean;
}
interface SearchCriteria {
fields: string[];
term: string;
}
interface Table<T> {
find(criteria: object | {}, queryOptions?: QueryOptions): Promise<T[]>;
findOne(criteria: number | object, queryOptions?: QueryOptions): Promise<T>;
count(criteria: object): Promise<string>;
where(query: string, params: any[] | object): Promise<T[]>;
search(criteria: SearchCriteria, queryOptions?: QueryOptions): Promise<any>;
save(data: object): Promise<T[]>;
insert(data: object): Promise<T[]>;
update(dataOrCriteria: object, changesMap?: object): Promise<T[]>;
destroy(criteria: object): Promise<T[]>;
}
interface Document {
countDoc(criteria: object): Promise<number>;
findDoc(criteria: number | string| object): Promise<object>;
searchDoc(criteria: SearchCriteria): Promise<object[]>;
saveDoc(doc: object): Promise<object>;
modify(docId: number | string, doc: object, fieldName?: string): Promise<object>;
}
interface Database {
attach(ctor: any, ...sources: any[]): Promise<any>;
detach(entity: string, collection: string): void;
reload(): void;
query(query: any, params: any, options: any): Promise<any>;
saveDoc(collection: any, doc: any): any;
saveDoc(collectionName: string, doc: object): Promise<any>;
createDocumentTable(path: any): Promise<any>;
getObject(path: any, collection: any): object;
dropTable(table: string, options: any): void;
createSchema(schemaName: string): void;
dropSchema(schemaName: string, options: any): void;
[name: string]: any;
run(query: string, params: any[] | object): Promise<object[]>;
}
}
+1
View File
@@ -832,6 +832,7 @@ declare namespace __MaterialUI {
className?: string;
openIcon?: React.ReactNode;
closeIcon?: React.ReactNode;
iconStyle?: React.CSSProperties;
}
export class CardHeader extends React.Component<CardHeaderProps, {}> {
}
+7 -4
View File
@@ -1,6 +1,9 @@
// Type definitions for noble
// Project: https://github.com/sandeepmistry/noble
// Definitions by: Seon-Wook Park <https://github.com/swook>, Hans Bakker <https://github.com/wind-rider>, Shantanu Bhadoria <https://github.com/shantanubhadoria>
// Definitions by: Seon-Wook Park <https://github.com/swook>
// Hans Bakker <https://github.com/wind-rider>
// Shantanu Bhadoria <https://github.com/shantanubhadoria>
// Luke Libraro <https://github.com/lukel99>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
@@ -8,9 +11,9 @@
import events = require("events");
export as namespace noble;
export declare function startScanning(serviceUUIDs?: string[], allowDuplicates?: boolean, callback?: (error: Error) => void): void;
export declare function startScanning(callback?: (error?: Error) => void): void;
export declare function startScanning(serviceUUIDs: string[], callback?: (error?: Error) => void): void;
export declare function startScanning(serviceUUIDs: string[], allowDuplicates: boolean, callback?: (error?: Error) => void): void;
export declare function stopScanning(callback?: () => void): void;
export declare function on(event: string, listener: Function): events.EventEmitter;
+4 -2
View File
@@ -4,16 +4,18 @@ import noble = require("noble");
function test_startScanning(): void {
"use strict";
noble.startScanning();
noble.startScanning((err) => {});
noble.startScanning(["0x180d"]);
noble.startScanning(["0x180d"], (err) => {});
noble.startScanning(["0x180d"], true);
noble.startScanning(["0x180d"], true, (error: Error): void => {});
noble.startScanning(["0x180d"], true, (err) => {});
}
test_startScanning();
function test_stopScanning(): void {
"use strict";
noble.stopScanning();
noble.stopScanning((): void => {});
noble.stopScanning(() => {});
}
test_stopScanning();
+1 -1
View File
@@ -19,4 +19,4 @@
"index.d.ts",
"noble-tests.ts"
]
}
}
+89 -8
View File
@@ -7,6 +7,7 @@
// Christian Vaagland Tellnes <https://github.com/tellnes>
// Wilco Bakker <https://github.com/WilcoBakker>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/************************************************
* *
@@ -377,6 +378,12 @@ declare namespace NodeJS {
| 'sunos'
| 'win32';
type Signals =
"SIGABRT" | "SIGALRM" | "SIGBUS" | "SIGCHLD" | "SIGCONT" | "SIGFPE" | "SIGHUP" | "SIGILL" | "SIGINT" | "SIGIO" |
"SIGIOT" | "SIGKILL" | "SIGPIPE" | "SIGPOLL" | "SIGPROF" | "SIGPWR" | "SIGQUIT" | "SIGSEGV" | "SIGSTKFLT" |
"SIGSTOP" | "SIGSYS" | "SIGTERM" | "SIGTRAP" | "SIGTSTP" | "SIGTTIN" | "SIGTTOU" | "SIGUNUSED" | "SIGURG" |
"SIGUSR1" | "SIGUSR2" | "SIGVTALRM" | "SIGWINCH" | "SIGXCPU" | "SIGXFSZ";
export interface Socket extends ReadWriteStream {
isTTY?: true;
}
@@ -449,6 +456,74 @@ declare namespace NodeJS {
send?(message: any, sendHandle?: any): void;
disconnect(): void;
connected: boolean;
/**
* EventEmitter
* 1. beforeExit
* 2. disconnect
* 3. exit
* 4. message
* 5. rejectionHandled
* 6. uncaughtException
* 7. unhandledRejection
* 8. warning
* 9. <All OS Signals>
*/
addListener(event: "beforeExit", listener: (code: number) => void): this;
addListener(event: "disconnect", listener: () => void): this;
addListener(event: "exit", listener: (code: number) => void): this;
addListener(event: "rejectionHandled", listener: (promise: Promise<any>) => void): this;
addListener(event: "uncaughtException", listener: (error: Error) => void): this;
addListener(event: "unhandledRejection", listener: (reason: any, promise: Promise<any>) => void): this;
addListener(event: "warning", listener: (warning: Error) => void): this;
addListener(event: Signals, listener: () => void): this;
emit(event: "beforeExit", listener: (code: number) => void): boolean;
emit(event: "disconnect", listener: () => void): boolean;
emit(event: "exit", listener: (code: number) => void): boolean;
emit(event: "rejectionHandled", listener: (promise: Promise<any>) => void): boolean;
emit(event: "uncaughtException", listener: (error: Error) => void): boolean;
emit(event: "unhandledRejection", listener: (reason: any, promise: Promise<any>) => void): boolean;
emit(event: "warning", listener: (warning: Error) => void): boolean;
emit(event: Signals, listener: () => void): boolean;
on(event: "beforeExit", listener: (code: number) => void): this;
on(event: "disconnect", listener: () => void): this;
on(event: "exit", listener: (code: number) => void): this;
on(event: "rejectionHandled", listener: (promise: Promise<any>) => void): this;
on(event: "uncaughtException", listener: (error: Error) => void): this;
on(event: "unhandledRejection", listener: (reason: any, promise: Promise<any>) => void): this;
on(event: "warning", listener: (warning: Error) => void): this;
on(event: "message", listener: (message: any, sendHandle: any) => void): this;
on(event: Signals, listener: () => void): this;
once(event: "beforeExit", listener: (code: number) => void): this;
once(event: "disconnect", listener: () => void): this;
once(event: "exit", listener: (code: number) => void): this;
once(event: "rejectionHandled", listener: (promise: Promise<any>) => void): this;
once(event: "uncaughtException", listener: (error: Error) => void): this;
once(event: "unhandledRejection", listener: (reason: any, promise: Promise<any>) => void): this;
once(event: "warning", listener: (warning: Error) => void): this;
once(event: Signals, listener: () => void): this;
prependListener(event: "beforeExit", listener: (code: number) => void): this;
prependListener(event: "disconnect", listener: () => void): this;
prependListener(event: "exit", listener: (code: number) => void): this;
prependListener(event: "rejectionHandled", listener: (promise: Promise<any>) => void): this;
prependListener(event: "uncaughtException", listener: (error: Error) => void): this;
prependListener(event: "unhandledRejection", listener: (reason: any, promise: Promise<any>) => void): this;
prependListener(event: "warning", listener: (warning: Error) => void): this;
prependListener(event: Signals, listener: () => void): this;
prependOnceListener(event: "beforeExit", listener: (code: number) => void): this;
prependOnceListener(event: "disconnect", listener: () => void): this;
prependOnceListener(event: "exit", listener: (code: number) => void): this;
prependOnceListener(event: "rejectionHandled", listener: (promise: Promise<any>) => void): this;
prependOnceListener(event: "uncaughtException", listener: (error: Error) => void): this;
prependOnceListener(event: "unhandledRejection", listener: (reason: any, promise: Promise<any>) => void): this;
prependOnceListener(event: "warning", listener: (warning: Error) => void): this;
prependOnceListener(event: Signals, listener: () => void): this;
}
export interface Global {
@@ -734,10 +809,10 @@ declare module "http" {
httpVersionMajor: number;
httpVersionMinor: number;
connection: net.Socket;
headers: any;
headers: { [key: string]: string | string[] };
rawHeaders: string[];
trailers: any;
rawTrailers: any;
trailers: { [key: string]: string };
rawTrailers: string[];
setTimeout(msecs: number, callback: Function): NodeJS.Timer;
/**
* Only valid for request obtained from http.Server.
@@ -920,8 +995,8 @@ declare module "cluster" {
// TODO: cluster.schedulingPolicy
settings: ClusterSettings;
setupMaster(settings?: ClusterSetupMasterSettings): void;
worker: Worker;
workers: {
worker?: Worker;
workers?: {
[index: string]: Worker
};
@@ -1391,6 +1466,12 @@ declare module "https" {
secureProtocol?: string;
}
export interface ClientRequest extends http.ClientRequest {}
export interface IncomingMessage extends http.IncomingMessage {}
export interface ServerResponse extends http.ServerResponse { }
export interface Agent extends http.Agent { }
export interface AgentOptions extends http.AgentOptions {
@@ -1409,9 +1490,9 @@ declare module "https" {
new (options?: AgentOptions): Agent;
};
export interface Server extends tls.Server { }
export function createServer(options: ServerOptions, requestListener?: Function): Server;
export function request(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
export function get(options: RequestOptions, callback?: (res: http.IncomingMessage) => void): http.ClientRequest;
export function createServer(options: ServerOptions, requestListener?: (req: IncomingMessage, res: ServerResponse) => void): Server;
export function request(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
export function get(options: RequestOptions, callback?: (res: IncomingMessage) => void): ClientRequest;
export var globalAgent: Agent;
}
+3
View File
@@ -1890,6 +1890,9 @@ namespace process_tests {
var module: NodeModule | undefined;
module = process.mainModule;
}
{
process.on("message", (req: any) => { });
}
}
///////////////////////////////////////////////////////////
+5 -5
View File
@@ -236,8 +236,8 @@ declare module "prosemirror-model" {
export class Schema {
constructor(spec: SchemaSpec)
spec: SchemaSpec;
nodes: Object;
marks: Object;
nodes: {[key: string]: NodeType};
marks: {[key: string]: MarkType};
cached: Object;
topNodeType: NodeType;
node(type: string | NodeType, attrs?: Object, content?: Fragment | ProsemirrorNode | ProsemirrorNode[], marks?: Mark[]): ProsemirrorNode
@@ -252,8 +252,8 @@ declare module "prosemirror-model" {
}
export class DOMSerializer {
constructor(nodes: Object, marks: Object)
nodes: Object;
marks: Object;
nodes: {[key: string]: NodeType};
marks: {[key: string]: MarkType};
serializeFragment(fragment: Fragment, options?: Object): DocumentFragment
serializeNode(node: ProsemirrorNode, options?: Object): Node
static renderSpec(doc: Document, structure: DOMOutputSpec): { dom: Node, contentDOM?: Node }
@@ -263,4 +263,4 @@ declare module "prosemirror-model" {
}
}
}
+4 -4
View File
@@ -587,8 +587,8 @@ declare namespace R {
* Returns the first element of the list which matches the predicate, or `undefined` if no
* element matches.
*/
find<T>(fn: (a: T) => boolean, list: T[]): T;
find<T>(fn: (a: T) => boolean): (list: T[]) => T;
find<T>(fn: (a: T) => boolean, list: T[]): T | undefined;
find<T>(fn: (a: T) => boolean): (list: T[]) => T | undefined;
/**
@@ -602,8 +602,8 @@ declare namespace R {
* Returns the last element of the list which matches the predicate, or `undefined` if no
* element matches.
*/
findLast<T>(fn: (a: T) => boolean, list: T[]): T;
findLast<T>(fn: (a: T) => boolean): (list: T[]) => T;
findLast<T>(fn: (a: T) => boolean, list: T[]): T | undefined;
findLast<T>(fn: (a: T) => boolean): (list: T[]) => T | undefined;
/**
* Returns the index of the last element of the list which matches the predicate, or
+1
View File
@@ -31,6 +31,7 @@ interface RangyRange extends Range {
equals(range:RangyRange):boolean;
refresh():any;
select():any;
toCharacterRange(containerNode:Node):{start:number, end:number};
}
interface RangySelection extends Selection {
+1
View File
@@ -74,6 +74,7 @@ function testRangyRange() {
rangyRange.splitBoundaries();
assertString(rangyRange.toHtml());
assertRangyRange(rangyRange.union(rangyRange));
let characterRange:{start:number, end:number} = rangyRange.toCharacterRange(new Node);
}
function testSelection() {
+31 -33
View File
@@ -1,22 +1,22 @@
// Type definitions for react-intl 2.2
// Type definitions for react-intl 2.3
// Project: http://formatjs.io/react/
// Definitions by: Bruno Grieder <https://github.com/bgrieder>,
// Christian Droulers <https://github.com/cdroulers>,
// Fedor Nezhivoi <https://github.com/gyzerok>,
// Till Wolff <https://github.com/tillwolff>,
// Karol Janyst <https://github.com/LKay>,
// Brian Houser <https://github.com/bhouser>
// Brian Houser <https://github.com/bhouser>,
// Krister Kari <https://github.com/kristerkari>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
declare namespace ReactIntl {
type DateSource = Date | string | number;
interface Locale {
locale: string;
fields?: { [key: string]: string },
pluralRuleFunction?: (n: number, ord: boolean) => string;
fields?: { [key: string]: string };
pluralRuleFunction?(n: number, ord: boolean): string;
}
type LocaleData = Locale[];
@@ -26,7 +26,7 @@ declare namespace ReactIntl {
withRef?: boolean;
}
type ComponentConstructor<P> = React.ComponentClass<P> | React.StatelessComponent<P>
type ComponentConstructor<P> = React.ComponentClass<P> | React.StatelessComponent<P>;
function injectIntl<P>(component: ComponentConstructor<P & InjectedIntlProps>, options?: InjectIntlConfig):
React.ComponentClass<P> & { WrappedComponent: ComponentConstructor<P & InjectedIntlProps> };
@@ -34,7 +34,7 @@ declare namespace ReactIntl {
function addLocaleData(data: Locale[] | Locale): void;
interface Messages {
[key: string]: FormattedMessage.MessageDescriptor
[key: string]: FormattedMessage.MessageDescriptor;
}
function defineMessages<T extends Messages>(messages: T): T;
@@ -64,19 +64,19 @@ declare namespace ReactIntl {
const intlShape: IntlShape;
interface InjectedIntl {
formatDate: (value: DateSource, options?: FormattedDate.PropsBase) => string;
formatTime: (value: DateSource, options?: FormattedTime.PropsBase) => string;
formatRelative: (value: DateSource, options?: FormattedRelative.PropsBase & { now?: any }) => string;
formatNumber: (value: number, options?: FormattedNumber.PropsBase) => string;
formatPlural: (value: number, options?: FormattedPlural.Base) => keyof FormattedPlural.PropsBase;
formatMessage: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string | number}) => string;
formatHTMLMessage: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string}) => string;
formatDate(value: DateSource, options?: FormattedDate.PropsBase): string;
formatTime(value: DateSource, options?: FormattedTime.PropsBase): string;
formatRelative(value: DateSource, options?: FormattedRelative.PropsBase & { now?: any }): string;
formatNumber(value: number, options?: FormattedNumber.PropsBase): string;
formatPlural(value: number, options?: FormattedPlural.Base): keyof FormattedPlural.PropsBase;
formatMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string | number | boolean | Date}): string;
formatHTMLMessage(messageDescriptor: FormattedMessage.MessageDescriptor, values?: {[key: string]: string | number | boolean | Date}): string;
locale: string;
formats: any;
messages: { [id: string]: string };
defaultLocale: string;
defaultFormats: any;
now : () => number;
now(): number;
}
interface InjectedIntlProps {
@@ -90,9 +90,9 @@ declare namespace ReactIntl {
}
namespace FormattedDate {
export interface PropsBase extends IntlComponent.DateTimeFormatProps {}
type PropsBase = IntlComponent.DateTimeFormatProps;
export interface Props extends PropsBase {
interface Props extends PropsBase {
value: DateSource;
}
}
@@ -100,16 +100,16 @@ declare namespace ReactIntl {
class FormattedDate extends React.Component<FormattedDate.Props, any> { }
namespace FormattedTime {
export interface PropsBase extends IntlComponent.DateTimeFormatProps {}
type PropsBase = IntlComponent.DateTimeFormatProps;
export interface Props extends PropsBase {
interface Props extends PropsBase {
value: DateSource;
}
}
class FormattedTime extends React.Component<FormattedTime.Props, any> { }
namespace FormattedRelative {
export interface PropsBase {
interface PropsBase {
/*
* one of "second", "minute", "hour", "day", "month" or "year"
*/
@@ -123,7 +123,7 @@ declare namespace ReactIntl {
initialNow?: any;
}
export interface Props extends PropsBase {
interface Props extends PropsBase {
value: DateSource;
}
}
@@ -131,13 +131,13 @@ declare namespace ReactIntl {
class FormattedRelative extends React.Component<FormattedRelative.Props, any> { }
namespace FormattedMessage {
export interface MessageDescriptor {
interface MessageDescriptor {
id: string;
description?: string;
defaultMessage?: string;
}
export interface Props extends MessageDescriptor {
interface Props extends MessageDescriptor {
values?: {[key: string]: string | number | JSX.Element};
tagName?: string;
}
@@ -147,26 +147,25 @@ declare namespace ReactIntl {
class FormattedHTMLMessage extends React.Component<FormattedMessage.Props, any> { }
namespace FormattedNumber {
export interface PropsBase extends Intl.NumberFormatOptions {
interface PropsBase extends Intl.NumberFormatOptions {
format?: string;
}
export interface Props extends PropsBase {
interface Props extends PropsBase {
value: number;
}
}
class FormattedNumber extends React.Component<FormattedNumber.Props, any> { }
namespace FormattedPlural {
export interface Base {
interface Base {
/*
* one of "cardinal" (default) | "ordinal"
*/
style?: "cardinal" | "ordinal";
}
export interface PropsBase extends Base {
interface PropsBase extends Base {
other?: any;
zero?: any;
one?: any;
@@ -175,15 +174,14 @@ declare namespace ReactIntl {
many?: any;
}
export interface Props extends PropsBase {
interface Props extends PropsBase {
value: number;
}
}
class FormattedPlural extends React.Component<FormattedPlural.Props, any> { }
namespace IntlProvider {
export interface Props {
interface Props {
locale?: string;
formats?: any;
messages?: any;
@@ -196,12 +194,12 @@ declare namespace ReactIntl {
class IntlProvider extends React.Component<IntlProvider.Props, any> {
getChildContext(): {
intl: InjectedIntl;
}
};
}
}
declare module "react-intl" {
export = ReactIntl
export = ReactIntl;
}
declare module "react-intl/locale-data/af" {
+23 -11
View File
@@ -3,8 +3,8 @@
* Updated by Fedor Nezhivoi
*/
import * as React from "react"
import * as reactMixin from "react-mixin"
import * as React from "react";
import * as reactMixin from "react-mixin";
import {
IntlProvider,
@@ -21,14 +21,14 @@ import {
FormattedPlural,
FormattedDate,
FormattedTime
} from "react-intl"
} from "react-intl";
import reactIntlEn = require("react-intl/locale-data/en");
addLocaleData(reactIntlEn);
interface SomeComponentProps {
className: string
className: string;
}
const SomeFunctionalComponentWithIntl: React.ComponentClass<SomeComponentProps> = injectIntl<SomeComponentProps>(({
@@ -51,7 +51,10 @@ const SomeFunctionalComponentWithIntl: React.ComponentClass<SomeComponentProps>
const formattedNumber = formatNumber(123, { format: "short" });
const formattedPlural = formatPlural(1, { style: "ordinal" });
const formattedMessage = formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" });
const formattedMessagePlurals = formatMessage({ id: "hello", defaultMessage: "Hello {name} you have {unreadCount, number} {unreadCount, plural, one {message} other {messages}}!" }, { name: "Roger", unreadCount: 123 });
const formattedMessagePlurals = formatMessage({
id: "hello",
defaultMessage: "Hello {name} you have {unreadCount, number} {unreadCount, plural, one {message} other {messages}}!" },
{ name: "Roger", unreadCount: 123 });
const formattedHTMLMessage = formatHTMLMessage({ id: "hello", defaultMessage: "Hello <strong>{name}</strong>!" }, { name: "Roger" });
return (
<div className={className}>
@@ -71,8 +74,17 @@ class SomeComponent extends React.Component<SomeComponentProps & InjectedIntlPro
const formattedNumber = intl.formatNumber(123, { format: "short" });
const formattedPlural = intl.formatPlural(1, { style: "ordinal" });
const formattedMessage = intl.formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" });
const formattedMessagePlurals = intl.formatMessage({ id: "hello", defaultMessage: "Hello {name} you have {unreadCount, number} {unreadCount, plural, one {message} other {messages}}!" }, { name: "Roger", unreadCount: 123 });
const formattedMessageNumber = intl.formatMessage({ id: "hello", defaultMessage: "Hello {num}!" }, { num: 1 });
const formattedMessageDate = intl.formatMessage({ id: "hello", defaultMessage: "Hello {date}!" }, { date: new Date() });
const formattedMessageBool = intl.formatMessage({ id: "hello", defaultMessage: "Hello {bool}!" }, { bool: true });
const formattedMessagePlurals = intl.formatMessage({
id: "hello",
defaultMessage: "Hello {name} you have {unreadCount, number} {unreadCount, plural, one {message} other {messages}}!" },
{ name: "Roger", unreadCount: 123 });
const formattedHTMLMessage = intl.formatHTMLMessage({ id: "hello", defaultMessage: "Hello <strong>{name}</strong>!" }, { name: "Roger" });
const formattedHTMLMessageNumber = intl.formatHTMLMessage({ id: "hello", defaultMessage: "Hello <strong>{num}</strong>!" }, { num: 1 });
const formattedHTMLMessageDate = intl.formatHTMLMessage({ id: "hello", defaultMessage: "Hello <strong>{date}</strong>!" }, { date: new Date() });
const formattedHTMLMessageBool = intl.formatHTMLMessage({ id: "hello", defaultMessage: "Hello <strong>{bool}</strong>!" }, { bool: true });
return <div className={this.props.className}>
<FormattedRelative
value={new Date().getTime()}
@@ -221,7 +233,7 @@ class SomeComponent extends React.Component<SomeComponentProps & InjectedIntlPro
<span className="number">{formattedNum}</span>
)}
</FormattedNumber>
</div>
</div>;
}
}
@@ -230,14 +242,14 @@ const SomeComponentWithIntl = injectIntl(SomeComponent);
class TestApp extends React.Component<{}, {}> {
render(): React.ReactElement<{}> {
const definedMessages = defineMessages({
"sup": {
sup: {
id: "sup",
defaultMessage: "Hai mom"
}
});
const messages = {
"hello": "Hello, {name}!"
hello: "Hello, {name}!"
};
return (
<IntlProvider locale="en" formats={{}} messages={messages} defaultLocale="en" defaultFormats={messages}>
@@ -250,9 +262,9 @@ class TestApp extends React.Component<{}, {}> {
const intlProvider = new IntlProvider({ locale: 'en' }, {});
const { intl } = intlProvider.getChildContext();
const wrappedComponent = <SomeComponentWithIntl.WrappedComponent className="test" intl={intl}/>
const wrappedComponent = <SomeComponentWithIntl.WrappedComponent className="test" intl={intl}/>;
export default {
TestApp,
SomeComponent: SomeComponentWithIntl
}
};
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+28 -28
View File
@@ -1,8 +1,8 @@
// Type definitions for react-leaflet 1.1
// Project: https://github.com/PaulLeCam/react-leaflet
// Definitions by: Dave Leaver <https://github.com/danzel>, David Schneider <https://github.com/davschne>
// Definitions by: Dave Leaver <https://github.com/danzel>, David Schneider <https://github.com/davschne>, Yui T. <https://github.com/yuit>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// TypeScript Version: 2.3
import * as Leaflet from 'leaflet';
import * as React from 'react';
@@ -143,7 +143,7 @@ export interface MapProps extends MapEvents, Leaflet.MapOptions, Leaflet.LocateO
zoom?: number;
}
export class Map<P extends MapProps, E extends Leaflet.Map> extends MapComponent<P, E> {
export class Map<P extends MapProps = MapProps, E extends Leaflet.Map = Leaflet.Map> extends MapComponent<P, E> {
className?: string;
container: HTMLDivElement;
getChildContext(): { layerContainer: E, map: E };
@@ -165,7 +165,7 @@ export interface PaneProps {
export interface PaneState {
name?: string;
}
export class Pane<P extends PaneProps, S extends PaneState> extends React.Component<P, S> {
export class Pane<P extends PaneProps = PaneProps, S extends PaneState = PaneState> extends React.Component<P, S> {
getChildContext(): { pane: string };
createPane(props: P): void;
removePane(): void;
@@ -181,7 +181,7 @@ export interface LayerContainer {
addLayer(layer: Leaflet.Layer): this;
removeLayer(layer: number | Leaflet.Layer): this;
}
export class MapLayer<P extends MapLayerProps, E extends Leaflet.Class> extends MapComponent<P, E> {
export class MapLayer<P extends MapLayerProps = MapLayerProps, E extends Leaflet.Class = Leaflet.Class> extends MapComponent<P, E> {
createLeafletElement(props: P): E;
updateLeafletElement(fromProps: P, toProps: P): void;
readonly layerContainer: LayerContainer | Leaflet.Map;
@@ -190,33 +190,33 @@ export class MapLayer<P extends MapLayerProps, E extends Leaflet.Class> extends
export interface GridLayerProps extends Leaflet.GridLayerOptions {
children?: Children;
}
export class GridLayer<P extends GridLayerProps, E extends Leaflet.GridLayer> extends MapLayer<P, E> {}
export class GridLayer<P extends GridLayerProps = GridLayerProps, E extends Leaflet.GridLayer = Leaflet.GridLayer> extends MapLayer<P, E> {}
export interface TileLayerProps extends TileLayerEvents, Leaflet.TileLayerOptions {
children?: Children;
url: string;
}
export class TileLayer<P extends TileLayerProps, E extends Leaflet.TileLayer> extends GridLayer<P, E> { }
export class TileLayer<P extends TileLayerProps = TileLayerProps, E extends Leaflet.TileLayer = Leaflet.TileLayer> extends GridLayer<P, E> { }
export interface WMSTileLayerProps extends TileLayerEvents, Leaflet.WMSOptions {
children?: Children;
url: string;
}
export class WMSTileLayer<P extends WMSTileLayerProps, E extends Leaflet.TileLayer.WMS> extends GridLayer<P, E> { }
export class WMSTileLayer<P extends WMSTileLayerProps = WMSTileLayerProps, E extends Leaflet.TileLayer.WMS = Leaflet.TileLayer.WMS> extends GridLayer<P, E> { }
export interface ImageOverlayProps extends Leaflet.ImageOverlayOptions {
bounds: Leaflet.LatLngBoundsExpression;
children?: Children;
url: string;
}
export class ImageOverlay<P extends ImageOverlayProps, E extends Leaflet.ImageOverlay> extends MapLayer<P, E> {
export class ImageOverlay<P extends ImageOverlayProps = ImageOverlayProps, E extends Leaflet.ImageOverlay = Leaflet.ImageOverlay> extends MapLayer<P, E> {
getChildContext(): { popupContainer: E };
}
export interface LayerGroupProps {
children?: Children;
}
export class LayerGroup<P extends LayerGroupProps, E extends Leaflet.LayerGroup> extends MapLayer<P, E> {
export class LayerGroup<P extends LayerGroupProps = LayerGroupProps, E extends Leaflet.LayerGroup = Leaflet.LayerGroup> extends MapLayer<P, E> {
getChildContext(): { layerContainer: E };
}
@@ -224,7 +224,7 @@ export interface MarkerProps extends MarkerEvents, Leaflet.MarkerOptions {
children?: Children;
position: Leaflet.LatLngExpression;
}
export class Marker<P extends MarkerProps, E extends Leaflet.Marker> extends MapLayer<P, E> {
export class Marker<P extends MarkerProps = MarkerProps, E extends Leaflet.Marker = Leaflet.Marker> extends MapLayer<P, E> {
getChildContext(): { popupContainer: E };
}
@@ -241,19 +241,19 @@ export interface CircleProps extends PathEvents, Leaflet.CircleMarkerOptions {
children?: Children;
radius: number;
}
export class Circle<P extends CircleProps, E extends Leaflet.Circle> extends Path<P, E> { }
export class Circle<P extends CircleProps = CircleProps, E extends Leaflet.Circle = Leaflet.Circle> extends Path<P, E> { }
export interface CircleMarkerProps extends PathEvents, Leaflet.CircleMarkerOptions {
center: Leaflet.LatLngExpression;
children?: Children;
radius: number;
}
export class CircleMarker<P extends CircleMarkerProps, E extends Leaflet.CircleMarker> extends Path<P, E> { }
export class CircleMarker<P extends CircleMarkerProps = CircleMarkerProps, E extends Leaflet.CircleMarker = Leaflet.CircleMarker> extends Path<P, E> { }
export interface FeatureGroupProps extends FeatureGroupEvents, Leaflet.PathOptions {
children?: Children;
}
export class FeatureGroup<P extends FeatureGroupProps, E extends Leaflet.FeatureGroup> extends Path<P, E> {
export class FeatureGroup<P extends FeatureGroupProps = FeatureGroupProps, E extends Leaflet.FeatureGroup = Leaflet.FeatureGroup> extends Path<P, E> {
getChildContext(): { layerContainer: E, popupContainer: E };
}
@@ -262,33 +262,33 @@ export interface GeoJSONProps extends FeatureGroupEvents, Leaflet.GeoJSONOptions
data: GeoJSON.GeoJsonObject;
style?: Leaflet.StyleFunction;
}
export class GeoJSON<P extends GeoJSONProps, E extends Leaflet.GeoJSON> extends Path<P, E> { }
export class GeoJSON<P extends GeoJSONProps = GeoJSONProps, E extends Leaflet.GeoJSON = Leaflet.GeoJSON> extends Path<P, E> { }
export interface PolylineProps extends PathEvents, Leaflet.PolylineOptions {
children?: Children;
positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][];
}
export class Polyline<P extends PolylineProps, E extends Leaflet.Polyline> extends Path<P, E> { }
export class Polyline<P extends PolylineProps = PolylineProps, E extends Leaflet.Polyline = Leaflet.Polyline> extends Path<P, E> { }
export interface PolygonProps extends PathEvents, Leaflet.PolylineOptions {
children?: Children;
popupContainer?: Leaflet.FeatureGroup;
positions: Leaflet.LatLngExpression[] | Leaflet.LatLngExpression[][] | Leaflet.LatLngExpression[][][];
}
export class Polygon<P extends PolygonProps, E extends Leaflet.Polygon> extends Path<P, E> { }
export class Polygon<P extends PolygonProps = PolygonProps, E extends Leaflet.Polygon = Leaflet.Polygon> extends Path<P, E> { }
export interface RectangleProps extends PathEvents, Leaflet.PolylineOptions {
children?: Children;
bounds: Leaflet.LatLngBoundsExpression;
popupContainer?: Leaflet.FeatureGroup;
}
export class Rectangle<P extends RectangleProps, E extends Leaflet.Rectangle> extends Path<P, E> { }
export class Rectangle<P extends RectangleProps = RectangleProps, E extends Leaflet.Rectangle = Leaflet.Rectangle> extends Path<P, E> { }
export interface PopupProps extends Leaflet.PopupOptions {
children?: Children;
position?: Leaflet.LatLngExpression;
}
export class Popup<P extends PopupProps, E extends Leaflet.Popup> extends MapComponent<P, E> {
export class Popup<P extends PopupProps = PopupProps, E extends Leaflet.Popup = Leaflet.Popup> extends MapComponent<P, E> {
onPopupOpen(arg: { popup: E }): void;
onPopupClose(arg: { popup: E }): void;
renderPopupContent(): void;
@@ -298,7 +298,7 @@ export class Popup<P extends PopupProps, E extends Leaflet.Popup> extends MapCom
export interface TooltipProps extends Leaflet.TooltipOptions {
children?: Children;
}
export class Tooltip<P extends TooltipProps, E extends Leaflet.Tooltip> extends MapComponent<P, E> {
export class Tooltip<P extends TooltipProps = TooltipProps, E extends Leaflet.Tooltip = Leaflet.Tooltip> extends MapComponent<P, E> {
onTooltipOpen(arg: { tooltip: E }): void;
onTooltipClose(arg: { tooltip: E }): void;
renderTooltipContent(): void;
@@ -306,21 +306,21 @@ export class Tooltip<P extends TooltipProps, E extends Leaflet.Tooltip> extends
}
export type MapControlProps = Leaflet.ControlOptions;
export class MapControl<P extends MapControlProps, E extends Leaflet.Control> extends React.Component<P, {}> {
export class MapControl<P extends MapControlProps = MapControlProps, E extends Leaflet.Control = Leaflet.Control> extends React.Component<P, {}> {
leafletElement: E;
createLeafletElement(props: P): E;
updateLeafletElement(fromProps: P, toProps: P): void;
}
export type AttributionControlProps = Leaflet.Control.AttributionOptions;
export class AttributionControl<P extends AttributionControlProps, E extends Leaflet.Control.Attribution> extends MapControl<P, E> { }
export class AttributionControl<P extends AttributionControlProps = AttributionControlProps, E extends Leaflet.Control.Attribution = Leaflet.Control.Attribution> extends MapControl<P, E> { }
export interface LayersControlProps extends LayersControlEvents, Leaflet.Control.LayersOptions {
baseLayers?: Leaflet.Control.LayersObject;
children?: Children;
overlays?: Leaflet.Control.LayersObject;
}
export class LayersControl<P extends AttributionControlProps, E extends Leaflet.Control.Layers> extends MapControl<P, E> { }
export class LayersControl<P extends LayersControlProps = LayersControlProps, E extends Leaflet.Control.Layers = Leaflet.Control.Layers> extends MapControl<P, E> { }
export namespace LayersControl {
interface BaseControlledLayerProps {
@@ -334,18 +334,18 @@ export namespace LayersControl {
addOverlay?(layer: Leaflet.Layer, name: string, checked: boolean): void;
name: string;
}
class ControlledLayer<P extends BaseControlledLayerProps> extends React.Component<P, {}> {
class ControlledLayer<P extends BaseControlledLayerProps = BaseControlledLayerProps> extends React.Component<P, {}> {
layer?: Leaflet.Layer;
getChildContext(): { layerContainer: LayerContainer };
addLayer(): void;
removeLayer(layer: Leaflet.Layer): void;
}
class BaseLayer<P extends ControlledLayerProps> extends ControlledLayer<P> { }
class Overlay<P extends ControlledLayerProps> extends ControlledLayer<P> { }
class BaseLayer<P extends ControlledLayerProps = ControlledLayerProps> extends ControlledLayer<P> { }
class Overlay<P extends ControlledLayerProps = ControlledLayerProps> extends ControlledLayer<P> { }
}
export type ScaleControlProps = Leaflet.Control.ScaleOptions;
export class ScaleControl<P extends ScaleControlProps, E extends Leaflet.Control.Scale> extends MapControl<P, E> { }
export class ScaleControl<P extends ScaleControlProps = ScaleControlProps, E extends Leaflet.Control.Scale = Leaflet.Control.Scale> extends MapControl<P, E> { }
export type ZoomControlProps = Leaflet.Control.ZoomOptions;
export class ZoomControl<P extends ZoomControlProps, E extends Leaflet.Control.Zoom> extends MapControl<P, E> { }
export class ZoomControl<P extends ZoomControlProps = ZoomControlProps, E extends Leaflet.Control.Zoom = Leaflet.Control.Zoom> extends MapControl<P, E> { }
+2 -2
View File
@@ -686,7 +686,7 @@ class CenterControl extends MapControl<MapControlProps, Leaflet.Control> { // n
const centerControl = new L.Control({ position: 'bottomright' }); // see http://leafletjs.com/reference.html#control-positions for other positions
const jsx = (
// PUT YOUR JSX FOR THE COMPONENT HERE:
<div {...this.props}>
<div>
{/* add your JSX */}
</div>
);
@@ -713,7 +713,7 @@ class LegendControl extends MapControl<MapControlProps & { className?: string },
componentWillMount() {
const legend = new L.Control({ position: 'bottomright' });
const jsx = (
<div {...this.props}>
<div>
{this.props.children}
</div>
);
+2
View File
@@ -268,6 +268,7 @@ export interface NavigationInitAction {
export interface NavigationResetAction {
type?: 'Navigation/RESET',
index: number,
key?: string | null,
actions: NavigationNavigateAction[],
}
@@ -319,6 +320,7 @@ export type NavigationAction =
| NavigationTabAction
export namespace NavigationActions {
function init(options?: NavigationInitAction): NavigationInitAction;
function navigate(options: NavigationNavigateAction): NavigationNavigateAction;
function reset(options: NavigationResetAction): NavigationResetAction;
function back(options?: NavigationBackAction): NavigationBackAction;
+11 -11
View File
@@ -15,12 +15,12 @@ type Store<S> = Redux.Store<S>;
type Dispatch<S> = Redux.Dispatch<S>;
type ActionCreator<A> = Redux.ActionCreator<A>;
export interface DispatchProp<T> {
dispatch: Dispatch<T>
export interface DispatchProp<S> {
dispatch: Dispatch<S>;
}
interface ComponentDecorator<TMergedProps> {
<TOwnProps>(component: Component<(TOwnProps & TMergedProps) | TOwnProps>): ComponentClass<TOwnProps>;
interface ComponentDecorator<TMergedProps, TOwnProps> {
<T extends TOwnProps>(component: Component<T & TMergedProps>): ComponentClass<T>;
}
interface ComponentMergeDecorator<TMergedProps, TOwnProps> {
@@ -46,21 +46,21 @@ interface ComponentMergeDecorator<TMergedProps, TOwnProps> {
* @param mergeProps
* @param options
*/
export declare function connect(): ComponentDecorator<DispatchProp<any>>;
export declare function connect(): ComponentDecorator<DispatchProp<any>, {}>;
export declare function connect<TStateProps, no_dispatch, TOwnProps>(
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps>
): ComponentDecorator<DispatchProp<any> & TStateProps>;
): ComponentDecorator<DispatchProp<any> & TStateProps, TOwnProps>;
export declare function connect<no_state, TDispatchProps, TOwnProps>(
mapStateToProps: null | undefined,
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>
): ComponentDecorator<TDispatchProps & TOwnProps>;
): ComponentDecorator<TDispatchProps, TOwnProps>;
export declare function connect<TStateProps, TDispatchProps, TOwnProps>(
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps>,
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>
): ComponentDecorator<TStateProps & TDispatchProps>;
): ComponentDecorator<TStateProps & TDispatchProps, TOwnProps>;
export declare function connect<TStateProps, no_dispatch, TOwnProps, TMergedProps>(
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps>,
@@ -91,21 +91,21 @@ export declare function connect<TStateProps, no_dispatch, TOwnProps>(
mapDispatchToProps: null | undefined,
mergeProps: null | undefined,
options: Options
): ComponentDecorator<DispatchProp<any> & TStateProps & TOwnProps>;
): ComponentDecorator<DispatchProp<any> & TStateProps, TOwnProps>;
export declare function connect<no_state, TDispatchProps, TOwnProps>(
mapStateToProps: null | undefined,
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>,
mergeProps: null | undefined,
options: Options
): ComponentDecorator<TDispatchProps>;
): ComponentDecorator<TDispatchProps, TOwnProps>;
export declare function connect<TStateProps, TDispatchProps, TOwnProps>(
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps>,
mapDispatchToProps: MapDispatchToPropsParam<TDispatchProps, TOwnProps>,
mergeProps: null | undefined,
options: Options
): ComponentDecorator<TStateProps & TDispatchProps>;
): ComponentDecorator<TStateProps & TDispatchProps, TOwnProps>;
export declare function connect<TStateProps, TDispatchProps, TOwnProps, TMergedProps>(
mapStateToProps: MapStateToPropsParam<TStateProps, TOwnProps>,
+49 -13
View File
@@ -108,12 +108,7 @@ declare var store: Store<TodoState>;
class MyRootComponent extends Component<any, any> {
}
class TodoApp extends Component<DispatchProp<any>, any> {
render (): null {
this.props.dispatch({ type: 'test' })
return null
}
}
class TodoApp extends Component<any, any> {}
interface TodoState {
todos: string[]|string;
}
@@ -156,9 +151,10 @@ ReactDOM.render(
// Inject just dispatch and don't listen to store
const WrappedTodoApp = connect()<{}>(TodoApp);
const AppWrap = (props: DispatchProp<any> & { children?: React.ReactNode }) => <div />
const WrappedApp = connect()(AppWrap);
<WrappedTodoApp />
<WrappedApp />
// Inject dispatch and every field in the global state
@@ -281,7 +277,7 @@ interface TestState {
isLoaded: boolean;
state1: number;
}
class TestComponent extends Component<TestProp, TestState> { }
class TestComponent extends Component<TestProp & DispatchProp<any>, TestState> { }
const WrappedTestComponent = connect()(TestComponent);
// return value of the connect()(TestComponent) is of the type TestComponent
@@ -290,7 +286,6 @@ ATestComponent = TestComponent;
ATestComponent = WrappedTestComponent;
let anElement: ReactElement<TestProp>;
<TestComponent property1={42} />;
<WrappedTestComponent property1={42} />;
<ATestComponent property1={42} />;
@@ -348,7 +343,7 @@ namespace TestTOwnPropsInference {
state: string;
}
class OwnPropsComponent extends React.Component<OwnProps & StateProps, void> {
class OwnPropsComponent extends React.Component<StateProps & OwnProps & DispatchProp<any>, void> {
render() {
return <div/>;
}
@@ -370,13 +365,13 @@ namespace TestTOwnPropsInference {
// React.createElement(ConnectedWithoutOwnProps, { anything: 'goes!' });
// This compiles, as expected.
React.createElement(ConnectedWithOwnProps, { state: 'string', own: 'string' });
React.createElement(ConnectedWithOwnProps, { own: 'string' });
// This should not compile, which is good.
// React.createElement(ConnectedWithOwnProps, { anything: 'goes!' });
// This compiles, as expected.
React.createElement(ConnectedWithTypeHint, { state: 'string', own: 'string' });
React.createElement(ConnectedWithTypeHint, { own: 'string' });
// This should not compile, which is good.
// React.createElement(ConnectedWithTypeHint, { anything: 'goes!' });
@@ -438,3 +433,44 @@ namespace TestMergedPropsInference {
}),
)(MergedPropsComponent);
}
namespace Issue16652 {
interface PassedProps {
commentIds: string[];
}
interface GeneratedStateProps {
comments: ({ id: string } | undefined)[];
}
class CommentList extends React.Component<PassedProps & GeneratedStateProps & DispatchProp<any>, void> {}
const mapStateToProps = (state: any, ownProps: PassedProps): GeneratedStateProps => {
return {
comments: ownProps.commentIds.map(id => ({ id })),
};
};
const ConnectedCommentList = connect<GeneratedStateProps, {}, PassedProps>(mapStateToProps)(
CommentList
);
<ConnectedCommentList commentIds={['a', 'b', 'c']} />
}
namespace Issue15463 {
interface ISpinnerProps{
showGlobalSpinner: boolean;
}
class SpinnerClass extends React.Component<ISpinnerProps & DispatchProp<any>, undefined> {
render() {
return (<div />);
}
}
export const Spinner = connect((state: any) => {
return { showGlobalSpinner: true };
})(SpinnerClass);
<Spinner />
}
+2 -2
View File
@@ -84,7 +84,7 @@ reduxForm({
// adapted from: http://redux-form.com/6.0.0-alpha.4/examples/initializeFromState/
import { connect } from 'react-redux'
import { connect, DispatchProp } from 'react-redux'
const { DOM: { input } } = React
interface DataShape {
@@ -125,7 +125,7 @@ const ConnectedDecoratedInitializeFromStateFormFunction = connect(
// React ComponentClass instead of StatelessComponent
class InitializeFromStateFormClass extends React.Component<Props, {}> {
class InitializeFromStateFormClass extends React.Component<Props & DispatchProp<any>, {}> {
render() {
return InitializeFromStateFormFunction(this.props);
}
+52
View File
@@ -0,0 +1,52 @@
// Type definitions for sharp-timer 0.3
// Project: https://github.com/afractal/SharpTimer
// Definitions by: Hermes Gjini - afractal <https://github.com/afractal/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export type ElapsedEvent = () => void;
export type ElapsingEvent = (intervalValue: number) => void;
export class Timer {
private _enabled;
private _stopped;
private _interval;
private _intervalElapsedEvents;
private _intervalElapsingEvents;
constructor(interval: number);
readonly enabled: boolean;
readonly stopped: boolean;
interval: number;
start(): void;
pause(): void;
resume(): void;
stop(): void;
onIntervalElapsed(intervalElapsedHandler: ElapsedEvent): void;
onIntervalElapsing(intervalElapsingHandler: ElapsingEvent): void;
toString(): string;
private getDoubleDigit(number);
private checkForValidInterval(interval);
}
export class Stopwatch {
private _isRunning;
private _elapsedMilliseconds;
private _startedTimeInMillis;
private _intervalIds;
private static readonly millisPerSecond;
private static readonly millisPerMinute;
private static readonly millisPerHour;
constructor();
readonly elapsed: string;
readonly elapsedMilliseconds: number;
readonly elapsedSeconds: number;
readonly elapsedMinutes: number;
readonly elapsedHours: number;
readonly isRunning: boolean;
static startNew(): Stopwatch;
start(): void;
stop(): void;
reset(): void;
restart(): void;
dispose(): void;
private getDoubleDigit(num);
}
+10
View File
@@ -0,0 +1,10 @@
import { Timer, Stopwatch } from 'sharp-timer';
let timer = new Timer(10);
timer.onIntervalElapsing(i => { });
timer.onIntervalElapsed(() => {
timer.stop();
});
timer.start();
+22
View File
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"sharp-timer-tests.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Chris Wrench <https://github.com/cgwrench>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="stripe"/>
/// <reference types="stripe/v2"/>
interface StripeCheckoutStatic {
configure(options: StripeCheckoutOptions): StripeCheckoutHandler;
+177 -157
View File
@@ -1,4 +1,4 @@
// Type definitions for stripe 2.x
// Type definitions for stripe 3.0
// Project: https://stripe.com/
// Definitions by: Andy Hawkins <https://github.com/a904guy/,http://a904guy.com>
// Eric J. Smith <https://github.com/ejsmith/>
@@ -7,164 +7,184 @@
// Justin Leider <https://github.com/jleider>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare const Stripe: StripeStatic;
export function Stripe(stripePublicKey: string): stripe.StripeStatic;
interface StripeStatic {
applePay: StripeApplePay;
setPublishableKey(key: string): void;
validateCardNumber(cardNumber: string): boolean;
validateExpiry(month: string, year: string): boolean;
validateCVC(cardCVC: string): boolean;
cardType(cardNumber: string): StripeCardDataBrand;
getToken(token: string, responseHandler: (status: number, response: StripeCardTokenResponse) => void): void;
card: StripeCard;
createToken(data: StripeCardTokenData, responseHandler: (status: number, response: StripeCardTokenResponse) => void): void;
bankAccount: StripeBankAccount;
}
export namespace stripe {
interface StripeStatic {
elements(options?: elements.ElementsCreateOptions): elements.Elements;
createToken(element: elements.Element, options?: TokenOptions): Promise<TokenResponse>;
}
interface StripeCardTokenData {
number: string;
exp_month?: number;
exp_year?: number;
exp?: string;
cvc?: string;
name?: string;
address_line1?: string;
address_line2?: string;
address_city?: string;
address_state?: string;
address_zip?: string;
address_country?: string;
}
interface TokenOptions {
name?: string;
address_line1?: string;
address_line2?: string;
address_city?: string;
address_state?: string;
address_zip?: string;
address_country?: string;
currency?: string;
}
interface StripeTokenResponse {
id: string;
client_ip: string;
created: number;
livemode: boolean;
object: string;
type: string;
used: boolean;
error?: StripeError;
}
interface StripeCardTokenResponse extends StripeTokenResponse {
card: StripeCard;
}
interface StripeError {
type: string;
code: string;
message: string;
param?: string;
}
type StripeCardDataBrand = 'Visa' | 'American Express' | 'MasterCard' | 'Discover' | 'JCB' | 'Diners Club' | 'Unknown';
type StripeCardDataFunding = 'credit' | 'debit' | 'prepaid' | 'unknown';
interface StripeCard {
object: string;
last4: string;
exp_month: number;
exp_year: number;
country?: string;
name?: string;
address_line1?: string;
address_line2?: string;
address_city?: string;
address_state?: string;
address_zip?: string;
address_country?: string;
brand?: StripeCardDataBrand;
funding?: StripeCardDataFunding;
createToken(data: StripeCardTokenData, responseHandler: (status: number, response: StripeCardTokenResponse) => void): void;
validateCardNumber(cardNumber: string): boolean;
validateExpiry(month: string, year: string): boolean;
validateCVC(cardCVC: string): boolean;
}
interface StripeBankAccount {
createToken(params: StripeBankTokenParams, stripeResponseHandler: (status: number, response: StripeBankTokenResponse) => void): void;
validateRoutingNumber(routingNumber: number | string, countryCode: string): boolean;
validateAccountNumber(accountNumber: number | string, countryCode: string): boolean;
}
interface StripeBankTokenParams {
country: string;
currency: string;
account_number: number | string;
routing_number?: number | string;
account_holder_name: string;
account_holder_type: string;
}
interface StripeBankTokenResponse extends StripeTokenResponse {
bank_account: {
country: string;
bank_name: string;
last4: number;
validated: boolean;
interface Token {
id: string;
object: string;
};
bank_account?: BankAccount;
card?: Card;
client_ip: string;
created: number;
livemode: boolean;
type: string;
used: boolean;
}
interface TokenResponse {
token?: Token;
error?: Error;
}
interface Error {
type: string;
charge: string;
message?: string;
code?: string;
declined_code?: string;
param?: string;
}
type statusType = 'new' | 'validated' | 'verified' | 'verification_failed' | 'errored';
interface BankAccount {
id: string;
object: string;
account_holder_name: string;
account_holder_type: string;
bank_name: string;
country: string;
currency: string;
fingerprint: string;
last4: string;
routing_number: string;
status: statusType;
}
type brandType = 'Visa' | 'American Express' | 'MasterCard' | 'Discover' | 'JCB' | 'Diners Club' | 'Unknown';
type checkType = 'pass' | 'fail' | 'unavailable' | 'unchecked';
type fundingType = 'credit' | 'debit' | 'prepaid' | 'unknown';
type tokenizationType = 'apple_pay' | 'android_pay';
interface Card {
id: string;
object: string;
address_city?: string;
address_country?: string;
address_line1?: string;
address_line1_check?: checkType;
address_line2?: string;
address_state?: string;
address_zip?: string;
address_zip_check?: checkType;
brand: brandType;
country: string;
currency?: string;
cvc_check?: checkType;
dynamic_last4: string;
exp_month: number;
exp_year: number;
fingerprint: string;
funding: fundingType;
last4: string;
metadata: any;
name?: string;
tokenization_method?: tokenizationType;
}
// Container for all elements related types
namespace elements {
interface ElementsCreateOptions {
fonts?: elements.Font[];
locale?: string;
}
type handler = (response?: ElementChangeResponse) => void;
type eventTypes = 'blur' | 'change' | 'focus' | 'ready';
interface Element {
// HTMLElement keeps giving this error for some reason:
// Cannot find name 'HTMLElement'
mount(domElement: string | any): void;
on(event: eventTypes, handler: handler): void;
blur(): void;
clear(): void;
unmount(): void;
update(options: ElementsOptions): void;
}
interface ElementChangeResponse {
brand: string;
complete: boolean;
empty: boolean;
value?: { postalCode: string | number };
error?: Error;
}
interface ElementOptions {
fonts?: elements.Font[];
locale?: string;
}
type elementsType = 'card' | 'cardNumber' | 'cardExpiry' | 'cardCvc' | 'postalCode';
interface Elements {
create(type: elementsType, options: ElementsOptions): Element;
}
interface ElementsOptions {
classes?: {
base?: string;
complete?: string;
empty?: string;
focus?: string;
invalid?: string;
webkitAutofill?: string;
};
hidePostalCode?: boolean;
hideIcon?: boolean;
iconStyle?: 'solid' | 'default';
style?: {
base?: Style;
complete?: Style;
empty?: Style;
invalid?: Style;
};
value?: string | {[objectKey: string]: string; };
}
interface Style extends StyleOptions {
':hover'?: StyleOptions;
':focus'?: StyleOptions;
'::placeholder'?: StyleOptions;
'::selection'?: StyleOptions;
':-webkit-autofill'?: StyleOptions;
}
interface Font {
family?: string;
src?: string;
style?: string;
unicodeRange?: string;
weight?: string;
}
interface StyleOptions {
color?: string;
fontFamily?: string;
fontSize?: string;
fontSmoothing?: string;
fontStyle?: string;
fontVariant?: string;
iconColor?: string;
lineHeight?: string;
letterSpacing?: string;
textDecoration?: string;
textShadow?: string;
textTransform?: string;
}
}
}
interface StripeApplePay {
checkAvailability(resopnseHandler: (result: boolean) => void): void;
buildSession(data: StripeApplePayPaymentRequest,
onSuccessHandler: (result: StripeApplePaySessionResult, completion: ((value: any) => void)) => void,
onErrorHanlder: (error: { message: string }) => void): any;
}
type StripeApplePayBillingContactField = 'postalAddress' | 'name';
type StripeApplePayShippingContactField = StripeApplePayBillingContactField | 'phone' | 'email';
type StripeApplePayShipping = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup';
interface StripeApplePayPaymentRequest {
billingContact: StripeApplePayPaymentContact;
countryCode: string;
currencyCode: string;
total: StripeApplePayLineItem;
lineItems?: StripeApplePayLineItem[];
requiredBillingContactFields?: StripeApplePayBillingContactField[];
requiredShippingContactFields?: StripeApplePayShippingContactField[];
shippingContact?: StripeApplePayPaymentContact;
shippingMethods?: StripeApplePayShippingMethod[];
shippingType?: StripeApplePayShipping[];
}
// https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types
interface StripeApplePayLineItem {
type: 'pending' | 'final';
label: string;
amount: number;
}
interface StripeApplePaySessionResult {
token: StripeCardTokenResponse;
shippingContact?: StripeApplePayPaymentContact;
shippingMethod?: StripeApplePayShippingMethod;
}
interface StripeApplePayShippingMethod {
label: string;
detail: string;
amount: number;
identifier: string;
}
interface StripeApplePayPaymentContact {
emailAddress: string;
phoneNumber: string;
givenName: string;
familyName: string;
addressLines: string[];
locality: string;
administrativeArea: string;
postalCode: string;
countryCode: string;
}
// The Stripe client side APIs are not made available to package managers for direct installation.
// As explained compliance reasons. Source: https://github.com/stripe/stripe-node/blob/master/README.md#these-are-serverside-bindings-only
// A release date versioning schema is used to version these APIs.
+37 -23
View File
@@ -1,25 +1,39 @@
function success(card: StripeCard) {
console.log(card.brand && card.brand.toString());
}
import {stripe, Stripe} from 'stripe';
const cardNumber = '4242424242424242';
const isValid = Stripe.validateCardNumber(cardNumber);
if (isValid) {
const tokenData: StripeCardTokenData = {
number: cardNumber,
exp_month: 1,
exp_year: 2100,
cvc: '111'
};
Stripe.card.createToken(tokenData, (status, response) => {
if (response.error) {
console.error(response.error.message);
if (response.error.param) {
console.error(response.error.param);
}
} else {
success(response.card);
const stripe = Stripe('public-key');
const elements = stripe.elements();
const style = {
base: {
color: '#32325d',
lineHeight: '24px',
fontFamily: 'Roboto, "Helvetica Neue", sans-serif',
fontSmoothing: 'antialiased',
fontSize: '16px',
'::placeholder': {
color: '#aab7c4'
}
});
}
},
invalid: {
color: '#B71C1C',
iconColor: '#B71C1C'
}
};
const card = elements.create('card', {hidePostalCode: true, style});
card.mount(document.createElement('div'));
card.on('ready', () => {
console.log('ready');
});
card.on('change', (resp: stripe.elements.ElementChangeResponse) => {
console.log(resp.brand);
});
stripe.createToken(card, {
name: 'Jimmy',
address_city: 'Toronto',
address_country: 'Canada'
})
.then((result: stripe.TokenResponse) => {
console.log(result.token);
},
(error: stripe.Error) => {
console.error(error);
});
+1 -1
View File
@@ -20,4 +20,4 @@
"index.d.ts",
"stripe-tests.ts"
]
}
}
+170
View File
@@ -0,0 +1,170 @@
// Type definitions for stripe 2.x
// Project: https://stripe.com/
// Definitions by: Andy Hawkins <https://github.com/a904guy/,http://a904guy.com>
// Eric J. Smith <https://github.com/ejsmith/>
// Amrit Kahlon <https://github.com/amritk/>
// Adam Cmiel <https://github.com/adamcmiel>
// Justin Leider <https://github.com/jleider>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare const Stripe: StripeStatic;
interface StripeStatic {
applePay: StripeApplePay;
setPublishableKey(key: string): void;
validateCardNumber(cardNumber: string): boolean;
validateExpiry(month: string, year: string): boolean;
validateCVC(cardCVC: string): boolean;
cardType(cardNumber: string): StripeCardDataBrand;
getToken(token: string, responseHandler: (status: number, response: StripeCardTokenResponse) => void): void;
card: StripeCard;
createToken(data: StripeCardTokenData, responseHandler: (status: number, response: StripeCardTokenResponse) => void): void;
bankAccount: StripeBankAccount;
}
interface StripeCardTokenData {
number: string;
exp_month?: number;
exp_year?: number;
exp?: string;
cvc?: string;
name?: string;
address_line1?: string;
address_line2?: string;
address_city?: string;
address_state?: string;
address_zip?: string;
address_country?: string;
}
interface StripeTokenResponse {
id: string;
client_ip: string;
created: number;
livemode: boolean;
object: string;
type: string;
used: boolean;
error?: StripeError;
}
interface StripeCardTokenResponse extends StripeTokenResponse {
card: StripeCard;
}
interface StripeError {
type: string;
code: string;
message: string;
param?: string;
}
type StripeCardDataBrand = 'Visa' | 'American Express' | 'MasterCard' | 'Discover' | 'JCB' | 'Diners Club' | 'Unknown';
type StripeCardDataFunding = 'credit' | 'debit' | 'prepaid' | 'unknown';
interface StripeCard {
object: string;
last4: string;
exp_month: number;
exp_year: number;
country?: string;
name?: string;
address_line1?: string;
address_line2?: string;
address_city?: string;
address_state?: string;
address_zip?: string;
address_country?: string;
brand?: StripeCardDataBrand;
funding?: StripeCardDataFunding;
createToken(data: StripeCardTokenData, responseHandler: (status: number, response: StripeCardTokenResponse) => void): void;
validateCardNumber(cardNumber: string): boolean;
validateExpiry(month: string, year: string): boolean;
validateCVC(cardCVC: string): boolean;
}
interface StripeBankAccount {
createToken(params: StripeBankTokenParams, stripeResponseHandler: (status: number, response: StripeBankTokenResponse) => void): void;
validateRoutingNumber(routingNumber: number | string, countryCode: string): boolean;
validateAccountNumber(accountNumber: number | string, countryCode: string): boolean;
}
interface StripeBankTokenParams {
country: string;
currency: string;
account_number: number | string;
routing_number?: number | string;
account_holder_name: string;
account_holder_type: string;
}
interface StripeBankTokenResponse extends StripeTokenResponse {
bank_account: {
country: string;
bank_name: string;
last4: number;
validated: boolean;
object: string;
};
}
interface StripeApplePay {
checkAvailability(resopnseHandler: (result: boolean) => void): void;
buildSession(data: StripeApplePayPaymentRequest,
onSuccessHandler: (result: StripeApplePaySessionResult, completion: ((value: any) => void)) => void,
onErrorHanlder: (error: { message: string }) => void): any;
}
type StripeApplePayBillingContactField = 'postalAddress' | 'name';
type StripeApplePayShippingContactField = StripeApplePayBillingContactField | 'phone' | 'email';
type StripeApplePayShipping = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup';
interface StripeApplePayPaymentRequest {
billingContact: StripeApplePayPaymentContact;
countryCode: string;
currencyCode: string;
total: StripeApplePayLineItem;
lineItems?: StripeApplePayLineItem[];
requiredBillingContactFields?: StripeApplePayBillingContactField[];
requiredShippingContactFields?: StripeApplePayShippingContactField[];
shippingContact?: StripeApplePayPaymentContact;
shippingMethods?: StripeApplePayShippingMethod[];
shippingType?: StripeApplePayShipping[];
}
// https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types
interface StripeApplePayLineItem {
type: 'pending' | 'final';
label: string;
amount: number;
}
interface StripeApplePaySessionResult {
token: StripeCardTokenResponse;
shippingContact?: StripeApplePayPaymentContact;
shippingMethod?: StripeApplePayShippingMethod;
}
interface StripeApplePayShippingMethod {
label: string;
detail: string;
amount: number;
identifier: string;
}
interface StripeApplePayPaymentContact {
emailAddress: string;
phoneNumber: string;
givenName: string;
familyName: string;
addressLines: string[];
locality: string;
administrativeArea: string;
postalCode: string;
countryCode: string;
}
// The Stripe client side APIs are not made available to package managers for direct installation.
// As explained compliance reasons. Source: https://github.com/stripe/stripe-node/blob/master/README.md#these-are-serverside-bindings-only
// A release date versioning schema is used to version these APIs.
+25
View File
@@ -0,0 +1,25 @@
function success(card: StripeCard) {
console.log(card.brand && card.brand.toString());
}
const cardNumber = '4242424242424242';
const isValid = Stripe.validateCardNumber(cardNumber);
if (isValid) {
const tokenData: StripeCardTokenData = {
number: cardNumber,
exp_month: 1,
exp_year: 2100,
cvc: '111'
};
Stripe.card.createToken(tokenData, (status, response) => {
if (response.error) {
console.error(response.error.message);
if (response.error.param) {
console.error(response.error.param);
}
} else {
success(response.card);
}
});
}
+26
View File
@@ -0,0 +1,26 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"types": [],
"paths": {
"stripe": ["stripe/v2"]
},
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"stripe-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }