diff --git a/notNeededPackages.json b/notNeededPackages.json index 4307815cfa..498e2e1c4a 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -114,6 +114,12 @@ "sourceRepoURL": "https://github.com/blakeembrey/camel-case", "asOfVersion": "1.2.1" }, + { + "libraryName": "chalk", + "typingsPackageName": "chalk", + "sourceRepoURL": "https://github.com/chalk/chalk", + "asOfVersion": "2.2.0" + }, { "libraryName": "change-case", "typingsPackageName": "change-case", diff --git a/types/angular/angular-tests.ts b/types/angular/angular-tests.ts index 6d8b11bffe..9c0671601f 100644 --- a/types/angular/angular-tests.ts +++ b/types/angular/angular-tests.ts @@ -644,6 +644,9 @@ isolateScope = element.find('div').isolateScope(); isolateScope = element.children().isolateScope(); let element2 = angular.element(element); let elementArray = angular.element(document.querySelectorAll('div')); +let elementReadyFn = angular.element(() => { + console.log('ready'); +}); // $timeout signature tests namespace TestTimeout { diff --git a/types/angular/jqlite.d.ts b/types/angular/jqlite.d.ts index 858201fb18..a9da89cf65 100644 --- a/types/angular/jqlite.d.ts +++ b/types/angular/jqlite.d.ts @@ -684,7 +684,7 @@ interface JQuery { } interface JQueryStatic { - (element: string | Element | Document | JQuery | ArrayLike): JQLite; + (element: string | Element | Document | JQuery | ArrayLike | (() => void)): JQLite; } /** diff --git a/types/body-parser/index.d.ts b/types/body-parser/index.d.ts index 497f3c8dc7..b4943e8023 100644 --- a/types/body-parser/index.d.ts +++ b/types/body-parser/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/expressjs/body-parser // Definitions by: Santi Albo , Vilic Vane , Jonathan Häberle , Gevik Babakhani , Tomasz Łaziuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 /// diff --git a/types/chalk/chalk-tests.ts b/types/chalk/chalk-tests.ts deleted file mode 100644 index 20bdd9382c..0000000000 --- a/types/chalk/chalk-tests.ts +++ /dev/null @@ -1,42 +0,0 @@ -import chalk = require('chalk'); - -var str = ''; -var bool = false; -var chain: chalk.ChalkChain; - -chalk.enabled = bool; -str = chalk.stripColor(str); - -bool = chalk.supportsColor; -bool = chalk.hasColor(str); - -// style a string -console.log( chalk.blue('Hello world!') ); - -// combine styled and normal strings -console.log( chalk.blue('Hello'), 'World' + chalk.red('!') ); - -// compose multiple styles using the chainable API -console.log( chalk.blue.bgRed.bold('Hello world!') ); - -// pass in multiple arguments -console.log( chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz') ); - -// nest styles -console.log( chalk.red('Hello', chalk.underline.bgBlue('world') + '!') ); - -// nest styles of the same type even (color, underline, background) -console.log( chalk.green('I am a green line ' + chalk.blue('with a blue substring') + ' that becomes green again!') ); - -chain = chalk.green; -chain = chain.underline; -str = chain('someString'); - -chalk.enabled = chalk.supportsColor = bool; - -var chalkObj = new chalk.constructor({enabled: false}); - -chain = chalkObj.green; -chain = chalkObj.underline; -chalkObj.enabled = true; -str = chain('foo'); diff --git a/types/chalk/index.d.ts b/types/chalk/index.d.ts deleted file mode 100644 index 3651e8077d..0000000000 --- a/types/chalk/index.d.ts +++ /dev/null @@ -1,133 +0,0 @@ -// Type definitions for chalk v0.4.0 -// Project: https://github.com/sindresorhus/chalk -// Definitions by: Diullei Gomes , Bart van der Schoor , Nico Jansen -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -export = Chalk; - -declare namespace Chalk { - export var enabled: boolean; - export var supportsColor: boolean; - export var styles: ChalkStyleMap; - - export function stripColor(value: string): any; - export function hasColor(str: string): boolean; - - export interface ChalkChain extends ChalkStyle { - (): boolean; - (...text: string[]): string; - } - - export interface ChalkStyleElement { - open: string; - close: string; - } - - // General - export var reset: ChalkChain; - export var bold: ChalkChain; - export var dim: ChalkChain; - export var italic: ChalkChain; - export var underline: ChalkChain; - export var inverse: ChalkChain; - export var hidden: ChalkChain; - export var strikethrough: ChalkChain; - - // Text colors - export var black: ChalkChain; - export var red: ChalkChain; - export var green: ChalkChain; - export var yellow: ChalkChain; - export var blue: ChalkChain; - export var magenta: ChalkChain; - export var cyan: ChalkChain; - export var white: ChalkChain; - export var gray: ChalkChain; - export var grey: ChalkChain; - - // Background colors - export var bgBlack: ChalkChain; - export var bgRed: ChalkChain; - export var bgGreen: ChalkChain; - export var bgYellow: ChalkChain; - export var bgBlue: ChalkChain; - export var bgMagenta: ChalkChain; - export var bgCyan: ChalkChain; - export var bgWhite: ChalkChain; - - - export interface ChalkStyle { - // General - reset: ChalkChain; - bold: ChalkChain; - dim: ChalkChain; - italic: ChalkChain; - underline: ChalkChain; - inverse: ChalkChain; - hidden: ChalkChain; - strikethrough: ChalkChain; - - // Text colors - black: ChalkChain; - red: ChalkChain; - green: ChalkChain; - yellow: ChalkChain; - blue: ChalkChain; - magenta: ChalkChain; - cyan: ChalkChain; - white: ChalkChain; - gray: ChalkChain; - grey: ChalkChain; - - // Background colors - bgBlack: ChalkChain; - bgRed: ChalkChain; - bgGreen: ChalkChain; - bgYellow: ChalkChain; - bgBlue: ChalkChain; - bgMagenta: ChalkChain; - bgCyan: ChalkChain; - bgWhite: ChalkChain; - } - - export interface ChalkStyleMap { - // General - reset: ChalkStyleElement; - bold: ChalkStyleElement; - dim: ChalkStyleElement; - italic: ChalkStyleElement; - underline: ChalkStyleElement; - inverse: ChalkStyleElement; - hidden: ChalkStyleElement; - strikethrough: ChalkStyleElement; - - // Text colors - black: ChalkStyleElement; - red: ChalkStyleElement; - green: ChalkStyleElement; - yellow: ChalkStyleElement; - blue: ChalkStyleElement; - magenta: ChalkStyleElement; - cyan: ChalkStyleElement; - white: ChalkStyleElement; - gray: ChalkStyleElement; - - // Background colors - bgBlack: ChalkStyleElement; - bgRed: ChalkStyleElement; - bgGreen: ChalkStyleElement; - bgYellow: ChalkStyleElement; - bgBlue: ChalkStyleElement; - bgMagenta: ChalkStyleElement; - bgCyan: ChalkStyleElement; - bgWhite: ChalkStyleElement; - } - - export const constructor: { - new (options: {enabled: boolean}): Chalk; - } - - export interface Chalk extends ChalkStyle { - enabled: boolean; - } -} diff --git a/types/chalk/tslint.json b/types/chalk/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/chalk/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "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 - } -} diff --git a/types/d3-transition/index.d.ts b/types/d3-transition/index.d.ts index 1ff8d46d04..eb60cec49f 100644 --- a/types/d3-transition/index.d.ts +++ b/types/d3-transition/index.d.ts @@ -569,7 +569,7 @@ export interface Transition(name: string): Transition; +export function transition(name?: string): Transition; /** * Returns a new transition from an existing transition. diff --git a/types/detect-browser/detect-browser-tests.ts b/types/detect-browser/detect-browser-tests.ts index 336da5150a..48abb964f8 100644 --- a/types/detect-browser/detect-browser-tests.ts +++ b/types/detect-browser/detect-browser-tests.ts @@ -1,5 +1,7 @@ +import { detect } from 'detect-browser'; +const browser = detect(); -import detectBrowser = require("detect-browser"); - -const n: string = detectBrowser.name; -const v: string = detectBrowser.version; +if (browser) { + const name: string = browser.name; + const version: string = browser.version; +} diff --git a/types/detect-browser/index.d.ts b/types/detect-browser/index.d.ts index 57ed80c411..351067ff59 100644 --- a/types/detect-browser/index.d.ts +++ b/types/detect-browser/index.d.ts @@ -1,14 +1,27 @@ -// Type definitions for detect-browser v1.6.2 +// Type definitions for detect-browser 2.0 // Project: https://github.com/DamonOehlman/detect-browser // Definitions by: Rogier Schouten // Definitions: https://github.com/borisyankov/DefinitelyTyped -/** - * Browser name - */ -export const name: "edge" | "yandexbrowser" | "chrome" | "crios" | "firefox" | "opera" | "ie" | "bb10" | "android" | "ios" | "safari"; +export type BrowserName = + "android" | + "bb10" | + "chrome" | + "crios" | + "edge" | + "firefox" | + "fxios" | + "ie" | + "ios" | + "kakaotalk" | + "opera" | + "phantomjs" | + "safari" | + "vivaldi" | + "yandexbrowser"; -/** - * Browser version - */ -export const version: string; +export function detect(): null | { + name: BrowserName | "node"; + version: string; + os: string; +}; diff --git a/types/detect-browser/tsconfig.json b/types/detect-browser/tsconfig.json index 076582077e..b1319407fc 100644 --- a/types/detect-browser/tsconfig.json +++ b/types/detect-browser/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ diff --git a/types/detect-browser/tslint.json b/types/detect-browser/tslint.json index a41bf5d19a..dc8ddaa586 100644 --- a/types/detect-browser/tslint.json +++ b/types/detect-browser/tslint.json @@ -1,79 +1,10 @@ { "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 + "indent": [ + true, + "spaces", + 4 + ] } } diff --git a/types/express-ejs-layouts/express-ejs-layouts-tests.ts b/types/express-ejs-layouts/express-ejs-layouts-tests.ts new file mode 100644 index 0000000000..9d77105a9d --- /dev/null +++ b/types/express-ejs-layouts/express-ejs-layouts-tests.ts @@ -0,0 +1,7 @@ +import * as express from 'express'; +import * as expressEjsLayouts from 'express-ejs-layouts'; + +function expressRequestHandlerTest() { + const app = express() + .use(expressEjsLayouts()); +} diff --git a/types/express-ejs-layouts/index.d.ts b/types/express-ejs-layouts/index.d.ts new file mode 100644 index 0000000000..b9c87cf5c1 --- /dev/null +++ b/types/express-ejs-layouts/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for express-ejs-layouts 2.3 +// Project: https://github.com/Soarez/express-ejs-layouts +// Definitions by: Erik Mavrinac +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { RequestHandler } from 'express'; + +declare function expressEjsLayouts(): RequestHandler; + +declare namespace expressEjsLayouts { +} + +export = expressEjsLayouts; diff --git a/types/chalk/tsconfig.json b/types/express-ejs-layouts/tsconfig.json similarity index 87% rename from types/chalk/tsconfig.json rename to types/express-ejs-layouts/tsconfig.json index 13ab93883b..7ade9f8819 100644 --- a/types/chalk/tsconfig.json +++ b/types/express-ejs-layouts/tsconfig.json @@ -2,8 +2,7 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6", - "dom" + "es6" ], "noImplicitAny": true, "noImplicitThis": true, @@ -19,6 +18,6 @@ }, "files": [ "index.d.ts", - "chalk-tests.ts" + "express-ejs-layouts-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/express-ejs-layouts/tslint.json b/types/express-ejs-layouts/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/express-ejs-layouts/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/express-rate-limit/index.d.ts b/types/express-rate-limit/index.d.ts index cb0d16ec61..fe8d8e4284 100644 --- a/types/express-rate-limit/index.d.ts +++ b/types/express-rate-limit/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/nfriedly/express-rate-limit // Definitions by: Cyril Schumacher , makepost // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 import express = require("express"); diff --git a/types/express-serve-static-core/index.d.ts b/types/express-serve-static-core/index.d.ts index 6d8b771e58..b0e463306d 100644 --- a/types/express-serve-static-core/index.d.ts +++ b/types/express-serve-static-core/index.d.ts @@ -2,6 +2,8 @@ // Project: http://expressjs.com // Definitions by: Boris Yankov , Michał Lytek , Kacper Polak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + // This extracts the core definitions from express to prevent a circular dependency between express and serve-static /// @@ -174,12 +176,7 @@ interface RequestRanges extends Array { type: string; } interface Errback { (err: Error): void; } -interface Request< - Body = any, - Query = any, - Params = any, - Cookies = any -> extends http.IncomingMessage, Express.Request { +interface Request extends http.IncomingMessage, Express.Request { /** * Return request header. @@ -440,14 +437,14 @@ interface Request< xhr: boolean; //body: { username: string; password: string; remember: boolean; title: string; }; - body: Body; + body: any; //cookies: { string; remember: boolean; }; - cookies: Cookies; + cookies: any; method: string; - params: Params; + params: any; /** * Clear cookie `name`. @@ -457,7 +454,7 @@ interface Request< */ clearCookie(name: string, options?: any): Response; - query: Query; + query: any; route: any; diff --git a/types/express-session/index.d.ts b/types/express-session/index.d.ts index 8c5faa7873..be289b9940 100644 --- a/types/express-session/index.d.ts +++ b/types/express-session/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Hiroki Horiuchi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Definitions by: Jacob Bogers diff --git a/types/express/express-tests.ts b/types/express/express-tests.ts index d578a24886..0c1081b49b 100644 --- a/types/express/express-tests.ts +++ b/types/express/express-tests.ts @@ -17,10 +17,9 @@ namespace express_tests { next(); }); - app.use((err: any, req: express.Request<{ hello: string; }>, res: express.Response, next: express.NextFunction) => { - console.log(req.body.hello); - console.error(err); - next(err); + app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => { + console.error(err); + next(err); }); app.get('/', (req, res) => { diff --git a/types/express/index.d.ts b/types/express/index.d.ts index 66bf4180c8..59f60e92df 100644 --- a/types/express/index.d.ts +++ b/types/express/index.d.ts @@ -2,7 +2,7 @@ // Project: http://expressjs.com // Definitions by: Boris Yankov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.2 /* =================== USAGE =================== @@ -76,12 +76,7 @@ declare namespace e { interface IRouterMatcher extends core.IRouterMatcher { } interface MediaType extends core.MediaType { } interface NextFunction extends core.NextFunction { } - interface Request< - Body = any, - Query = any, - Params = any, - Cookies = any - > extends core.Request { } + interface Request extends core.Request { } interface RequestHandler extends core.RequestHandler { } interface RequestParamHandler extends core.RequestParamHandler { } export interface Response extends core.Response { } diff --git a/types/fossil-delta/index.d.ts b/types/fossil-delta/index.d.ts index 98ab4cc600..3b79af9cc4 100644 --- a/types/fossil-delta/index.d.ts +++ b/types/fossil-delta/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for fossil-delta 0.2.5 +// Type definitions for fossil-delta 1.0.0 // Project: https://github.com/dchest/fossil-delta-js // Definitions by: Endel Dreyer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -8,5 +8,5 @@ type ByteArray = Array | Uint8Array | Buffer; export function create(origin: ByteArray, target: ByteArray): Array; -export function apply(origin: ByteArray, delta: Array): Array; +export function apply(origin: ByteArray, delta: Array, ops?: { verifyChecksum: boolean }): Array; export function outputSize(delta: Array): number; diff --git a/types/grasp/grasp-tests.ts b/types/grasp/grasp-tests.ts new file mode 100644 index 0000000000..647f57d8fd --- /dev/null +++ b/types/grasp/grasp-tests.ts @@ -0,0 +1,50 @@ +import fs = require("fs"); +import * as grasp from "grasp"; + +grasp(); // $ExpectError +grasp({ args: [] }); // $ExpectType void + +// $ExpectType void +grasp({ + args: [], + error: console.error, + callback: console.log, + exit: process.exit, + console, + stdin: process.stdin, + fs, + input: "foo bar" +}); + +// $ExpectError +grasp({ + args: [], + textFormat: { cyan: "cyan" } +}); + +// $ExpectType string +grasp.VERSION; + +const fooquery = grasp.search("fooquery"); // $ExpectError +const equery = grasp.search("equery"); +const squery = grasp.search("squery"); + +// $ExpectType Node[] +grasp.search("equery", "pattern", "input"); + +// $ExpectType Node[] +equery("pattern")("input"); + +// $ExpectType (input: string) => Node[] +squery("pattern"); + +const replacer = grasp.replace("equery", "pattern"); + +// $ExpectType string +replacer("replacement", "input"); + +// $ExpectType string +replacer((getRaw, node, query, named) => { + getRaw(node); // $ExpectType string + return "foo"; +}, "input"); diff --git a/types/grasp/index.d.ts b/types/grasp/index.d.ts new file mode 100644 index 0000000000..bafaac5fdb --- /dev/null +++ b/types/grasp/index.d.ts @@ -0,0 +1,72 @@ +// Type definitions for grasp 0.6 +// Project: http://graspjs.com +// Definitions by: Isaac Wolkerstorfer +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +/// + +import * as fs from "fs"; +import * as cliColor from "cli-color"; +// Though Grasp does not use esprima, the parser it uses (flow-parser) has a compatible Node type and existing typedefs +import { Node } from "estree"; + +export = grasp; + +declare function grasp(options: { + args: string[] | Record | string; + error?: (message: string) => void; + callback?: (result: string) => void; + exit?: (code: number) => void; + input?: string; + + // The following are "overrides" for defaults, such as console, cli-color, + // process.stdin, or fs. In most cases grasp only makes use of a small + // surface area of the types, but I think if someone really wants to pass a + // fake fs that only implements the subset of methods they think grasp uses, + // it should be up to them to use a cast rather than the typedef to be + // overly lenient. We never know if grasp might change their internal use of + // fs, after all. + fs?: typeof fs; + console?: typeof console; + textFormat?: typeof cliColor; + stdin?: typeof process.stdin; +}): void; + +declare namespace grasp { + const VERSION: string; + + // Both the search and replace functions are curryable, which leads to quite + // a bit of noise. Using generic currying will discard variable name + // information, so we hand-roll it here + + function search(engine: QueryEngineType, selector: string, input: string): Node[]; + function search(engine: QueryEngineType, selector: string): (input: string) => Node[]; + function search(engine: QueryEngineType): GraspSearchWithQueryEngine; + + function replace(engine: QueryEngineType, selector: string, replacement: Replacement, input: string): string; + function replace(engine: QueryEngineType, selector: string, replacement: Replacement): (input: string) => string; + function replace(engine: QueryEngineType, selector: string): GraspReplaceWithSelector; + function replace(engine: QueryEngineType): GraspReplaceWithQueryEngine; + + type QueryEngineType = "squery" | "equery"; + + type Replacement = + | string + | (( + getRaw: (node: Node) => string, + node: Node, + query: (q: string) => Node[], + named: { [key: string]: string | Node } + ) => string); + + type GraspSearchWithQueryEngine = ((selector: string, input: string) => Node[]) & + ((selector: string) => (input: string) => Node[]); + + type GraspReplaceWithQueryEngine = ((selector: string) => GraspReplaceWithSelector) & + ((selector: string, replacement: Replacement) => (input: string) => string) & + ((selector: string, replacement: Replacement, input: string) => string); + + type GraspReplaceWithSelector = ((replacement: Replacement) => (input: string) => string) & + ((replacement: Replacement, input: string) => string); +} diff --git a/types/grasp/tsconfig.json b/types/grasp/tsconfig.json new file mode 100644 index 0000000000..e0996e4408 --- /dev/null +++ b/types/grasp/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "grasp-tests.ts"] +} diff --git a/types/grasp/tslint.json b/types/grasp/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/grasp/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/gulp-util/gulp-util-tests.ts b/types/gulp-util/gulp-util-tests.ts index 651f9bff9b..67468829d3 100644 --- a/types/gulp-util/gulp-util-tests.ts +++ b/types/gulp-util/gulp-util-tests.ts @@ -7,15 +7,16 @@ import path = require('path'); import should = require('should'); import Stream = require('stream'); import through = require('through2'); -var es = require('event-stream'); +const es = require('event-stream'); +//TODO: import es = require('event-stream'); // ReSharper disable WrongExpressionStatement describe('File()', () => { it('should return a valid file', done => { - var fname = path.join(__dirname, './fixtures/test.coffee'); - var base = path.join(__dirname, './fixtures/'); - var file = new util.File({ - base: base, + const fname = path.join(__dirname, './fixtures/test.coffee'); + const base = path.join(__dirname, './fixtures/'); + const file = new util.File({ + base, cwd: __dirname, path: fname }); @@ -32,10 +33,10 @@ describe('File()', () => { }); it('should return a valid file 2', done => { - var fname = path.join(__dirname, './fixtures/test.coffee'); - var base = __dirname; - var file = new util.File({ - base: base, + const fname = path.join(__dirname, './fixtures/test.coffee'); + const base = __dirname; + const file = new util.File({ + base, cwd: __dirname, path: fname }); @@ -54,32 +55,31 @@ describe('File()', () => { describe('replaceExtension()', () => { it('should return a valid replaced extension on nested', done => { - var fname = path.join(__dirname, './fixtures/test.coffee'); - var expected = path.join(__dirname, './fixtures/test.js'); - var nu = util.replaceExtension(fname, '.js'); + const fname = path.join(__dirname, './fixtures/test.coffee'); + const expected = path.join(__dirname, './fixtures/test.js'); + const nu = util.replaceExtension(fname, '.js'); should.exist(nu); nu.should.equal(expected); done(); }); it('should return a valid replaced extension on flat', done => { - var fname = 'test.coffee'; - var expected = 'test.js'; - var nu = util.replaceExtension(fname, '.js'); + const fname = 'test.coffee'; + const expected = 'test.js'; + const nu = util.replaceExtension(fname, '.js'); should.exist(nu); nu.should.equal(expected); done(); }); it('should not return a valid replaced extension on empty string', done => { - var fname = ''; - var expected = ''; - var nu = util.replaceExtension(fname, '.js'); + const fname = ''; + const expected = ''; + const nu = util.replaceExtension(fname, '.js'); should.exist(nu); nu.should.equal(expected); done(); }); - }); describe('colors', () => { @@ -96,14 +96,14 @@ describe('date', () => { done(); }); it('should return today\'s date', done => { - var time = new Date(); - var dateutil = util.date('HH:MM:ss'); - dateutil.should.equal(('0' + time.getHours()).slice(-2) + ':' + ('0' + time.getMinutes()).slice(-2) + ':' + ('0' + time.getSeconds()).slice(-2)); + const time = new Date(); + const dateutil = util.date('HH:MM:ss'); + dateutil.should.equal(`${('0' + time.getHours()).slice(-2)}:${('0' + time.getMinutes()).slice(-2)}:${('0' + time.getSeconds()).slice(-2)}`); done(); }); }); -var now = new Date(); +const now = new Date(); // Basic usage util.date(now, 'dddd, mmmm dS, yyyy, h:MM:ss TT'); @@ -157,11 +157,11 @@ util.date(now, 'N'); describe('log()', () => { it('should work i guess', done => { - var writtenValue = ''; + const writtenValue = ''; util.log(1, 2, 3, 4, 'five'); - var time = util.date(new Date(), 'HH:MM:ss'); - writtenValue.should.eql('[' + util.colors.gray(time) + '] 1 2 3 4 five\n'); + const time = util.date(new Date(), 'HH:MM:ss'); + writtenValue.should.eql(`[${util.colors.gray(time)}] 1 2 3 4 five\n`); done(); }); @@ -169,34 +169,34 @@ describe('log()', () => { describe('template()', () => { it('should work with just a template', done => { - var opt = { + const opt = { name: 'todd', file: { path: 'hi.js' } }; - var expected = 'test todd hi.js'; + const expected = 'test todd hi.js'; - var tmpl = util.template('test <%= name %> <%= file.path %>'); + const tmpl = util.template('test <%= name %> <%= file.path %>'); should.exist(tmpl); 'function'.should.equal(typeof (tmpl)); // eval it now - var etmpl = tmpl(opt); + const etmpl = tmpl(opt); 'string'.should.equal(typeof (etmpl)); etmpl.should.equal(expected); done(); }); it('should work with a template and data', done => { - var opt = { + const opt = { name: 'todd', file: { path: 'hi.js' } }; - var expected = 'test todd hi.js'; - var tmpl = util.template('test <%= name %> <%= file.path %>', opt); + const expected = 'test todd hi.js'; + const tmpl = util.template('test <%= name %> <%= file.path %>', opt); should.exist(tmpl); 'string'.should.equal(typeof (tmpl)); tmpl.should.equal(expected); @@ -204,11 +204,11 @@ describe('template()', () => { }); //it('should throw an error when no file object is passed', done => { - // var opt = { + // const opt = { // name: 'todd' // }; // try { - // var tmpl = util.template('test <%= name %> <%= file.path %>', opt); + // const tmpl = util.template('test <%= name %> <%= file.path %>', opt); // } catch (err) { // should.exist(err); // done(); @@ -216,23 +216,23 @@ describe('template()', () => { //}); it('should ignore modified templateSettings', done => { - var templateSettings = require('lodash.templatesettings'); + const templateSettings = require('lodash.templatesettings'); templateSettings.interpolate = /\{\{([\s\S]+?)\}\}/g; - var opt = { + const opt = { name: 'todd', file: { path: 'hi.js' } }; - var expected = 'test {{name}} hi.js'; + const expected = 'test {{name}} hi.js'; - var tmpl = util.template('test {{name}} <%= file.path %>'); + const tmpl = util.template('test {{name}} <%= file.path %>'); should.exist(tmpl); 'function'.should.equal(typeof (tmpl)); // eval it now - var etmpl = tmpl(opt); + const etmpl = tmpl(opt); 'string'.should.equal(typeof (etmpl)); etmpl.should.equal(expected); @@ -240,26 +240,25 @@ describe('template()', () => { }); it('should allow ES6 delimiters', done => { - var opt = { + const opt = { name: 'todd', file: { path: 'hi.js' } }; - var expected = 'test todd hi.js'; + const expected = 'test todd hi.js'; - var tmpl = util.template('test ${name} ${file.path}'); + const tmpl = util.template('test ${name} ${file.path}'); // tslint:disable-line no-invalid-template-strings should.exist(tmpl); 'function'.should.equal(typeof (tmpl)); // eval it now - var etmpl = tmpl(opt); + const etmpl = tmpl(opt); 'string'.should.equal(typeof (etmpl)); etmpl.should.equal(expected); done(); }); - }); describe('env', () => { @@ -276,8 +275,8 @@ describe('noop()', () => { done(); }); it('should return a stream that passes through all data', done => { - var inp = [1, 2, 3, 4, 5, 6, 7, 8, 9]; - var stream = util.noop(); + const inp = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + const stream = util.noop(); es.readArray(inp) .pipe(stream) .pipe(es.writeArray((err: Error, arr: any[]) => { @@ -291,7 +290,7 @@ describe('noop()', () => { describe('beep()', () => { it('should send the right code to stdout', done => { - var writtenValue = ''; + const writtenValue = ''; util.beep(); writtenValue.should.equal('\x07'); @@ -338,45 +337,45 @@ describe('isNull()', () => { }); // linefeed -declare var lines: string[]; +declare const lines: string[]; lines.join(util.linefeed); describe('combine()', () => { it('should return a function', done => { - var src = [1, 2, 3]; - var inp = es.readArray(src); - var factory = util.combine(inp); + const src = [1, 2, 3]; + const inp = es.readArray(src); + const factory = util.combine(inp); factory.should.be.type('function'); done(); }); it('should return a function that returns a stream combination', done => { - var src = [1, 2, 3]; - var inp = es.readArray(src); - var inp2 = es.writeArray((err: Error, data: any[]) => { + const src = [1, 2, 3]; + const inp = es.readArray(src); + const inp2 = es.writeArray((err: Error, data: any[]) => { should.not.exist(err); data.should.eql(src); done(); }); - var factory = util.combine(inp, inp2); + const factory = util.combine(inp, inp2); factory().should.be.instanceof(Stream.Readable); }); it('should return a function that returns a stream combination when given an array', done => { - var src = [1, 2, 3]; - var inp = es.readArray(src); - var inp2 = es.writeArray((err: Error, data: any[]) => { + const src = [1, 2, 3]; + const inp = es.readArray(src); + const inp2 = es.writeArray((err: Error, data: any[]) => { should.not.exist(err); data.should.eql(src); done(); }); - var factory = util.combine([inp, inp2]); + const factory = util.combine([inp, inp2]); factory().should.be.instanceof(Stream.Readable); }); }); describe('buffer()', () => { it('should buffer stuff and return an array into the callback', done => { - var src = [1, 2, 3]; - var inp = es.readArray(src); + const src = [1, 2, 3]; + const inp = es.readArray(src); inp.pipe(util.buffer((err: Error, data: any[]) => { should.not.exist(err); should.exist(data); @@ -385,8 +384,8 @@ describe('buffer()', () => { })); }); it('should buffer stuff and emit it as a data event', done => { - var src = [1, 2, 3]; - var inp = es.readArray(src); + const src = [1, 2, 3]; + const inp = es.readArray(src); inp.pipe(util.buffer()).on('data', (data: any[]) => { should.exist(data); data.should.eql(src); @@ -394,8 +393,8 @@ describe('buffer()', () => { }); }); it('should buffer stuff and return a stream with the buffered data', done => { - var src = [1, 2, 3]; - var inp = es.readArray(src); + const src = [1, 2, 3]; + const inp = es.readArray(src); inp.pipe(util.buffer()).pipe(es.through((data: any[]) => { should.exist(data); data.should.eql(src); @@ -406,35 +405,35 @@ describe('buffer()', () => { describe('PluginError()', () => { it('should default name to Error', () => { - var err = new util.PluginError('test', 'something broke'); + const err = new util.PluginError('test', 'something broke'); err.name.should.equal('Error'); }); it('should default name to Error, even when wrapped error has no name', () => { - var realErr = { message: 'something broke' }; - var err = new util.PluginError('test', realErr); + const realErr = { message: 'something broke' }; + const err = new util.PluginError('test', realErr); err.name.should.equal('Error'); }); it('should print the plugin name in toString', () => { - var err = new util.PluginError('test', 'something broke'); + const err = new util.PluginError('test', 'something broke'); err.toString().indexOf('test').should.not.equal(-1); }); it('should not include the stack by default in toString', () => { - var err = new util.PluginError('test', 'something broke'); + const err = new util.PluginError('test', 'something broke'); // just check that there are no 'at' lines err.toString().indexOf('at').should.equal(-1); }); it('should include the stack when specified in toString', () => { - var err = new util.PluginError('test', 'something broke', { stack: "at huh", showStack: true }); + const err = new util.PluginError('test', 'something broke', { stack: "at huh", showStack: true }); // just check that there are 'at' lines err.toString().indexOf('at').should.not.equal(-1); }); it('should take arguments as one object', () => { - var err = new util.PluginError({ + const err = new util.PluginError({ plugin: 'test', message: 'something broke' }); @@ -443,7 +442,7 @@ describe('PluginError()', () => { }); it('should take arguments as plugin name and one object', () => { - var err = new util.PluginError('test', { + const err = new util.PluginError('test', { message: 'something broke' }); err.plugin.should.equal('test'); @@ -451,22 +450,22 @@ describe('PluginError()', () => { }); it('should take arguments as plugin name and message', () => { - var err = new util.PluginError('test', 'something broke'); + const err = new util.PluginError('test', 'something broke'); err.plugin.should.equal('test'); err.message.should.equal('something broke'); }); it('should take arguments as plugin name, message, and one object', () => { - var err = new util.PluginError('test', 'something broke', { showStack: true }); + const err = new util.PluginError('test', 'something broke', { showStack: true }); err.plugin.should.equal('test'); err.message.should.equal('something broke'); err.showStack.should.equal(true); }); it('should take arguments as plugin name, error, and one object', () => { - var realErr = new Error('something broke'); - (realErr).fileName = 'original.js'; - var err = new util.PluginError('test', realErr, { showStack: true, fileName: 'override.js' }); + const realErr = new Error('something broke') as Error & { fileName: string }; + realErr.fileName = 'original.js'; + const err = new util.PluginError('test', realErr, { showStack: true, fileName: 'override.js' }); err.plugin.should.equal('test'); err.message.should.equal('something broke'); err.fileName.should.equal('override.js'); @@ -474,26 +473,27 @@ describe('PluginError()', () => { }); it('should take properties from error', () => { - var realErr = new Error('something broke'); - (realErr).abstractProperty = 'abstract'; - var err = new util.PluginError('test', realErr); + const realErr = new Error('something broke') as Error & { abstractProperty: string }; + realErr.abstractProperty = 'abstract'; + const err = new util.PluginError('test', realErr); err.plugin.should.equal('test'); err.message.should.equal('something broke'); - (err).abstractProperty.should.equal('abstract'); + // TODO: use generics to make this work without a cast? + (err as util.PluginError & { abstractProperty: string }).abstractProperty.should.equal('abstract'); }); it('should be configured to show properties by default', () => { - var err = new util.PluginError('test', 'something broke'); + const err = new util.PluginError('test', 'something broke'); err.showProperties.should.be.true; }); it('should not be configured to take option to show properties', () => { - var err = new util.PluginError('test', 'something broke', { showProperties: false }); + const err = new util.PluginError('test', 'something broke', { showProperties: false }); err.showProperties.should.be.false; }); it('should show properties', () => { - var err = new util.PluginError('test', 'it broke', { showProperties: true }); + const err = new util.PluginError('test', 'it broke', { showProperties: true }); err.fileName = 'original.js'; err.lineNumber = 35; err.toString().indexOf('it broke').should.not.equal(-1); @@ -502,25 +502,25 @@ describe('PluginError()', () => { }); it('should show properties', () => { - var realErr = new Error('something broke'); - (realErr).fileName = 'original.js'; - (realErr).lineNumber = 35; - var err = new util.PluginError('test', realErr, { showProperties: true }); + const realErr = new Error('something broke') as Error & { fileName: string, lineNumber: number }; + realErr.fileName = 'original.js'; + realErr.lineNumber = 35; + const err = new util.PluginError('test', realErr, { showProperties: true }); err.toString().indexOf('message:').should.equal(-1); err.toString().indexOf('fileName:').should.not.equal(-1); }); it('should not show properties', () => { - var realErr = new Error('something broke'); - (realErr).fileName = 'original.js'; - (realErr).lineNumber = 35; - var err = new util.PluginError('test', realErr, { showProperties: false }); + const realErr = new Error('something broke') as Error & { fileName: string, lineNumber: number }; + realErr.fileName = 'original.js'; + realErr.lineNumber = 35; + const err = new util.PluginError('test', realErr, { showProperties: false }); err.toString().indexOf('message:').should.equal(-1); err.toString().indexOf('fileName:').should.equal(-1); }); it('should not show properties, but should show stack', () => { - var err = new util.PluginError('test', 'it broke', { stack: 'test stack', showStack: true, showProperties: false }); + const err = new util.PluginError('test', 'it broke', { stack: 'test stack', showStack: true, showProperties: false }); err.fileName = 'original.js'; err.lineNumber = 35; err.toString().indexOf('message:').should.equal(-1); @@ -529,40 +529,40 @@ describe('PluginError()', () => { }); it('should not show properties, but should show stack for real error', () => { - var realErr = new Error('something broke'); - (realErr).fileName = 'original.js'; - (realErr).lineNumber = 35; - (realErr).stack = 'test stack'; - var err = new util.PluginError('test', realErr, { showStack: true, showProperties: false }); + const realErr = new Error('something broke') as Error & { fileName: string, lineNumber: number }; + realErr.fileName = 'original.js'; + realErr.lineNumber = 35; + realErr.stack = 'test stack'; + const err = new util.PluginError('test', realErr, { showStack: true, showProperties: false }); err.toString().indexOf('message:').should.equal(-1); err.toString().indexOf('fileName:').should.equal(-1); err.toString().indexOf('test stack').should.not.equal(-1); }); it('should not show properties, but should show stack for _stack', () => { - var realErr = new Error('something broke'); - (realErr).fileName = 'original.js'; - (realErr).lineNumber = 35; - (realErr)._stack = 'test stack'; - var err = new util.PluginError('test', realErr, { showStack: true, showProperties: false }); + const realErr = new Error('something broke') as Error & { fileName: string, lineNumber: number, _stack: string }; + realErr.fileName = 'original.js'; + realErr.lineNumber = 35; + realErr._stack = 'test stack'; + const err = new util.PluginError('test', realErr, { showStack: true, showProperties: false }); err.toString().indexOf('message:').should.equal(-1); err.toString().indexOf('fileName:').should.equal(-1); err.toString().indexOf('test stack').should.not.equal(-1); }); it('should show properties and stack', () => { - var realErr = new Error('something broke'); - (realErr).fileName = 'original.js'; - (realErr).stack = 'test stack'; - var err = new util.PluginError('test', realErr, { showStack: true }); + const realErr = new Error('something broke') as Error & { fileName: string }; + realErr.fileName = 'original.js'; + realErr.stack = 'test stack'; + const err = new util.PluginError('test', realErr, { showStack: true }); err.toString().indexOf('message:').should.equal(-1); err.toString().indexOf('fileName:').should.not.equal(-1); err.toString().indexOf('test stack').should.not.equal(-1); }); it('should show properties added after the error is created', () => { - var realErr = new Error('something broke'); - var err = new util.PluginError('test', realErr); + const realErr = new Error('something broke'); + const err = new util.PluginError('test', realErr); err.fileName = 'original.js'; err.toString().indexOf('message:').should.equal(-1); err.toString().indexOf('fileName:').should.not.equal(-1); @@ -571,8 +571,8 @@ describe('PluginError()', () => { it('should toString quickly', function(done) { this.timeout(100); - var err = new util.PluginError('test', 'it broke', { showStack: true }); - var str = err.toString(); + const err = new util.PluginError('test', 'it broke', { showStack: true }); + const str = err.toString(); done(); }); @@ -580,15 +580,15 @@ describe('PluginError()', () => { it('should toString quickly with original error', function(done) { this.timeout(100); - var realErr = new Error('it broke'); - var err = new util.PluginError('test', realErr, { showStack: true }); - var str = err.toString(); + const realErr = new Error('it broke'); + const err = new util.PluginError('test', realErr, { showStack: true }); + const str = err.toString(); done(); }); it('should not show "Details:" if there are no properties to show', () => { - var err = new util.PluginError('plugin', 'message'); + const err = new util.PluginError('plugin', 'message'); err.toString().indexOf('Details:').should.equal(-1); }); }); diff --git a/types/gulp-util/index.d.ts b/types/gulp-util/index.d.ts index ee059ca986..d7538ee572 100644 --- a/types/gulp-util/index.d.ts +++ b/types/gulp-util/index.d.ts @@ -1,53 +1,50 @@ -// Type definitions for gulp-util v3.0.x +// Type definitions for gulp-util 3.0 // Project: https://github.com/gulpjs/gulp-util // Definitions by: jedmao // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// -/// import vinyl = require('vinyl'); -import chalk = require('chalk'); +import chalk from 'chalk'; import through2 = require('through2'); export { vinyl as File }; /** -* Replaces a file extension in a path. Returns the new path. -*/ + * Replaces a file extension in a path. Returns the new path. + */ export function replaceExtension(npath: string, ext: string): string; -export var colors: typeof chalk; +export const colors: typeof chalk; -export var date: { - (now?: Date, mask?: string, convertLocalTimeToUTC?: boolean): any; - (date?: string, mask?: string, convertLocalTimeToUTC?: boolean): any; +export const date: { + (now?: Date | string, mask?: string, convertLocalTimeToUTC?: boolean): any; masks: any; }; /** -* Logs stuff. Already prefixed with [gulp] and all that. Use the right colors -* for values. If you pass in multiple arguments it will join them by a space. -*/ + * Logs stuff. Already prefixed with [gulp] and all that. Use the right colors + * for values. If you pass in multiple arguments it will join them by a space. + */ export function log(message?: any, ...optionalParams: any[]): void; /** -* This is a lodash.template function wrapper. You must pass in a valid gulp -* file object so it is available to the user or it will error. You can not -* configure any of the delimiters. Look at the lodash docs for more info. -*/ + * This is a lodash.template function wrapper. You must pass in a valid gulp + * file object so it is available to the user or it will error. You can not + * configure any of the delimiters. Look at the lodash docs for more info. + */ export function template(tmpl: string): (opt: { file: { path: string } }) => string; export function template(tmpl: string, opt: { file: { path: string } }): string; -export var env: any; +export const env: any; export function beep(): void; /** -* Returns a stream that does nothing but pass data straight through. -*/ -export var noop: typeof through2; + * Returns a stream that does nothing but pass data straight through. + */ +export const noop: typeof through2; export function isStream(obj: any): boolean; @@ -55,47 +52,46 @@ export function isBuffer(obj: any): boolean; export function isNull(obj: any): boolean; -export var linefeed: string; +export const linefeed: string; export function combine(streams: NodeJS.ReadWriteStream[]): () => NodeJS.ReadWriteStream; export function combine(...streams: NodeJS.ReadWriteStream[]): () => NodeJS.ReadWriteStream; /** -* This is similar to es.wait but instead of buffering text into one string -* it buffers anything into an array (so very useful for file objects). -*/ + * This is similar to es.wait but instead of buffering text into one string + * it buffers anything into an array (so very useful for file objects). + */ export function buffer(cb?: (err: Error, data: any[]) => void): NodeJS.ReadWriteStream; export class PluginError implements Error, PluginErrorOptions { constructor(options?: PluginErrorOptions); constructor(pluginName: string, options?: PluginErrorOptions); - constructor(pluginName: string, message: string, options?: PluginErrorOptions); - constructor(pluginName: string, message: Error, options?: PluginErrorOptions); + constructor(pluginName: string, message: string | Error, options?: PluginErrorOptions); /** - * The module name of your plugin. - */ + * The module name of your plugin. + */ name: string; /** - * Can be a string or an existing error. - */ + * Can be a string or an existing error. + */ message: any; fileName: string; lineNumber: number; /** - * You need to include the message along with this stack. If you pass an - * error in as the message the stack will be pulled from that, otherwise one - * will be created. - */ + * You need to include the message along with this stack. If you pass an + * error in as the message the stack will be pulled from that, otherwise one + * will be created. + */ stack: string; /** - * By default the stack will not be shown. Set this to true if you think the - * stack is important for your error. - */ + * By default the stack will not be shown. Set this to true if you think the + * stack is important for your error. + */ showStack: boolean; /** - * Error properties will be included in err.toString(). Can be omitted by - * setting this to false. - */ + * Error properties will be included in err.toString(). Can be omitted by + * setting this to false. + */ showProperties: boolean; plugin: string; error: Error; @@ -103,30 +99,30 @@ export class PluginError implements Error, PluginErrorOptions { export interface PluginErrorOptions { /** - * The module name of your plugin. - */ + * The module name of your plugin. + */ name?: string; /** - * Can be a string or an existing error. - */ + * Can be a string or an existing error. + */ message?: any; fileName?: string; lineNumber?: number; /** - * You need to include the message along with this stack. If you pass an - * error in as the message the stack will be pulled from that, otherwise one - * will be created. - */ + * You need to include the message along with this stack. If you pass an + * error in as the message the stack will be pulled from that, otherwise one + * will be created. + */ stack?: string; /** - * By default the stack will not be shown. Set this to true if you think the - * stack is important for your error. - */ + * By default the stack will not be shown. Set this to true if you think the + * stack is important for your error. + */ showStack?: boolean; /** - * Error properties will be included in err.toString(). Can be omitted by - * setting this to false. - */ + * Error properties will be included in err.toString(). Can be omitted by + * setting this to false. + */ showProperties?: boolean; plugin?: string; error?: Error; diff --git a/types/gulp-util/tslint.json b/types/gulp-util/tslint.json index e87060ef20..a1de4a6061 100644 --- a/types/gulp-util/tslint.json +++ b/types/gulp-util/tslint.json @@ -1,80 +1,8 @@ { "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-invalid-template-strings": 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 + "comment-format": false, // TODO + "no-reference-import": false, // TODO: fix "should" + "no-var-requires": false // TODO } } diff --git a/types/i18n/index.d.ts b/types/i18n/index.d.ts index 0ddc39ffbf..6ed7e9fb8a 100644 --- a/types/i18n/index.d.ts +++ b/types/i18n/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Maxime LUCE // FindQ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 declare namespace i18n { interface ConfigurationOptions { diff --git a/types/jest-json-schema/index.d.ts b/types/jest-json-schema/index.d.ts new file mode 100644 index 0000000000..67f1c51f7e --- /dev/null +++ b/types/jest-json-schema/index.d.ts @@ -0,0 +1,19 @@ +// Type definitions for jest-json-schema 1.2 +// Project: https://github.com/americanexpress/jest-json-schema#readme +// Definitions by: Igor Korolev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// +import * as ajv from "ajv"; + +declare global { + namespace jest { + interface Matchers { + toMatchSchema(schema: object): R; + } + } +} + +export const matchers: jest.ExpectExtendMap; +export function matchersWithOptions(options: ajv.Options): jest.ExpectExtendMap; diff --git a/types/jest-json-schema/jest-json-schema-tests.ts b/types/jest-json-schema/jest-json-schema-tests.ts new file mode 100644 index 0000000000..a66c54a7e9 --- /dev/null +++ b/types/jest-json-schema/jest-json-schema-tests.ts @@ -0,0 +1,13 @@ +import { matchers } from 'jest-json-schema'; + +expect.extend(matchers); + +it('validates my json', () => { + const schema = { + properties: { + hello: { type: 'string' }, + }, + required: ['hello'], + }; + expect({ hello: 'world' }).toMatchSchema(schema); +}); diff --git a/types/jest-json-schema/package.json b/types/jest-json-schema/package.json new file mode 100644 index 0000000000..ee16c03768 --- /dev/null +++ b/types/jest-json-schema/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "ajv": "^4.11.5" + } +} diff --git a/types/jest-json-schema/tsconfig.json b/types/jest-json-schema/tsconfig.json new file mode 100644 index 0000000000..e8d55cbd89 --- /dev/null +++ b/types/jest-json-schema/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", + "jest-json-schema-tests.ts" + ] +} diff --git a/types/jest-json-schema/tslint.json b/types/jest-json-schema/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/jest-json-schema/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/klaw/index.d.ts b/types/klaw/index.d.ts index cbe78af067..8134b728c0 100644 --- a/types/klaw/index.d.ts +++ b/types/klaw/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for klaw v1.3.0 +// Type definitions for klaw v2.1.0 // Project: https://github.com/jprichardson/node-klaw // Definitions by: Matthew McEachen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -25,6 +25,7 @@ declare module "klaw" { pathSorter?: (pathA: string, pathB: string) => number fs?: any // fs or mock-fs filter?: (path: string) => boolean + depthLimit?: number } type Event = "close" | "data" | "end" | "readable" | "error" diff --git a/types/klaw/v1/index.d.ts b/types/klaw/v1/index.d.ts new file mode 100644 index 0000000000..cbe78af067 --- /dev/null +++ b/types/klaw/v1/index.d.ts @@ -0,0 +1,44 @@ +// Type definitions for klaw v1.3.0 +// Project: https://github.com/jprichardson/node-klaw +// Definitions by: Matthew McEachen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "klaw" { + + import * as fs from "fs" + import { Readable, ReadableOptions } from 'stream' + + function K(root: string, options?: K.Options): K.Walker + + namespace K { + interface Item { + path: string + stats: fs.Stats + } + + type QueueMethod = "shift" | "pop" + + interface Options extends ReadableOptions { + queueMethod?: QueueMethod + pathSorter?: (pathA: string, pathB: string) => number + fs?: any // fs or mock-fs + filter?: (path: string) => boolean + } + + type Event = "close" | "data" | "end" | "readable" | "error" + + interface Walker { + on(event: Event, listener: Function): this + on(event: "close", listener: () => void): this + on(event: "data", listener: (item: Item) => void): this + on(event: "end", listener: () => void): this + on(event: "readable", listener: () => void): this + on(event: "error", listener: (err: Error) => void): this + read(): Item + } + } + + export = K +} diff --git a/types/klaw/v1/klaw-tests.ts b/types/klaw/v1/klaw-tests.ts new file mode 100644 index 0000000000..2487aafd85 --- /dev/null +++ b/types/klaw/v1/klaw-tests.ts @@ -0,0 +1,43 @@ +import * as klaw from "klaw"; +const path = require('path'); + +// README.md: Streams 1 (push) example: + +let items: klaw.Item[] = [] // files, directories, symlinks, etc + +klaw('/some/dir') + .on('data', function(item: klaw.Item) { + items.push(item) + }) + .on('end', function() { + console.dir(items) // => [ ... array of files] + }) + +// README.md: Streams 2 & 3 (pull) with error handling + +klaw('/some/dir') + .on('readable', function() { + let item: klaw.Item; + while (item = this.read()) { + items.push(item) + } + }) + .on('error', function(err: Error, item: klaw.Item) { + console.log(err.message) + console.log(item.path) // the file the error occurred on + }) + .on('end', function() { + console.log(items) // => [ ... array of files] + }) + +// README.md: Example (ignore hidden directories): + +var filterFunc = function(item: string): boolean { + var basename = path.basename(item); + return basename === '.' || basename[0] !== '.' +} + +klaw('/some/dir', { filter: filterFunc }) + .on('data', function(item: klaw.Item) { + // only items of none hidden folders will reach here + }) diff --git a/types/klaw/v1/tsconfig.json b/types/klaw/v1/tsconfig.json new file mode 100644 index 0000000000..35caa3f9ea --- /dev/null +++ b/types/klaw/v1/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "paths": { + "klaw": [ + "klaw/v1" + ] + }, + "noImplicitAny": true, + "noImplicitThis": false, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "klaw-tests.ts" + ] +} \ No newline at end of file diff --git a/types/koa-morgan/index.d.ts b/types/koa-morgan/index.d.ts index f52baa788c..b4be38122b 100644 --- a/types/koa-morgan/index.d.ts +++ b/types/koa-morgan/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/koa-modules/morgan // Definitions by: Vesa Poikajärvi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 import { IncomingMessage, ServerResponse } from 'http'; import * as Koa from 'koa'; diff --git a/types/lolex/index.d.ts b/types/lolex/index.d.ts index de08060883..c0dec4cd56 100644 --- a/types/lolex/index.d.ts +++ b/types/lolex/index.d.ts @@ -70,9 +70,10 @@ export interface LolexClock { * * @param callback Callback to be fired. * @param timeout How many ticks to wait to run the callback. + * @param args Any extra arguments to pass to the callback. * @returns Time identifier for cancellation. */ - setTimeout(callback: () => any, timeout: number): TTimerId; + setTimeout(callback: () => any, timeout: number, ...args: any[]): TTimerId; /** * Clears a timer, as long as it was created using setTimeout. @@ -86,9 +87,10 @@ export interface LolexClock { * * @param callback Callback to be fired. * @param timeout How many ticks to wait between callbacks. + * @param args Any extra arguments to pass to the callback. * @returns Time identifier for cancellation. */ - setInterval(callback: () => any, timeout: number): TTimerId; + setInterval(callback: () => any, timeout: number, ...args: any[]): TTimerId; /** * Clears a timer, as long as it was created using setInterval. diff --git a/types/microsoftteams/index.d.ts b/types/microsoftteams/index.d.ts index 669488a7df..4ff2d9813a 100644 --- a/types/microsoftteams/index.d.ts +++ b/types/microsoftteams/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for microsoftteams 1.1 +// Type definitions for microsoftteams 1.2 // Project: https://github.com/OfficeDev/microsoft-teams-library-js // Definitions by: Bhargav Krishna // Jay Ongg diff --git a/types/mocha/index.d.ts b/types/mocha/index.d.ts index 07f59e6628..4ae915f683 100644 --- a/types/mocha/index.d.ts +++ b/types/mocha/index.d.ts @@ -27,6 +27,9 @@ interface MochaSetupOptions { // grep string or regexp to filter tests with grep?: any; + + // require modules before running tests + require?: string[]; } declare var mocha: Mocha; diff --git a/types/mocha/mocha-tests.ts b/types/mocha/mocha-tests.ts index 55ba6fa961..c3fa00da84 100644 --- a/types/mocha/mocha-tests.ts +++ b/types/mocha/mocha-tests.ts @@ -339,6 +339,10 @@ function test_setup_reporter_string_option() { mocha.setup({ reporter: 'html' }); } +function test_setup_require_stringArray_option() { + mocha.setup({ require: ['ts-node/register'] }); +} + function test_setup_reporter_function_option() { mocha.setup({ reporter: class { } }); } @@ -372,7 +376,8 @@ function test_setup_all_options() { reporter: 'html', bail: true, ignoreLeaks: true, - grep: 'test' + grep: 'test', + require: ['ts-node/register'] }); } diff --git a/types/mongoose-geojson-schema/index.d.ts b/types/mongoose-geojson-schema/index.d.ts new file mode 100644 index 0000000000..2cd97a8141 --- /dev/null +++ b/types/mongoose-geojson-schema/index.d.ts @@ -0,0 +1,79 @@ +// Type definitions for mongoose-geojson-schema 2.1 +// Project: https://github.com/rideamigoscorp/mongoose-geojson-schema#readme +// Definitions by: Bond +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +import mongoose = require('mongoose'); + +declare module 'mongoose' { + namespace Schema { + namespace Types { + class GeoJSON extends SchemaType { + constructor(key: string, options?: object); + cast(geojson: object): this; + static schemaName: 'GeoJSON'; + } + + class Point extends SchemaType { + constructor(key: string, options?: object); + cast(geojson: object): this; + static schemaName: 'Point'; + } + + class MultiPoint extends SchemaType { + constructor(key: string, options?: object); + cast(geojson: object): this; + static schemaName: 'MultiPoint'; + } + + class LineString extends SchemaType { + constructor(key: string, options?: object); + cast(geojson: object): this; + static schemaName: 'LineString'; + } + + class MultiLineString extends SchemaType { + constructor(key: string, options?: object); + cast(geojson: object): this; + static schemaName: 'MultiLineString'; + } + + class Polygon extends SchemaType { + constructor(key: string, options?: object); + cast(geojson: object): this; + static schemaName: 'Polygon'; + } + + class MultiPolygon extends SchemaType { + constructor(key: string, options?: object); + cast(geojson: object): this; + static schemaName: 'MultiPolygon'; + } + + class Geometry extends SchemaType { + constructor(key: string, options?: object); + cast(geojson: object): this; + static schemaName: 'Geometry'; + } + + class GeometryCollection extends SchemaType { + constructor(key: string, options?: object); + cast(geojson: object): this; + static schemaName: 'GeometryCollection'; + } + + class Feature extends SchemaType { + constructor(key: string, options?: object); + cast(geojson: object): this; + static schemaName: 'Feature'; + } + + class FeatureCollection extends SchemaType { + constructor(key: string, options?: object); + cast(geojson: object): this; + static schemaName: 'FeatureCollection'; + } + } + } +} diff --git a/types/mongoose-geojson-schema/mongoose-geojson-schema-tests.ts b/types/mongoose-geojson-schema/mongoose-geojson-schema-tests.ts new file mode 100644 index 0000000000..3694ab5144 --- /dev/null +++ b/types/mongoose-geojson-schema/mongoose-geojson-schema-tests.ts @@ -0,0 +1,22 @@ +'use strict'; + +import * as mongoose from 'mongoose'; +import * as mongooseGeoJSONSchema from 'mongoose-geojson-schema'; + +const TestSchema = new mongoose.Schema( + { + title: String, + test: {}, + point: mongoose.Schema.Types.Point, + multipoint: mongoose.Schema.Types.MultiPoint, + linestring: mongoose.Schema.Types.LineString, + multilinestring: mongoose.Schema.Types.MultiLineString, + polygon: mongoose.Schema.Types.Polygon, + multipolygon: mongoose.Schema.Types.MultiPolygon, + geometry: mongoose.Schema.Types.Geometry, + geometrycollection: mongoose.Schema.Types.GeometryCollection, + feature: mongoose.Schema.Types.Feature, + featurecollection: mongoose.Schema.Types.FeatureCollection, + }, + { typeKey: '$type', collection: 'echoes' } +); diff --git a/types/mongoose-geojson-schema/tsconfig.json b/types/mongoose-geojson-schema/tsconfig.json new file mode 100644 index 0000000000..9d3afc8952 --- /dev/null +++ b/types/mongoose-geojson-schema/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", + "mongoose-geojson-schema-tests.ts" + ] +} diff --git a/types/mongoose-geojson-schema/tslint.json b/types/mongoose-geojson-schema/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/mongoose-geojson-schema/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/morgan/index.d.ts b/types/morgan/index.d.ts index 1558f24ee4..097758465a 100644 --- a/types/morgan/index.d.ts +++ b/types/morgan/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: James Roland Cabresos // Paolo Scanferla // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.2 import express = require('express'); diff --git a/types/multer/index.d.ts b/types/multer/index.d.ts index 5c300a5585..d6e73f9ddf 100644 --- a/types/multer/index.d.ts +++ b/types/multer/index.d.ts @@ -6,7 +6,7 @@ // Michael Ledin // HyunSeob Lee // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 import * as express from 'express'; diff --git a/types/oauth2-server/index.d.ts b/types/oauth2-server/index.d.ts index 93e3e9398b..44d158690a 100644 --- a/types/oauth2-server/index.d.ts +++ b/types/oauth2-server/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Robbie Van Gorkom , // Charles Irick // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 import { Request, RequestHandler } from "express"; diff --git a/types/optics-agent/index.d.ts b/types/optics-agent/index.d.ts index 496437994f..b4c171bdd8 100644 --- a/types/optics-agent/index.d.ts +++ b/types/optics-agent/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/apollostack/optics-agent-js#readme // Definitions by: Crevil // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 import { GraphQLSchema } from "graphql"; import { Request, Response } from "express"; diff --git a/types/passport-oauth2/index.d.ts b/types/passport-oauth2/index.d.ts index 09facb2ef7..6be0c6ad44 100644 --- a/types/passport-oauth2/index.d.ts +++ b/types/passport-oauth2/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/jaredhanson/passport-oauth2#readme // Definitions by: Pasi Eronen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.2 import { Request } from 'express'; import { Strategy } from 'passport'; diff --git a/types/passport-saml/index.d.ts b/types/passport-saml/index.d.ts index e93869ca87..930a05dbfe 100644 --- a/types/passport-saml/index.d.ts +++ b/types/passport-saml/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/bergie/passport-saml // Definitions by: Chris Barth // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.1 import passport = require('passport'); import express = require('express'); diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 8a3545a267..2dcec3f6eb 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -3299,6 +3299,11 @@ interface ImagePropertiesAndroid { * It should also be used if the image is slightly bigger than the view. */ resizeMethod?: 'auto' | 'resize' | 'scale' + + /** + * Duration of fade in animation. + */ + fadeDuration?: number; } /** diff --git a/types/redux-first-router/index.d.ts b/types/redux-first-router/index.d.ts index 89be27f524..410cbc74cc 100644 --- a/types/redux-first-router/index.d.ts +++ b/types/redux-first-router/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/faceyspacey/redux-first-router#readme // Definitions by: Valbrand // viggyfresh +// janb87 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -113,8 +114,8 @@ export interface Meta { export interface Action { type: string; - payload: Payload; - meta: Meta; + payload?: Payload; + meta?: Meta; query?: object; navKey?: Nullable; } @@ -193,9 +194,9 @@ export type Payload = object; export type ScrollUpdater = (performedByUser: boolean) => void; -export const NOT_FOUND: string; +export const NOT_FOUND: '@@redux-first-router/NOT_FOUND'; -export function actionToPath(action: ReceivedAction, routesMap: RoutesMap): string; +export function actionToPath(action: ReceivedAction, routesMap: RoutesMap, querySerializer?: QuerySerializer): string; export function back(): void; diff --git a/types/redux-first-router/redux-first-router-tests.ts b/types/redux-first-router/redux-first-router-tests.ts index 8b8a7b1c5d..39b00c7a94 100644 --- a/types/redux-first-router/redux-first-router-tests.ts +++ b/types/redux-first-router/redux-first-router-tests.ts @@ -1,4 +1,13 @@ -import { connectRoutes, LocationState, RoutesMap } from 'redux-first-router'; +import { + connectRoutes, + LocationState, + RoutesMap, + actionToPath, + ReceivedAction, + redirect, + Action as ReduxFirstRouterAction, + QuerySerializer +} from 'redux-first-router'; import { createStore, applyMiddleware, @@ -40,5 +49,22 @@ const storeEnhancer = compose(enhancer const store = createStore(reducer, storeEnhancer); +const receivedAction: ReceivedAction = { + type: 'HOME', + payload: {} +}; +actionToPath(receivedAction, routesMap); // $ExpectType string + +const querySerializer: QuerySerializer = { + stringify: (params) => '', + parse: (queryString) => ({}) +}; +actionToPath(receivedAction, routesMap, querySerializer); // $ExpectType string + +const action: ReduxFirstRouterAction = { + type: 'HOME' +}; +redirect(action); // $ExpectType Action + // $ExpectType Store store; diff --git a/types/selectize/index.d.ts b/types/selectize/index.d.ts index f6c2498d70..449d09ce52 100644 --- a/types/selectize/index.d.ts +++ b/types/selectize/index.d.ts @@ -244,6 +244,14 @@ declare namespace Selectize { */ searchConjunction?: string; + /** + * If truthy, Selectize will make all optgroups be in the same order as they were added (by the `$order` + * property). Otherwise, it will order based on the score of the results in each. + * + * Default: false + */ + lockOptgroupOrder?: boolean; + /** * An array of optgroup values that indicates the order they should be listed in in the dropdown. * If not provided, groups will be ordered by the ranking of the options within them. @@ -426,7 +434,7 @@ declare namespace Selectize { /** * Resets / clears all selected items from the control. */ - clear(): void; + clear(silent?: boolean): void; /** * Returns the jQuery element of the item matching the given value. @@ -436,18 +444,18 @@ declare namespace Selectize { /** * "Selects" an item. Adds it to the list at the current caret position. */ - addItem(value: T): void; + addItem(value: T, silent?: boolean): void; /** * Removes the selected item matching the provided value. */ - removeItem(value: T): void; + removeItem(value: T, silent?: boolean): void; /** * Invokes the "create" method provided in the selectize options that should provide the data for the * new item, given the user input. Once this completes, it will be added to the item list. */ - createItem(value: T): void; + createItem(value: T, triggerDropdown?: boolean, callback?: (data?: any) => void): void; /** * Re-renders the selected item lists. diff --git a/types/swagger-node-runner/index.d.ts b/types/swagger-node-runner/index.d.ts index 89af13679d..92ee7919dd 100644 --- a/types/swagger-node-runner/index.d.ts +++ b/types/swagger-node-runner/index.d.ts @@ -2,7 +2,7 @@ // Project: https://www.npmjs.com/package/swagger-node-runner // Definitions by: Michael Mrowetz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.2 /* =================== USAGE =================== diff --git a/types/twitter-text/index.d.ts b/types/twitter-text/index.d.ts index accac12333..b09af9d34c 100644 --- a/types/twitter-text/index.d.ts +++ b/types/twitter-text/index.d.ts @@ -42,7 +42,7 @@ export declare function splitTags(text: string): string[]; export declare function extractHashtags(text: string): string[]; export declare function extractHashtagsWithIndices(text: string): HashtagWithIndices[]; export declare function extractUrls(text: string): string[]; -export declare function extractUrlsWithIndices(text: string): UrlWithIndices[]; +export declare function extractUrlsWithIndices(text: string, options?: {extractUrlsWithoutProtocol: boolean}): UrlWithIndices[]; export declare function extractMentions(text: string): string[]; export declare function extractMentionsWithIndices(text: string): MentionWithIndices[]; export declare function extractMentionsOrListsWithIndices(text: string): MentionOrListWithIndices[]; diff --git a/types/url-metadata/index.d.ts b/types/url-metadata/index.d.ts new file mode 100644 index 0000000000..2d909b15e1 --- /dev/null +++ b/types/url-metadata/index.d.ts @@ -0,0 +1,57 @@ +// Type definitions for url-metadata 2.1 +// Project: https://github.com/LevelNewsOrg/url-metadata +// Definitions by: Kevin Gravier +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = urlMetadata; + +declare function urlMetadata(url: string, options?: urlMetadata.Options): Promise; + +declare namespace urlMetadata { + interface Options { + userAgent?: string; + fromEmail?: string; + maxRedirects?: number; + timeout?: number; + descriptionLength?: number; + ensureSecureImageRequest?: boolean; + sourceMap?: { [key: string]: string }; + encode?: () => void; + } + + interface Result { + "url": string; + "canonical": string; + "title": string; + "image": string; + "author": string; + "description": string; + "keywords": string; + "source": string; + "og:url": string; + "og:locale": string; + "og:locale:alternate": string; + "og:title": string; + "og:type": string; + "og:description": string; + "og:determiner": string; + "og:site_name": string; + "og:image": string; + "og:image:secure_url": string; + "og:image:type": string; + "og:image:width": string; + "og:image:height": string; + "article:published_time"?: string; + "article:modified_time"?: string; + "article:expiration_time"?: string; + "article:author"?: string; + "article:section"?: string; + "article:tag"?: string; + "og:article:published_time"?: string; + "og:article:modified_time"?: string; + "og:article:expiration_time"?: string; + "og:article:author"?: string; + "og:article:section"?: string; + "og:article:tag"?: string; + } +} diff --git a/types/url-metadata/tsconfig.json b/types/url-metadata/tsconfig.json new file mode 100644 index 0000000000..e12ebe2932 --- /dev/null +++ b/types/url-metadata/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", + "url-metadata-tests.ts" + ] +} diff --git a/types/url-metadata/tslint.json b/types/url-metadata/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/url-metadata/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/url-metadata/url-metadata-tests.ts b/types/url-metadata/url-metadata-tests.ts new file mode 100644 index 0000000000..ab45090783 --- /dev/null +++ b/types/url-metadata/url-metadata-tests.ts @@ -0,0 +1,15 @@ +import * as urlMetadata from "url-metadata"; + +const opts: urlMetadata.Options = { + userAgent: "url-metadata-test", + fromEmail: "testing@url-metadata.com", + maxRedirects: 3, + timeout: 10000, + descriptionLength: 10000, + ensureSecureImageRequest: true +}; +const url = "https://google.com"; + +urlMetadata(url, opts).then((result: urlMetadata.Result) => { + result; // $ExpectType Result +}); diff --git a/types/vis/index.d.ts b/types/vis/index.d.ts index dbb1d68647..ccf74b2567 100644 --- a/types/vis/index.d.ts +++ b/types/vis/index.d.ts @@ -295,8 +295,6 @@ export interface TimelineEventPropertiesResult { /** * Options that can be passed to a DataSet. - * - * @interface DataSetOptions */ export interface DataSetOptions extends DataSetQueueOptions { /** @@ -304,9 +302,6 @@ export interface DataSetOptions extends DataSetQueueOptions { * When data is fetched from a server which uses some specific field to identify items, * this field name can be specified in the DataSet using the option fieldId. * For example CouchDB uses the field "_id" to identify documents. - * - * @type {string} - * @memberOf DataSetOptions */ fieldId?: string; @@ -317,9 +312,6 @@ export interface DataSetOptions extends DataSetQueueOptions { * This is useful for example to automatically convert stringified dates coming * from a server into JavaScript Date objects. * The available data types are listed in section Data Types. - * - * @type {*} - * @memberOf DataSetOptions */ type?: any; } @@ -335,9 +327,6 @@ export interface DataSetQueueOptions { * Default value is null. * max: number - When the queue exceeds the given maximum number of entries, the queue is flushed automatically. Default value is Infinity. * Default value is Infinity. - * - * @type {(any | boolean)} - * @memberOf DataSetOptions */ queue?: any | boolean; } @@ -346,27 +335,20 @@ export class DataSet { /** * Creates an instance of DataSet. * - * @param {DataSetOptions} [options] DataSet options. - * - * @memberOf DataSet + * @param [options] DataSet options. */ constructor(options: DataSetOptions); /** * Creates an instance of DataSet. * - * @param {T[]} [data] An Array with items. - * @param {DataSetOptions} [options] DataSet options. - * - * @memberOf DataSet + * @param [data] An Array with items. + * @param [options] DataSet options. */ constructor(data?: T[], options?: DataSetOptions); /** * The number of items in the DataSet. - * - * @type {number} - * @memberOf DataSet */ length: number; @@ -374,21 +356,17 @@ export class DataSet { * Add one or multiple items to the DataSet. * Adding an item will fail when there already is an item with the same id. * - * @param {(T | T[])} data data can be a single item or an array with items. - * @param {IdType} [senderId] Optional sender id. - * @returns {IdType[]} The function returns an array with the ids of the added items. - * - * @memberOf DataSet + * @param data data can be a single item or an array with items. + * @param [senderId] Optional sender id. + * @returns The function returns an array with the ids of the added items. */ add(data: T | T[], senderId?: IdType): IdType[]; /** * Clear all data from the DataSet. * - * @param {IdType} [senderId] Optional sender id. - * @returns {IdType[]} The function returns an array with the ids of the removed items. - * - * @memberOf DataSet + * @param [senderId] Optional sender id. + * @returns The function returns an array with the ids of the removed items. */ clear(senderId?: IdType): IdType[]; @@ -396,63 +374,50 @@ export class DataSet { * Find all distinct values of a specified field. * If data items do not contain the specified field are ignored. * - * @param {string} field The search term. - * @returns {any[]} Returns an unordered array containing all distinct values. - * - * @memberOf DataSet + * @param field The search term. + * @returns Returns an unordered array containing all distinct values. */ distinct(field: string): any[]; /** * Flush queued changes. * Only available when the DataSet is configured with the option queue. - * - * @memberOf DataSet */ flush(): void; /** * Execute a callback function for every item in the dataset. * - * @param {(item: T, id: IdType) => void} callback The item callback. - * @param {DataSelectionOptions} [options] Optional options - * - * @memberOf DataSet + * @param callback The item callback. + * @param [options] Optional options */ forEach(callback: (item: T, id: IdType) => void, options?: DataSelectionOptions): void; /** * Get all items from the DataSet. * - * @param {DataSelectionOptions} [options] Optional options. - * @returns {T[]} When no item is found, null is returned when a single item was requested, + * @param [options] Optional options. + * @returns When no item is found, null is returned when a single item was requested, * and and empty Array is returned in case of multiple id's. - * - * @memberOf DataSet */ get(options?: DataSelectionOptions): T[]; /** * Get a single item from the DataSet. * - * @param {IdType} id The item id. - * @param {DataSelectionOptions} [options] - * @returns {T} When no item is found, null is returned when a single item was requested, + * @param id The item id. + * @returns When no item is found, null is returned when a single item was requested, * and and empty Array is returned in case of multiple id's. - * - * @memberOf DataSet */ get(id: IdType, options?: DataSelectionOptions): T; /** * Get multiple items from the DataSet. * - * @param {IdType[]} ids Array of item ids. - * @param {DataSelectionOptions} [options] Optional options. - * @returns {T[]} When no item is found, null is returned when a single item was requested, + * @param ids Array of item ids. + * @param [options] Optional options. + * @returns When no item is found, null is returned when a single item was requested, * and and empty Array is returned in case of multiple id's. - * - * @memberOf DataSet */ get(ids: IdType[], options?: DataSelectionOptions): T[]; @@ -461,92 +426,69 @@ export class DataSet { * In case of a DataView, this function does not return the DataSet * to which the DataView is connected. * - * @returns {DataSet} The DataSet itself. - * - * @memberOf DataSet + * @returns The DataSet itself. */ getDataSet(): DataSet; /** * Get ids of all items or of a filtered set of items. * - * @param {DataSelectionOptions} [options] - * @returns {IdType[]} ids of all items or of a filtered set of items. - * - * @memberOf DataSet + * @returns ids of all items or of a filtered set of items. */ getIds(options?: DataSelectionOptions): IdType[]; /** * Map every item in the DataSet. * - * @param {(item: T, id: IdType) => T} callback The mapping callback. - * @param {DataSelectionOptions} [options] Optional options. - * @returns {T[]} The mapped items. - * - * @memberOf DataSet + * @param callback The mapping callback. + * @param [options] Optional options. + * @returns The mapped items. */ map(callback: (item: T, id: IdType) => any, options?: DataSelectionOptions): any[]; /** * Find the item with maximum value of specified field. * - * @param {string} field - * @returns {T} Returns null if no item is found. - * - * @memberOf DataSet + * @returns Returns null if no item is found. */ max(field: string): T; /** * Find the item with minimum value of specified field. * - * @param {string} field - * @returns {T} Returns null if no item is found. - * - * @memberOf DataSet + * @returns Returns null if no item is found. */ min(field: string): T; /** * Subscribe from an event. * - * @param {string} event The event name. - * @param {((event: string, properties: any, senderId: IdType) => void)} callback + * @param event The event name. + * @param callback * a callback function which will be called each time the event occurs. - * - * @memberOf DataSet */ on(event: string, callback: (event: string, properties: any, senderId: IdType) => void): void; /** * Unsubscribe to an event. * - * @param {string} event The event name. - * @param {((event: string, properties: any, senderId: IdType) => void)} callback + * @param event The event name. + * @param callback * The exact same callback that was used when calling 'on'. - * - * @memberOf DataSet */ off(event: string, callback: (event: string, properties: any, senderId: IdType) => void): void; /** * Remove one or more items by id. * - * @param {IdType} id The item id. - * @param {IdType} [senderId] The sender id. - * @returns {IdType[]} Returns an array with the ids of the removed items. - * - * @memberOf DataSet + * @param id The item id. + * @param [senderId] The sender id. + * @returns Returns an array with the ids of the removed items. */ remove(id: IdType | IdType[], senderId?: IdType): IdType[]; /** * Set options for the DataSet. - * - * @param {DataSetQueueOptions} [options] - * - * @memberOf DataSet */ setOptions(options?: DataSetQueueOptions): void; @@ -554,11 +496,8 @@ export class DataSet { * Update one or multiple existing items. * When an item doesn't exist, it will be created. * - * @param {(T | T[])} data a single item or an array with items. - * @param {IdType} [senderId] - * @returns {IdType[]} Returns an array with the ids of the updated items. - * - * @memberOf DataSet + * @param data a single item or an array with items. + * @returns Returns an array with the ids of the updated items. */ update(data: T | T[], senderId?: IdType): IdType[]; } @@ -567,8 +506,6 @@ export class DataSet { * The DataSet contains functionality to format, filter, and sort data retrieved * via the methods get, getIds, forEach, and map. * These methods can have these options as a parameter. - * - * @interface DataSelectionOptions */ export interface DataSelectionOptions { /** @@ -577,9 +514,6 @@ export interface DataSelectionOptions { * By default, all properties of the items are emitted. * When fields is defined, only the properties whose name is specified * in fields will be included in the returned items. - * - * @type {(string[] | any)} - * @memberOf DataSelectionOptions */ fields?: string[] | any; @@ -589,9 +523,6 @@ export interface DataSelectionOptions { * When a field type is specified, this field in the items will be converted to the specified type. * This can be used for example to convert ISO strings containing a date to a JavaScript Date object, * or convert strings to numbers or vice versa. The available data types are listed in section Data Types. - * - * @type {*} - * @memberOf DataSelectionOptions */ type?: any; @@ -602,16 +533,11 @@ export interface DataSelectionOptions { * The function must return a boolean. * All items for which the filter function returns true will be emitted. * See section Data Filtering. - * - * @memberOf DataSelectionOptions */ filter?(item: T): boolean; /** * Order the items by a field name or custom sort function. - * - * @type {(string | any)} - * @memberOf DataSelectionOptions */ order?: string | any; @@ -620,9 +546,6 @@ export interface DataSelectionOptions { * Allowed values are 'Array' | 'Object'. * The default returnType is an Array. * The Object type will return a JSON object with the ID's as keys. - * - * @type {string} - * @memberOf DataSelectionOptions */ returnType?: string; } @@ -920,27 +843,19 @@ export type NetworkEvents = * The visualization is easy to use and supports custom shapes, styles, colors, sizes, images, and more. * The network visualization works smooth on any modern browser for up to a few thousand nodes and edges. * To handle a larger amount of nodes, Network has clustering support. Network uses HTML canvas for rendering. - * - * @export - * @class Network - * @implements {INetwork} */ export class Network { /** * Creates an instance of Network. * - * @param {HTMLElement} container the HTML element representing the network container - * @param {IData} data network data - * @param {IOptions} [options] optional network options - * - * @memberOf Network + * @param container the HTML element representing the network container + * @param data network data + * @param [options] optional network options */ constructor(container: HTMLElement, data: Data, options?: Options); /** * Remove the network from the DOM and remove all Hammer bindings and references. - * - * @memberOf Network */ destroy(): void; @@ -950,9 +865,7 @@ export class Network { * the network will stabilize again. * This method is also performed when first initializing the network. * - * @param {IData} data network data - * - * @memberOf Network + * @param data network data */ setData(data: Data): void; @@ -961,9 +874,7 @@ export class Network { * All available options can be found in the modules above. * Each module requires it's own container with the module name to contain its options. * - * @param {IOptions} options network options - * - * @memberOf Network + * @param options network options */ setOptions(options: Options): void; @@ -971,10 +882,8 @@ export class Network { * Set an event listener. * Depending on the type of event you get different parameters for the callback function. * - * @param {string} eventName the name of the event, f.e. 'click' - * @param {(params?: any) => void} callback the callback function that will be raised - * - * @memberOf Network + * @param eventName the name of the event, f.e. 'click' + * @param callback the callback function that will be raised */ on(eventName: NetworkEvents, callback: (params?: any) => void): void; @@ -983,10 +892,8 @@ export class Network { * The function you supply has to be the exact same as the one you used in the on function. * If no function is supplied, all listeners will be removed. * - * @param {string} eventName the name of the event, f.e. 'click' - * @param {(params?: any) => void} [callback] the exact same callback function that was used when calling 'on' - * - * @memberOf Network + * @param eventName the name of the event, f.e. 'click' + * @param [callback] the exact same callback function that was used when calling 'on' */ off(eventName: NetworkEvents, callback?: (params?: any) => void): void; @@ -995,10 +902,8 @@ export class Network { * After it has taken place, the event listener will be removed. * Depending on the type of event you get different parameters for the callback function. * - * @param {string} eventName the name of the event, f.e. 'click' - * @param {(params?: any) => void} callback the callback function that will be raised once - * - * @memberOf Network + * @param eventName the name of the event, f.e. 'click' + * @param callback the callback function that will be raised once */ once(eventName: NetworkEvents, callback: (params?: any) => void): void; @@ -1007,10 +912,8 @@ export class Network { * Input and output are in the form of {x:Number, y:Number} (IPosition interface). * The DOM values are relative to the network container. * - * @param {IPosition} position the canvas coordinates - * @returns {IPosition} the DOM coordinates - * - * @memberOf Network + * @param position the canvas coordinates + * @returns the DOM coordinates */ canvasToDOM(position: Position): Position; @@ -1019,17 +922,13 @@ export class Network { * Input and output are in the form of {x:Number,y:Number} (IPosition interface). * The DOM values are relative to the network container. * - * @param {IPosition} position the DOM coordinates - * @returns {IPosition} the canvas coordinates - * - * @memberOf Network + * @param position the DOM coordinates + * @returns the canvas coordinates */ DOMtoCanvas(position: Position): Position; /** * Redraw the network. - * - * @memberOf Network */ redraw(): void; @@ -1037,19 +936,13 @@ export class Network { * Set the size of the canvas. * This is automatically done on a window resize. * - * @param {string} width width in a common format, f.e. '100px' - * @param {string} height height in a common format, f.e. '100px' - * - * @memberOf Network + * @param width width in a common format, f.e. '100px' + * @param height height in a common format, f.e. '100px' */ setSize(width: string, height: string): void; /** * The joinCondition function is presented with all nodes. - * - * @param {IClusterOptions} [options] - * - * @memberOf Network */ cluster(options?: ClusterOptions): void; @@ -1059,10 +952,8 @@ export class Network { * All options of this object are explained below. * The joinCondition is only presented with the connected nodes. * - * @param {string} nodeId the id of the node - * @param {IClusterOptions} [options] the cluster options - * - * @memberOf Network + * @param nodeId the id of the node + * @param [options] the cluster options */ clusterByConnection(nodeId: string, options?: ClusterOptions): void; @@ -1074,19 +965,15 @@ export class Network { * For all qualifying nodes, clusterByConnection is performed on each of them. * The options object is described for clusterByConnection and does the same here. * - * @param {number} [hubsize] optional hubsize - * @param {IClusterOptions} [options] optional cluster options - * - * @memberOf Network + * @param [hubsize] optional hubsize + * @param [options] optional cluster options */ clusterByHubsize(hubsize?: number, options?: ClusterOptions): void; /** * This method will cluster all nodes with 1 edge with their respective connected node. * - * @param {IClusterOptions} [options] optional cluster options - * - * @memberOf Network + * @param [options] optional cluster options */ clusterOutliers(options?: ClusterOptions): void; @@ -1101,10 +988,8 @@ export class Network { * * network.clustering.findNode('fred') will return ['A','B','C','fred']. * - * @param {IdType} nodeId the node id. - * @returns {IdType[]} an array of nodeIds showing where the node is - * - * @memberOf Network + * @param nodeId the node id. + * @returns an array of nodeIds showing where the node is */ findNode(nodeId: IdType): IdType[]; @@ -1112,8 +997,8 @@ export class Network { * Similar to findNode in that it returns all the edge ids that were * created from the provided edge during clustering. * - * @param {IdType} baseEdgeId the base edge id - * @returns {IdType[]} an array of edgeIds + * @param baseEdgeId the base edge id + * @returns an array of edgeIds */ getClusteredEdges(baseEdgeId: IdType): IdType[]; @@ -1122,9 +1007,6 @@ export class Network { * baseEdgeId provided in data.edges ie. * After clustering the 'SelectEdge' event is fired but provides only the clustered edge. * This method can then be used to return the baseEdgeId. - * - * @param {IdType} clusteredEdgeId - * @returns {IdType} */ getBaseEdge(clusteredEdgeId: IdType): IdType; @@ -1134,9 +1016,6 @@ export class Network { * the edges between clusters are created and the previous edges are hidden, * until the cluster is opened. This method takes an edgeId (ie. a base edgeId from data.edges) * and applys the options to it and any edges that were created from it while clustering. - * - * @param {IdType} startEdgeId - * @param {IEdgeOptions} [options] */ updateEdge(startEdgeId: IdType, options?: EdgeOptions): void; @@ -1149,10 +1028,7 @@ export class Network { /** * Returns true if the node whose ID has been supplied is a cluster. * - * @param {IdType} nodeId the node id. - * @returns {boolean} - * - * @memberOf Network + * @param nodeId the node id. */ isCluster(nodeId: IdType): boolean; @@ -1160,10 +1036,7 @@ export class Network { * Returns an array of all nodeIds of the nodes that * would be released if you open the cluster. * - * @param {IdType} clusterNodeId the id of the cluster node - * @returns {IdType[]} - * - * @memberOf Network + * @param clusterNodeId the id of the cluster node */ getNodesInCluster(clusterNodeId: IdType): IdType[]; @@ -1174,10 +1047,8 @@ export class Network { * releaseFunction, which is a function that can be used to manually * position the nodes after the cluster is opened. * - * @param {IdType} nodeId the node id - * @param {IOpenClusterOptions} [options] optional open cluster options - * - * @memberOf Network + * @param nodeId the node id + * @param [options] optional open cluster options */ openCluster(nodeId: IdType, options?: OpenClusterOptions): void; @@ -1186,25 +1057,19 @@ export class Network { * and would like it to start in the same way next time, * ask for the seed using this method and put it in the layout.randomSeed option. * - * @returns {number} the current seed of the network. - * - * @memberOf Network + * @returns the current seed of the network. */ getSeed(): number; /** * Programatically enable the edit mode. * Similar effect to pressing the edit button. - * - * @memberOf Network */ enableEditMode(): void; /** * Programatically disable the edit mode. * Similar effect to pressing the close icon (small cross in the corner of the toolbar). - * - * @memberOf Network */ disableEditMode(): void; @@ -1213,40 +1078,30 @@ export class Network { * To get out of this mode, call disableEditMode(). * The callback functions defined in handlerFunctions still apply. * To use these methods without having the manipulation GUI, make sure you set enabled to false. - * - * @memberOf Network */ addNodeMode(): void; /** * Edit the selected node. * The explaination from addNodeMode applies here as well. - * - * @memberOf Network */ editNode(): void; /** * Go into addEdge mode. * The explaination from addNodeMode applies here as well. - * - * @memberOf Network */ addEdgeMode(): void; /** * Go into editEdge mode. * The explaination from addNodeMode applies here as well. - * - * @memberOf Network */ editEdgeMode(): void; /** * Delete selected. * Having edit mode or manipulation enabled is not required. - * - * @memberOf Network */ deleteSelected(): void; @@ -1256,11 +1111,6 @@ export class Network { * Alternative inputs are a String containing a nodeId or nothing. * When a String is supplied, the position of the node corresponding to the ID is returned. * When nothing is supplied, the positions of all nodes are returned. - * - * @param {string[]} nodeIds - * @returns {{[nodeId: IdType]: IPosition}} - * - * @memberOf Network */ getPositions(nodeIds?: IdType[]): { [nodeId: string]: Position }; getPositions(nodeId: IdType): Position; @@ -1278,8 +1128,6 @@ export class Network { * This method does not support clustering. * At the moment it is not possible to cache positions when using clusters since * they cannot be correctly initialized from just the positions. - * - * @memberOf Network */ storePositions(): void; @@ -1287,21 +1135,15 @@ export class Network { * You can use this to programatically move a node. * The supplied x and y positions have to be in canvas space! * - * @param {IdType} nodeId the node that will be moved - * @param {number} x new canvas space x position - * @param {number} y new canvas space y position - * - * @memberOf Network + * @param nodeId the node that will be moved + * @param x new canvas space x position + * @param y new canvas space y position */ moveNode(nodeId: IdType, x: number, y: number): void; /** * Returns a bounding box for the node including label. * - * @param {IdType} nodeId - * @returns {IBoundingBox} - * - * @memberOf Network */ getBoundingBox(nodeId: IdType): BoundingBox; @@ -1310,20 +1152,14 @@ export class Network { * If you supply an edgeId, vis will first match the id to nodes. * If no match is found, it will search in the edgelist and return an array: [fromId, toId]. * - * @param {IdType} nodeOrEdgeId a node or edge id - * @returns {(IdType[] | {fromId: IdType, toId: IdType}[])} - * - * @memberOf Network + * @param nodeOrEdgeId a node or edge id */ getConnectedNodes(nodeOrEdgeId: IdType): IdType[] | Array<{ fromId: IdType, toId: IdType }>; /** * Returns an array of edgeIds of the edges connected to this node. * - * @param {IdType} nodeId the node id - * @returns {IdType[]} - * - * @memberOf Network + * @param nodeId the node id */ getConnectedEdges(nodeId: IdType): IdType[]; @@ -1331,8 +1167,6 @@ export class Network { * Start the physics simulation. * This is normally done whenever needed and is only really useful * if you stop the simulation yourself and wish to continue it afterwards. - * - * @memberOf Network */ startSimulation(): void; @@ -1340,8 +1174,6 @@ export class Network { * This stops the physics simulation and triggers a stabilized event. * Tt can be restarted by dragging a node, * altering the dataset or calling startSimulation(). - * - * @memberOf Network */ stopSimulation(): void; @@ -1350,18 +1182,13 @@ export class Network { * All the stabilization options above are used. * You can optionally supply the number of iterations it should do. * - * @param {number} [iterations] the number of iterations it should do - * - * @memberOf Network + * @param [iterations] the number of iterations it should do */ stabilize(iterations?: number): void; /** * Returns an object with selected nodes and edges ids. * - * @returns {{ nodes: IdType[], edges: IdType[] }} - * - * @memberOf Network */ getSelection(): { nodes: IdType[], edges: IdType[] }; @@ -1369,9 +1196,6 @@ export class Network { * Returns an array of selected node ids like so: * [nodeId1, nodeId2, ..]. * - * @returns {IdType[]} - * - * @memberOf Network */ getSelectedNodes(): IdType[]; @@ -1379,9 +1203,6 @@ export class Network { * Returns an array of selected edge ids like so: * [edgeId1, edgeId2, ..]. * - * @returns {IdType[]} - * - * @memberOf Network */ getSelectedEdges(): IdType[]; @@ -1389,10 +1210,6 @@ export class Network { * Returns a nodeId or undefined. * The DOM positions are expected to be in pixels from the top left corner of the canvas. * - * @param {IPosition} position - * @returns {IdType} - * - * @memberOf Network */ getNodeAt(position: Position): IdType; @@ -1400,10 +1217,6 @@ export class Network { * Returns a edgeId or undefined. * The DOM positions are expected to be in pixels from the top left corner of the canvas. * - * @param {IPosition} position - * @returns {IdType} - * - * @memberOf Network */ getEdgeAt(position: Position): IdType; @@ -1412,10 +1225,6 @@ export class Network { * If highlightEdges is true or undefined, the neighbouring edges will also be selected. * This method unselects all other objects before selecting its own objects. Does not fire events. * - * @param {IdType[]} nodeIds - * @param {boolean} [highlightEdges] - * - * @memberOf Network */ selectNodes(nodeIds: IdType[], highlightEdges?: boolean): void; @@ -1424,9 +1233,6 @@ export class Network { * This method unselects all other objects before selecting its own objects. * Does not fire events. * - * @param {IdType[]} edgeIds - * - * @memberOf Network */ selectEdges(edgeIds: IdType[]): void; @@ -1434,18 +1240,12 @@ export class Network { * Sets the selection. * You can also pass only nodes or edges in selection object. * - * @param {{ nodes: IdType[], edges: IdType[] }} selection - * @param {ISelectionOptions} [options] - * - * @memberOf Network */ setSelection(selection: { nodes: IdType[], edges: IdType[] }, options?: SelectionOptions): void; /** * Unselect all objects. * Does not fire events. - * - * @memberOf Network */ unselectAll(): void; @@ -1453,27 +1253,21 @@ export class Network { * Returns the current scale of the network. * 1.0 is comparible to 100%, 0 is zoomed out infinitely. * - * @returns {number} the current scale of the network - * - * @memberOf Network + * @returns the current scale of the network */ getScale(): number; /** * Returns the current central focus point of the view in the form: { x: {Number}, y: {Number} } * - * @returns {IPosition} the view position; - * - * @memberOf Network + * @returns the view position; */ getViewPosition(): Position; /** * Zooms out so all nodes fit on the canvas. * - * @param {IFitOptions} [options] All options are optional for the fit method - * - * @memberOf Network + * @param [options] All options are optional for the fit method */ fit(options?: FitOptions): void; @@ -1482,26 +1276,17 @@ export class Network { * What that means is the view will lock onto that node, if it is moving, the view will also move accordingly. * If the view is dragged by the user, the focus is broken. You can supply options to customize the effect. * - * @param {IdType} nodeId - * @param {IFocusOptions} [options] - * - * @memberOf Network */ focus(nodeId: IdType, options?: FocusOptions): void; /** * You can animate or move the camera using the moveTo method. * - * @param {IMoveToOptions} options - * - * @memberOf Network */ moveTo(options: MoveToOptions): void; /** * Programatically release the focussed node. - * - * @memberOf Network */ releaseNode(): void; @@ -1509,63 +1294,41 @@ export class Network { * If you use the configurator, you can call this method to get an options object that contains * all differences from the default options caused by users interacting with the configurator. * - * @returns {*} - * - * @memberOf Network */ getOptionsFromConfigurator(): any; } /** * Options interface for focus function. - * - * @export - * @interface IFocusOptions - * @extends {IViewPortOptions} */ export interface FocusOptions extends ViewPortOptions { /** * Locked denotes whether or not the view remains locked to * the node once the zoom-in animation is finished. * Default value is true. - * - * @type {boolean} - * @memberOf IFocusOptions */ locked?: boolean; } /** * Base options interface for some viewport functions. - * - * @export - * @interface IViewPortOptions */ export interface ViewPortOptions { /** * The scale is the target zoomlevel. * Default value is 1.0. - * - * @type {number} the scale. - * @memberOf IFocusOptions */ scale?: number; /** * The offset (in DOM units) is how many pixels from the center the view is focussed. * Default value is {x:0,y:0} - * - * @type {IPosition} - * @memberOf IFocusOptions */ offset?: Position; /** * For animation you can either use a Boolean to use it with the default options or * disable it or you can define the duration (in milliseconds) and easing function manually. - * - * @type {(IAnimationOptions | boolean)} - * @memberOf IFitOptions */ animation?: AnimationOptions | boolean; } @@ -1573,33 +1336,20 @@ export interface ViewPortOptions { /** * You will have to define at least a scale, position or offset. * Otherwise, there is nothing to move to. - * - * @export - * @interface IMoveToOptions - * @extends {IViewPortOptions} */ export interface MoveToOptions extends ViewPortOptions { /** * The position (in canvas units!) is the position of the central focus point of the camera. - * - * @type {IPosition} - * @memberOf IMoveToOptions */ position?: Position; } /** * Animation options interface. - * - * @export - * @interface IAnimationOptions */ export interface AnimationOptions { /** * The duration (in milliseconds). - * - * @type {number} - * @memberOf IAnimationOptions */ duration: number; /** @@ -1609,34 +1359,22 @@ export interface AnimationOptions { * linear, easeInQuad, easeOutQuad, easeInOutQuad, easeInCubic, * easeOutCubic, easeInOutCubic, easeInQuart, easeOutQuart, easeInOutQuart, * easeInQuint, easeOutQuint, easeInOutQuint. - * - * @type {string} - * @memberOf IAnimationOptions */ easingFunction: string; } /** * Optional options for the fit method. - * - * @export - * @interface IFitOptions */ export interface FitOptions { /** * The nodes can be used to zoom to fit only specific nodes in the view. - * - * @type {string[]} - * @memberOf IFitOptions */ nodes?: string[]; /** * For animation you can either use a Boolean to use it with the default options or * disable it or you can define the duration (in milliseconds) and easing function manually. - * - * @type {(IAnimationOptions | boolean)} - * @memberOf IFitOptions */ animation: AnimationOptions | boolean; } @@ -1648,9 +1386,6 @@ export interface SelectionOptions { /** * These values are in canvas space. - * - * @export - * @interface IBoundingBox */ export interface BoundingBox { top: number; @@ -1661,9 +1396,6 @@ export interface BoundingBox { /** * Cluster methods options interface. - * - * @export - * @interface IClusterOptions */ export interface ClusterOptions { /** @@ -1672,8 +1404,6 @@ export interface ClusterOptions { * and calls this function with their data as argument. If this function returns true, * this node will be added to the cluster. You have access to all options (including the default) * as well as any custom fields you may have added to the node to determine whether or not to include it in the cluster. - * - * @memberOf IClusterOptions */ joinCondition?(nodeOptions: any): boolean; @@ -1683,9 +1413,6 @@ export interface ClusterOptions { * supplied by you (clusterNodeProperties), all contained nodes and all contained edges. * You can use this to update the properties of the cluster based on which items it contains. * The function should return the properties to create the cluster node. - * - * @type {(clusterOptions: any, childNodesOptions: any[], childEdgesOptions: any[])} - * @memberOf IClusterOptions */ processProperties?(clusterOptions: any, childNodesOptions: any[], childEdgesOptions: any[]): any; @@ -1696,9 +1423,6 @@ export interface ClusterOptions { * This allows you to style your cluster node any way you want. * This is also the style object that is provided in the processProperties function for fine tuning. * If undefined, default node options will be used. - * - * @type {INodeOptions} - * @memberOf IClusterOptions */ clusterNodeProperties?: NodeOptions; @@ -1709,18 +1433,12 @@ export interface ClusterOptions { * Using this, you can style the edges connecting to the cluster any way you want. * If none are provided, the options from the edges that are replaced are used. * If undefined, default edge options will be used. - * - * @type {IEdgeOptions} - * @memberOf IClusterOptions */ clusterEdgeProperties?: EdgeOptions; } /** * Options for the openCluster function of Network. - * - * @export - * @interface IOpenClusterOptions */ export interface OpenClusterOptions { /** @@ -1734,8 +1452,6 @@ export interface OpenClusterOptions { * For all nodeIds not listed in this returned object, * we will position them at the location of the cluster. * This is also the default behaviour when no releaseFunction is defined. - * - * @memberOf IOpenClusterOptions */ releaseFunction( clusterPosition: Position,