diff --git a/types/acorn/acorn-tests.ts b/types/acorn/acorn-tests.ts index 72ca71d2f6..7574df2481 100644 --- a/types/acorn/acorn-tests.ts +++ b/types/acorn/acorn-tests.ts @@ -1,13 +1,13 @@ import acorn = require('acorn'); import * as ESTree from 'estree'; -declare var token: acorn.Token; -declare var tokens: acorn.Token[]; -declare var comment: acorn.Comment; -declare var comments: acorn.Comment[]; -declare var program: ESTree.Program; -var any: any; -var string: string; +declare let token: acorn.Token; +declare let tokens: acorn.Token[]; +declare let comment: acorn.Comment; +declare let comments: acorn.Comment[]; +declare let program: ESTree.Program; +let any: any; +let string: string; // acorn string = acorn.version; @@ -32,16 +32,12 @@ const parser = new acorn.Parser({}, 'export default ""', 0); const node = new acorn.Node(parser, 1, 1); class LooseParser { - constructor(input: string, options = {}) { - - } + constructor(input: string, options = {}) {} // this means you can extend LooseParser - test() { - - } + test() {} } -acorn.addLooseExports(function () { +acorn.addLooseExports(() => { return { type: 'Program', sourceType: 'script', @@ -50,7 +46,7 @@ acorn.addLooseExports(function () { type: 'EmptyStatement' } ] - } + }; }, LooseParser, {}); acorn.parseExpressionAt('string', 2); @@ -63,8 +59,7 @@ acorn.isIdentifierChar(56); acorn.getLineInfo('string', 56); -acorn.plugins['test'] = function (p: acorn.Parser, config: any) { -} +acorn.plugins['test'] = (p: acorn.Parser, config: any) => {}; acorn.tokenizer('console.log("hello world)', {locations: true}).getToken(); acorn.tokenizer('console.log("hello world)', {locations: true})[Symbol.iterator]().next(); diff --git a/types/acorn/index.d.ts b/types/acorn/index.d.ts index ce7da6d368..5d02bd716c 100644 --- a/types/acorn/index.d.ts +++ b/types/acorn/index.d.ts @@ -1,10 +1,8 @@ -// Type definitions for Acorn v4.0.3 +// Type definitions for Acorn 4.0 // Project: https://github.com/marijnh/acorn // Definitions by: RReverser , e-cloud // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - export as namespace acorn; export = acorn; import * as ESTree from 'estree'; @@ -181,7 +179,7 @@ declare namespace acorn { _typeof: TokenType; _void: TokenType; _delete: TokenType; - } + }; class TokContext { constructor(token: string, isExpr: boolean, preserveSpace: boolean, override: (p: Parser) => void); @@ -230,19 +228,18 @@ declare namespace acorn { const version: string; - interface IParse { - (input: string, options?: Options): ESTree.Program; - } + // TODO: rename type. + type IParse = (input: string, options?: Options) => ESTree.Program; const parse: IParse; function parseExpressionAt(input: string, pos?: number, options?: Options): ESTree.Expression; interface ITokenizer { - getToken() : Token, - [Symbol.iterator](): Iterator + getToken(): Token; + [Symbol.iterator](): Iterator; } - + function tokenizer(input: string, options: Options): ITokenizer; let parse_dammit: IParse | undefined; @@ -250,12 +247,10 @@ declare namespace acorn { let pluginsLoose: PluginsObject | undefined; interface ILooseParserClass { - new (input: string, options?: Options): ILooseParser + new (input: string, options?: Options): ILooseParser; } - interface ILooseParser { - - } + interface ILooseParser {} function addLooseExports(parse: IParse, parser: ILooseParserClass, plugins: PluginsObject): void; } diff --git a/types/acorn/tslint.json b/types/acorn/tslint.json index a41bf5d19a..2d05b8507c 100644 --- a/types/acorn/tslint.json +++ b/types/acorn/tslint.json @@ -1,79 +1,9 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, "export-just-namespace": false, - "import-spacing": false, "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "no-unnecessary-class": false } } diff --git a/types/angulartics/index.d.ts b/types/angulartics/index.d.ts index e1b36bc210..40ff202329 100644 --- a/types/angulartics/index.d.ts +++ b/types/angulartics/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for Angulartics 1.4 // Project: http://luisfarzati.github.io/angulartics/ -// Definitions by: Steven Fan -// Bateast2 +// Definitions by: Bateast2 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/cytoscape/index.d.ts b/types/cytoscape/index.d.ts index 40a500a354..85b3a97e46 100644 --- a/types/cytoscape/index.d.ts +++ b/types/cytoscape/index.d.ts @@ -978,7 +978,7 @@ declare namespace cytoscape { * An analogue to run a layout on a subset of the graph exists as eles.layout(). * http://js.cytoscape.org/#cy.layout */ - layout(layout: LayoutOptions): void; + layout(layout: LayoutOptions): LayoutManipulation; /** * Get a new layout, which can be used to algorithmically * position the nodes in the graph. @@ -991,7 +991,7 @@ declare namespace cytoscape { * Note that you must call layout.run() in order for it to affect the graph. * An analogue to make a layout on a subset of the graph exists as eles.makeLayout(). */ - makeLayout(options: LayoutOptions): void; + makeLayout(options: LayoutOptions): LayoutManipulation; } /** diff --git a/types/geodesy/geodesy-tests.ts b/types/geodesy/geodesy-tests.ts index 984b8e80c2..6f6641520e 100644 --- a/types/geodesy/geodesy-tests.ts +++ b/types/geodesy/geodesy-tests.ts @@ -4,7 +4,9 @@ import { Dms, Vector3d, OsGridRef, - LatLonEllipsoidal as LatLon, LatLonSpherical } from 'geodesy'; + LatLonEllipsoidal as LatLon, LatLonSpherical, + LatLonVectors +} from 'geodesy'; /** * Mgrs @@ -165,3 +167,38 @@ LatLonSpherical.crossingParallels(point1, point2, 30); const polygon = [new LatLonSpherical(0, 0), new LatLonSpherical(1, 0), new LatLonSpherical(0, 1)]; LatLonSpherical.areaOf(polygon); // 6.18e9 m² LatLonSpherical.areaOf(polygon, 6371e3); // 6.18e9 m² + +/** + * LatLonVectors + */ +const point3 = new LatLonVectors(49.78846, -97.44306); +const point4 = new LatLonVectors(49.79822, -97.4592); +const point5 = new LatLonVectors(49.7981, -97.41371); +const point6 = new LatLonVectors(49.76851, -97.41371); +const point7 = new LatLonVectors(49.76873, -97.45954); +const point8 = new LatLonVectors(49.78846, -97.44306); +point3.toVector(); // Vector3d { x: -0.08363305717526297, y: -0.6401716454146233, z: 0.7636660108677438 } +point3.greatCircle(45); // Vector3d { x: -0.6311975610221534, y: 0.6270426835846277, z: 0.45651627782881243 } +point3.distanceTo(point4, 6371e3); // 1587.463492544562 m +point3.bearingTo(point4); // 313.1353494923952 deg +point3.midpointTo(point4); // LatLon { lat: 49.79334028019261, lon: -97.45112918683637 } +point3.intermediatePointTo(point4, 0.25); // LatLon { lat: 49.79090021013134, lon: -97.44709439015365 } +point3.intermediatePointOnChordTo(point4, 0.5); // LatLon { lat: 49.7933402801926, lon: -97.45112918683637 } +point3.destinationPoint(100, 0, 6371e3); // LatLon { lat: 49.78935932160593, lon: -97.44306000000003 } +point3.crossTrackDistanceTo(point4, point5, 6371e3); // 1080.7461902301488 m +point3.crossTrackDistanceTo(point4, 60, 6371e3); // 1519.091945034438 m +point3.alongTrackDistanceTo(point4, point5, 6371e3); // 1162.7673995854138 m +point3.alongTrackDistanceTo(point4, 60, 6371e3); // 460.86875216457025 m +point3.nearestPointOnSegment(point4, point5); // LatLon { lat: 49.79817930627353, lon: -97.44299978937423 } +point3.isBetween(point4, point5); // true + +const boundary = [point4, point5, point6, point7]; +point3.enclosedBy(boundary); // true +point3.equals(point4); // false +point3.equals(point8); // true +point3.toString('dms', 3); // 49°47′18.456″N, 097°26′35.016″W + +// Static functions +LatLonVectors.intersection(point4, point5, point3, 1); // LatLon { lat: 49.7981787830497, lon: -97.44279718554108 } +LatLonVectors.areaOf(boundary, 6371e3); // 10768180.94129682 m^2 +LatLonVectors.meanOf(boundary); // LatLon { lat: 49.783392242641824, lon: -97.43653998581752 } diff --git a/types/geodesy/index.d.ts b/types/geodesy/index.d.ts index d66de9fe3d..15a53796e0 100644 --- a/types/geodesy/index.d.ts +++ b/types/geodesy/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for geodesy 1.1 +// Type definitions for geodesy 1.2 // Project: https://github.com/chrisveness/geodesy // Definitions by: Denis Carriere // Gilbert Handy +// Harry Nicholls // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export type format = 'd' | 'dm' | 'dms'; @@ -168,3 +169,27 @@ export class LatLonSpherical { static areaOf(polygon: LatLonSpherical[], radius?: number): number; toString(format?: string, dp?: number): string; } + +export class LatLonVectors { + lat: number; + lon: number; + constructor(lat: number, lon: number); + toVector(): Vector3d; + greatCircle(bearing: number): Vector3d; + distanceTo(point: LatLonVectors, radius?: number): number; + bearingTo(point: LatLonVectors): number; + midpointTo(point: LatLonVectors): number; + intermediatePointTo(point: LatLonVectors, fraction: number): LatLonVectors; + intermediatePointOnChordTo(point: LatLonVectors, fraction: number): LatLonVectors; + destinationPoint(distance: number, bearing: number, radius?: number): LatLonVectors; + static intersection(path1start: LatLonVectors, path1brngEnd: LatLonVectors | number, path2start: LatLonVectors, path2brngEnd: LatLonVectors | number): LatLonVectors; + crossTrackDistanceTo(pathStart: LatLonVectors, pathBrngEnd: LatLonVectors | number, radius?: number): number; + alongTrackDistanceTo(pathStart: LatLonVectors, pathBrngEnd: LatLonVectors | number, radius?: number): number; + nearestPointOnSegment(point1: LatLonVectors, point2: LatLonVectors): LatLonVectors; + isBetween(point1: LatLonVectors, point2: LatLonVectors): boolean; + enclosedBy(polygon: LatLonVectors[]): boolean; + static areaOf(polygon: LatLonVectors[], radius?: number): number; + static meanOf(points: ReadonlyArray): LatLonVectors; + equals(point: LatLonVectors): boolean; + toString(format?: string, dp?: number): string; + } diff --git a/types/guid/guid-tests.ts b/types/guid/guid-tests.ts new file mode 100644 index 0000000000..52e0a738d1 --- /dev/null +++ b/types/guid/guid-tests.ts @@ -0,0 +1,18 @@ +import guid = require('guid'); + +// $ExpectType object +guid.create(); + +// $ExpectType string +guid.raw(); + +const newRawGuid = guid.raw(); + +// $ExpectType boolean +guid.isGuid(newRawGuid); + +// $ExpectType string +guid.EMPTY; + +// $ExpectType object +guid(guid.create()); diff --git a/types/guid/index.d.ts b/types/guid/index.d.ts new file mode 100644 index 0000000000..6025e90bf1 --- /dev/null +++ b/types/guid/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for guid 1.0 +// Project: https://github.com/dandean/guid +// Definitions by: Marc-Andre Roy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export = guid; + +declare function guid(guid: object): object; + +declare namespace guid { + const EMPTY: string; + + const prototype: { + }; + + function create(): object; + + function isGuid(value: string): boolean; + + function raw(): string; +} diff --git a/types/guid/tsconfig.json b/types/guid/tsconfig.json new file mode 100644 index 0000000000..17563577fd --- /dev/null +++ b/types/guid/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "guid-tests.ts" + ] +} diff --git a/types/guid/tslint.json b/types/guid/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/guid/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/iota.lib.js/index.d.ts b/types/iota.lib.js/index.d.ts new file mode 100644 index 0000000000..758c6a0b3c --- /dev/null +++ b/types/iota.lib.js/index.d.ts @@ -0,0 +1,486 @@ +// Type definitions for iota.lib.js 0.4 +// Project: https://github.com/iotaledger/iota.lib.js +// Definitions by: Fogsh +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare class IotaClass { + constructor(settings: { + provider: string; + sandbox?: boolean; + token?: boolean; + } | { + host: string; + port: number; + sandbox?: boolean; + token?: boolean; + }); + + api: IotaApi; + utils: IotaUtils; + multisig: IotaMultisig; + valid: IotaValid; + + version: string; +} + +export = IotaClass; + +// +// Types +// + +type Security = 1 | 2 | 3; +type IOTAUnit = "i" | "Ki" | "Mi" | "Gi" | "Ti" | "Pi"; + +// +// Objects +// + +interface TransactionObject { + hash: string; + signatureMessageFragment: string; + address: string; + value: number; + tag: string; + timestamp: number; + currentIndex: number; + lastIndex: number; + bundle: number; + trunkTransaction: string; + branchTransaction: string; + attachmentTimestamp: number; + attachmentTimestampLowerBound: number; + attachmentTimestampUpperBound: number; + nonce: string; +} + +interface InputObject { + address: string; + balance: number; + keyIndex: number; + security: Security; +} + +interface TransferObject { + address: string; + value: number; + message: string; + tag: string; +} + +interface NodeInfo { + appName: string; + appVersion: string; + duration: number; + jreAvailableProcessors: number; + jreFreeMemory: number; + jreVersion: string; + jreMaxMemory: number; + jreTotalMemory: number; + latestMilestone: string; + latestMilestoneIndex: number; + latestSolidSubtangleMilestone: string; + latestSolidSubtangleMilestoneIndex: number; + neighbors: number; + packetsQueueSize: number; + time: number; + tips: number; + transactionsToRequest: number; +} + +interface Neighbor { + address: string; + numberOfAllTransactions: number; + numberOfRandomTransactionRequests: number; + numberOfInvalidTransactions: number; + numberOfSentTransactions: number; + numberOfNewTransactions: number; + connectionType: "udp" | "tcp"; +} + +// +// iota.api +// + +interface IriApi { + getNodeInfo( + callback: (error: Error, info: NodeInfo) => void + ): void; + + getNeighbors( + callback: (error: Error, neighbors: Neighbor[]) => void + ): void; + + addNeighbors( + uris: string[], + callback: (error: Error, addedNeighbors: number) => void + ): void; + + removeNeighbors( + uris: string[], + callback: (error: Error, removedNeighbors: number[]) => void + ): void; + + getTips( + callback: (error: Error, hashes: string[]) => void + ): void; + + findTransactions( + searchValues: { + addresses?: string[] + bundles?: string[] + tags?: string[] + approvees?: string[] + }, + callback: (error: Error, hashes: string[]) => void + ): void; + + getTrytes( + hashes: string[], + callback: (error: Error, trytes: string[]) => void + ): void; + + getInclusionStates( + transactions: string[], + tips: string[], + callback: (error: Error, states: boolean[]) => void + ): void; + + getBalances( + addresses: string[], + treshold: number, + callback: (error: Error, response: { + balances: number[] + milestone: string; + milestoneIndex: number; + duration: number; + }) => void + ): void; + + getTransactionsToApprove( + depth: number, + callback: (error: Error, response: { + trunkTransaction: string; + branchTransaction: string; + duration: number; + }) => void + ): void; + + attachToTangle( + trunkTransaction: string, + branchTransaction: string, + minWeightMagnitude: number, + trytes: string[], + callback: (error: Error, trytes: string[]) => void + ): void; + + interruptAttachingToTangle( + callback: (error: Error, response: {}) => void + ): void; + + broadcastTransactions( + trytes: string[], + callback: (error: Error, response: {}) => void + ): void; + + storeTransactions( + trytes: string[], + callback: (error: Error, response: {}) => void + ): void; +} + +// +// iota.api +// + +interface IotaApi extends IriApi { + getTransactionsObjects( + hashes: string[], + callback?: (error: Error, transactions: TransactionObject[]) => void + ): void; + + findTransactionObjects( + searchValues: { + addresses?: string[] + bundles?: string[] + tags?: string[] + approvees?: string[] + }, + callback?: (error: Error, transactions: TransactionObject[]) => void + ): void; + + getLatestInclusion( + hashes: string[], + callback?: (error: Error, states: boolean[]) => void + ): void; + + broadcastAndStore( + trytes: string[], + callback?: (error: Error, response: {}) => void + ): void; + + getNewAddress( + seed: string, + options?: { + index?: number; + checksum?: boolean; + total?: number; + security?: Security + returnAll?: boolean; + }, + callback?: (error: Error, response: string | string[]) => void + ): void; + + getInputs( + seed: string, + options?: { + start?: number; + end?: number; + security?: Security + threshold?: boolean; + }, + callback?: (error: Error, response: { + inputs: InputObject[] + }) => void + ): void; + + prepareTransfers( + seed: string, + transfers: TransferObject[], + options?: { + inputs?: string[], + address?: string, + security?: Security + }, + callback?: (error: Error, response: { + trytes: string[] + }) => void + ): void; + + sendTrytes( + trytes: string[], + depth: number, + minWeightMagnitude: number, + callback?: (error: Error, response: { + inputs: TransactionObject[] + }) => void + ): void; + + sendTransfer( + seed: string, + depth: number, + minWeightMagnitude: number, + transfers: TransferObject[], + options?: { + inputs: string[], + address: string; + }, + callback?: (error: Error, response: { + inputs: TransactionObject[] + }) => void + ): void; + + replayBundle( + transactionHash: string, + depth: number, + minWeightMagnitude: number, + callback?: (error: Error, response: {}) => void + ): void; + + broadcastBundle( + transactionHash: string, + callback?: (error: Error, response: {}) => void + ): void; + + getBundle( + transactionHash: string, + callback?: (error: Error, bundle: TransactionObject[]) => void + ): void; + + getTransfers( + seed: string, + options?: { + start?: number; + end?: number; + security?: Security + inclusionStates?: boolean; + }, + callback?: (error: Error, transfers: TransactionObject[][]) => void + ): void; + + getAccountData( + seed: string, + options?: { + start: number; + end: number; + security?: Security + }, + callback?: (error: Error, response: { + latestAddress: string; + addresses: string[] + transfers: string[] + inputs: InputObject[] + balance: number; + }) => void + ): void; + + isReattachable( + address: string | string[], + callback?: (error: Error, response: boolean | boolean[]) => void + ): void; +} + +// +// iota.utils +// + +interface IotaUtils { + convertUnits( + value: number, + fromUnit: IOTAUnit, + toUnit: IOTAUnit + ): number; + + addChecksum( + inputValue: string, + checksumLength?: number, + isAddress?: boolean + ): string; + + addChecksum( + inputValue: string[], + checksumLength?: number, + isAddress?: boolean + ): string[]; + + noChecksum( + address: string + ): string; + + isValidChecksum( + addressWithChecksum: string + ): boolean; + + transactionObject( + trytes: string + ): TransactionObject; + + transactionTrytes( + transaction: TransactionObject + ): string; + + categorizeTransfers( + transfers: TransactionObject[], + addresses: string[] + ): { + sent: TransactionObject[] + received: TransactionObject[] + }; + + toTrytes( + input: string + ): string; + + fromTrytes( + trytes: string + ): string; + + extractJson( + bundle: TransactionObject[] + ): string; + + validateSignatures( + signedBundle: string[], + inputAddress: string + ): boolean; + + isBundle( + bundle: TransactionObject[] + ): boolean; +} + +// +// iota.multisig +// + +interface IotaMultisig { + getKey( + seed: string, + index: number, + security: Security + ): string; + + getDigest( + seed: string, + index: number, + security: Security + ): string; + + address( + digestTrytes: string | string[] + ): MultisigAddress; + + validateAddress( + multisigAddress: string, + digests: string[] + ): boolean; + + initiateTransfer( + securitySum: number, + inputAddress: string, + remainderAddress: string, + transfers: TransferObject[], + callback?: (error: Error, bundle: TransactionObject[]) => void + ): void; + + addSignature( + bundleToSign: TransactionObject[], + inputAddress: string, + key: string, + callback?: (error: Error, bundle: TransactionObject[]) => void + ): void; +} + +interface MultisigAddress { + absorb( + digest: string | string[] + ): MultisigAddress; + + finalize(): string; +} + +// +// iota.valid +// + +interface IotaValid { + isAddress(address: string): boolean; + + isTrytes(trytes: string, length?: number): boolean; + + isValue(value: any): boolean; + + isNum(value: any): boolean; + + isHash(hash: any): boolean; + + isTransfersArray(transfers: any): boolean; + + isArrayOfHashes(hashes: any): boolean; + + isArrayOfTrytes(trytes: any): boolean; + + isArrayOfAttachedTrytes(trytes: any): boolean; + + isArrayOfTxObjects(transactions: any): boolean; + + isInputs(inputs: any): boolean; + + isString(string: any): boolean; + + isArray(array: any): boolean; + + isObject(object: any): boolean; + + isUri(uri: any): boolean; +} diff --git a/types/iota.lib.js/iota.lib.js-tests.ts b/types/iota.lib.js/iota.lib.js-tests.ts new file mode 100644 index 0000000000..6b3c3a9b85 --- /dev/null +++ b/types/iota.lib.js/iota.lib.js-tests.ts @@ -0,0 +1,94 @@ +import IOTA = require("iota.lib.js"); + +const config = { + node: "https://localhost:14265", + address: "999999999999999999999999999999999999999999999999999999999999999999999999999999999", + transaction: "999999999999999999999999999999999999999999999999999999999999999999999999999999999" +}; + +const iota = new IOTA({ + provider: config.node +}); + +// +// iota.api +// + +iota.api.getNodeInfo((error, info) => { +}); + +iota.api.getNeighbors((error, info) => { +}); + +iota.api.addNeighbors(["udp://127.0.0.2:14600"], (error, count) => { +}); + +iota.api.removeNeighbors(["udp://127.0.0.2:14600"], (error, count) => { +}); + +iota.api.findTransactions({ + addresses: [config.address] +}, (error, hashes) => { +}); + +iota.api.getTrytes([config.address], (error, trytes) => { +}); + +iota.api.getInclusionStates([config.address], [config.transaction], (error, states) => { +}); + +iota.api.getBalances([config.address], 1, (error, states) => { +}); + +iota.api.getTransactionsToApprove(1, (error, transactions) => { +}); + +iota.api.getTransactionsObjects([config.transaction], (err, response) => { +}); + +iota.api.findTransactionObjects({ + addresses: [config.address] +}, (err, response) => { +}); + +iota.api.getLatestInclusion([config.address], (err, response) => { +}); + +// +// iota.utils +// + +iota.utils.convertUnits(1000, "i", "Mi"); + +const checksum = iota.utils.addChecksum(config.address); +iota.utils.noChecksum(checksum); +iota.utils.isValidChecksum(checksum); + +const transactionObj = iota.utils.transactionObject(new Array(2674).join("9")); +iota.utils.transactionTrytes(transactionObj); + +const trytes = iota.utils.toTrytes("HELLO TANGLE"); +iota.utils.fromTrytes(trytes); + +// +// iota.valid +// + +iota.valid.isAddress(config.address); + +iota.valid.isTrytes(trytes); + +iota.valid.isValue(0); + +iota.valid.isNum(0); + +iota.valid.isHash(config.address); + +const transferObj = { + address: config.address, + message: "", + value: 0, + tag: "" +}; + +iota.valid.isTransfersArray([transferObj]); diff --git a/types/iota.lib.js/tsconfig.json b/types/iota.lib.js/tsconfig.json new file mode 100644 index 0000000000..b206b83455 --- /dev/null +++ b/types/iota.lib.js/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "iota.lib.js-tests.ts" + ] +} \ No newline at end of file diff --git a/types/iota.lib.js/tslint.json b/types/iota.lib.js/tslint.json new file mode 100644 index 0000000000..2750cc0197 --- /dev/null +++ b/types/iota.lib.js/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } \ No newline at end of file diff --git a/types/json-query/index.d.ts b/types/json-query/index.d.ts new file mode 100644 index 0000000000..929ab738ae --- /dev/null +++ b/types/json-query/index.d.ts @@ -0,0 +1,58 @@ +// Type definitions for json-query 2.2 +// Project: http://github.com/mmckegg/json-query#readme +// Definitions by: Matt Traynham +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = JsonQuery; + +declare function JsonQuery( + selector: JsonQuery.Selector | JsonQuery.SelectorWithQueryParams, + options: JsonQuery.Options +): JsonQuery.Result; + +declare namespace JsonQuery { + type Selector = string; + + type QueryParam = any; + // No way to support [Selector, ...QueryParam[]]? + // 10 params should be more than enough, hopefully. + type SelectorWithQueryParams = + [Selector, QueryParam] + | [Selector, QueryParam] + | [Selector, QueryParam] + | [Selector, QueryParam, QueryParam] + | [Selector, QueryParam, QueryParam, QueryParam] + | [Selector, QueryParam, QueryParam, QueryParam, QueryParam] + | [Selector, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam] + | [Selector, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam] + | [Selector, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam] + | [Selector, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam] + | [Selector, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam] + | [Selector, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam, QueryParam]; + + type Context = any; + + type Filter = (input: Context, ...args: any[]) => Context; + interface Locals { + [filterName: string]: Filter; + } + + interface Options { + data?: Context; + rootContext?: Context; + source?: Context; + context?: Context; + parent?: Context; + locals?: Locals; + globals?: boolean; + force?: boolean; + allowRegexp?: boolean; + } + + interface Result { + value: any; + key: string; + references: any[]; + parents: string[]; + } +} diff --git a/types/json-query/json-query-tests.ts b/types/json-query/json-query-tests.ts new file mode 100644 index 0000000000..5da1ca9e78 --- /dev/null +++ b/types/json-query/json-query-tests.ts @@ -0,0 +1,123 @@ +import jsonQuery = require('json-query'); + +// API +let data: jsonQuery.Context = { + people: [ + {name: 'Matt', country: 'NZ'}, + {name: 'Pete', country: 'AU'}, + {name: 'Mikey', country: 'NZ'} + ] +}; +jsonQuery('people[country=NZ].name', {data}); // => {value: 'Matt', parents: [...], key: 0} ... etc + +// Deep Queries +data = { + grouped_people: { + friends: [ + {name: 'Steve', country: 'NZ'}, + {name: 'Jane', country: 'US'}, + {name: 'Mike', country: 'AU'}, + {name: 'Mary', country: 'NZ'} + ], + enemies: [ + {name: 'Evil Steve', country: 'AU'}, + {name: 'Betty', country: 'NZ'} + ] + } +}; +const result: any = jsonQuery('grouped_people[**][*country=NZ]', {data}).value; + +// Inner Queries +data = { + page: { + id: 'page_1', + title: 'Test' + }, + comments_lookup: { + page_1: [ + {id: 'comment_1', parent_id: 'page_1', content: "I am a comment"} + ] + } +}; +jsonQuery('comments_lookup[{page.id}]', {data}); + +// Local functions (helpers) +const locals: jsonQuery.Locals = { + greetingName: (input: jsonQuery.Context) => { + if (input.known_as) { + return input.known_as; + } else { + return input.name; + } + }, + and: (inputA: jsonQuery.Context, inputB: boolean) => { + return inputA && inputB; + }, + text: (input: jsonQuery.Context, text: string) => { + return text; + }, + then: (input: jsonQuery.Context, thenValue: string, elseValue: string) => { + if (input) { + return thenValue; + } else { + return elseValue; + } + } +}; +data = { + is_fullscreen: true, + is_playing: false, + user: { + name: "Matthew McKegg", + known_as: "Matt" + } +}; +jsonQuery('user:greetingName', {data, locals}).value; // => "Matt" +jsonQuery(['is_fullscreen:and({is_playing}):then(?, ?)', "Playing big!", "Not so much"], {data, locals}).value; // => "Not so much" +jsonQuery(':text(This displays text cos we made it so)', {locals}).value; // => "This displays text cos we made it so" +jsonQuery('people:select(name, country)', { + data, + locals: { + select: (input: jsonQuery.Context, ...keys: string[]) => { + if (Array.isArray(input)) { + return input.map((item: any) => { + return Object.keys(item).reduce((result: {[p: string]: any}, key: string) => { + if (~keys.indexOf(key)) { + result[key] = item[key]; + } + return result; + }, {}); + }); + } + } + } +}); +jsonQuery('people[*:recentlyUpdated]', { + data, + locals: { + recentlyUpdated: (item: {updatedAt: number}) => { + return item.updatedAt < Date.now() - (30 * 24 * 60 * 60 * 1000); + } + } +}); + +// Context +data = { + styles: { + bold: 'font-weight:strong', + red: 'color: red' + }, + paragraphs: [ + {content: "I am a red paragraph", style: 'red'}, + {content: "I am a bold paragraph", style: 'bold'}, + ], +}; +let pageHtml = ''; +data.paragraphs.forEach((paragraph: {content: string, style: string}) => { + const style = jsonQuery('styles[{.style}]', {data, source: paragraph}).value; + const content = jsonQuery('.content', {data, source: paragraph}).value; // pretty pointless :) + pageHtml += `

${content}

`; +}); + +// Query Params +jsonQuery(['people[country=?]', 'NZ'], {data}); diff --git a/types/json-query/tsconfig.json b/types/json-query/tsconfig.json new file mode 100644 index 0000000000..9a317f4d83 --- /dev/null +++ b/types/json-query/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "json-query-tests.ts" + ] +} \ No newline at end of file diff --git a/types/json-query/tslint.json b/types/json-query/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/json-query/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/lil-uuid/index.d.ts b/types/lil-uuid/index.d.ts new file mode 100644 index 0000000000..fb0a783142 --- /dev/null +++ b/types/lil-uuid/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for lil-uuid 0.1 +// Project: https://github.com/lil-js/uuid +// Definitions by: Pr1st0n +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/** + * Generate a random UUID + * + * @returns UUID string. + */ +export function uuid(): string; + +/** + * Check if a given string has a valid UUID format. It supports multiple version (3, 4 and 5). + * + * @param uuid UUID string. + * @returns True if string is valid UUID, false otherwise. + */ +export function isUUID(uuid: string): boolean; diff --git a/types/lil-uuid/lil-uuid-tests.ts b/types/lil-uuid/lil-uuid-tests.ts new file mode 100644 index 0000000000..8b39216e67 --- /dev/null +++ b/types/lil-uuid/lil-uuid-tests.ts @@ -0,0 +1,4 @@ +import * as lil from 'lil-uuid'; + +lil.uuid(); +lil.isUUID('f47ac10b-58cc-4372-a567-0e02b2c3d479'); diff --git a/types/lil-uuid/tsconfig.json b/types/lil-uuid/tsconfig.json new file mode 100644 index 0000000000..889bd07cca --- /dev/null +++ b/types/lil-uuid/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "lil-uuid-tests.ts" + ] +} diff --git a/types/lil-uuid/tslint.json b/types/lil-uuid/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/lil-uuid/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/material-ui/index.d.ts b/types/material-ui/index.d.ts index 91bcef28d9..22b5d1711f 100644 --- a/types/material-ui/index.d.ts +++ b/types/material-ui/index.d.ts @@ -947,6 +947,7 @@ declare namespace __MaterialUI { export interface ChipProps { backgroundColor?: string; className?: string; + containerElement?: React.ReactNode | string; labelColor?: string; labelStyle?: React.CSSProperties; onRequestDelete?: React.TouchEventHandler; diff --git a/types/material-ui/material-ui-tests.tsx b/types/material-ui/material-ui-tests.tsx index 1034d47cad..987c6dd030 100644 --- a/types/material-ui/material-ui-tests.tsx +++ b/types/material-ui/material-ui-tests.tsx @@ -3030,6 +3030,8 @@ const ChipExampleSimple = () => ( Blue Label Color UI Avatar Styled + String Container + {}}>ReactNode Container ); diff --git a/types/mock-knex/index.d.ts b/types/mock-knex/index.d.ts new file mode 100644 index 0000000000..5633000ab9 --- /dev/null +++ b/types/mock-knex/index.d.ts @@ -0,0 +1,79 @@ +// Type definitions for mock-knex 0.3 +// Project: https://github.com/colonyamerican/mock-knex +// Definitions by: Jesse Zhang +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +/// + +import * as Knex from "knex"; +import { EventEmitter } from "events"; + +/** + * Attaches mocked client to knex instance + * + * @param knex initialized knex client + */ +export function mock(knex: Knex): void; + +/** + * Detaches mocked client from knex instance + * + * @param knex initialized knex client + */ +export function unmock(knex: Knex): void; + +/** + * Returns query Tracker instance + */ +export function getTracker(): Tracker; + +/** + * The tracker enables you to catch and respond to queries that occur during testing, see Test for more examples. + */ +export interface Tracker extends EventEmitter { + /** + * Enables query tracking mock on mocked knex client + */ + install(): void; + + /** + * Disables query tracking mock on mocked knex client. Also resets 'step' counter. + */ + uninstall(): void; + + /** + * Add event listener for 'query' event. It gets esecuted for each query that should end up in database. + * Instead of this callback gets executed and its up to you to assert queries and mock database responses. + * + * @param callback A function that gets executed on 'query' event. + */ + on(event: 'query', callback: (query: QueryDetails, step: number) => void): this; +} + +/** + * The object containing query details that is being sent to knex database dialect on query execution. + * Object properties signature matches with knex toSQL() output with additional method returns(values). + */ +export interface QueryDetails extends Knex.Sql { + /** + * Function that needs to be called to mock database query result for knex. + * + * @param error The Error, string or instance of Error, which represents why the result was rejected + */ + reject(error: Error | string): void; + + /** + * Function that needs to be called to mock database query result for knex. + * + * @param values An array of mock data to be returned by database. For Bookshelf this is mostly array of objects. Knex could return any type of data. + */ + response(values: any[], options?: QueryDetailsResponseOption): void; +} + +export interface QueryDetailsResponseOption { + /** + * Is this a stream response, defaults to false + */ + stream: boolean; +} diff --git a/types/mock-knex/mock-knex-tests.ts b/types/mock-knex/mock-knex-tests.ts new file mode 100644 index 0000000000..ec4ef0024e --- /dev/null +++ b/types/mock-knex/mock-knex-tests.ts @@ -0,0 +1,29 @@ +import * as knex from "knex"; +import * as mockDb from "mock-knex"; + +const db = knex({ + client: 'sqlite' +}); + +mockDb.mock(db); + +const tracker = mockDb.getTracker(); +tracker.install(); +tracker.on('query', (query, step) => { + if (query.method === "first" || step === 1) { + query.response([{ + a: 1 + }, { + a: 2 + }, { + a: 3 + }], { + stream: false + }); + } else { + query.reject(new Error("bad query")); + } +}); +tracker.uninstall(); + +mockDb.unmock(db); diff --git a/types/mock-knex/tsconfig.json b/types/mock-knex/tsconfig.json new file mode 100644 index 0000000000..427ad9f843 --- /dev/null +++ b/types/mock-knex/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "mock-knex-tests.ts" + ] +} diff --git a/types/mock-knex/tslint.json b/types/mock-knex/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/mock-knex/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/moment-holiday/index.d.ts b/types/moment-holiday/index.d.ts new file mode 100644 index 0000000000..fffe81ed73 --- /dev/null +++ b/types/moment-holiday/index.d.ts @@ -0,0 +1,71 @@ +// Type definitions for moment-holiday 1.5 +// Project: https://github.com/kodie/moment-holiday +// Definitions by: Robert Winslow Dalpe +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import * as moment from 'moment'; + +declare module 'moment' { + interface Moment extends Object { + holiday( + holidays?: string[] | string, + adjust?: boolean): Moment | false | { [holidayName: string]: Moment }; + + holidays( + holidays?: string[] | string, + adjust?: boolean): Moment | false | { [holidayName: string]: Moment }; + + isHoliday( + holidays?: string[] | string | null, + adjust?: boolean): boolean | string | string[]; + + previousHoliday(count?: number, adjust?: boolean): Moment[] | Moment; + + previousHolidays(count?: number, adjust?: boolean): Moment[] | Moment; + + nextHoliday(count?: number, adjust?: boolean): Moment[] | Moment; + + nextHolidays(count?: number, adjust?: boolean): Moment[] | Moment; + + holidaysBetween(m: Moment, adjust?: boolean): Moment[] | false; + } + + interface HolidayDefinition { + date: string; + keywords?: string[]; + keywords_y?: string[]; + keywords_n?: string[]; + regions?: string[]; + regions_n?: string[]; + } + + interface HolidaysMapping { + [holidayName: string]: HolidayDefinition; + } + + interface Holidays { + active: HolidaysMapping; + active_last: HolidaysMapping; + } + + interface HolidayModifier { + set( + holidays: HolidaysMapping | string | string[], + specifics?: any): HolidayModifier; + + add( + holidays: HolidaysMapping | string, + specifics?: any): HolidayModifier; + + remove(holidays: string | string[]): HolidayModifier; + + undo(): HolidayModifier; + + load(locales: string | string[]): HolidayModifier; + + extendParser(parserFunc: (m: Moment, date: string) => Moment | Moment[] | false | void): HolidayModifier; + } + + let holidays: Holidays; + let modifyHolidays: HolidayModifier; +} diff --git a/types/moment-holiday/moment-holiday-tests.ts b/types/moment-holiday/moment-holiday-tests.ts new file mode 100644 index 0000000000..474cf246fb --- /dev/null +++ b/types/moment-holiday/moment-holiday-tests.ts @@ -0,0 +1,127 @@ +import moment = require('moment'); +import 'moment-holiday'; + +let holidayResult: moment.Moment | false | { [holidayName: string]: moment.Moment }; +holidayResult = moment().holiday([]); +holidayResult = moment().holiday([], false); +holidayResult = moment().holiday([], true); +holidayResult = moment().holiday('string'); +holidayResult = moment().holiday('string', false); +holidayResult = moment().holiday('string', true); +holidayResult = moment().holiday(['array', 'of', 'strings']); +holidayResult = moment().holiday(['array', 'of', 'strings'], false); +holidayResult = moment().holiday(['array', 'of', 'strings'], true); + +holidayResult = moment().holidays([]); +holidayResult = moment().holidays([], false); +holidayResult = moment().holidays([], true); +holidayResult = moment().holidays('string'); +holidayResult = moment().holidays('string', false); +holidayResult = moment().holidays('string', true); +holidayResult = moment().holidays(['array', 'of', 'strings']); +holidayResult = moment().holidays(['array', 'of', 'strings'], false); +holidayResult = moment().holidays(['array', 'of', 'strings'], true); + +let isHolidayResult: boolean | string | string[]; +isHolidayResult = moment().isHoliday(); +isHolidayResult = moment().isHoliday([]); +isHolidayResult = moment().isHoliday([], false); +isHolidayResult = moment().isHoliday([], true); +isHolidayResult = moment().isHoliday(['array', 'of', 'strings']); +isHolidayResult = moment().isHoliday(['array', 'of', 'strings'], false); +isHolidayResult = moment().isHoliday(['array', 'of', 'strings'], true); +isHolidayResult = moment().isHoliday('string'); +isHolidayResult = moment().isHoliday('string', false); +isHolidayResult = moment().isHoliday('string', true); +isHolidayResult = moment().isHoliday(null); +isHolidayResult = moment().isHoliday(null, false); +isHolidayResult = moment().isHoliday(null, true); + +let previousHolidayResult: moment.Moment[] | moment.Moment; +previousHolidayResult = moment().previousHoliday(); +previousHolidayResult = moment().previousHoliday(1); +previousHolidayResult = moment().previousHoliday(1, false); +previousHolidayResult = moment().previousHoliday(1, true); +previousHolidayResult = moment().previousHolidays(); +previousHolidayResult = moment().previousHolidays(1); +previousHolidayResult = moment().previousHolidays(1, false); +previousHolidayResult = moment().previousHolidays(1, true); + +let nextHolidayResult: moment.Moment[] | moment.Moment; +nextHolidayResult = moment().nextHoliday(); +nextHolidayResult = moment().nextHoliday(1); +nextHolidayResult = moment().nextHoliday(1, false); +nextHolidayResult = moment().nextHoliday(1, true); +nextHolidayResult = moment().nextHolidays(); +nextHolidayResult = moment().nextHolidays(1); +nextHolidayResult = moment().nextHolidays(1, false); +nextHolidayResult = moment().nextHolidays(1, true); + +let holidaysBetweenResult: moment.Moment[] | false; +holidaysBetweenResult = moment().holidaysBetween(moment()); +holidaysBetweenResult = moment().holidaysBetween(moment(), false); +holidaysBetweenResult = moment().holidaysBetween(moment(), true); + +let holidayDefinition: moment.HolidayDefinition = { + date: 'string' +}; +holidayDefinition = { + date: 'string', + keywords: ['array'], +}; +holidayDefinition = { + date: 'string', + keywords: ['array'], + keywords_n: ['array'], +}; +holidayDefinition = { + date: 'string', + keywords: ['array'], + keywords_n: ['array'], + keywords_y: ['array'], +}; +holidayDefinition = { + date: 'string', + keywords: ['array'], + keywords_n: ['array'], + keywords_y: ['array'], + regions: ['array'], +}; +holidayDefinition = { + date: 'string', + keywords: ['array'], + keywords_n: ['array'], + keywords_y: ['array'], + regions: ['array'], + regions_n: ['array'] +}; + +const holidays: moment.Holidays = moment.holidays; +let activeHolidays: moment.HolidaysMapping = moment.holidays.active; +activeHolidays = { + 'Some holiday name': holidayDefinition +}; + +let lastActiveHolidays: moment.HolidaysMapping = moment.holidays.active_last; +lastActiveHolidays = { + 'Some holiday name': holidayDefinition +}; + +let holidayModifier: moment.HolidayModifier = moment.modifyHolidays; +holidayModifier = holidayModifier.set('string'); +holidayModifier = holidayModifier.set(['array']); +holidayModifier = holidayModifier.set(activeHolidays); +holidayModifier = holidayModifier.set('string', {}); +holidayModifier = holidayModifier.set(['array'], {}); +holidayModifier = holidayModifier.set(activeHolidays, {}); +holidayModifier = holidayModifier.add(activeHolidays); +holidayModifier = holidayModifier.add('string'); +holidayModifier = holidayModifier.add(activeHolidays, {}); +holidayModifier = holidayModifier.add('string', {}); +holidayModifier = holidayModifier.remove('string'); +holidayModifier = holidayModifier.remove(['array']); +holidayModifier = holidayModifier.undo(); +holidayModifier = holidayModifier.load('string'); +holidayModifier = holidayModifier.load(['string']); +holidayModifier = holidayModifier.extendParser((m: moment.Moment, d: string): moment.Moment | moment.Moment[] | false | void => { +}); diff --git a/types/moment-holiday/package.json b/types/moment-holiday/package.json new file mode 100644 index 0000000000..4c7554a28e --- /dev/null +++ b/types/moment-holiday/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "moment": ">=2.0.0" + } +} diff --git a/types/moment-holiday/tsconfig.json b/types/moment-holiday/tsconfig.json new file mode 100644 index 0000000000..d03f37e12c --- /dev/null +++ b/types/moment-holiday/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "moment-holiday-tests.ts" + ] +} diff --git a/types/moment-holiday/tslint.json b/types/moment-holiday/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/moment-holiday/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 2fa564ce3e..6d65f5999e 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -14,7 +14,6 @@ // Kelvin Jin // Alvis HT Tang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 /************************************************ * * diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 6b0574e603..d33dee0c93 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -1620,19 +1620,7 @@ namespace path_tests { // returns // ['foo', 'bar', 'baz'] - console.log(process.env.PATH); - // '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin' - - process.env.PATH.split(path.delimiter); - // returns - // ['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin'] - - console.log(process.env.PATH); - // 'C:\Windows\system32;C:\Windows;C:\Program Files\nodejs\' - - process.env.PATH.split(path.delimiter); - // returns - // ['C:\Windows\system32', 'C:\Windows', 'C:\Program Files\nodejs\'] + process.env["PATH"]; // $ExpectType string path.parse('/home/user/dir/file.txt'); // returns @@ -3075,11 +3063,11 @@ client.listbreakpoints((err, body, packet) => { }); //////////////////////////////////////////////////// namespace async_hooks_tests { const hooks: async_hooks.HookCallbacks = { - init: (asyncId: number, type: string, triggerAsyncId: number, resource: object) => void {}, - before: (asyncId: number) => void {}, - after: (asyncId: number) => void {}, - destroy: (asyncId: number) => void {}, - promiseResolve: (asyncId: number) => void {} + init() {}, + before() {}, + after() {}, + destroy() {}, + promiseResolve() {}, }; const asyncHook = async_hooks.createHook(hooks); @@ -3346,7 +3334,8 @@ namespace http2_tests { settings, allowHTTP1: true }; - let secureServerOptions: http2.SecureServerOptions = { ...serverOptions }; + // tslint:disable-next-line prefer-object-spread (ts2.1 feature) + let secureServerOptions: http2.SecureServerOptions = Object.assign({}, serverOptions); secureServerOptions.ca = ''; let onRequestHandler = (request: http2.Http2ServerRequest, response: http2.Http2ServerResponse) => { // Http2ServerRequest @@ -3443,7 +3432,8 @@ namespace http2_tests { selectPadding: (frameLen: number, maxFrameLen: number) => 0, settings }; - let secureClientSessionOptions: http2.SecureClientSessionOptions = { ...clientSessionOptions }; + // tslint:disable-next-line prefer-object-spread (ts2.1 feature) + let secureClientSessionOptions: http2.SecureClientSessionOptions = Object.assign({}, clientSessionOptions); secureClientSessionOptions.ca = ''; let onConnectHandler = (session: http2.Http2Session, socket: net.Socket) => {}; @@ -3696,8 +3686,9 @@ namespace inspector_tests { session.disconnect(); // Unknown post method - session.post('A.b', { key: 'value' }, (err: Error, params: object) => {}); - session.post('A.b', (err: Error, params: object) => {}); + session.post('A.b', { key: 'value' }, (err, params) => {}); + // TODO: parameters are implicitly 'any' and need type annotation + session.post('A.b', (err: Error | null, params?: {}) => {}); session.post('A.b'); // Known post method const parameter: inspector.Runtime.EvaluateParameterType = { expression: '2 + 2' }; @@ -3710,7 +3701,9 @@ namespace inspector_tests { session.post('Runtime.evaluate'); // General event - session.on('inspectorNotification', (message: inspector.InspectorNotification) => {}); + session.on('inspectorNotification', message => { + message; // $ExpectType InspectorNotification<{}> + }); // Known events session.on('Debugger.paused', (message: inspector.InspectorNotification) => { const method: string = message.method; diff --git a/types/node/tsconfig.json b/types/node/tsconfig.json index e3ac3b2f91..9f4317b9f4 100644 --- a/types/node/tsconfig.json +++ b/types/node/tsconfig.json @@ -5,6 +5,7 @@ ], "compilerOptions": { "module": "commonjs", + "target": "es6", "lib": [ "es6" ], diff --git a/types/nouislider/index.d.ts b/types/nouislider/index.d.ts index 4389b87d49..0e070e89c7 100644 --- a/types/nouislider/index.d.ts +++ b/types/nouislider/index.d.ts @@ -8,102 +8,102 @@ export = noUiSlider; export as namespace noUiSlider; declare namespace noUiSlider { - /** + /** * To create a slider, call noUiSlider.create() with an element and your options. */ - function create(target: HTMLElement, options: Options): void; + function create(target: HTMLElement, options: Options): void; - interface Options { - /** + interface Options { + /** * The start option sets the number of handles and their start positions, relative to range. */ - start: number | number[] | number[][]; - /** + start: number | number[] | number[][]; + /** * All values on the slider are part of a range. The range has a minimum and maximum value. * The minimum value cannot be equal to the maximum value. */ - range: Object; - /** + range: { [key: string]: number | number[] }; + /** * The connect setting can be used to control the (green) bar between the handles, or the edges of the slider. - * Pass an array with a boolean for every connecting element, including the edges of the slider. + * Pass an array with a boolean for every connecting element, including the edges of the slider. * The length of this array must match the handle count + 1. * Setting true sets the bars between the handles, but not between the handles and the sliders edges. */ - connect?: boolean | boolean[]; - /** + connect?: boolean | boolean[]; + /** * When using two handles, the minimum distance between the handles can be set using the margin option. * The margin value is relative to the value set in 'range'. * This option is only available on standard linear sliders. */ - margin?: number; - /** + margin?: number; + /** * The limit option is the opposite of the margin option, * limiting the maximum distance between two handles. * As with the margin option, the limit option can only be used on linear sliders. */ - limit?: number; - /** + limit?: number; + /** * Padding limits how close to the slider edges handles can be. */ - padding?: number; - /** + padding?: number; + /** * By default, the slider slides fluently. * In order to make the handles jump between intervals, you can use this option. * The step option is relative to the values provided to range. */ - step?: number; - /** + step?: number; + /** * The orientation setting can be used to set the slider to "vertical" or "horizontal". * Set dimensions! Vertical sliders don't assume a default height, so you'll need to set one. * You can use any unit you want, including % or px. */ - orientation?: "vertical" | "horizontal"; - /** + orientation?: 'vertical' | 'horizontal'; + /** * By default the sliders are top-to-bottom and left-to-right, * but you can change this using the direction option, * which decides where the upper side of the slider is. */ - direction?: "ltr" | "rtl"; - /** - * noUiSlider can provide a basic tooltip without using its events system. - * Set the tooltips option to true to enable. - * This option can also accept formatting options to format the tooltips content. + direction?: 'ltr' | 'rtl'; + /** + * noUiSlider can provide a basic tooltip without using its events system. + * Set the tooltips option to true to enable. + * This option can also accept formatting options to format the tooltips content. * In that case, pass an array with a formatter for each handle, true to use the default or false to display no tooltip. */ - tooltips?: boolean | Object | ((...args:any[]) => any); - /** + tooltips?: boolean | Object | ((...args: any[]) => any); + /** * Set the animate option to false to prevent the slider from animating to a new value with when calling .val(). */ - animate?: boolean; - /** + animate?: boolean; + /** * The animationDuration option can be used to set the animation speed assumed by the slider library. * In addition to this, you must manually set the CSS (-webkit-)transition property for the .noUi-state-tap .noUi-origin selector. */ - animationDuration?: number; - /** + animationDuration?: number; + /** * When a non-linear slider has been configured, the snap option can be set to true to force the slider to jump * between the specified values. */ - snap?: boolean; - /** + snap?: boolean; + /** * All values on the slider are part of a range. The range has a minimum and maximum value. */ - behaviour?: string; - /** + behaviour?: string; + /** * To format the slider output, noUiSlider offers a format option. * Simply specify to and from functions to encode and decode the values. * See manual formatting to the right for usage information. * By default, noUiSlider will format output with 2 decimals. */ - format?: Object | ((...args:any[]) => any); - /** + format?: Object | ((...args: any[]) => any); + /** * Allows you to generate points along the slider. */ - pips?: PipsOptions; - } + pips?: PipsOptions; + } - interface PipsOptions { - /** + interface PipsOptions { + /** * The 'range' mode uses the slider range to determine where the pips should be. A pip is generated for every percentage specified. * * The 'steps', like 'range', uses the slider range. In steps mode, a pip is generated for every step. @@ -118,83 +118,92 @@ declare namespace noUiSlider { * The 'values' mode is similar to positions, but it accepts values instead of percentages. The stepped option can be used for this mode. * */ - mode: "range" | "steps" | "positions" | "count" | "values"; - /** + mode: 'range' | 'steps' | 'positions' | 'count' | 'values'; + /** * Range Mode: percentage for range mode * Step Mode: step number for steps * Positions Mode: percentage-based positions on the slider * Count Mode: positions between pips */ - density?: number; - /** + density?: number; + /** * Step Mode: The filter option can be used to filter the generated pips. * The filter function must return 0 (no value), 1 (large value) or 2 (small value). */ - filter?: (...args: any[]) => PipFilterResult; - /** + filter?: (...args: any[]) => PipFilterResult; + /** * format for step mode * see noUiSlider format */ - format?: Object | ((...args:any[]) => any); - /** + format?: Object | ((...args: any[]) => any); + /** * * values for positions and values mode * number pips for count mode */ - values?: number | number[]; - /** + values?: number | number[]; + /** * stepped option for positions, values and count mode */ - stepped?: boolean; - } + stepped?: boolean; + } - const enum PipFilterResult { - NoValue, - LargeValue, - SmallValue, - } + const enum PipFilterResult { + NoValue, + LargeValue, + SmallValue, + } - interface Callback { - /** + interface Callback { + /** * Array for both one-handle and two-handle sliders. It contains the current slider values, * with formatting applied. */ - (values: any[], handle: number, unencodedValues: number[]): void; - } + (values: any[], handle: number, unencodedValues: number[]): void; + } - interface noUiSlider { - /** + interface noUiSlider { + /** * Bind event to the slider. */ - on(eventName: string, callback: Callback): void; - /** + on(eventName: string, callback: Callback): void; + /** * Unbind event to the slider. */ - off(eventName: string): void; - /** + off(eventName: string): void; + /** * Destroy's the slider. */ - destroy(): void; - /** + destroy(): void; + /** * To get the current slider value. For one-handle sliders, calling .get() will return the value. * For two-handle sliders, an array[value, value] will be returned. */ - get(): number | number[]; - /** + get(): number | number[]; + /** * noUiSlider will keep your values within the slider range, which saves you a bunch of validation. * If you have configured the slider to use one handle, you can change the current value by passing * a number to the .set() method. If you have two handles, pass an array. One-handled sliders * will also accept arrays. Within an array, you can set one position to null * if you want to leave a handle unchanged. */ - set(value: number | (number | null)[]): void; - /** + set(value: number | (number | null)[]): void; + /** * To return to the initial slider values, you can use the .reset() method. This will only reset the slider values. */ - reset(): void; - } + reset(): void; + /** + * Exposes the options used to create the noUiSlider instance + */ + options: Options; + /** + * method that can change the 'margin', 'limit', 'step', 'range', 'animate' and 'snap' options. + * All other options require changes to the slider's HTML or event bindings. + */ + updateOptions(newOptions: Options, fireSetEvent?: boolean): void; + } - interface Instance extends HTMLElement { - noUiSlider: noUiSlider; - } + interface Instance extends HTMLElement { + noUiSlider: noUiSlider; + } } diff --git a/types/nunjucks/index.d.ts b/types/nunjucks/index.d.ts index 002f8b93f8..d307bd27d5 100644 --- a/types/nunjucks/index.d.ts +++ b/types/nunjucks/index.d.ts @@ -1,148 +1,139 @@ -// Type definitions for nunjucks +// Type definitions for nunjucks 3.0 // Project: http://mozilla.github.io/nunjucks/ // Definitions by: Ruben Slabbert // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 +export function render(name: string, context?: object): string; +export function render(name: string, context?: object, callback?: (err: any, res: string) => any): void; -declare namespace Nunjucks { - function render(name: string, context?: Object): string; - function render(name: string, context?: Object, callback?: (err: any, res: string) => any): void; +export function renderString(src: string, context: object): string; +export function renderString(src: string, context: object, callback?: (err: any, res: string) => any): void; - function renderString(src: string, context: Object): string; - function renderString(src: string, context: Object, callback?: (err: any, res: string) => any): void; +export function compile(src: string, env?: Environment, callback?: (err: any, res: Template) => any): Template; - function compile(src: string, env?: Environment): Template; - function compile(src: string, env?: Environment, callback?: (err: any, res: Template) => any): Template; +export function precompile(path: string, opts?: PrecompileOptions): string; +export function precompileString(src: string, opts?: PrecompileOptions): string; - function precompile(path: string, opts?: PrecompileOptions): string; - function precompileString(src: string, opts?: PrecompileOptions): string; - - interface PrecompileOptions { - name?: string; - asFunction?: boolean; - force?: boolean; - env?: Environment; - include?: string[]; - exclude?: string[]; - wrapper?(templates: { name: string, template: string }, opts: PrecompileOptions): string; - } - - class Template { - constructor(src: string, env?: Environment, eagerCompile?: boolean); - render(context?: Object): string; - render(context?: Object, callback?: (err: any, res: string) => any): void; - } - - function configure(options: ConfigureOptions): Environment; - function configure(path: string, options?: ConfigureOptions): Environment; - function configure(path: string[], options?: ConfigureOptions): Environment; - - interface ConfigureOptions { - autoescape?: boolean; - throwOnUndefined?: boolean; - trimBlocks?: boolean; - lstripBlocks?: boolean; - watch?: boolean; - noCache?: boolean; - web?: { - useCache?: boolean, - async?: boolean - }; - express?: Object; - tags?: { - blockStart?: string, - blockEnd?: string, - variableStart?: string, - variableEnd?: string, - commentStart?: string, - commentEnd?: string - }; - } - - class Environment { - options: { - autoescape: boolean; - }; - - constructor(); - constructor(loader: ILoader, opts?: ConfigureOptions); - constructor(loaders: ILoader[], opts?: ConfigureOptions); - - render(name: string, context?: Object): string; - render(name: string, context?: Object, callback?: (err: any, res: string) => any): void; - - renderString(name: string, context: Object): string; - renderString(name: string, context: Object, callback?: (err: any, res: string) => any): void; - - addFilter(name: string, func: (...args: any[]) => any, async?: boolean): void; - getFilter(name: string): void; - - addExtension(name: string, ext: Extension): void; - removeExtension(name: string): void; - getExtension(name: string): Extension; - hasExtension(name: string): void; - - addGlobal(name: string, value: any): void; - - getTemplate(name: string, eagerCompile?: boolean): Template; - getTemplate(name: string, eagerCompile?: boolean, callback?: (err: any, templ: Template) => Template): void; - - express(app: Object): void; - } - - interface Extension { - tags: string[]; - // Parser API is undocumented it is suggested to check the source: https://github.com/mozilla/nunjucks/blob/master/src/parser.js - parse(parser: any, nodes: any, lexer: any): any; - } - - function installJinjaCompat(): void; - - interface ILoader { - async?: boolean; - getSource(name: string): LoaderSource; - extend?(extender: ILoader): ILoader; - } - - // Needs both Loader and ILoader since nunjucks uses a custom object system - // Object system is also responsible for the extend methods - class Loader { - on(name: string, func: (...args: any[]) => any): void; - emit(name: string, ...args: any[]): void; - resolve(from: string, to: string): string; - isRelative(filename: string): boolean; - extend(toExtend: ILoader): ILoader; - } - - interface LoaderSource { - src: string; - path: string; - noCache: boolean; - } - - interface FileSystemLoaderOptions { - /** if true, the system will automatically update templates when they are changed on the filesystem */ - watch?: boolean; - - /** if true, the system will avoid using a cache and templates will be recompiled every single time */ - noCache?: boolean; - } - - class FileSystemLoader extends Loader implements ILoader { - init(searchPaths: string[], opts: any): void; - getSource(name: string): LoaderSource; - constructor(searchPaths?: string | string[], opts?: FileSystemLoaderOptions); - } - - export class WebLoader implements ILoader { - constructor(baseUrl: string, opts?: any); - getSource(name: string): LoaderSource; - } - - class PrecompiledLoader extends Loader implements ILoader { - init(searchPaths: string[], opts: any): void; - getSource(name: string): LoaderSource; - } +export interface PrecompileOptions { + name?: string; + asFunction?: boolean; + force?: boolean; + env?: Environment; + include?: string[]; + exclude?: string[]; + wrapper?(templates: { name: string, template: string }, opts: PrecompileOptions): string; } -export = Nunjucks; +export class Template { + constructor(src: string, env?: Environment, eagerCompile?: boolean); + render(context?: object): string; + render(context?: object, callback?: (err: any, res: string) => any): void; +} + +export function configure(options: ConfigureOptions): Environment; +export function configure(path: string | string[], options?: ConfigureOptions): Environment; + +export interface ConfigureOptions { + autoescape?: boolean; + throwOnUndefined?: boolean; + trimBlocks?: boolean; + lstripBlocks?: boolean; + watch?: boolean; + noCache?: boolean; + web?: { + useCache?: boolean, + async?: boolean + }; + express?: object; + tags?: { + blockStart?: string, + blockEnd?: string, + variableStart?: string, + variableEnd?: string, + commentStart?: string, + commentEnd?: string + }; +} + +export class Environment { + options: { + autoescape: boolean; + }; + + constructor(loader?: ILoader | ILoader[] | null, opts?: ConfigureOptions); + render(name: string, context?: object): string; + render(name: string, context?: object, callback?: (err: any, res: string) => any): void; + + renderString(name: string, context: object): string; + renderString(name: string, context: object, callback?: (err: any, res: string) => any): void; + + addFilter(name: string, func: (...args: any[]) => any, async?: boolean): void; + getFilter(name: string): void; + + addExtension(name: string, ext: Extension): void; + removeExtension(name: string): void; + getExtension(name: string): Extension; + hasExtension(name: string): void; + + addGlobal(name: string, value: any): void; + + getTemplate(name: string, eagerCompile?: boolean): Template; + getTemplate(name: string, eagerCompile?: boolean, callback?: (err: any, templ: Template) => Template): void; + + express(app: object): void; +} + +export interface Extension { + tags: string[]; + // Parser API is undocumented it is suggested to check the source: https://github.com/mozilla/nunjucks/blob/master/src/parser.js + parse(parser: any, nodes: any, lexer: any): any; +} + +export function installJinjaCompat(): void; + +export interface ILoader { + async?: boolean; + getSource(name: string): LoaderSource; + extend?(extender: ILoader): ILoader; +} + +// Needs both Loader and ILoader since nunjucks uses a custom object system +// Object system is also responsible for the extend methods +export class Loader { + on(name: string, func: (...args: any[]) => any): void; + emit(name: string, ...args: any[]): void; + resolve(from: string, to: string): string; + isRelative(filename: string): boolean; + extend(toExtend: ILoader): ILoader; +} + +export interface LoaderSource { + src: string; + path: string; + noCache: boolean; +} + +export interface FileSystemLoaderOptions { + /** if true, the system will automatically update templates when they are changed on the filesystem */ + watch?: boolean; + + /** if true, the system will avoid using a cache and templates will be recompiled every single time */ + noCache?: boolean; +} + +export class FileSystemLoader extends Loader implements ILoader { + init(searchPaths: string[], opts: any): void; + getSource(name: string): LoaderSource; + constructor(searchPaths?: string | string[], opts?: FileSystemLoaderOptions); +} + +export class WebLoader implements ILoader { + constructor(baseUrl: string, opts?: any); + getSource(name: string): LoaderSource; +} + +export class PrecompiledLoader extends Loader implements ILoader { + init(searchPaths: string[], opts: any): void; + getSource(name: string): LoaderSource; +} diff --git a/types/nunjucks/nunjucks-tests.ts b/types/nunjucks/nunjucks-tests.ts index 7407cc65ba..9f3afcddfe 100644 --- a/types/nunjucks/nunjucks-tests.ts +++ b/types/nunjucks/nunjucks-tests.ts @@ -1,27 +1,35 @@ - import nunjucks = require("nunjucks"); - nunjucks.configure({ autoescape: false }); let rendered = nunjucks.render("./noexists.html"); -let ctx = { items: ["Hello", "this", "is", "for", "testing"] }; -let src = "{% for item in items %}{{item}}{% endfor %}"; +nunjucks.render('foo.html', { username: 'James' }); +nunjucks.render('async.html', (err: any, res: string) => {}); + +const ctx = { items: ["Hello", "this", "is", "for", "testing"] }; +const src = "{% for item in items %}{{item}}{% endfor %}"; rendered = nunjucks.renderString(src, ctx); +nunjucks.renderString('Hello {{ username }}', { username: 'James' }); -let compiled = nunjucks.compile(src); +const compiled = nunjucks.compile(src); rendered = compiled.render(ctx); +nunjucks.compile('Hello {{ username }}').render({ username: 'James' }); rendered = nunjucks.precompileString(src, { name: "TestyWesty" }); -let template = new nunjucks.Template(src); +const template = new nunjucks.Template(src); rendered = template.render(ctx); let env = nunjucks.configure({ autoescape: false }); +nunjucks.configure('/views'); +nunjucks.configure('views', { + autoescape: true, + watch: true +}); rendered = env.renderString(src, ctx); env.addExtension("SpawnGlitter", { diff --git a/types/nunjucks/tsconfig.json b/types/nunjucks/tsconfig.json index 39cf9bfbca..5824ce2f1f 100644 --- a/types/nunjucks/tsconfig.json +++ b/types/nunjucks/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -20,4 +20,4 @@ "index.d.ts", "nunjucks-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/nunjucks/tslint.json b/types/nunjucks/tslint.json index a41bf5d19a..2c7c1bed53 100644 --- a/types/nunjucks/tslint.json +++ b/types/nunjucks/tslint.json @@ -1,79 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false + "interface-name": false } } diff --git a/types/p-lazy/p-lazy-tests.ts b/types/p-lazy/p-lazy-tests.ts index d240ae826e..16ab9e466b 100644 --- a/types/p-lazy/p-lazy-tests.ts +++ b/types/p-lazy/p-lazy-tests.ts @@ -1,7 +1,7 @@ import PLazy = require('p-lazy'); const lazyPromise = new PLazy((resolve, reject) => { - if (typeof resolve === 'object') { + if (!true) { resolve('foo'); } else { reject(new Error()); diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 2f96611b86..5875b4ef50 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -10,6 +10,7 @@ // Simon Højberg // Charles-Philippe Clermont // Samson Keung +// Angelo Ocana // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -1196,19 +1197,18 @@ declare namespace R { pair(fst: F, snd: S): [F, S]; /** - * Accepts as its arguments a function and any number of values and returns a function that, - * when invoked, calls the original function with all of the values prepended to the - * original function's arguments list. In some libraries this function is named `applyLeft`. + * Takes a function `f` and a list of arguments, and returns a function `g`. + * When applied, `g` returns the result of applying `f` to the arguments + * provided initially followed by the arguments provided to `g`. */ - partial(fn: (...a: any[]) => any, ...args: any[]): (...a: any[]) => any; - partial(fn: (...a: any[]) => T, ...args: any[]): (...a: any[]) => T; + partial(fn: (...a: any[]) => T, args: any[]): (...a: any[]) => T; /** - * Accepts as its arguments a function and any number of values and returns a function that, - * when invoked, calls the original function with all of the values appended to the original - * function's arguments list. + * Takes a function `f` and a list of arguments, and returns a function `g`. + * When applied, `g` returns the result of applying `f` to the arguments + * provided to `g` followed by the arguments provided initially. */ - partialRight(fn: (...a: any[]) => any, ...args: any[]): (...a: any[]) => any; + partialRight(fn: (...a: any[]) => T, args: any[]): (...a: any[]) => T; /** * Takes a predicate and a list and returns the pair of lists of elements diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 3767109e8e..ddaf6d95b1 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -266,18 +266,18 @@ R.times(i, 5); return a * b; } - const double = R.partial(multiply, 2); + const double = R.partial(multiply, [2]); double(2); // => 4 function greet(salutation: string, title: string, firstName: string, lastName: string) { return `${salutation}, ${title} ${firstName} ${lastName}!`; } - const sayHello = R.partial(greet, "Hello"); - const sayHelloToMs = R.partial(sayHello, "Ms."); + const sayHello = R.partial(greet, ["Hello"]); + const sayHelloToMs = R.partial(sayHello, ["Ms."]); sayHelloToMs("Jane", "Jones"); // => 'Hello, Ms. Jane Jones!' - const greetMsJaneJones = R.partialRight(greet, "Ms.", "Jane", "Jones"); + const greetMsJaneJones = R.partialRight(greet, ["Ms.", "Jane", "Jones"]); greetMsJaneJones("Hello"); // => 'Hello, Ms. Jane Jones!' })(); diff --git a/types/react-grid-layout/index.d.ts b/types/react-grid-layout/index.d.ts index bf3f5805d9..7c59c0bf39 100644 --- a/types/react-grid-layout/index.d.ts +++ b/types/react-grid-layout/index.d.ts @@ -64,6 +64,11 @@ declare namespace ReactGridLayout { */ maxH?: number; + /** + * set by DragEvents (onDragStart, onDrag, onDragStop) and ResizeEvents (onResizeStart, onResize, onResizeStop) + */ + moved?: boolean; + /** * If true, equal to `isDraggable: false` and `isResizable: false`. */ @@ -168,6 +173,11 @@ declare namespace ReactGridLayout { */ isResizable?: boolean; + /** + * Enable or disable grid rearrangement when dragging/resizing an element. + */ + isRearrangeable?: boolean; + /** * Uses CSS3 `translate()` instead of position top/left. * This makes about 6x faster paint performance. diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 2b82a43ee1..1c0cb7d0e8 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -6966,7 +6966,7 @@ export interface PanResponderGestureState { */ export interface PanResponderCallbacks { onMoveShouldSetPanResponder?: (e: GestureResponderEvent, gestureState: PanResponderGestureState) => boolean - onStartShouldSetPanResponder?: (e: GestureResponderEvent, gestureState: PanResponderGestureState) => void + onStartShouldSetPanResponder?: (e: GestureResponderEvent, gestureState: PanResponderGestureState) => boolean onPanResponderGrant?: (e: GestureResponderEvent, gestureState: PanResponderGestureState) => void onPanResponderMove?: (e: GestureResponderEvent, gestureState: PanResponderGestureState) => void onPanResponderRelease?: (e: GestureResponderEvent, gestureState: PanResponderGestureState) => void diff --git a/types/react-responsive/index.d.ts b/types/react-responsive/index.d.ts index 2b9a37839f..dde02d8dae 100644 --- a/types/react-responsive/index.d.ts +++ b/types/react-responsive/index.d.ts @@ -1,65 +1,90 @@ -// Type definitions for react-responsive 1.1.3 +// Type definitions for react-responsive 3.0 // Project: https://github.com/contra/react-responsive // Definitions by: Alexey Svetliakov +// Alec Hill +// Javier Gonzalez // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.4 -declare module "react-responsive" { - import * as React from "react"; - - namespace MediaQuery { - export interface MediaQueryProps { - query?: string; - // matchers - orientation?: "portrait" | "landscape"; - scan?: "progressive" | "interlace"; - aspectRatio?: string; - deviceAspectRatio?: string; - height?: number | string; - deviceHeight?: number | string; - width?: number | string; - deviceWidth?: number | string; - color?: boolean; - colorIndex?: boolean; - monochrome?: boolean; - resolution?: number | string; - // types - minAspectRatio?: string; - maxAspectRatio?: string; - minDeviceAspectRatio?: string; - maxDeviceAspectRatio?: string; - minHeight?: number | string; - maxHeight?: number | string; - minDeviceHeight?: number | string; - maxDeviceHeight?: number | string; - minDeviceWidth?: number | string; - maxDeviceWidth?: number | string; - minWidth?: number | string; - maxWidth?: number | string; - minColor?: number; - maxColor?: number; - minColorIndex?: number; - maxColorIndex?: number; - minMonochrome?: number; - maxMonochrome?: number; - minResolution?: number | string; - maxResolution?: number | string; - // types - all?: boolean; - grid?: boolean; - aural?: boolean; - braille?: boolean; - handheld?: boolean; - print?: boolean; - projection?: boolean; - screen?: boolean; - tty?: boolean; - tv?: boolean; - embossed?: boolean; - } - } - - class MediaQuery extends React.Component { } - export = MediaQuery; +import * as React from "react"; +export interface MediaQueryTypes { + all?: boolean; + grid?: boolean; + aural?: boolean; + braille?: boolean; + handheld?: boolean; + print?: boolean; + projection?: boolean; + screen?: boolean; + tty?: boolean; + tv?: boolean; + embossed?: boolean; } + +export type MediaQueryType = keyof MediaQueryTypes; + +export interface MediaQueryMatchers { + aspectRatio?: string; + deviceAspectRatio?: string; + height?: number | string; + deviceHeight?: number | string; + width?: number | string; + deviceWidth?: number | string; + color?: boolean; + colorIndex?: boolean; + monochrome?: boolean; + resolution?: number | string; + orientation?: 'portrait' | 'landscape'; + scan?: 'progressive' | 'interlace'; + type?: MediaQueryType; +} + +export interface MediaQueryFeatures extends MediaQueryMatchers { + minAspectRatio?: string; + maxAspectRatio?: string; + + minDeviceAspectRatio?: string; + maxDeviceAspectRatio?: string; + + minHeight?: number | string; + maxHeight?: number | string; + + minDeviceHeight?: number | string; + maxDeviceHeight?: number | string; + + minWidth?: number | string; + maxWidth?: number | string; + + minDeviceWidth?: number | string; + maxDeviceWidth?: number | string; + + minColor?: number; + maxColor?: number; + + minColorIndex?: number; + maxColorIndex?: number; + + minMonochrome?: number; + maxMonochrome?: number; + + minResolution?: number | string; + maxResolution?: number | string; +} + +export interface MediaQueryAllQueryable extends MediaQueryFeatures, MediaQueryTypes {} + +export interface MediaQueryProps extends MediaQueryAllQueryable { + component?: string | React.SFC | React.ClassType | React.ComponentClass; + query?: string; + style?: React.CSSProperties; + className?: string; + children?: React.ReactNode | ((matches: boolean) => React.ReactNode); + values?: Partial; + onBeforeChange?: (matches: boolean) => void; + onChange?: (matches: boolean) => void; +} + +declare class MediaQuery extends React.Component { } +export function toQuery(matchers: Partial): string; +export default MediaQuery; diff --git a/types/react-responsive/react-responsive-tests.tsx b/types/react-responsive/react-responsive-tests.tsx index 28f8f39c30..3445a8d1cf 100644 --- a/types/react-responsive/react-responsive-tests.tsx +++ b/types/react-responsive/react-responsive-tests.tsx @@ -1,7 +1,9 @@ import * as React from "react"; -import * as MediaQuery from "react-responsive"; +import MediaQuery, { + toQuery +} from "react-responsive"; -class Test extends React.Component { +class QueryTests extends React.Component { render() { return (
@@ -37,6 +39,99 @@ class Test extends React.Component {
- ) + ); } } + +const ChildrenPropTest: React.SFC = ({ children }) => ; + +class PropsTests extends React.Component { + render() { + return ( +
+ +
  • Item 1
  • +
  • Item 2
  • +
    + +
  • Item 1
  • +
  • Item 2
  • +
    + +
  • Item 1
  • +
  • Item 2
  • +
    + +
    Wrapped
    +
    Content
    +
    + + uppercase me! + + + Values supplied for SSR + +
    + ); + } +} + +class FunctionChildrenTest extends React.Component { + render() { + return ( + + {(matches: boolean) => { + if (matches) { + return
    Media query matches!
    ; + } else { + return
    Media query does not match!
    ; + } + }} +
    + ); + } +} + +class CallbackTest extends React.Component { + onBeforeChange = (matches: boolean): void => { + if (matches) { + // do something + } + } + + onChange = (matches: boolean): void => { + if (matches) { + // do something else + } + } + + render() { + return ( + + Media query matches! + + ); + } +} + +const queryStrTest: string = toQuery({ + type: 'print', + screen: true, + minHeight: 666 +}); diff --git a/types/react-responsive/tsconfig.json b/types/react-responsive/tsconfig.json index 61a49072b7..294f0c8cde 100644 --- a/types/react-responsive/tsconfig.json +++ b/types/react-responsive/tsconfig.json @@ -2,12 +2,11 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6", - "dom" + "es6" ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -22,4 +21,4 @@ "index.d.ts", "react-responsive-tests.tsx" ] -} \ No newline at end of file +} diff --git a/types/react-responsive/tslint.json b/types/react-responsive/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/react-responsive/tslint.json +++ b/types/react-responsive/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" } diff --git a/types/react-responsive/v1/index.d.ts b/types/react-responsive/v1/index.d.ts new file mode 100644 index 0000000000..2b9a37839f --- /dev/null +++ b/types/react-responsive/v1/index.d.ts @@ -0,0 +1,65 @@ +// Type definitions for react-responsive 1.1.3 +// Project: https://github.com/contra/react-responsive +// Definitions by: Alexey Svetliakov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +declare module "react-responsive" { + import * as React from "react"; + + namespace MediaQuery { + export interface MediaQueryProps { + query?: string; + // matchers + orientation?: "portrait" | "landscape"; + scan?: "progressive" | "interlace"; + aspectRatio?: string; + deviceAspectRatio?: string; + height?: number | string; + deviceHeight?: number | string; + width?: number | string; + deviceWidth?: number | string; + color?: boolean; + colorIndex?: boolean; + monochrome?: boolean; + resolution?: number | string; + // types + minAspectRatio?: string; + maxAspectRatio?: string; + minDeviceAspectRatio?: string; + maxDeviceAspectRatio?: string; + minHeight?: number | string; + maxHeight?: number | string; + minDeviceHeight?: number | string; + maxDeviceHeight?: number | string; + minDeviceWidth?: number | string; + maxDeviceWidth?: number | string; + minWidth?: number | string; + maxWidth?: number | string; + minColor?: number; + maxColor?: number; + minColorIndex?: number; + maxColorIndex?: number; + minMonochrome?: number; + maxMonochrome?: number; + minResolution?: number | string; + maxResolution?: number | string; + // types + all?: boolean; + grid?: boolean; + aural?: boolean; + braille?: boolean; + handheld?: boolean; + print?: boolean; + projection?: boolean; + screen?: boolean; + tty?: boolean; + tv?: boolean; + embossed?: boolean; + } + } + + class MediaQuery extends React.Component { } + export = MediaQuery; + +} diff --git a/types/react-responsive/v1/react-responsive-tests.tsx b/types/react-responsive/v1/react-responsive-tests.tsx new file mode 100644 index 0000000000..28f8f39c30 --- /dev/null +++ b/types/react-responsive/v1/react-responsive-tests.tsx @@ -0,0 +1,42 @@ +import * as React from "react"; +import * as MediaQuery from "react-responsive"; + +class Test extends React.Component { + render() { + return ( +
    +
    Device Test!
    + +
    You are a desktop or laptop
    + +
    You also have a huge screen
    +
    + +
    You are sized like a tablet or mobile phone though
    +
    +
    + +
    You are a tablet or mobile phone
    +
    + +
    You are portrait
    +
    + +
    You are landscape
    +
    + +
    You are retina
    +
    + +
    You are a desktop or laptop
    + +
    You also have a huge screen
    +
    + +
    You are sized like a tablet or mobile phone though
    +
    +
    +
    + ) + } +} diff --git a/types/react-responsive/v1/tsconfig.json b/types/react-responsive/v1/tsconfig.json new file mode 100644 index 0000000000..774fd47a00 --- /dev/null +++ b/types/react-responsive/v1/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "react-responsive": [ + "react-responsive/v1" + ], + "react-responsive/*": [ + "react-responsive/v1/*" + ] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-responsive-tests.tsx" + ] +} diff --git a/types/react-s-alert/index.d.ts b/types/react-s-alert/index.d.ts new file mode 100644 index 0000000000..42a0557162 --- /dev/null +++ b/types/react-s-alert/index.d.ts @@ -0,0 +1,55 @@ +// Type definitions for react-s-alert 1.3 +// Project: https://github.com/juliancwirko/react-s-alert +// Definitions by: mitsuruog +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import * as React from "react"; + +declare class SAlert extends React.Component {} + +declare namespace SAlert { + interface SAlertConfigProps { + position?: string; + offset?: number; + stack?: boolean | SAlertStackProps; + effect?: string; + beep?: string | boolean | SAlertBeepProps; + timeout?: string | number; + html?: boolean; + onClose?: () => void; + onShow?: () => void; + customFields?: object; + contentTemplate?: (...args: any[]) => any; + } + + interface SAlertProps extends SAlertConfigProps { + message?: string; + } + + interface SAlertStackProps { + limit?: number; + spacing?: number; + } + + interface SAlertBeepProps { + info?: string; + error?: string; + warning?: string; + success?: string; + } + + function info(msg?: string, data?: SAlertConfigProps): number; + + function error(msg?: string, data?: SAlertConfigProps): number; + + function warning(msg?: string, data?: SAlertConfigProps): number; + + function success(msg?: string, data?: SAlertConfigProps): number; + + function close(id: number): void; + + function closeAll(): void; +} + +export default SAlert; diff --git a/types/react-s-alert/react-s-alert-tests.tsx b/types/react-s-alert/react-s-alert-tests.tsx new file mode 100644 index 0000000000..5c8af89a96 --- /dev/null +++ b/types/react-s-alert/react-s-alert-tests.tsx @@ -0,0 +1,46 @@ +import * as React from "react"; +import Alert from "react-s-alert"; + +const config = { + position: "top", + offset: 100, + stack: { + limit: 3, + spacing: 50, + }, + effect: "genie", + beep: { + info: "beep.mp3", + error: "beep.mp3", + warning: "beep.mp3", + success: "beep.mp3", + }, + timeout: 1000, + html: true, + onClose: () => {}, + onShow: () => {}, + customFields: {}, +}; + +class Test extends React.Component { + render() { + return ( +
    + + +
    + ); + } +} + +Alert.info("I am a info message.", config); +Alert.error("I am an error message.", config); +Alert.warning("I am a warning message.", config); +Alert.success("I am a success message", config); + +const index = Alert.info("Hello"); +Alert.close(index); + +Alert.closeAll(); diff --git a/types/react-s-alert/tsconfig.json b/types/react-s-alert/tsconfig.json new file mode 100644 index 0000000000..c029ed03aa --- /dev/null +++ b/types/react-s-alert/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-s-alert-tests.tsx" + ] +} diff --git a/types/react-s-alert/tslint.json b/types/react-s-alert/tslint.json new file mode 100644 index 0000000000..593f1d33c8 --- /dev/null +++ b/types/react-s-alert/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" + } diff --git a/types/semantic-ui/index.d.ts b/types/semantic-ui/index.d.ts index e36ff8c748..00b2c7c273 100644 --- a/types/semantic-ui/index.d.ts +++ b/types/semantic-ui/index.d.ts @@ -2,7 +2,7 @@ // Project: http://semantic-ui.com/ // Definitions by: Leonard Thieu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 +// TypeScript Version: 2.3 /// diff --git a/types/supercluster/index.d.ts b/types/supercluster/index.d.ts index 5fb9ccf792..7fd487ae09 100644 --- a/types/supercluster/index.d.ts +++ b/types/supercluster/index.d.ts @@ -33,6 +33,27 @@ export interface Options { * Whether timing info should be logged. */ log?: boolean; + /** + * a reduce function for calculating custom cluster properties + * + * @example + * function (accumulated, props) { accumulated.sum += props.sum; } + */ + reduce?: (accumulated: any, props: any) => void; + /** + * initial properties of a cluster (before running the reducer) + * + * @example + * function () { return {sum: 0}; } + */ + initial?: () => any; + /** + * properties to use for individual points when running the reducer + * + * @example + * function (props) { return {sum: props.my_value}; } + */ + map?: (props: any) => any; } export class Supercluster { diff --git a/types/supercluster/supercluster-tests.ts b/types/supercluster/supercluster-tests.ts index 2fe5eeff39..e3120206e9 100644 --- a/types/supercluster/supercluster-tests.ts +++ b/types/supercluster/supercluster-tests.ts @@ -2,21 +2,36 @@ import supercluster, { Point } from 'supercluster'; const point1: Point = { type: 'Feature', - properties: {}, + properties: {my_value: 2}, geometry: { type: 'Point', coordinates: [10, 20] } }; const point2: Point = { type: 'Feature', - properties: {}, + properties: {my_value: 3}, geometry: { type: 'Point', coordinates: [20, 30] } }; const points = [point1, point2]; +const initialFunction = () => { + return {sum: 0}; +}; + +const mapFunction = (props: any) => { + return {sum: props.my_value}; +}; + +const reduceFunction = (accumulated: any, props: any) => { + accumulated.sum += props.sum; +}; + const index = supercluster({ radius: 40, maxZoom: 16, extent: 256, - log: true + log: true, + initial: initialFunction, + map: mapFunction, + reduce: reduceFunction, }); index.load(points); const clusters = index.getClusters([-180, -85, 180, 85], 2); diff --git a/types/underscore.string/index.d.ts b/types/underscore.string/index.d.ts index c173dfbfa5..2d067679d5 100644 --- a/types/underscore.string/index.d.ts +++ b/types/underscore.string/index.d.ts @@ -91,6 +91,13 @@ declare module 'underscore' { */ clean(str: string): string; + /** + * Replace diacritic characters with closest ASCII equivalents. + * cleanDiacritics('ääkkönen') => 'aakkonen' + * @param str + */ + cleanDiacritics(str: string): string; + /** * Count occurences of a sub string. * ('Hello world', 'l') => 3 diff --git a/types/underscore.string/underscore.string-tests.ts b/types/underscore.string/underscore.string-tests.ts index 8eed630854..545f6362d6 100644 --- a/types/underscore.string/underscore.string-tests.ts +++ b/types/underscore.string/underscore.string-tests.ts @@ -13,6 +13,8 @@ _.chop('whitespace', 3); _.clean(' foo bar '); +_.cleanDiacritics('ääkkönen'); + _.chars('Hello'); _.swapCase('hELLO');