mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 12:42:58 +08:00
Merge more from types-2.0 to `master (#13770)
* Add memoizee definitions * Fix common issues, added doc * Removed blank line * fix test * Fix test methods * Fix check style * Fix check style * Fixing semver header * Fixing semver header * `memoizee`: Clean up types * Types 2.0 - Fix JS-quantities (#12739) * Enable strict null checking per readme FAQ. * Add tslint.json. * Improve test file with project spec. * Fix js-quantities d.ts, with adjustment of test. * Add trailing newline to tslint. * Simplify functional interface per linter. * js-quantities: add readme examples to tests * js-quantities: fix & clean declaration * d3-selection: Mark before param of insert() as optional (#13090) Selection<etc>.insert functions perfectly well without a `before` selector -- it does so in many d3 official examples. This corrects the type signature to mark it as optional. * [react-intl] bugfix for #12716 (#12906) * fix for issue introduced in https://github.com/DefinitelyTyped/DefinitelyTyped/pull/12716 * injectIntl is now usable as class decorator * fixed test * use inferface instead of type * format document * fix chai-json-schema styling (#13537) * googlemaps: Allow Marker.setAnimation(null) and Marker.setMap(null) (#13240) * googlemaps: Allow Marker.setAnimation(null) * Also, turn on strictNullChecks * Allow new google.maps.Map(null) since it's technically possible with Google's example code from the docs Signed-off-by: Iqbal Yusuf <iyusuf@corelogic.com> * googlemaps: Allow Marker.setMap(null) * Also, add more test code from the Google Maps API documentation Signed-off-by: Grant Hutchins <ghutchins@pivotal.io> * Added the brand property to the StripeCardData and fix style issues, lint (#13084) * Add the "brand" field to StipeCardData Added the StipeCardDataBrand type. Added the `brand` property to the `StripeCardData` declaration with the type `'Visa' | 'American Express' | 'MasterCard' | 'Discover JCB' | 'Diners Club' | 'Unknown'` Reference: https://stripe.com/docs/api#card_object * Run linter, fix issues. set --strictNullChecks. Unsure about ambient declaration: Removed as it seemed to be in error: 1. case was not correct 2. the export was the type of the global which is unconditionally defined. 3. this module does not seem a suitable candidate for a UMD declaration. * Use header version of 0.0; explain Stripe versioning in comments * Restore global * Added tests
This commit is contained in:
24
chai-json-schema/index.d.ts
vendored
24
chai-json-schema/index.d.ts
vendored
@@ -6,19 +6,19 @@
|
||||
// <reference types="node"/>
|
||||
// <reference types="chai" />
|
||||
|
||||
declare namespace Chai {
|
||||
export interface Assert {
|
||||
jsonSchema(value: any, schema: any, msg?: string): void;
|
||||
notJsonSchema(value: any, schema: any, msg?: string): void;
|
||||
}
|
||||
declare global {
|
||||
namespace Chai {
|
||||
export interface Assert {
|
||||
jsonSchema(value: any, schema: any, msg?: string): void;
|
||||
notJsonSchema(value: any, schema: any, msg?: string): void;
|
||||
}
|
||||
|
||||
export interface LanguageChains {
|
||||
jsonSchema(schema: any, msg?: string): void;
|
||||
export interface LanguageChains {
|
||||
jsonSchema(schema: any, msg?: string): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare module "chai-json-schema" {
|
||||
function chaiJsonSchema(chai: any, utils: any): void;
|
||||
namespace chaiJsonSchema {}
|
||||
export = chaiJsonSchema;
|
||||
}
|
||||
declare function chaiJsonSchema(chai: any, utils: any): void;
|
||||
declare namespace chaiJsonSchema { }
|
||||
export = chaiJsonSchema;
|
||||
|
||||
@@ -1,5 +1 @@
|
||||
{ "extends": "../tslint.json",
|
||||
"rules": {
|
||||
"no-single-declare-module": false
|
||||
}
|
||||
}
|
||||
{ "extends": "../tslint.json" }
|
||||
|
||||
@@ -846,60 +846,43 @@ newDiv2 = body.append(function (d, i, g) {
|
||||
// without insert<...> typing returned selection has group element of type BaseType
|
||||
let newParagraph: d3Selection.Selection<d3Selection.BaseType, BodyDatum, HTMLElement, any>;
|
||||
newParagraph = body.insert('p', 'p.second-paragraph');
|
||||
newParagraph = body.insert('p');
|
||||
|
||||
// Two arguments; the first can be string, selection , or a
|
||||
|
||||
const typeValueFunction = function (
|
||||
this: HTMLBodyElement,
|
||||
d: BodyDatum,
|
||||
i: number,
|
||||
g: HTMLBodyElement[] | d3Selection.ArrayLike<HTMLBodyElement>
|
||||
) {
|
||||
return this.ownerDocument.createElement('p'); // this-type HTMLParagraphElement
|
||||
}
|
||||
|
||||
const beforeValueFunction = function (
|
||||
this: HTMLBodyElement,
|
||||
d: BodyDatum,
|
||||
i: number,
|
||||
g: HTMLBodyElement[] | d3Selection.ArrayLike<HTMLBodyElement>
|
||||
) {
|
||||
return this.children[0];
|
||||
}
|
||||
|
||||
let newParagraph2: d3Selection.Selection<HTMLParagraphElement, BodyDatum, HTMLElement, any>;
|
||||
|
||||
// 2 args, with 3 possibilities each, makes 9 possible combinations:
|
||||
newParagraph2 = body.insert<HTMLParagraphElement>('p', 'p.second-paragraph');
|
||||
newParagraph2 = body.insert<HTMLParagraphElement>('p', beforeValueFunction);
|
||||
newParagraph2 = body.insert<HTMLParagraphElement>('p');
|
||||
|
||||
newParagraph2 = body.insert(d3Selection.creator<HTMLParagraphElement>('p'), 'p.second-paragraph');
|
||||
newParagraph2 = body.insert(function (d, i, g) {
|
||||
let that: HTMLBodyElement = this;
|
||||
// let that2: SVGElement = this; // fails, type mismatch
|
||||
let datum: BodyDatum = d;
|
||||
let index: number = i;
|
||||
let group: HTMLBodyElement[] | d3Selection.ArrayLike<HTMLBodyElement> = g;
|
||||
console.log('Body element foo property: ', d.foo); // data of type BodyDatum
|
||||
return this.ownerDocument.createElement('p'); // this-type HTMLParagraphElement
|
||||
}, 'p.second-paragraph');
|
||||
newParagraph2 = body.insert(d3Selection.creator<HTMLParagraphElement>('p'), beforeValueFunction);
|
||||
newParagraph2 = body.insert(d3Selection.creator<HTMLParagraphElement>('p'));
|
||||
|
||||
// newParagraph2 = body.insert<HTMLParagraphElement>(function(d) {
|
||||
// return this.ownerDocument.createElement('a'); // fails, HTMLParagraphElement expected by type parameter, HTMLAnchorElement returned
|
||||
// }, 'p.second-paragraph');
|
||||
newParagraph2 = body.insert(typeValueFunction, 'p.second-paragraph');
|
||||
newParagraph2 = body.insert(typeValueFunction, beforeValueFunction);
|
||||
newParagraph2 = body.insert(typeValueFunction);
|
||||
|
||||
// newParagraph2 = body.insert(function(d) {
|
||||
// return this.ownerDocument.createElement('a'); // fails, HTMLParagraphElement expected by type inference, HTMLAnchorElement returned
|
||||
// }, 'p.second-paragraph');
|
||||
|
||||
newParagraph2 = body.insert(d3Selection.creator<HTMLParagraphElement>('p'), function (d, i, g) {
|
||||
let that: HTMLBodyElement = this;
|
||||
// let that2: SVGElement = this; // fails, type mismatch
|
||||
let datum: BodyDatum = d;
|
||||
let index: number = i;
|
||||
let group: HTMLBodyElement[] | d3Selection.ArrayLike<HTMLBodyElement> = g;
|
||||
console.log('Body element foo property: ', d.foo); // data of type BodyDatum
|
||||
return this.children[0]; // this type HTMLBodyElement
|
||||
});
|
||||
|
||||
newParagraph2 = body.insert(
|
||||
// type
|
||||
function (d, i, g) {
|
||||
let that: HTMLBodyElement = this;
|
||||
// let that2: SVGElement = this; // fails, type mismatch
|
||||
let datum: BodyDatum = d;
|
||||
let index: number = i;
|
||||
let group: HTMLBodyElement[] | d3Selection.ArrayLike<HTMLBodyElement> = g;
|
||||
console.log('Body element foo property: ', d.foo); // data of type BodyDatum
|
||||
return this.ownerDocument.createElement('p'); // this-type HTMLParagraphElement
|
||||
},
|
||||
// before
|
||||
function (d, i, g) {
|
||||
let that: HTMLBodyElement = this;
|
||||
// let that2: SVGElement = this; // fails, type mismatch
|
||||
let datum: BodyDatum = d;
|
||||
let index: number = i;
|
||||
let group: HTMLBodyElement[] | d3Selection.ArrayLike<HTMLBodyElement> = g;
|
||||
console.log('Body element foo property: ', d.foo); // data of type BodyDatum
|
||||
return this.children[0]; // this type HTMLBodyElement
|
||||
});
|
||||
|
||||
// sort(...) -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
2
d3-selection/index.d.ts
vendored
2
d3-selection/index.d.ts
vendored
@@ -519,7 +519,7 @@ interface Selection<GElement extends BaseType, Datum, PElement extends BaseType,
|
||||
*/
|
||||
insert<ChildElement extends BaseType>(
|
||||
type: string | ValueFn<GElement, Datum, ChildElement>,
|
||||
before: string | ValueFn<GElement, Datum, BaseType>
|
||||
before?: string | ValueFn<GElement, Datum, BaseType>
|
||||
): Selection<ChildElement, Datum, PElement, PDatum>;
|
||||
|
||||
/**
|
||||
|
||||
@@ -141,19 +141,102 @@ var mapTypeStyle: google.maps.MapTypeStyle ={
|
||||
stylers: [],
|
||||
};
|
||||
|
||||
// https://developers.google.com/maps/documentation/javascript/adding-a-google-map
|
||||
function initMap() {
|
||||
var uluru = {lat: -25.363, lng: 131.044};
|
||||
// https://developers.google.com/maps/documentation/javascript/markers
|
||||
function initMap1() {
|
||||
var myLatLng = {lat: -25.363, lng: 131.044};
|
||||
|
||||
var map = new google.maps.Map(document.getElementById('map'), {
|
||||
zoom: 4,
|
||||
center: uluru
|
||||
center: myLatLng
|
||||
});
|
||||
|
||||
var marker = new google.maps.Marker({
|
||||
position: uluru,
|
||||
position: myLatLng,
|
||||
map: map,
|
||||
title: 'Hello World!'
|
||||
});
|
||||
}
|
||||
|
||||
var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
|
||||
var mapOptions = {
|
||||
zoom: 4,
|
||||
center: myLatlng
|
||||
}
|
||||
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
|
||||
|
||||
var marker = new google.maps.Marker({
|
||||
position: myLatlng,
|
||||
title:"Hello World!"
|
||||
});
|
||||
|
||||
// To add the marker to the map, call setMap();
|
||||
marker.setMap(map);
|
||||
|
||||
marker.setMap(null);
|
||||
|
||||
// The following example creates a marker in Stockholm, Sweden using a DROP
|
||||
// animation. Clicking on the marker will toggle the animation between a BOUNCE
|
||||
// animation and no animation.
|
||||
|
||||
var marker: google.maps.Marker;
|
||||
|
||||
function initMap2() {
|
||||
var map = new google.maps.Map(document.getElementById('map'), {
|
||||
zoom: 13,
|
||||
center: {lat: 59.325, lng: 18.070}
|
||||
});
|
||||
|
||||
marker = new google.maps.Marker({
|
||||
map: map,
|
||||
draggable: true,
|
||||
animation: google.maps.Animation.DROP,
|
||||
position: {lat: 59.327, lng: 18.067}
|
||||
});
|
||||
marker.addListener('click', toggleBounce);
|
||||
}
|
||||
|
||||
function toggleBounce() {
|
||||
if (marker.getAnimation() !== null) {
|
||||
marker.setAnimation(null);
|
||||
} else {
|
||||
marker.setAnimation(google.maps.Animation.BOUNCE);
|
||||
}
|
||||
}
|
||||
|
||||
// In the following example, markers appear when the user clicks on the map.
|
||||
// Each marker is labeled with a single alphabetical character.
|
||||
var labels = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
var labelIndex = 0;
|
||||
|
||||
function initialize() {
|
||||
var bangalore = { lat: 12.97, lng: 77.59 };
|
||||
var map = new google.maps.Map(document.getElementById('map'), {
|
||||
zoom: 12,
|
||||
center: bangalore
|
||||
});
|
||||
|
||||
// This event listener calls addMarker() when the map is clicked.
|
||||
google.maps.event.addListener(map, 'click', function(event: any) {
|
||||
addMarker(event.latLng, map);
|
||||
});
|
||||
|
||||
// Add a marker at the center of the map.
|
||||
addMarker(bangalore, map);
|
||||
}
|
||||
|
||||
// Adds a marker to the map.
|
||||
function addMarker(location: google.maps.LatLngLiteral, map: google.maps.Map) {
|
||||
// Add the marker at the clicked location, and add the next-available label
|
||||
// from the array of alphabetical characters.
|
||||
var marker = new google.maps.Marker({
|
||||
position: location,
|
||||
label: labels[labelIndex++ % labels.length],
|
||||
map: map
|
||||
});
|
||||
}
|
||||
|
||||
google.maps.event.addDomListener(window, 'load', initialize);
|
||||
|
||||
/***** OverlayView *****/
|
||||
// https://developers.google.com/maps/documentation/javascript/customoverlays
|
||||
var div = document.createElement('div');
|
||||
@@ -183,4 +266,4 @@ var rectangle = new google.maps.Rectangle({
|
||||
east: -116.234,
|
||||
west: -116.251
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
8
googlemaps/index.d.ts
vendored
8
googlemaps/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Google Maps JavaScript API 3.25
|
||||
// Project: https://developers.google.com/maps/
|
||||
// Definitions by: Folia A/S <http://www.folia.dk>, Chris Wrench <https://github.com/cgwrench>, Kiarash Ghiaseddin <https://github.com/Silver-Connection/DefinitelyTyped>
|
||||
// Definitions by: Folia A/S <http://www.folia.dk>, Chris Wrench <https://github.com/cgwrench>, Kiarash Ghiaseddin <https://github.com/Silver-Connection/DefinitelyTyped>, Grant Hutchins <https://github.com/nertzy>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/*
|
||||
@@ -30,7 +30,7 @@ THE SOFTWARE.
|
||||
declare namespace google.maps {
|
||||
/***** Map *****/
|
||||
export class Map extends MVCObject {
|
||||
constructor(mapDiv: Element, opts?: MapOptions);
|
||||
constructor(mapDiv: Element|null, opts?: MapOptions);
|
||||
fitBounds(bounds: LatLngBounds|LatLngBoundsLiteral): void;
|
||||
getBounds(): LatLngBounds;
|
||||
getCenter(): LatLng;
|
||||
@@ -536,14 +536,14 @@ declare namespace google.maps {
|
||||
getTitle(): string;
|
||||
getVisible(): boolean;
|
||||
getZIndex(): number;
|
||||
setAnimation(animation: Animation): void;
|
||||
setAnimation(animation: Animation|null): void;
|
||||
setAttribution(attribution: Attribution): void;
|
||||
setClickable(flag: boolean): void;
|
||||
setCursor(cursor: string): void;
|
||||
setDraggable(flag: boolean): void;
|
||||
setIcon(icon: string|Icon|Symbol): void;
|
||||
setLabel(label: string|MarkerLabel): void;
|
||||
setMap(map: Map|StreetViewPanorama): void;
|
||||
setMap(map: Map|StreetViewPanorama|null): void;
|
||||
setOpacity(opacity: number): void;
|
||||
setOptions(options: MarkerOptions): void;
|
||||
setPlace(place: Place): void;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -17,4 +17,4 @@
|
||||
"index.d.ts",
|
||||
"google.maps-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
132
js-quantities/index.d.ts
vendored
132
js-quantities/index.d.ts
vendored
@@ -1,79 +1,73 @@
|
||||
// Type definitions for JS-quantities
|
||||
// Type definitions for JS-quantities 1.6
|
||||
// Project: http://gentooboontoo.github.io/js-quantities/
|
||||
// Definitions by: William Comartin <https://github.com/wcomartin>
|
||||
// Definitions by: William Rummler <https://github.com/wrummler>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare var Qty: QtyModule.QtyStatic;
|
||||
|
||||
declare namespace QtyModule {
|
||||
interface QtyStatic {
|
||||
(value: string): Qty;
|
||||
(value: number): Qty;
|
||||
(value: number, unit: string): Qty;
|
||||
(value: Qty): Qty;
|
||||
}
|
||||
|
||||
interface Qty {
|
||||
version: string;
|
||||
|
||||
scalar: number;
|
||||
baseScalar: number;
|
||||
|
||||
parse(value: string): Qty;
|
||||
|
||||
swiftConverter(srcUnits:string, dstUnits:string): (value:number) => number;
|
||||
|
||||
getkinds(): string[];
|
||||
|
||||
getUnits(kind:string): string[];
|
||||
|
||||
getAliases(unitName:string): string[];
|
||||
|
||||
formatter(scalar:number, units:string):string;
|
||||
|
||||
toFloat(): number;
|
||||
|
||||
isUnitless(): boolean;
|
||||
|
||||
isCompatible(other:string|Qty): boolean;
|
||||
|
||||
isInverse(other:string|Qty): boolean
|
||||
|
||||
kind(): string;
|
||||
|
||||
isBase(): boolean;
|
||||
|
||||
toBase(): Qty;
|
||||
declare const Qty: Qty.Type;
|
||||
|
||||
declare interface Qty {
|
||||
readonly numerator: string[];
|
||||
readonly denominator: string[];
|
||||
readonly scalar: number;
|
||||
readonly baseScalar: number;
|
||||
readonly initValue: string;
|
||||
units(): string;
|
||||
|
||||
eq(other:Qty): boolean;
|
||||
lt(other:Qty): boolean;
|
||||
lte(other:Qty): boolean;
|
||||
gt(other:Qty): boolean;
|
||||
gte(other:Qty): boolean;
|
||||
|
||||
toPrec(precQuantity: Qty|string|number): Qty;
|
||||
|
||||
toString(targetUnitsOrMaxDecimalsOrPrec?:number|string|Qty, maxDecimals?: number): string;
|
||||
|
||||
format(targetUnits?:string, formatter?:(scalar:number, units:string) => string): string;
|
||||
|
||||
compareTo(other:Qty|string): number;
|
||||
|
||||
same(other: Qty): boolean;
|
||||
|
||||
isCompatible(value: Qty.UnitSource): boolean;
|
||||
kind(): string;
|
||||
isUnitless(): boolean;
|
||||
isBase(): boolean;
|
||||
toBase(): Qty;
|
||||
toFloat(): number;
|
||||
to(value: Qty.UnitSource): Qty;
|
||||
inverse(): Qty;
|
||||
eq(value: Qty.UnitSource): boolean;
|
||||
same(value: Qty.UnitSource): boolean;
|
||||
lt(value: Qty.UnitSource): boolean;
|
||||
lte(value: Qty.UnitSource): boolean;
|
||||
gt(value: Qty.UnitSource): boolean;
|
||||
gte(value: Qty.UnitSource): boolean;
|
||||
compareTo(value: Qty): Qty.ComparisonResult;
|
||||
add(value: Qty.Source): Qty;
|
||||
sub(value: Qty.Source): Qty;
|
||||
mul(value: Qty.Source): Qty;
|
||||
div(value: Qty.Source): Qty;
|
||||
toPrec(value: Qty.Source): Qty;
|
||||
toString(valueOrPrecision?: Qty.Source): string;
|
||||
toString(value: string, precision: number): string;
|
||||
format(formatter?: Qty.Formatter): string;
|
||||
format(value: string, formatter?: Qty.Formatter): string;
|
||||
}
|
||||
|
||||
isDegrees(): boolean;
|
||||
declare namespace Qty {
|
||||
|
||||
isTemperature(): boolean;
|
||||
interface Type {
|
||||
(value: Source): Qty;
|
||||
(value: number, unit: string): Qty;
|
||||
new (value: Source): Qty;
|
||||
new (value: number, unit: string): Qty;
|
||||
parse(value: string): Qty;
|
||||
getKinds(): string[];
|
||||
getUnits(kind?: string): string[];
|
||||
getAliases(unit: string): string[];
|
||||
swiftConverter(sourceUnit: string, targetUnit: string): Converter;
|
||||
formatter: Formatter;
|
||||
readonly Error: any;
|
||||
mulSafe(n1: number, n2: number): number;
|
||||
divSafe(n1: number, n2: number): number;
|
||||
}
|
||||
|
||||
to(other:string|Qty): Qty;
|
||||
interface Converter {
|
||||
(sourceValue: number): number;
|
||||
(sourceValues: number[]): number[];
|
||||
}
|
||||
|
||||
add(other:string|Qty): Qty;
|
||||
sub(other:string|Qty): Qty;
|
||||
mul(other:number|string|Qty): Qty;
|
||||
div(other:number|string|Qty): Qty;
|
||||
}
|
||||
}
|
||||
type Formatter = (scalar: number, unit: string) => string;
|
||||
|
||||
type ComparisonResult = -1 | 0 | 1;
|
||||
|
||||
type Source = UnitSource | number;
|
||||
|
||||
type UnitSource = Qty | string;
|
||||
}
|
||||
|
||||
export default Qty;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -17,4 +17,4 @@
|
||||
"index.d.ts",
|
||||
"js-quantities-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
3
js-quantities/tslint.json
Normal file
3
js-quantities/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
29
memoizee/index.d.ts
vendored
Normal file
29
memoizee/index.d.ts
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
// Type definitions for memoizee 0.4
|
||||
// Project: https://github.com/medikoo/memoizee
|
||||
// Definitions by: Juan Picado <https://github.com/juanpicado>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace memoizee {
|
||||
interface Options {
|
||||
length?: number;
|
||||
maxAge?: number;
|
||||
max?: number;
|
||||
preFetch?: number | true;
|
||||
promise?: boolean;
|
||||
dispose?: (value: any) => void;
|
||||
async?: boolean;
|
||||
primitive?: boolean;
|
||||
normalizer?: (value: any) => void;
|
||||
resolvers?: Array<(arg: any) => any>;
|
||||
}
|
||||
|
||||
interface Memoized<F> {
|
||||
delete: F;
|
||||
clear: F & (() => void);
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable:forbidden-types
|
||||
declare function memoizee<F extends Function>(f: F, options?: memoizee.Options): F & memoizee.Memoized<F>;
|
||||
|
||||
export = memoizee;
|
||||
61
memoizee/memoizee-tests.ts
Normal file
61
memoizee/memoizee-tests.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import memoize = require('memoizee');
|
||||
|
||||
var fn = function (one: string, two?: number, three?: any) { /* ... */ };
|
||||
|
||||
let memoized = memoize(fn);
|
||||
memoized('foo', 3, 'bar');
|
||||
memoized('foo', 3, 'bar');
|
||||
memoized = memoize(fn, { length: 2 });
|
||||
memoized('foo');
|
||||
memoized('foo', undefined);
|
||||
memoized('foo', 3, {});
|
||||
memoized('foo', 3, 13);
|
||||
memoized('foo', undefined);
|
||||
memoized('foo', undefined);
|
||||
memoized('foo', 3, {});
|
||||
memoized('foo', 3, 13);
|
||||
memoized('foo', 3, 13);
|
||||
memoized = memoize(fn, { primitive: true });
|
||||
memoized('/path/one');
|
||||
memoized('/path/one');
|
||||
memoized = memoize(fn, { dispose: function (value:number) { /*…*/ } });
|
||||
var foo3 = memoized('foo', 3);
|
||||
var bar7 = memoized('bar', 7);
|
||||
memoized.clear('foo', 3); // Dispose called with foo3 value
|
||||
memoized.clear('bar', 7); // Dispose called with bar7 value
|
||||
memoized.delete('foo', 0);
|
||||
var mFn = memoize(function (hash:any) {
|
||||
// body of memoized function
|
||||
}, { normalizer: function (args:any) {
|
||||
// args is arguments object as accessible in memoized function
|
||||
return JSON.stringify(args[0]);
|
||||
} });
|
||||
|
||||
mFn({ foo: 'bar' });
|
||||
|
||||
memoized = memoize(fn, { length: 2, resolvers: [String, Boolean] });
|
||||
memoized(String(12), [1,2,3].length);
|
||||
memoized("12", Number(true));
|
||||
memoized(String({ toString: function () { return "12"; } }), Number({}));
|
||||
|
||||
{
|
||||
var afn = function (a:number, b:number) {
|
||||
return new Promise(function (res) { res(a + b); });
|
||||
};
|
||||
let memoized = memoize(afn, { promise: true });
|
||||
memoized(3, 7);
|
||||
memoized(3, 7);
|
||||
}
|
||||
|
||||
memoized = memoize(fn, { maxAge: 1000, preFetch: 0.6 });
|
||||
|
||||
memoized('foo', 3);
|
||||
memoized('foo', 3);
|
||||
|
||||
setTimeout(function () {
|
||||
memoized('foo', 3);
|
||||
}, 500);
|
||||
|
||||
setTimeout(function () {
|
||||
memoized('foo', 3);
|
||||
}, 1300);
|
||||
20
memoizee/tsconfig.json
Normal file
20
memoizee/tsconfig.json
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"memoizee-tests.ts"
|
||||
]
|
||||
}
|
||||
1
memoizee/tslint.json
Normal file
1
memoizee/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
8
react-intl/index.d.ts
vendored
8
react-intl/index.d.ts
vendored
@@ -1,6 +1,6 @@
|
||||
// Type definitions for react-intl 2.2.0
|
||||
// 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>
|
||||
// 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>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
///<reference types="react" />
|
||||
@@ -13,7 +13,7 @@ declare namespace ReactIntl {
|
||||
pluralRuleFunction?: (n: number, ord: boolean) => string;
|
||||
}
|
||||
|
||||
function injectIntl<TOriginalProps, TOwnProps>(component: React.ComponentClass<TOriginalProps> | React.StatelessComponent<TOriginalProps>): React.ComponentClass<TOwnProps>;
|
||||
function injectIntl<T extends React.ComponentClass<InjectedIntlProps> | React.StatelessComponent<InjectedIntlProps>>(component: T): T;
|
||||
|
||||
function addLocaleData(data: Locale[] | Locale): void;
|
||||
|
||||
@@ -45,6 +45,10 @@ declare namespace ReactIntl {
|
||||
formatHTMLMessage: (messageDescriptor: FormattedMessage.MessageDescriptor, values?: Object) => string;
|
||||
}
|
||||
|
||||
interface InjectedIntlProps {
|
||||
intl?: InjectedIntl
|
||||
}
|
||||
|
||||
namespace IntlComponent {
|
||||
interface DateTimeFormatProps {
|
||||
/*
|
||||
|
||||
@@ -9,20 +9,20 @@ import * as React from "react"
|
||||
import * as reactMixin from "react-mixin"
|
||||
|
||||
import {
|
||||
IntlProvider,
|
||||
InjectedIntl,
|
||||
addLocaleData,
|
||||
hasLocaleData,
|
||||
injectIntl,
|
||||
intlShape,
|
||||
defineMessages,
|
||||
FormattedRelative,
|
||||
FormattedMessage,
|
||||
FormattedHTMLMessage,
|
||||
FormattedNumber,
|
||||
FormattedPlural,
|
||||
FormattedDate,
|
||||
FormattedTime
|
||||
IntlProvider,
|
||||
InjectedIntl,
|
||||
addLocaleData,
|
||||
hasLocaleData,
|
||||
injectIntl,
|
||||
intlShape,
|
||||
defineMessages,
|
||||
FormattedRelative,
|
||||
FormattedMessage,
|
||||
FormattedHTMLMessage,
|
||||
FormattedNumber,
|
||||
FormattedPlural,
|
||||
FormattedDate,
|
||||
FormattedTime
|
||||
} from "react-intl"
|
||||
|
||||
import reactIntlEn = require("react-intl/locale-data/en");
|
||||
@@ -31,7 +31,8 @@ addLocaleData(reactIntlEn);
|
||||
console.log(hasLocaleData("en"));
|
||||
|
||||
interface SomeComponentProps {
|
||||
intl: InjectedIntl
|
||||
className: string,
|
||||
intl?: InjectedIntl
|
||||
}
|
||||
|
||||
class SomeComponent extends React.Component<SomeComponentProps, void> {
|
||||
@@ -47,14 +48,14 @@ class SomeComponent extends React.Component<SomeComponentProps, void> {
|
||||
const formattedPlural = intl.formatPlural(1, { one: "hai!" });
|
||||
const formattedMessage = intl.formatMessage({ id: "hello", defaultMessage: "Hello {name}!" }, { name: "Roger" });
|
||||
const formattedHTMLMessage = intl.formatHTMLMessage({ id: "hello", defaultMessage: "Hello <strong>{name}</strong>!" }, { name: "Roger" });
|
||||
return <div>
|
||||
return <div className={this.props.className}>
|
||||
<FormattedRelative
|
||||
value={new Date().getTime() }
|
||||
value={new Date().getTime()}
|
||||
units="hour"
|
||||
style="numeric"
|
||||
format="yyyy-MM-dd"
|
||||
updateInterval={123}
|
||||
initialNow={new Date() } />
|
||||
initialNow={new Date()} />
|
||||
|
||||
<FormattedMessage
|
||||
id="test"
|
||||
@@ -102,7 +103,7 @@ class SomeComponent extends React.Component<SomeComponentProps, void> {
|
||||
many="haiku" />
|
||||
|
||||
<FormattedDate
|
||||
value={new Date() }
|
||||
value={new Date()}
|
||||
format="short"
|
||||
localeMatcher="best fit"
|
||||
formatMatcher="basic"
|
||||
@@ -119,7 +120,7 @@ class SomeComponent extends React.Component<SomeComponentProps, void> {
|
||||
timeZoneName="short" />
|
||||
|
||||
<FormattedTime
|
||||
value={new Date() }
|
||||
value={new Date()}
|
||||
format="short"
|
||||
localeMatcher="best fit"
|
||||
formatMatcher="basic"
|
||||
@@ -138,9 +139,9 @@ class SomeComponent extends React.Component<SomeComponentProps, void> {
|
||||
<FormattedNumber value={123}>
|
||||
{(formattedNum: string) => (
|
||||
<span className="number">{formattedNum}</span>
|
||||
) }
|
||||
</FormattedNumber>
|
||||
</div>
|
||||
)}
|
||||
</FormattedNumber>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,9 +160,9 @@ class TestApp extends React.Component<{}, {}> {
|
||||
"hello": "Hello, {name}!"
|
||||
};
|
||||
return (
|
||||
<IntlProvider locale="en" formats={{}} messages={messages} defaultLocale="en" defaultFormats={messages}>
|
||||
<SomeComponentWithIntl />
|
||||
</IntlProvider>
|
||||
<IntlProvider locale="en" formats={{}} messages={messages} defaultLocale="en" defaultFormats={messages}>
|
||||
<SomeComponentWithIntl className="just-for-test" />
|
||||
</IntlProvider>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
45
stripe/index.d.ts
vendored
45
stripe/index.d.ts
vendored
@@ -1,8 +1,10 @@
|
||||
// Type definitions for stripe
|
||||
// Type definitions for stripe 0.0
|
||||
// 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>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare const Stripe: StripeStatic;
|
||||
|
||||
interface StripeStatic {
|
||||
applePay: StripeApplePay;
|
||||
setPublishableKey(key: string): void;
|
||||
@@ -49,6 +51,8 @@ interface StripeError {
|
||||
param?: string;
|
||||
}
|
||||
|
||||
type StripeCardDataBrand = 'Visa' | 'American Express' | 'MasterCard' | 'Discover JCB' | 'Diners Club' | 'Unknown';
|
||||
|
||||
interface StripeCardData {
|
||||
object: string;
|
||||
last4: string;
|
||||
@@ -62,18 +66,17 @@ interface StripeCardData {
|
||||
address_state?: string;
|
||||
address_zip?: string;
|
||||
address_country?: string;
|
||||
brand?: StripeCardDataBrand;
|
||||
createToken(data: StripeTokenData, responseHandler: (status: number, response: StripeTokenResponse) => void): void;
|
||||
}
|
||||
|
||||
interface StripeBankAccount
|
||||
{
|
||||
createToken(params: StripeBankTokenParams, stripeResponseHandler: (status:number, response: StripeBankTokenResponse) => void): void;
|
||||
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
|
||||
{
|
||||
interface StripeBankTokenParams {
|
||||
country: string;
|
||||
currency: string;
|
||||
account_number: number | string;
|
||||
@@ -82,8 +85,7 @@ interface StripeBankTokenParams
|
||||
account_holder_type: string;
|
||||
}
|
||||
|
||||
interface StripeBankTokenResponse
|
||||
{
|
||||
interface StripeBankTokenResponse {
|
||||
id: string;
|
||||
bank_account: {
|
||||
country: string;
|
||||
@@ -100,13 +102,7 @@ interface StripeBankTokenResponse
|
||||
error?: StripeError;
|
||||
}
|
||||
|
||||
declare var Stripe: StripeStatic;
|
||||
declare module "Stripe" {
|
||||
export = StripeStatic;
|
||||
}
|
||||
|
||||
interface StripeApplePay
|
||||
{
|
||||
interface StripeApplePay {
|
||||
checkAvailability(resopnseHandler: (result: boolean) => void): void;
|
||||
buildSession(data: StripeApplePayPaymentRequest,
|
||||
onSuccessHandler: (result: StripeApplePaySessionResult, completion: ((value: any) => void)) => void,
|
||||
@@ -117,8 +113,7 @@ type StripeApplePayBillingContactField = 'postalAddress' | 'name';
|
||||
type StripeApplePayShippingContactField = StripeApplePayBillingContactField | 'phone' | 'email';
|
||||
type StripeApplePayShipping = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup';
|
||||
|
||||
interface StripeApplePayPaymentRequest
|
||||
{
|
||||
interface StripeApplePayPaymentRequest {
|
||||
billingContact: StripeApplePayPaymentContact;
|
||||
countryCode: string;
|
||||
currencyCode: string;
|
||||
@@ -132,30 +127,26 @@ interface StripeApplePayPaymentRequest
|
||||
}
|
||||
|
||||
// https://developer.apple.com/reference/applepayjs/1916082-applepay_js_data_types
|
||||
interface StripeApplePayLineItem
|
||||
{
|
||||
interface StripeApplePayLineItem {
|
||||
type: 'pending' | 'final';
|
||||
label: string;
|
||||
amount: number;
|
||||
}
|
||||
|
||||
interface StripeApplePaySessionResult
|
||||
{
|
||||
interface StripeApplePaySessionResult {
|
||||
token: StripeTokenResponse;
|
||||
shippingContact?: StripeApplePayPaymentContact;
|
||||
shippingMethod?: StripeApplePayShippingMethod;
|
||||
}
|
||||
|
||||
interface StripeApplePayShippingMethod
|
||||
{
|
||||
interface StripeApplePayShippingMethod {
|
||||
label: string;
|
||||
detail: string;
|
||||
amount: number;
|
||||
identifier: string;
|
||||
}
|
||||
|
||||
interface StripeApplePayPaymentContact
|
||||
{
|
||||
interface StripeApplePayPaymentContact {
|
||||
emailAddress: string;
|
||||
phoneNumber: string;
|
||||
givenName: string;
|
||||
@@ -166,3 +157,7 @@ interface StripeApplePayPaymentContact
|
||||
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
stripe/stripe-tests.ts
Normal file
25
stripe/stripe-tests.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
function success(card: StripeCardData) {
|
||||
console.log(card.brand && card.brand.toString());
|
||||
}
|
||||
|
||||
const cardNumber = '4242424242424242';
|
||||
|
||||
const isValid = Stripe.validateCardNumber(cardNumber);
|
||||
if (isValid) {
|
||||
const tokenData: StripeTokenData = {
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
@@ -14,6 +14,7 @@
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts"
|
||||
"index.d.ts",
|
||||
"stripe-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
3
stripe/tslint.json
Normal file
3
stripe/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "../tslint.json"
|
||||
}
|
||||
Reference in New Issue
Block a user