diff --git a/README.md b/README.md index 29d174ef77..4b16884273 100644 --- a/README.md +++ b/README.md @@ -144,6 +144,10 @@ For a good example package, see [base64-js](https://github.com/DefinitelyTyped/D Example where a type parameter is acceptable: `function id(value: T): T;`. Example where it is not acceptable: `function parseJson(json: string): T;`. Exception: `new Map()` is OK. +* Using the types `Function` and `Object` is almost never a good idea. In 99% of cases it's possible to specify a more specific type. Examples are `(x: number) => number` for [functions](http://www.typescriptlang.org/docs/handbook/functions.html#function-types) and `{ x: number, y: number }` for objects. If there is no certainty at all about the type, [`any`](http://www.typescriptlang.org/docs/handbook/basic-types.html#any) is the right choice, not `Object`. If the only known fact about the type is that it's some object, use the type [`object`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#object-type), not `Object` or `{ [key: string]: any }`. +* `var foo: string | any`: + When `any` is used in a union type, the resulting type is still `any`. So while the `string` portion of this type annotation may _look_ useful, it in fact offers no additional typechecking over simply using `any`. + Depending on the intention, acceptable alternatives could be `any`, `string`, or `string | object`. #### Removing a package @@ -199,7 +203,14 @@ This script uses [dtslint](https://github.com/Microsoft/dtslint). #### What exactly is the relationship between this repository and the `@types` packages on NPM? The `master` branch is automatically published to the `@types` scope on NPM thanks to [types-publisher](https://github.com/Microsoft/types-publisher). -This usually happens within an hour of changes being merged. + +#### I've submitted a pull request. How long until it is merged? + +It depends, but most pull requests will be merged within a week. PRs that have been approved by an author listed in the definition's header are usually merged more quickly; PRs for new definitions will take more time as they require more review from maintainers. Each PR is reviewed by a TypeScript or DefinitelyTyped team member before being merged, so please be patient as human factors may cause delays. Check the [PR Burndown Board](https://github.com/DefinitelyTyped/DefinitelyTyped/projects/3?card_filter_query=is%3Aopen) to see progress as maintainers work through the open PRs. + +#### My PR is merged; when will the `@types` NPM package be updated? + +NPM packages should update within a few hours. If it's been more than 24 hours, ping @RyanCavanaugh and @andy-ms on the PR to investigate. #### I'm writing a definition that depends on another definition. Should I use `` or an import? diff --git a/notNeededPackages.json b/notNeededPackages.json index c7a7168ff0..457498b676 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -558,6 +558,12 @@ "sourceRepoURL": "https://github.com/tildeio/route-recognizer", "asOfVersion": "0.3.0" }, + { + "libraryName": "router5", + "typingsPackageName": "router5", + "sourceRepoURL": "https://github.com/router5/router5", + "asOfVersion": "5.0.0" + }, { "libraryName": "samchon", "typingsPackageName": "samchon", diff --git a/package.json b/package.json index b12e3fe2eb..db67595b77 100644 --- a/package.json +++ b/package.json @@ -23,8 +23,5 @@ "devDependencies": { "dtslint": "github:Microsoft/dtslint#production", "types-publisher": "Microsoft/types-publisher#production" - }, - "dependencies": { - "@egjs/axes": "^2.0.0" } } diff --git a/scripts/fix-tslint.ts b/scripts/fix-tslint.ts index 419ebcd0de..36cb23ebbd 100644 --- a/scripts/fix-tslint.ts +++ b/scripts/fix-tslint.ts @@ -39,7 +39,16 @@ function fix(config: any): any { const out: any = {}; for (const key in config) { let value = config[key]; - out[key] = value; + out[key] = key === "rules" ? fixRules(value) : value; } return out; } + +function fixRules(rules: any): any { + const out: any = {}; + for (const key in rules) { + out[key] = rules[key]; + } + return out; +} + diff --git a/types/ably/tslint.json b/types/ably/tslint.json index 3db14f85ea..d9d49e375e 100644 --- a/types/ably/tslint.json +++ b/types/ably/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false + } +} diff --git a/types/activex-adodb/package.json b/types/activex-adodb/package.json index d798f99261..d9b1031263 100644 --- a/types/activex-adodb/package.json +++ b/types/activex-adodb/package.json @@ -1 +1,6 @@ -{ "dependencies": { "activex-helpers": "*"}} \ No newline at end of file +{ + "private": true, + "dependencies": { + "activex-helpers": "*" + } +} \ No newline at end of file diff --git a/types/activex-adodb/tsconfig.json b/types/activex-adodb/tsconfig.json index 484faf1ed0..81c6088e56 100644 --- a/types/activex-adodb/tsconfig.json +++ b/types/activex-adodb/tsconfig.json @@ -6,7 +6,6 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "strict": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/types/activex-scripting/package.json b/types/activex-scripting/package.json index d798f99261..d9b1031263 100644 --- a/types/activex-scripting/package.json +++ b/types/activex-scripting/package.json @@ -1 +1,6 @@ -{ "dependencies": { "activex-helpers": "*"}} \ No newline at end of file +{ + "private": true, + "dependencies": { + "activex-helpers": "*" + } +} \ No newline at end of file diff --git a/types/activex-scripting/tsconfig.json b/types/activex-scripting/tsconfig.json index 190e7bdcd6..e237423341 100644 --- a/types/activex-scripting/tsconfig.json +++ b/types/activex-scripting/tsconfig.json @@ -6,7 +6,6 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "strict": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/types/activex-wia/package.json b/types/activex-wia/package.json index d798f99261..d9b1031263 100644 --- a/types/activex-wia/package.json +++ b/types/activex-wia/package.json @@ -1 +1,6 @@ -{ "dependencies": { "activex-helpers": "*"}} \ No newline at end of file +{ + "private": true, + "dependencies": { + "activex-helpers": "*" + } +} \ No newline at end of file diff --git a/types/activex-wia/tsconfig.json b/types/activex-wia/tsconfig.json index b06917d12c..b98459223d 100644 --- a/types/activex-wia/tsconfig.json +++ b/types/activex-wia/tsconfig.json @@ -6,7 +6,6 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "strict": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/types/adone/tslint.json b/types/adone/tslint.json index f0ae61d2bf..ef323bd7a5 100644 --- a/types/adone/tslint.json +++ b/types/adone/tslint.json @@ -5,9 +5,11 @@ "align": false, "no-namespace": false, "strict-export-declare-modifiers": false, + "no-any-union": false, "no-boolean-literal-compare": false, "no-mergeable-namespace": false, "no-single-declare-module": false, + "no-unnecessary-generics": false, "no-unnecessary-qualifier": false, "unified-signatures": false, "space-before-function-paren": false diff --git a/types/aframe/tsconfig.json b/types/aframe/tsconfig.json index 9488fe8297..f11ddb6188 100755 --- a/types/aframe/tsconfig.json +++ b/types/aframe/tsconfig.json @@ -1,25 +1,25 @@ { "compilerOptions": { - "baseUrl": "..", - "lib": [ - "es5", - "dom", - "es2015.iterable", - "es2015.promise" - ], - "module": "commonjs", - "noImplicitAny": true, - "noImplicitThis": true, - "removeComments": false, - "sourceMap": true, - "strictNullChecks": true, - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "typeRoots": [ "../" ], - "types": [ ] + "module": "commonjs", + "lib": [ + "es5", + "dom", + "es2015.iterable", + "es2015.promise" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true }, "files": [ - "index.d.ts", - "aframe-tests.ts" + "index.d.ts", + "aframe-tests.ts" ] -} +} \ No newline at end of file diff --git a/types/aframe/tslint.json b/types/aframe/tslint.json index d88586e5bd..71ee04c4e1 100644 --- a/types/aframe/tslint.json +++ b/types/aframe/tslint.json @@ -1,3 +1,6 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } } diff --git a/types/angular-bootstrap-calendar/package.json b/types/angular-bootstrap-calendar/package.json index 4c6d24a445..fce08a048d 100644 --- a/types/angular-bootstrap-calendar/package.json +++ b/types/angular-bootstrap-calendar/package.json @@ -1,4 +1,5 @@ { + "private": true, "dependencies": { "moment": ">=2.14.0" } diff --git a/types/angular-localforage/package.json b/types/angular-localforage/package.json index 07bf3d2615..22ff6e6118 100644 --- a/types/angular-localforage/package.json +++ b/types/angular-localforage/package.json @@ -1,4 +1,5 @@ { + "private": true, "dependencies": { "localforage": "^1.5.0" } diff --git a/types/angular-resource/tslint.json b/types/angular-resource/tslint.json index ff19c22fa3..b4b1464296 100644 --- a/types/angular-resource/tslint.json +++ b/types/angular-resource/tslint.json @@ -8,6 +8,7 @@ "no-object-literal-type-assertion": false, "ban-types": false, "space-before-function-paren": false, - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/angular/jqlite.d.ts b/types/angular/jqlite.d.ts index fd199da74b..858201fb18 100644 --- a/types/angular/jqlite.d.ts +++ b/types/angular/jqlite.d.ts @@ -661,8 +661,21 @@ interface JQuery { controller(name?: string): any; injector(): ng.auto.IInjectorService; - /** It's declared generic for custom scope interfaces */ + /** + * Returns the `$scope` of the element. + * + * **IMPORTANT**: Requires `debugInfoEnabled` to be true. + * + * See https://docs.angularjs.org/guide/production#disabling-debug-data for more information. + */ scope(): T; + /** + * Returns the `$scope` of the element. + * + * **IMPORTANT**: Requires `debugInfoEnabled` to be true. + * + * See https://docs.angularjs.org/guide/production#disabling-debug-data for more information. + */ isolateScope(): T; inheritedData(key: string, value: any): this; diff --git a/types/anydb-sql-migrations/index.d.ts b/types/anydb-sql-migrations/index.d.ts index ae922c37ae..f6e12ed752 100644 --- a/types/anydb-sql-migrations/index.d.ts +++ b/types/anydb-sql-migrations/index.d.ts @@ -20,7 +20,7 @@ export interface MigrationTask { down: MigFn; name: string; } -export declare function create(db: AnydbSql, tasks: any): { +export declare function create(db: AnydbSql, tasks: string | MigrationTask[]): { run: () => Promise; migrateTo: (target?: string) => Promise; check: (f: (m: { diff --git a/types/anydb-sql-migrations/package.json b/types/anydb-sql-migrations/package.json index 5557c21ec8..7ce063c332 100644 --- a/types/anydb-sql-migrations/package.json +++ b/types/anydb-sql-migrations/package.json @@ -1,5 +1,6 @@ { - "dependencies": { - "anydb-sql": "^0.6.53" - } -} + "private": true, + "dependencies": { + "anydb-sql": "^0.6.53" + } +} \ No newline at end of file diff --git a/types/arcgis-to-geojson-utils/tslint.json b/types/arcgis-to-geojson-utils/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/arcgis-to-geojson-utils/tslint.json +++ b/types/arcgis-to-geojson-utils/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/argparse/argparse-tests.ts b/types/argparse/argparse-tests.ts index f5b9e76f81..aef18b665b 100644 --- a/types/argparse/argparse-tests.ts +++ b/types/argparse/argparse-tests.ts @@ -1,25 +1,24 @@ - // near copy of each of the tests from https://github.com/nodeca/argparse/tree/master/examples import { ArgumentParser, RawDescriptionHelpFormatter } from 'argparse'; -var args: any; +let args: any; -var simpleExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse example', +const simpleExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse example', }); simpleExample.addArgument( - ['-f', '--foo'], - { - help: 'foo bar', - } + ['-f', '--foo'], + { + help: 'foo bar', + } ); simpleExample.addArgument( - ['-b', '--bar'], - { - help: 'bar foo', - } + ['-b', '--bar'], + { + help: 'bar foo', + } ); simpleExample.printHelp(); @@ -35,13 +34,10 @@ args = simpleExample.parseArgs('--foo 5 --bar 6'.split(' ')); console.dir(args); console.log('-----------'); - - - -var choicesExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: choice' +const choicesExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: choice' }); choicesExample.addArgument(['foo'], { choices: 'abc' }); @@ -55,56 +51,53 @@ console.log('-----------'); // choicesExample.parseArgs(['X']); // console.dir(args); - - - -var constantExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: constant' +const constantExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: constant' }); constantExample.addArgument( - ['-a'], - { - action: 'storeConst', - dest: 'answer', - help: 'store constant', - constant: 42 - } + ['-a'], + { + action: 'storeConst', + dest: 'answer', + help: 'store constant', + constant: 42 + } ); constantExample.addArgument( - ['--str'], - { - action: 'appendConst', - dest: 'types', - help: 'append constant "str" to types', - constant: 'str' - } + ['--str'], + { + action: 'appendConst', + dest: 'types', + help: 'append constant "str" to types', + constant: 'str' + } ); constantExample.addArgument( - ['--int'], - { - action: 'appendConst', - dest: 'types', - help: 'append constant "int" to types', - constant: 'int' - } + ['--int'], + { + action: 'appendConst', + dest: 'types', + help: 'append constant "int" to types', + constant: 'int' + } ); constantExample.addArgument( - ['--true'], - { - action: 'storeTrue', - help: 'store true constant' - } + ['--true'], + { + action: 'storeTrue', + help: 'store true constant' + } ); constantExample.addArgument( - ['--false'], - { - action: 'storeFalse', - help: 'store false constant' - } + ['--false'], + { + action: 'storeFalse', + help: 'store false constant' + } ); constantExample.printHelp(); @@ -113,27 +106,24 @@ console.log('-----------'); args = constantExample.parseArgs('-a --str --int --true'.split(' ')); console.dir(args); - - - -var nargsExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: nargs' +const nargsExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: nargs' }); nargsExample.addArgument( - ['-f', '--foo'], - { - help: 'foo bar', - nargs: 1 - } + ['-f', '--foo'], + { + help: 'foo bar', + nargs: 1 + } ); nargsExample.addArgument( - ['-b', '--bar'], - { - help: 'bar foo', - nargs: '*' - } + ['-b', '--bar'], + { + help: 'bar foo', + nargs: '*' + } ); nargsExample.printHelp(); @@ -145,40 +135,34 @@ console.log('-----------'); args = nargsExample.parseArgs('--bar b c f --foo a'.split(' ')); console.dir(args); - - - -var parent_parser = new ArgumentParser({ addHelp: false }); +const parent_parser = new ArgumentParser({ addHelp: false }); // note addHelp:false to prevent duplication of the -h option parent_parser.addArgument( - ['--parent'], - { type: 'int', help: 'parent' } + ['--parent'], + { type: 'int', help: 'parent' } ); -var foo_parser = new ArgumentParser({ - parents: [parent_parser], - description: 'child1' +const foo_parser = new ArgumentParser({ + parents: [parent_parser], + description: 'child1' }); foo_parser.addArgument(['foo']); args = foo_parser.parseArgs(['--parent', '2', 'XXX']); console.log(args); -var bar_parser = new ArgumentParser({ - parents: [parent_parser], - description: 'child2' +const bar_parser = new ArgumentParser({ + parents: [parent_parser], + description: 'child2' }); bar_parser.addArgument(['--bar']); args = bar_parser.parseArgs(['--bar', 'YYY']); console.log(args); - - - -var prefixCharsExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: prefix_chars', - prefixChars: '-+' +const prefixCharsExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: prefix_chars', + prefixChars: '-+' }); prefixCharsExample.addArgument(['+f', '++foo']); prefixCharsExample.addArgument(['++bar'], { action: 'storeTrue' }); @@ -193,39 +177,36 @@ console.dir(args); args = prefixCharsExample.parseArgs(['++foo', '2', '++bar']); console.dir(args); - - - -var subparserExample = new ArgumentParser({ - version: '0.0.1', - addHelp: true, - description: 'Argparse examples: sub-commands' +const subparserExample = new ArgumentParser({ + version: '0.0.1', + addHelp: true, + description: 'Argparse examples: sub-commands' }); -var subparsers = subparserExample.addSubparsers({ - title: 'subcommands', - dest: "subcommand_name" +const subparsers = subparserExample.addSubparsers({ + title: 'subcommands', + dest: "subcommand_name" }); -var bar = subparsers.addParser('c1', { addHelp: true, help: 'c1 help' }); +let bar = subparsers.addParser('c1', { addHelp: true, help: 'c1 help' }); bar.addArgument( - ['-f', '--foo'], - { - action: 'store', - help: 'foo3 bar3' - } + ['-f', '--foo'], + { + action: 'store', + help: 'foo3 bar3' + } ); -var bar = subparsers.addParser( - 'c2', - { aliases: ['co'], addHelp: true, help: 'c2 help' } +bar = subparsers.addParser( + 'c2', + { aliases: ['co'], addHelp: true, help: 'c2 help' } ); bar.addArgument( - ['-b', '--bar'], - { - action: 'store', - type: 'int', - help: 'foo3 bar3' - } + ['-b', '--bar'], + { + action: 'store', + type: 'int', + help: 'foo3 bar3' + } ); subparserExample.printHelp(); console.log('-----------'); @@ -241,66 +222,51 @@ console.dir(args); console.log('-----------'); subparserExample.parseArgs(['c1', '-h']); - - - -var functionExample = new ArgumentParser({ description: 'Process some integers.' }); +const functionExample = new ArgumentParser({ description: 'Process some integers.' }); function sum(arr: number[]) { - return arr.reduce(function(a, b) { - return a + b; - }, 0); + return arr.reduce((a, b) => a + b, 0); } function max(arr: number[]) { - return Math.max.apply(Math, arr); + return Math.max.apply(Math, arr); } - functionExample.addArgument(['integers'], { - metavar: 'N', - type: 'int', - nargs: '+', - help: 'an integer for the accumulator' + metavar: 'N', + type: 'int', + nargs: '+', + help: 'an integer for the accumulator' }); functionExample.addArgument(['--sum'], { - dest: 'accumulate', - action: 'storeConst', - constant: sum, - defaultValue: max, - help: 'sum the integers (default: find the max)' + dest: 'accumulate', + action: 'storeConst', + constant: sum, + defaultValue: max, + help: 'sum the integers (default: find the max)' }); args = functionExample.parseArgs('--sum 1 2 -1'.split(' ')); console.log(args.accumulate(args.integers)); - - - -var formatterExample = new ArgumentParser({ - prog: 'PROG', - formatterClass: RawDescriptionHelpFormatter, - description: 'Keep the formatting\n' + - ' exactly as it is written\n' + - '\n' + - 'here\n' +const formatterExample = new ArgumentParser({ + prog: 'PROG', + formatterClass: RawDescriptionHelpFormatter, + description: `Keep the formatting\nexactly as it is written\n\nhere\n`, }); formatterExample.addArgument(['--foo'], { - help: ' foo help should not\n' + - ' retain this odd formatting' + help: `foo help should not\nretain this odd formatting`, }); formatterExample.addArgument(['spam'], { - 'help': 'spam help' + help: 'spam help', }); -var group = formatterExample.addArgumentGroup({ - title: 'title', - description: ' This text\n' + - ' should be indented\n' + - ' exactly like it is here\n' +const group = formatterExample.addArgumentGroup({ + title: 'title', + description: `This text\nshould be indented\nexactly like it is here\n`, }); group.addArgument(['--bar'], { - help: 'bar help' + help: 'bar help' }); formatterExample.printHelp(); diff --git a/types/argparse/index.d.ts b/types/argparse/index.d.ts index 2661b01c12..f19aadbe96 100644 --- a/types/argparse/index.d.ts +++ b/types/argparse/index.d.ts @@ -1,31 +1,39 @@ -// Type definitions for argparse v1.0.3 +// Type definitions for argparse 1.0 // Project: https://github.com/nodeca/argparse // Definitions by: Andrew Schurman +// Tomasz Łaziuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 - -export declare class ArgumentParser extends ArgumentGroup { +export class ArgumentParser extends ArgumentGroup { constructor(options?: ArgumentParserOptions); - addSubparsers(options?: SubparserOptions): SubParser; - parseArgs(args?: string[], ns?: Namespace | Object): any; + parseArgs(args?: string[], ns?: Namespace | object): any; printUsage(): void; printHelp(): void; formatUsage(): string; formatHelp(): string; - parseKnownArgs(args?: string[], ns?: Namespace | Object): any[]; + parseKnownArgs(args?: string[], ns?: Namespace | object): any[]; convertArgLineToArg(argLine: string): string[]; exit(status: number, message: string): void; error(err: string | Error): void; } -interface Namespace { } +export class Namespace { + constructor(options: object); + get(key: K, defaultValue?: D): this[K] | D; + isset(key: K): boolean; + set(key: K, value: V): this; + set(key: K, value: V): this & Record; + set(obj: K): this & K; + unset(key: K, defaultValue?: D): this[K] | D; +} -declare class SubParser { +export class SubParser { addParser(name: string, options?: SubArgumentParserOptions): ArgumentParser; } -declare class ArgumentGroup { +export class ArgumentGroup { addArgument(args: string[], options?: ArgumentOptions): void; addArgumentGroup(options?: ArgumentGroupOptions): ArgumentGroup; addMutuallyExclusiveGroup(options?: { required: boolean }): ArgumentGroup; @@ -33,7 +41,7 @@ declare class ArgumentGroup { getDefault(dest: string): any; } -interface SubparserOptions { +export interface SubparserOptions { title?: string; description?: string; prog?: string; @@ -44,12 +52,12 @@ interface SubparserOptions { metavar?: string; } -interface SubArgumentParserOptions extends ArgumentParserOptions { +export interface SubArgumentParserOptions extends ArgumentParserOptions { aliases?: string[]; help?: string; } -interface ArgumentParserOptions { +export interface ArgumentParserOptions { description?: string; epilog?: string; addHelp?: boolean; @@ -62,26 +70,27 @@ interface ArgumentParserOptions { version?: string; } -interface ArgumentGroupOptions { +export interface ArgumentGroupOptions { prefixChars?: string; argumentDefault?: any; title?: string; description?: string; } -export declare class HelpFormatter { } -export declare class ArgumentDefaultsHelpFormatter { } -export declare class RawDescriptionHelpFormatter { } -export declare class RawTextHelpFormatter { } +export class HelpFormatter { } +export class ArgumentDefaultsHelpFormatter { } +export class RawDescriptionHelpFormatter { } +export class RawTextHelpFormatter { } -interface ArgumentOptions { +export interface ArgumentOptions { action?: string; optionStrings?: string[]; dest?: string; nargs?: string | number; constant?: any; defaultValue?: any; - type?: string | Function; + // type may be a string (primitive) or a Function (constructor) + type?: string | Function; // tslint:disable-line:ban-types choices?: string | string[]; required?: boolean; help?: string; diff --git a/types/argparse/tslint.json b/types/argparse/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/argparse/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/autobahn/index.d.ts b/types/autobahn/index.d.ts index 3c576e2dc8..7f01a53e3a 100644 --- a/types/autobahn/index.d.ts +++ b/types/autobahn/index.d.ts @@ -205,7 +205,7 @@ declare namespace autobahn { type DeferFactory = () => When.Promise; - type OnChallengeHandler = (session: Session, method: string, extra: any) => When.Promise; + type OnChallengeHandler = (session: Session, method: string, extra: any) => string; interface IConnectionOptions { use_es6_promises?: boolean; diff --git a/types/autoprefixer/package.json b/types/autoprefixer/package.json index aa284a6db8..c4c2b4c357 100644 --- a/types/autoprefixer/package.json +++ b/types/autoprefixer/package.json @@ -1,5 +1,6 @@ { - "dependencies": { - "postcss": "^5.2.15" - } + "private": true, + "dependencies": { + "postcss": "^5.2.15" + } } diff --git a/types/awesomplete/tslint.json b/types/awesomplete/tslint.json index 3db14f85ea..d9d49e375e 100644 --- a/types/awesomplete/tslint.json +++ b/types/awesomplete/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false + } +} diff --git a/types/backoff/backoff-tests.ts b/types/backoff/backoff-tests.ts new file mode 100644 index 0000000000..86da837721 --- /dev/null +++ b/types/backoff/backoff-tests.ts @@ -0,0 +1,351 @@ +import * as backoff from 'backoff'; + +const fibonacciBackoff = backoff.fibonacci(); +fibonacciBackoff; // $ExpectType Backoff +backoff.fibonacci({ + randomisationFactor: 0, + initialDelay: 10, + maxDelay: 300 +}); +backoff.fibonacci({randomisationFactor: 0}); +backoff.fibonacci({initialDelay: 10}); +backoff.fibonacci({maxDelay: 300}); + +backoff.exponential(); // $ExpectType Backoff +backoff.exponential({ + factor: 1, + randomisationFactor: 0, + initialDelay: 10, + maxDelay: 300 +}); +backoff.exponential({factor: 1}); +backoff.exponential({randomisationFactor: 0}); +backoff.exponential({initialDelay: 10}); +backoff.exponential({maxDelay: 300}); + +const fibonacciStrategy = new backoff.FibonacciStrategy(); +new backoff.FibonacciStrategy({ + randomisationFactor: 0, + initialDelay: 10, + maxDelay: 300 +}); +new backoff.FibonacciStrategy({randomisationFactor: 0}); +new backoff.FibonacciStrategy({initialDelay: 10}); +new backoff.FibonacciStrategy({maxDelay: 300}); + +fibonacciStrategy.next(); // $ExpectType number +fibonacciStrategy.reset(); + +const exponentialStrategy = new backoff.ExponentialStrategy(); +new backoff.ExponentialStrategy({ + factor: 1, + randomisationFactor: 0, + initialDelay: 10, + maxDelay: 300 +}); +new backoff.ExponentialStrategy({factor: 1}); +new backoff.ExponentialStrategy({randomisationFactor: 0}); +new backoff.ExponentialStrategy({initialDelay: 10}); +new backoff.ExponentialStrategy({maxDelay: 300}); + +exponentialStrategy.next(); // $ExpectType number +exponentialStrategy.reset(); + +class MyStrategy extends backoff.BackoffStrategy { + constructor() { + super({ + randomisationFactor: 0, + initialDelay: 10, + maxDelay: 300 + }); + } + + protected next_() { + return 1; + } + + protected reset_() { + } +} + +const myStrategy = new MyStrategy(); +exponentialStrategy.next(); // $ExpectType number +exponentialStrategy.reset(); + +// $ExpectType TypedFunctionCall +backoff.call((cb: (err: Error) => void) => {}, (err) => { + err; // $ExpectType Error +}); +// $ExpectType TypedFunctionCall +backoff.call((cb: (err: Error, r1: string) => void) => {}, (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error +}); +// TypedFunctionCall +backoff.call((cb: (err: Error, r1: string, r2: number) => void) => {}, (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error +}); +// TypedFunctionCall +backoff.call((cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => {}, (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error +}); +// TypedFunctionCall<[number], Error, string, undefined, undefined> +backoff.call( + (t1: number, cb: (err: Error, r1: string) => void) => { + }, + 1, + (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error + }); +// TypedFunctionCall<[number], Error, string, number, undefined> +backoff.call( + (t1: number, cb: (err: Error, r1: string, r2: number) => void) => { + }, + 1, + (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error + }); +// TypedFunctionCall<[number], Error, string, number, boolean> +backoff.call( + (t1: number, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + 1, + (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string], Error, string, undefined, undefined> +backoff.call( + (t1: number, t2: string, cb: (err: Error, r1: string) => void) => { + }, + 1, 'foo', + (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string], Error, string, number, undefined> +backoff.call( + (t1: number, t2: string, cb: (err: Error, r1: string, r2: number) => void) => { + }, + 1, 'foo', + (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string], Error, string, number, boolean> +backoff.call( + (t1: number, t2: string, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + 1, 'foo', + (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string, boolean], Error, string, undefined, undefined> +backoff.call( + (t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string) => void) => { + }, + 1, 'foo', true, + (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string, boolean], Error, string, number, undefined> +backoff.call( + (t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string, r2: number) => void) => { + }, + 1, 'foo', true, + (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string, boolean], Error, string, number, boolean> +backoff.call( + (t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + 1, 'foo', true, + (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error + }); +// $ExpectType FunctionCallAny +backoff.call( + (t1: number, t2: string, t3: boolean, t4: string, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + 1, 'foo', true, 'bar', + (err: Error, r1: string, r2: number, r3: boolean) => {}); + +fibonacciBackoff.failAfter(10); +fibonacciBackoff.backoff(new Error('foo')); +fibonacciBackoff.reset(); + +fibonacciBackoff.on('backoff', (number, delay) => { + number; // $ExpectType number + delay; // $ExpectType number +}); +fibonacciBackoff.on('ready', (number, delay) => { + number; // $ExpectType number + delay; // $ExpectType number +}); +fibonacciBackoff.on('fail', (err) => { + err; // $ExpectType any +}); + +// TypedFunctionCall +new backoff.FunctionCall((cb: (err: Error) => void) => {}, [], (err) => { + err; // $ExpectType Error +}); +// TypedFunctionCall +new backoff.FunctionCall((cb: (err: Error, r1: string) => void) => {}, [], (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error +}); +// TypedFunctionCall +new backoff.FunctionCall((cb: (err: Error, r1: string, r2: number) => void) => {}, [], (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error +}); +// TypedFunctionCall +new backoff.FunctionCall((cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => {}, [], (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error +}); +// TypedFunctionCall<[number], Error, string, undefined, undefined> +new backoff.FunctionCall( + (t1: number, cb: (err: Error, r1: string) => void) => { + }, + [1], + (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error + }); +// TypedFunctionCall<[number], Error, string, number, undefined> +new backoff.FunctionCall( + (t1: number, cb: (err: Error, r1: string, r2: number) => void) => { + }, + [1], + (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error + }); +// TypedFunctionCall<[number], Error, string, number, boolean> +new backoff.FunctionCall( + (t1: number, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + [1], + (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string], Error, string, undefined, undefined> +new backoff.FunctionCall( + (t1: number, t2: string, cb: (err: Error, r1: string) => void) => { + }, + [1, 'foo'], + (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string], Error, string, number, undefined> +new backoff.FunctionCall( + (t1: number, t2: string, cb: (err: Error, r1: string, r2: number) => void) => { + }, + [1, 'foo'], + (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string], Error, string, number, boolean> +new backoff.FunctionCall( + (t1: number, t2: string, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + [1, 'foo'], + (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string, boolean], Error, string, undefined, undefined> +new backoff.FunctionCall( + (t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string) => void) => { + }, + [1, 'foo', true], + (err, r1) => { + r1; // $ExpectType string + err; // $ExpectType Error + }); +// TypedFunctionCall<[number, string, boolean], Error, string, number, undefined> +new backoff.FunctionCall( + (t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string, r2: number) => void) => { + }, + [1, 'foo', true], + (err, r1, r2) => { + r1; // $ExpectType string + r2; // $ExpectType number + err; // $ExpectType Error + }); +const functionCall = new backoff.FunctionCall( + (t1: number, t2: string, t3: boolean, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + [1, 'foo', true], + (err, r1, r2, r3) => { + r1; // $ExpectType string + r2; // $ExpectType number + r3; // $ExpectType boolean + err; // $ExpectType Error + }); +functionCall; // TypedFunctionCall<[number, string, boolean], Error, string, number, boolean> +// $ExpectType FunctionCallAny +new backoff.FunctionCall( + (t1: number, t2: string, t3: boolean, t4: string, cb: (err: Error, r1: string, r2: number, r3: boolean) => void) => { + }, + [1, 'foo', true, 'bar'], + (err: Error, r1: string, r2: number, r3: boolean) => {}); + +functionCall.isPending(); // $ExpectType boolean +functionCall.isRunning(); // $ExpectType boolean +functionCall.isCompleted(); // $ExpectType boolean +functionCall.isAborted(); // $ExpectType boolean +functionCall.setStrategy(myStrategy); // $ExpectType TypedFunctionCall<[number, string, boolean], Error, string, number, boolean> +functionCall.retryIf(err => err.status === 503); // $ExpectType TypedFunctionCall<[number, string, boolean], Error, string, number, boolean> +functionCall.failAfter(10); // $ExpectType TypedFunctionCall<[number, string, boolean], Error, string, number, boolean> +functionCall.getLastResult(); // $ExpectType [Error, string, number, boolean] +functionCall.getNumRetries(); // $ExpectType number +functionCall.start(); +functionCall.abort(); +functionCall.on('call', args => { + args; // $ExpectType [number, string, boolean] +}); +functionCall.on('callback', args => { + args; // $ExpectType [Error, string, number, boolean] +}); +functionCall.on('backoff', (number, delay, err) => { + number; // $ExpectType number + delay; // $ExpectType number + err; // $ExpectType any +}); +functionCall.on('abort', () => {}); diff --git a/types/backoff/index.d.ts b/types/backoff/index.d.ts new file mode 100644 index 0000000000..1c2f1ea605 --- /dev/null +++ b/types/backoff/index.d.ts @@ -0,0 +1,525 @@ +// Type definitions for backoff 2.5 +// Project: https://github.com/MathieuTurcotte/node-backoff#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 +/// +import { EventEmitter } from 'events'; + +/** + * Constructs a Fibonacci backoff (10, 10, 20, 30, 50, etc.). + * + * @param options.randomisationFactor: defaults to 0, must be between 0 and 1 + * @param options.initialDelay: defaults to 100 ms + * @param options.maxDelay: defaults to 10000 ms + * + * With these values, the backoff delay will increase from 100 ms to 10000 ms. The + * randomisation factor controls the range of randomness and must be between 0 + * and 1. By default, no randomisation is applied on the backoff delay. + */ +export function fibonacci(options?: Options): Backoff; + +/** + * Constructs an exponential backoff (10, 20, 40, 80, etc.). + * + * @param options.randomisationFactor: defaults to 0, must be between 0 and 1 + * @param options.initialDelay: defaults to 100 ms + * @param options.maxDelay: defaults to 10000 ms + * @param options.factor: defaults to 2, must be greater than 1 + * + * With these values, the backoff delay will increase from 100 ms to 10000 ms. The + * randomisation factor controls the range of randomness and must be between 0 + * and 1. By default, no randomisation is applied on the backoff delay. + */ +export function exponential(options?: ExponentialOptions): Backoff; + +export interface Options { + randomisationFactor?: number; + initialDelay?: number; + maxDelay?: number; +} + +export interface ExponentialOptions extends Options { + factor?: number; +} + +/** + * Constructs a `FunctionCall` instance for the given function. The wrapped + * function will get retried until it succeds or reaches the maximum number + * of backoffs. In both cases, the callback function will be invoked with the + * last result returned by the wrapped function. + * + * It is the caller's responsability to initiate the call by invoking the + * `start` method on the returned `FunctionCall` instance. + * + * @param wrappedFunction: function to call in a backoff handler, i.e. the wrapped function + * @param args: function's arguments + * @param callback: function's callback accepting an error as its first argument + * + */ +export function call(wrappedFunction: (cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall; +export function call(wrappedFunction: (cb: (err: E, r1: R1, r2: R2) => void) => void, + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall; +export function call(wrappedFunction: (cb: (err: E, r1: R1) => void) => void, + callback: (error: E, r1: R1) => void): TypedFunctionCall; +export function call(wrappedFunction: (cb: (err: E) => void) => void, + callback: (err: E) => void): TypedFunctionCall; +export function call(wrappedFunction: (t1: T1, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + t1: T1, + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1], E, R1, R2, R3>; +export function call(wrappedFunction: (t1: T1, cb: (err: E, r1: R1, r2: R2) => void) => void, + t1: T1, + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1], E, R1, R2>; +export function call(wrappedFunction: (t1: T1, cb: (err: E, r1: R1) => void) => void, + t1: T1, + callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1], E, R1>; +export function call(wrappedFunction: (t1: T1, cb: (err: E) => void) => void, + t1: T1, + callback: (err: E) => void): TypedFunctionCall<[T1], E>; +export function call(wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + t1: T1, t2: T2, + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1, T2], E, R1, R2, R3>; +export function call(wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1, r2: R2) => void) => void, + t1: T1, t2: T2, + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1, T2], E, R1, R2>; +export function call(wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1) => void) => void, + t1: T1, t2: T2, + callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1, T2], E, R1>; +export function call(wrappedFunction: (t1: T1, t2: T2, cb: (err: E) => void) => void, + t1: T1, t2: T2, + callback: (err: E) => void): TypedFunctionCall<[T1, T2], E>; +export function call(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + t1: T1, t2: T2, t3: T3, + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1, T2, T3], E, R1, R2, R3>; +export function call(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1, r2: R2) => void) => void, + t1: T1, t2: T2, t3: T3, + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1, T2, T3], E, R1, R2>; +export function call(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1) => void) => void, + t1: T1, t2: T2, t3: T3, + callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1, T2, T3], E, R1>; +export function call(wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E) => void) => void, + t1: T1, t2: T2, t3: T3, + callback: (err: E) => void): TypedFunctionCall<[T1, T2, T3], E>; +export function call(wrappedFunction: (...args: any[]) => void, ...args: any[]): FunctionCallAny; + +export class Backoff extends EventEmitter { + /** + * Constructs a new backoff object from a specific backoff strategy. The backoff + * strategy must implement the `BackoffStrategy`interface defined bellow. + * + * @param strategy: the backoff strategy to use + */ + constructor(strategy: BackoffStrategy); + + /** + * Sets a limit on the maximum number of backoffs that can be performed before + * a fail event gets emitted and the backoff instance is reset. By default, there + * is no limit on the number of backoffs that can be performed. + * + * @param numberOfBackoffs: maximum number of backoffs before the fail event gets + * emitted, must be greater than 0 + */ + failAfter(numberOfBackoffs: number): void; + + /** + * Starts a backoff operation. If provided, the error parameter will be emitted + * as the last argument of the `backoff` and `fail` events to let the listeners + * know why the backoff operation was attempted. + * + * An error will be thrown if a backoff operation is already in progress. + * + * In practice, this method should be called after a failed attempt to perform a + * sensitive operation (connecting to a database, downloading a resource over the + * network, etc.). + */ + backoff(error?: any): void; + + /** + * Resets the backoff delay to the initial backoff delay and stop any backoff + * operation in progress. After reset, a backoff instance can and should be + * reused. + * + * In practice, this method should be called after having successfully completed + * the sensitive operation guarded by the backoff instance or if the client code + * request to stop any reconnection attempt. + */ + reset(): void; + + /** + * Emitted when a backoff operation is started. Signals to the client how long + * the next backoff delay will be. + * @param number: number of backoffs since last reset, starting at 0 + * @param delay: backoff delay in milliseconds + * @param err: optional error parameter passed to `backoff.backoff([err])` + */ + addListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + /** + * Emitted when a backoff operation is done. Signals that the failing operation + * should be retried. + * + * @param number: number of backoffs since last reset, starting at 0 + * @param delay: backoff delay in milliseconds + */ + addListener(event: 'ready', listener: (number: number, delay: number) => void): this; + /** + * Emitted when the maximum number of backoffs is reached. This event will only + * be emitted if the client has set a limit on the number of backoffs by calling + * `backoff.failAfter(numberOfBackoffs)`. The backoff instance is automatically + * reset after this event is emitted. + * + * @param err: optional error parameter passed to `backoff.backoff([err])` + */ + addListener(event: 'fail', listener: (error?: any) => void): this; + on(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + on(event: 'ready', listener: (number: number, delay: number) => void): this; + on(event: 'fail', listener: (error?: any) => void): this; + once(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + once(event: 'ready', listener: (number: number, delay: number) => void): this; + once(event: 'fail', listener: (error?: any) => void): this; + prependListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + prependListener(event: 'ready', listener: (number: number, delay: number) => void): this; + prependListener(event: 'fail', listener: (error?: any) => void): this; + prependOnceListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + prependOnceListener(event: 'ready', listener: (number: number, delay: number) => void): this; + prependOnceListener(event: 'fail', listener: (error?: any) => void): this; + removeListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + removeListener(event: 'ready', listener: (number: number, delay: number) => void): this; + removeListener(event: 'fail', listener: (error?: any) => void): this; + removeAllListeners(event?: 'backoff' | 'ready' | 'fail'): this; + listeners(event: 'backoff'): Array<(number: number, delay: number, error?: any) => void>; + listeners(event: 'ready'): Array<(number: number, delay: number) => void>; + listeners(event: 'fail'): Array<(error?: any) => void>; + emit(event: 'backoff', number: number, delay: number, error?: any): boolean; + emit(event: 'ready', number: number, delay: number): boolean; + emit(event: 'fail', error?: any): boolean; + eventNames(): Array<'backoff' | 'ready' | 'fail'>; + listenerCount(type: 'backoff' | 'ready' | 'fail'): number; +} + +export abstract class BackoffStrategy { + /** + * The options are the following. + * + * @param options.randomisationFactor: defaults to 0, must be between 0 and 1 + * @param options.initialDelay: defaults to 100 ms + * @param options.maxDelay: defaults to 10000 ms + */ + constructor(options?: Options); + getMaxDelay(): number; + getInitialDelay(): number; + + /** + * Computes and returns the next backoff delay. + */ + next(): number; + + /** + * Resets the backoff delay to its initial value. + */ + reset(): void; + protected abstract next_(): number; + protected abstract reset_(): void; +} + +/** + * Exponential (10, 20, 40, 80, etc.) backoff strategy implementation. + */ +export class ExponentialStrategy extends BackoffStrategy { + /** + * The options are the following. + * + * @param options.randomisationFactor: defaults to 0, must be between 0 and 1 + * @param options.initialDelay: defaults to 100 ms + * @param options.maxDelay: defaults to 10000 ms + * @param options.factor: defaults to 2, must be greater than 1 + */ + constructor(options?: ExponentialOptions); + /** + * Computes and returns the next backoff delay. + */ + next(): number; + /** + * Resets the backoff delay to its initial value. + */ + reset(): void; + protected next_(): number; + protected reset_(): number; +} + +/** + * Fibonacci (10, 10, 20, 30, 50, etc.) backoff strategy implementation. + */ +export class FibonacciStrategy extends BackoffStrategy { + /** + * The options are the following. + * + * @param options.randomisationFactor: defaults to 0, must be between 0 and 1 + * @param options.initialDelay: defaults to 100 ms + * @param options.maxDelay: defaults to 10000 ms + */ + constructor(options?: Options); + next(): number; + reset(): void; + protected next_(): number; + protected reset_(): number; +} + +/** + * This class manages the calling of an asynchronous function within a backoff + * loop. + * + * This class should rarely be instantiated directly since the factory method + * `backoff.call(fn, [args, ...], callback)` offers a more convenient and safer + * way to create `FunctionCall` instances. + */ +export const FunctionCall: FunctionCallConstructor; + +/** + * Constructs a function handler for the given asynchronous function. + * + * @param fn: asynchronous function to call + * @param args: an array containing fn's args + * @param callback: fn's callback + */ +export interface FunctionCallConstructor { + new (wrappedFunction: (cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + args: undefined[], + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall; + new (wrappedFunction: (cb: (err: E, r1: R1, r2: R2) => void) => void, + args: undefined[], + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall; + new (wrappedFunction: (cb: (err: E, r1: R1) => void) => void, + args: undefined[], + callback: (error: E, r1: R1) => void): TypedFunctionCall; + new (wrappedFunction: (cb: (err: E) => void) => void, + args: undefined[], + callback: (err: E) => void): TypedFunctionCall; + + new (wrappedFunction: (t1: T1, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + args: [T1], + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1], E, R1, R2, R3>; + new (wrappedFunction: (t1: T1, cb: (err: E, r1: R1, r2: R2) => void) => void, + args: [T1], + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1], E, R1, R2>; + new (wrappedFunction: (t1: T1, cb: (err: E, r1: R1) => void) => void, + args: [T1], + callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1], E, R1>; + new (wrappedFunction: (t1: T1, cb: (err: E) => void) => void, + args: [T1], + callback: (err: E) => void): TypedFunctionCall<[T1], E>; + + new (wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + args: [T1, T2], + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1, T2], E, R1, R2, R3>; + new (wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1, r2: R2) => void) => void, + args: [T1, T2], + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1, T2], E, R1, R2>; + new (wrappedFunction: (t1: T1, t2: T2, cb: (err: E, r1: R1) => void) => void, + args: [T1, T2], + callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1, T2], E, R1>; + new (wrappedFunction: (t1: T1, t2: T2, cb: (err: E) => void) => void, + args: [T1, T2], + callback: (err: E) => void): TypedFunctionCall<[T1, T2], E>; + + new (wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1, r2: R2, r3: R3) => void) => void, + args: [T1, T2, T3], + callback: (error: E, r1: R1, r2: R2, r3: R3) => void): TypedFunctionCall<[T1, T2, T3], E, R1, R2, R3>; + new (wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1, r2: R2) => void) => void, + args: [T1, T2, T3], + callback: (error: E, r1: R1, r2: R2) => void): TypedFunctionCall<[T1, T2, T3], E, R1, R2>; + new (wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E, r1: R1) => void) => void, + args: [T1, T2, T3], + callback: (error: E, r1: R1) => void): TypedFunctionCall<[T1, T2, T3], E, R1>; + new (wrappedFunction: (t1: T1, t2: T2, t3: T3, cb: (err: E) => void) => void, + args: [T1, T2, T3], + callback: (err: E) => void): TypedFunctionCall<[T1, T2, T3], E>; + + new (wrappedFunction: (...args: any[]) => void, + args: any[], + callback: (error: any, ...resArgs: any[]) => void): FunctionCallAny; +} + +export type TypedFunctionCall = FunctionCall & FunctionCallArgs; +export type FunctionCallAny = FunctionCall & FunctionCallArgsAny; + +export interface FunctionCall extends EventEmitter { + /** + * Returns whether the call is pending, i.e. hasn't been started. + */ + isPending(): boolean; + + /** + * Returns whether the call is in progress. + */ + isRunning(): boolean; + + /** + * Returns whether the call is completed. + */ + isCompleted(): boolean; + + /** + * Returns whether the call is aborted. + */ + isAborted(): boolean; + + /** + * Sets the backoff strategy to use. This method should be called before + * `call.start()` otherwise an exception will be thrown. + * + * @param strategy: strategy instance to use, defaults to `FibonacciStrategy`. + */ + setStrategy(strategy: BackoffStrategy): this; + + /** + * Sets the maximum number of backoffs before the call is aborted. By default, + * there is no limit on the number of backoffs that can be performed. + * + * This method should be called before `call.start()` otherwise an exception will + * be thrown. + * + * @param maxNumberOfBackoffs: maximum number of backoffs before the call is aborted + */ + failAfter(maxNumberOfBackoffs: number): this; + + /** + * Sets the predicate which will be invoked to determine whether a given error + * should be retried or not, e.g. a network error would be retriable while a type + * error would stop the function call. By default, all errors are considered to be + * retriable. + * + * This method should be called before `call.start()` otherwise an exception will + * be thrown. + * + * @param predicate: a function which takes in as its argument the error returned + * by the wrapped function and determines whether it is retriable. + */ + retryIf(predicate: (error: any) => boolean): this; + + /** + * Returns the number of times the wrapped function call was retried. For a + * wrapped function that succeeded immediately, this would return 0. This + * method can be called at any point in time during the call life cycle, i.e. + * before, during and after the wrapped function invocation. + */ + getNumRetries(): number; + + /** + * Initiates the call the wrapped function. This method should only be called + * once otherwise an exception will be thrown. + */ + start(): void; + + /** + * Aborts the call and causes the completion callback to be invoked with an abort + * error if the call was pending or running; does nothing otherwise. This method + * can safely be called multiple times. + */ + abort(): void; + + /** + * Emitted each time the wrapped function is called. + * @param args: wrapped function's arguments + */ + addListener(event: 'call', listener: (args: T) => void): this; + + /** + * Emitted each time a backoff operation is started. + * + * @param number: backoff number, starts at 0 + * @param delay: backoff delay in milliseconds + * @param err: the error that triggered the backoff operation + */ + addListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + + /** + * Emitted when a call is aborted. + */ + addListener(event: 'abort', listener: () => void): this; + on(event: 'call', listener: (args: T) => void): this; + on(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + on(event: 'abort', listener: () => void): this; + once(event: 'call', listener: (args: T) => void): this; + once(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + once(event: 'abort', listener: () => void): this; + prependListener(event: 'call', listener: (args: T) => void): this; + prependListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + prependListener(event: 'abort', listener: () => void): this; + prependOnceListener(event: 'call', listener: (args: T) => void): this; + prependOnceListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + prependOnceListener(event: 'abort', listener: () => void): this; + removeListener(event: 'call', listener: (args: T) => void): this; + removeListener(event: 'backoff', listener: (number: number, delay: number, error?: any) => void): this; + removeListener(event: 'abort', listener: () => void): this; + removeAllListeners(event?: 'call' | 'callback' | 'backoff' | 'abort'): this; + listeners(event: 'call'): Array<(args: T) => void>; + listeners(event: 'backoff'): Array<(number: number, delay: number, error?: any) => void>; + listeners(event: 'abort'): Array<() => void>; + emit(event: 'call', args: T): boolean; + emit(event: 'backoff', number: number, delay: number, error?: any): boolean; + emit(event: 'abort'): boolean; + eventNames(): Array<'call' | 'callback' | 'backoff' | 'abort'>; + listenerCount(type: 'call' | 'callback' | 'backoff' | 'abort'): number; +} + +// Waiting for https://github.com/Microsoft/TypeScript/pull/17884 +export interface FunctionCallArgs { + /** + * Returns an array containing the last arguments passed to the completion callback + * of the wrapped function. For example, to get the error code returned by the last + * call, one would do the following. + * + * ``` js + * var results = call.getLastResult(); + * // The error code is the first parameter of the callback. + * var error = results[0]; + * ``` + * + * Note that if the call was aborted, it will contain the abort error and not the + * last error returned by the wrapped function. + */ + getLastResult(): [E, R1, R2, R3]; + /** + * Emitted each time the wrapped function invokes its callback + * @param results: wrapped function's return values + */ + addListener(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this; + on(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this; + once(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this; + prependListener(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this; + prependOnceListener(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this; + removeListener(event: 'callback', listener: (results: [E, R1, R2, R3]) => void): this; + listeners(event: 'callback'): Array<(results: [E, R1, R2, R3]) => void>; + emit(event: 'callback', results: [E, R1, R2, R3]): boolean; +} + +export interface FunctionCallArgsAny { + /** + * Returns an array containing the last arguments passed to the completion callback + * of the wrapped function. For example, to get the error code returned by the last + * call, one would do the following. + * + * ``` js + * var results = call.getLastResult(); + * // The error code is the first parameter of the callback. + * var error = results[0]; + * ``` + * + * Note that if the call was aborted, it will contain the abort error and not the + * last error returned by the wrapped function. + */ + getLastResult(): any[]; + /** + * Emitted each time the wrapped function invokes its callback + * @param results: wrapped function's return values + */ + addListener(event: 'callback', listener: (results: any[]) => void): this; + on(event: 'callback', listener: (results: any[]) => void): this; + once(event: 'callback', listener: (results: any[]) => void): this; + prependListener(event: 'callback', listener: (results: any[]) => void): this; + prependOnceListener(event: 'callback', listener: (results: any[]) => void): this; + removeListener(event: 'callback', listener: (results: any[]) => void): this; + listeners(event: 'callback'): Array<(results: any[]) => void>; + emit(event: 'callback', results: any[]): boolean; +} diff --git a/types/router5/tsconfig.json b/types/backoff/tsconfig.json similarity index 86% rename from types/router5/tsconfig.json rename to types/backoff/tsconfig.json index 37c1347cad..ed5117f056 100644 --- a/types/router5/tsconfig.json +++ b/types/backoff/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -17,6 +17,6 @@ }, "files": [ "index.d.ts", - "router5-tests.ts" + "backoff-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/backoff/tslint.json b/types/backoff/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/backoff/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/baidumap-web-sdk/baidumap.overlay.d.ts b/types/baidumap-web-sdk/baidumap.overlay.d.ts index d723ac5e48..0cff89c694 100644 --- a/types/baidumap-web-sdk/baidumap.overlay.d.ts +++ b/types/baidumap-web-sdk/baidumap.overlay.d.ts @@ -43,7 +43,8 @@ declare namespace BMap { displayOnMinLevel?: number displayOnMaxLevel?: number } - class Marker implements Overlay { + interface Marker extends Overlay {} + class Marker { constructor(point: Point, opts?: MarkerOptions) openInfoWindow(infoWnd: InfoWindow): void closeInfoWindow(): void @@ -100,7 +101,8 @@ declare namespace BMap { class IconSequence { constructor(symbol: Symbol, offset?: string, repeat?: string, fixedRotation?: boolean) } - class PointCollection implements Overlay { + interface PointCollection extends Overlay {} + class PointCollection { constructor(points: Point[], opts?: PointCollectionOption) setPoints(points: Point[]): void setStyles(styles: PointCollectionOption): void @@ -121,7 +123,8 @@ declare namespace BMap { shadow?: Icon title?: string } - class InfoWindow implements Overlay { + interface InfoWindow extends Overlay {} + class InfoWindow { constructor(content: string | HTMLElement, opts?: InfoWindowOptions) setWidth(width: number): void setHeight(height: number): void @@ -149,7 +152,8 @@ declare namespace BMap { onrestore: (event: { type: string, target: any }) => void onclickclose: (event: { type: string, target: any }) => void } - class Polygon implements Overlay { + interface Polygon extends Overlay {} + class Polygon { constructor(points: Array, opts?: PolygonOptions) setPath(path: Point[]): void getPath(): Point[] @@ -213,7 +217,8 @@ declare namespace BMap { enableClicking?: boolean } type ShapeType = number - class Icon implements Overlay { + interface Icon extends Overlay {} + class Icon { constructor(url: string, size: Size, opts?: IconOptions) anchor: Size size: Size @@ -230,7 +235,8 @@ declare namespace BMap { setInfoWindowAnchor(anchor: Size): void setPrintImageUrl(url: string): void } - class Label implements Overlay { + interface Label extends Overlay {} + class Label { constructor(content: string, opts?: LabelOptions) setStyle(styles: Object): void setContent(content: string): void @@ -256,7 +262,8 @@ declare namespace BMap { onremove: (event: { type: string, target: any }) => void onrightclick: (event: { type: string, target: any }) => void } - class Circle implements Overlay { + interface Circle extends Overlay {} + class Circle { constructor(center: Point, radius: number, opts?: CircleOptions) setCenter(center: Point): void getCenter(): Point @@ -315,7 +322,8 @@ declare namespace BMap { enableEditing?: boolean enableClicking?: boolean } - class Hotspot implements Overlay { + interface Hotspot extends Overlay {} + class Hotspot { constructor(position: Point, opts?: HotspotOptions) setPosition(position: Point): void getPosition(): Point @@ -324,7 +332,8 @@ declare namespace BMap { setUserData(data: any): void getUserData(): any } - class Symbol implements Overlay { + interface Symbol extends Overlay {} + class Symbol { constructor(path: string | SymbolShapeType, opts?: SymbolOptions) setPath(path: string | SymbolShapeType): void setAnchor(anchor: Size): void @@ -336,7 +345,8 @@ declare namespace BMap { setFillOpacity(opacity: number): void setFillColor(color: string): void } - class Polyline implements Overlay { + interface Polyline extends Overlay {} + class Polyline { constructor(points: Point[], opts?: PolylineOptions) setPath(path: Point[]): void getPath(): Point[] @@ -371,7 +381,8 @@ declare namespace BMap { onremove: (event: { type: string, target: any }) => void onlineupdate: (event: { type: string, target: any }) => void } - class GroundOverlay implements Overlay { + interface GroundOverlay extends Overlay {} + class GroundOverlay { constructor(bounds: Bounds, opts?: GroundOverlayOptions) setBounds(bounds: Bounds): void getBounds(): Bounds diff --git a/types/bittorrent-protocol/tslint.json b/types/bittorrent-protocol/tslint.json index dfea11be1a..62d2486032 100644 --- a/types/bittorrent-protocol/tslint.json +++ b/types/bittorrent-protocol/tslint.json @@ -1,6 +1,8 @@ { "extends": "dtslint/dt.json", "rules": { - "no-misused-new": false + // TODOs + "no-misused-new": false, + "no-any-union": false } } diff --git a/types/bluebird-global/tslint.json b/types/bluebird-global/tslint.json index b936b5e2b9..1d81af2349 100644 --- a/types/bluebird-global/tslint.json +++ b/types/bluebird-global/tslint.json @@ -5,6 +5,7 @@ "no-empty-interface": false, "array-type": false, "unified-signatures": false, - "ban-types": false + "ban-types": false, + "no-unnecessary-generics": false } } diff --git a/types/bootstrap.v3.datetimepicker/package.json b/types/bootstrap.v3.datetimepicker/package.json index 4c6d24a445..fce08a048d 100644 --- a/types/bootstrap.v3.datetimepicker/package.json +++ b/types/bootstrap.v3.datetimepicker/package.json @@ -1,4 +1,5 @@ { + "private": true, "dependencies": { "moment": ">=2.14.0" } diff --git a/types/bootstrap.v3.datetimepicker/tslint.json b/types/bootstrap.v3.datetimepicker/tslint.json index e6e6a68ad5..5b3c4f7877 100644 --- a/types/bootstrap.v3.datetimepicker/tslint.json +++ b/types/bootstrap.v3.datetimepicker/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { + "no-any-union": false, // TODO "quotemark": [true, "double", "avoid-escape"] } } diff --git a/types/bootstrap.v3.datetimepicker/v3/package.json b/types/bootstrap.v3.datetimepicker/v3/package.json index 4c6d24a445..fce08a048d 100644 --- a/types/bootstrap.v3.datetimepicker/v3/package.json +++ b/types/bootstrap.v3.datetimepicker/v3/package.json @@ -1,4 +1,5 @@ { + "private": true, "dependencies": { "moment": ">=2.14.0" } diff --git a/types/botvs/botvs-tests.ts b/types/botvs/botvs-tests.ts new file mode 100644 index 0000000000..96c424c164 --- /dev/null +++ b/types/botvs/botvs-tests.ts @@ -0,0 +1,7 @@ +_N(0, 1); +_C(() => void 0); +Sleep(1e3); +const data: botvs.Record | undefined = void 0; +console.log(data); +TA.Alligator([]); +talib.help('XML'); diff --git a/types/botvs/index.d.ts b/types/botvs/index.d.ts new file mode 100644 index 0000000000..2eabcb98da --- /dev/null +++ b/types/botvs/index.d.ts @@ -0,0 +1,4106 @@ +// Type definitions for botvs 0.1 +// Project: https://www.botvs.com/ +// Definitions by: acrazing +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +import Highstock = require('highcharts/highstock'); + +declare global { + namespace botvs { + /** + * 订单的状态 + */ + type VOrderState = object; + + /** + * 订单的类型 + */ + type VOrderType = object; + + /** + * 仓位的类型 + */ + type VPositionType = object; + + /** + * K线周期 + */ + type VPeriod = object; + + /** + * 日志类型 + */ + type VLogType = object; + + interface ChartOptions extends Highstock.Options { + __isStock?: boolean; + } + + interface RChart { + add(series?: number, data?: number, index?: number): void; + reset(): void; + } + + interface Socket { + write(data: string, timeout?: number): number; + read(size?: number): Buffer | null; + close(): void; + } + + /** + * 标准OHLC结构, 用来画K线和指标分析用的,由GetRecords函数返回此结构数组 + */ + interface Record { + /** + * 一个时间戳, 精确到毫秒,与Javascript的 new Date().getTime() 得到的结果格式一样 + */ + Time: number; + /** + * 开盘价 + */ + Open: number; + /** + * 最高价 + */ + High: number; + /** + * 最低价 + */ + Low: number; + /** + * 收盘价 + */ + Close: number; + /** + * 成交量 + */ + Volume: number; + } + + /** + * 市场深度单 + */ + interface MarketOrder { + /** + * 价格 + */ + Price: number; + /** + * 数量 + */ + Amount: number; + } + + /** + * 市场行情 + */ + interface Ticker { + /** + * 最高价 + */ + High: number; + /** + * 最低价 + */ + Low: number; + /** + * 卖一价 + */ + Sell: number; + /** + * 买一价 + */ + Buy: number; + /** + * 最后成交价 + */ + Last: number; + /** + * 最近成交量 + */ + Volume: number; + } + + /** + * 订单结构, 由GetOrder函数返回 + */ + interface Order { + /** + * 交易单唯一标识 + */ + Id: string; + /** + * 下单价格 + */ + Price: number; + /** + * 下单数量 + */ + Amount: number; + /** + * 成交数量 + */ + DealAmount: number; + /** + * 订单状态, 参考常量里的订单状态 + */ + Status: VOrderState; + /** + * 订单类型, 参考常量里的订单类型 + */ + Type: VOrderType; + } + + /** + * 市场深度,由GetDepth函数返回 + */ + interface Depth { + /** + * 卖单数组, MarketOrder数组, 按价格从低向高排序 + */ + Asks: MarketOrder[]; + /** + * 买单数组, MarketOrder数组, 按价格从高向低排序 + */ + Bids: MarketOrder[]; + } + + /** + * 获取所有交易历史(非自己),由GetTrades函数返回 + */ + interface Trade { + /** + * Id(交易所返回的此Trade的唯一Id) + */ + Id: string; + /** + * 时间(Unix timestamp 毫秒) + */ + Time: number; + /** + * 价格 + */ + Price: number; + /** + * 数量 + */ + Amount: number; + /** + * 订单类型, 参考常量里的订单类型 + */ + Type: VOrderType; + } + + /** + * 手续费结构, 由GetFee函数返回(如国外平台bitfinex买入卖出手续费跟账户交易量相关) + */ + interface Fee { + /** + * 卖出手续费, 为一个浮点数, 如0.2表示0.2%的手续费 + */ + Sell: number; + /** + * 买入手续费, 格式同上 + */ + Buy: number; + } + + /** + * 账户信息, 由GetAccount函数返回 + */ + interface Account { + /** + * 余额(人民币或者美元, 在Poloniex交易所里BTC_ETC这样的品种, Balance就指的是BTC的数量, + * Stocks指的是ETC数量, BTC38的ETC_BTC相当于Poloniex的BTC_ETC, 指的是以BTC计价) + */ + Balance: number; + /** + * 冻结的余额 + */ + FrozenBalance: number; + /** + * BTC/LTC数量, 现货为当前可操作币的余额(去掉冻结的币), + * 期货的话为合约当前可用保证金(传统期货为此属性) + */ + Stocks: number; + /** + * 冻结的BTC/LTC数量(传统期货无此属性) + */ + FrozenStocks: number; + } + + /** + * 期货交易中的持有仓位信息, 由GetPosition()函数返回此结构数组 + */ + interface Position { + /** + * 杆杠大小, 796期货有可能为5, 10, 20三个参数, OKCoin为10或者20, + * BitVC期货和OK期货的全仓模式返回为固定的10, 因为原生API不支持 + */ + MarginLevel: number; + /** + * 持仓量, 796期货表示持币的数量, BitVC指持仓的总金额(100的倍数), + * OKCoin表示合约的份数(整数且大于1) + */ + Amount: number; + /** + * 可平量, 只有股票有此选项, 表示可以平仓的数量(股票为T+1)今日仓不能平 + */ + CanCover: number; + /** + * 仓位冻结量 + */ + FrozenAmount: number; + /** + * 持仓均价 + */ + Price: number; + /** + * 持仓浮动盈亏(数据货币单位:BTC/LTC, 传统期货单位:RMB, 股票不支持此字段, + * 注: OKCoin期货全仓情况下指实现盈余, 并非持仓盈亏, 逐仓下指持仓盈亏) + */ + Profit: number; + /** + * PD_LONG为多头仓位(CTP中用closebuy_today平仓), PD_SHORT为空头仓位(CTP用closesell_today)平仓, + * (CTP期货中)PD_LONG_YD为咋日多头仓位(用closebuy平), PD_SHORT_YD为咋日空头仓位(用closesell平) + */ + Type: VPositionType; + /** + * 商品期货为合约代码, 股票为'交易所代码_股票代码', 具体参数SetContractType的传入类型 + */ + ContractType: string; + } + + interface AsyncJob { + wait(timeout?: number): T | null | undefined; + } + + interface Exchange { + /** + * 返回交易所名称(string) + * + * @return {string} + */ + GetName(): string; + + /** + * 返回交易所自定义的标签(string) + * + * @return {string} + */ + GetLabel(): string; + + /** + * 返回交易所使用的美元的汇率, OKCoin期货返回官方提供的汇率, 该值不受SetRate影响 + * + * @return {number} + */ + GetUSDCNY(): number; + + /** + * 返回交易所使用的流通货币与人民币的汇率, 返回1表示禁用汇率转换 + * + * 汇率接口调用雅虎提供的接口, 5分钟更新一次 + * 所有函数自动经过汇率转换,如果为1指禁用汇率转换 + * + * @return {number} + */ + GetRate(): number; + + /** + * 设置交易所的流通货币的汇率, 返回设置前的汇率, 设置为1指禁用汇率转换 + * + * 比如796期货设置SetRate(6.13), 就是设定USD/EUR对CNY的汇率为6.13, 程序所有价格会自动用这个汇率计算 + * SetRate(), 如果不加参数,则恢复系统内置汇率 + * SetRate(1), 就是禁用汇率转换 + * + * @param {number} rate + */ + SetRate(rate?: number): void; + + /** + * 设置价格与品种下单量的小数位精度, 设置后会自动截断 + * + * exchange.SetPrecision(2, 3); // 设置价格小数位精度为2位, 品种下单量小数位精度为3位 + * + * @param {number} PricePrecision + * @param {number} AmountPrecision + */ + SetPrecision(PricePrecision: number, AmountPrecision: number): void; + + /** + * 返回交易所操作的货币名称(string), 传统期货CTP返回的固定为STOCK + * + * @return {string} + */ + GetCurrency(): string; + + /** + * 返回交易所操作的基础货币名称(string), BTC_CNY就返回CNY, ETH_BTC就返回BTC + * + * @return {string} + */ + GetBaseCurrency(): string; + + /** + * 返回一个Ticker结构 + * + * @return {botvs.Ticker} + */ + GetTicker(): Ticker; + + /** + * 返回一个Depth结构 + * + * @return {botvs.Depth} + */ + GetDepth(): Depth; + + /** + * 返回一个Trade数组, 按时间从低到高的顺序, 只支持数字货币(BTC/LTC) + * + * @return {botvs.Trade[]} + */ + GetTrades(): Trade[]; + + /** + * 返回一个K线历史, K线周期在创建机器人时指定, Record数组结构 + * + * 不加参数, 默认返回添加机器人时时指量的K线周期, 但也可以自定义K线周期 + * 支持: PERIOD_M1 指1分钟, PERIOD_M5 指5分钟, PERIOD_M15 指15分钟, + * PERIOD_M30 指30分钟, PERIOD_H1 指1小时, PERIOD_D1 指一天 + * + * @param {number} Period + * @return {botvs.Record[]} + */ + GetRecords(Period?: VPeriod): Record[]; + + /** + * 返回一个Account结构, 如exchange.GetAccount(), 将返回主交易所账户信息 + * + * @return {botvs.Account} + */ + GetAccount(): Account; + + /** + * 下买单, Price为买单价格,Amount为数量, 返回一个订单ID + * + * 可以跟多余的参数做为附加消息显示到日志, 如exchange.Buy(1000,0.1, "OK", 123) + * 支持现货(火币/BitVC/OKCoin/OKCoin国际/OKCoin期货/BTCChina/BitYes)市价单, 市价单价格指定为-1 + * exchange.Buy(1000), 指买市价1000元的币, BTCChina例外exchange.Buy(0.3)指市价买0.3个币 + * + * @param {number} Price + * @param {number} Amount + * @param {*[]} args + * @return {string} - 订单ID + */ + Buy(Price: number, Amount: number, ...args: any[]): string; + + /** + * 跟Buy函数一样的调用方法和场景 {@see Exchange#Buy} + * + * @param {number} Price + * @param {number} Amount + * @return {string} + */ + Sell(Price: number, Amount: number): string; + + /** + * 获取所有未完成的订单, 返回一个Order数组结构 + * + * @return {botvs.Order[]} + */ + GetOrders(): Order[]; + + /** + * 根据订单号获取订单详情, 返回一个Order结构 + * + * @param {string} orderId + * @return {botvs.Order} + */ + GetOrder(orderId: string): Order; + + /** + * 根据订单号取消一个订单, 返回true或者false + * + * @param {string} orderId + * @return {boolean} + */ + CancelOrder(orderId: string): boolean; + + /** + * 不下单, 只记录交易信息, logType可为LOG_TYPE_BUY/LOG_TYPE_SELL/LOG_TYPE_CANCEL + * + * @param {VLogType} logType + * @param {string} orderId + * @param {number} price + * @param {number} amount + */ + Log(logType: VLogType, orderId: string, price: number, amount: number): void; + + /** + * 返回币最小交易数量 + * + * @return {number} + */ + GetMinStock(): number; + + /** + * 返回一笔订单要求的最小金额(价格*数量) + * + * Bitstamp要求5美元(程序会根据汇率自动转换为人民币), 其它没有限制 + * + * @return {number} + */ + GetMinPrice(): number; + + /** + * 返回一个Fee结构 + * + * @return {botvs.Fee} + */ + GetFee(): Fee; + + /** + * 返回最后一次REST API请求返回的原始内容(字符串), 用户可以用来自己解析扩展信息 + * + * 注: 模拟测试的话,会一直返回一个空字符串, 只在真实环境下有效 + * exchange.GetAccount(); + * var obj = JSON.parse(exchange.GetRawJSON()); + * + * 传统商品期货API获取更多信息 + * exchange.GetAccount(); + * Log(exchange.GetRawJSON());//在GetAccount成功后调用, 获取更详细的账户信息, 可以用JSON.parse解析 + * 也支持GetTicker, GetDepth后的exchange.GetRawJSON(), 以及GetPosition与GetOrders,GetOrder这三个调用后的详细反馈数据 + * + * @return {string} + */ + GetRawJSON(): string; + + /** + * 多线程异步支持函数, 可以把所有支持的函数的操作变成异步并发的.(只支持数字货币交易平台) + * + * Support: GetTicker, GetDepth, GetTrades, GetRecords, GetAccount, GetOrders, GetOrder, CancelOrder, Buy, + * Sell, GetPosition var a = exchange.Go("GetTicker"); // GetTicker 异步多线程执行 var b = + * exchange.Go("GetDepth"); var c = exchange.Go("Buy", 1000, 0.1); var d = exchange.Go("GetRecords", + * PERIOD_H1); + * + * // 上面四种操作是并发多线程异步执行, 不会耗时, 立即返回的 + * + * var ticker = a.wait(); // 调用wait方法等待返回异步获取ticker结果 + * var depth = b.wait(); // 返回深度, 如果获取失败也是有可能返回null的 + * var orderId = c.wait(1000); // 返回订单号, 限定1秒超时, 超时返回undefined, 此对像可以继续调用wait等待如果上次wait超时 + * // 注意: 判断undefiend要用typeof(xx) === "undefined", 因为null==undefined在JavaScript里是成立的 + * + * var records = d.wait(); // 等待K线结果 + * var ret = d.wait(); // 这里wait了一个已经wait过且结束的异步操作, 会返回null, 并记录出错信息. + * // Python与Javascript的区别, Python的wait返回两个参数, 第一个是异步的api返回的结果, 第二个表示是异步调用是否完成 + * ret, ok = d.wait() // ok是一定返回True的, 除非策略被停止 + * ret, ok = d.wait(100) // ok返回False, 如果等待超时, 或者wait了一个已经结束的实例 + * + * @param {keyof botvs.Exchange} Method + * @param Args + * @return {botvs.AsyncJob} + */ + Go(Method: keyof Exchange, ...Args: any[]): AsyncJob; + + /** + * 调用交易所其它功能接口 + * + * 支持所有数字货币交易所 + * exchange.IO("api", "cancel_borrow", "symbol=cny&borrow_id=123"); // no need api & sign + * Detail: {@link https://www.botvs.com/bbs-topic/146} + * + * // 只支持Websocket模式(huobi, okcoin.cn, BTCC支持)与商品期货CTP协议 + * + * exchange.IO("websocket"); // 切换行情通信协议到websocket(默认为rest), Ticker, + * Depth会切换为websocket协议来更新, 商品期货CTP无需切换 + * + * + * // 切换GetTicker, GetDepth数据更新模式 + * + * exchange.IO("mode", 0); // 立即返回模式, 如果当前还没有接收到交易所最新的行情数据推送, 就立即返回旧的行情数据, + * 如果有新的数据就返回新的数据 + * + * exchange.IO("mode", 1); // 缓存模式(默认模式), + * 如果当前还没有收到交易所最新的行情数据(同上一次api获取的数据比较), 就等待接收然后再返回, 如果调用该函数之前收到了最新的行情数据, + * 就立即返回最新的数据 + * + * exchange.IO("mode", 2); // 强制更新模式, 进入等待一直到接收到交易所下一次的最新推送数据后返回 + * + * + * + * // 如果想第一时间获取最新的行情可以切换到websocket后不Sleep的立即检测数据, GetTicker, GetDepth用缓存模式进行工作 + * + * exchange.IO("websocket"); + * + * while (true) { + * Log(exchange.GetTicker()); + * } + * + * 传统商品期货扩展的IO功能 + * exchange.IO("status"); // 返回true证明与CTP服务器行情与数据的两台服务器都连接正常 + * exchange.IO("instruments"); // 返回交易所所有的合约列表{合约名: 详情}字典形式, 只支持实盘 + * exchange.IO("products"); // 返回交易所所有的产品列表{产品名: 详情}字典形式, 只支持实盘 + * exchange.IO("subscribed"); // 返回已订阅行情的合约, 格式同上, 只支持实盘 + * exchange.IO("settlement"); // 结算单查询, 不加第二个参数默认返回之前一个交易日的, + * 加参数如"20170317"指返回20170317的结算单, 只支持实盘 + * exchange.IO("wait"); // 有任何品种更新行情信息时才返回, 可带第二个参数(毫秒数)指定超时, + * 超时返回-1, 正常返回事件接收的时间(nano级), 只支持实盘 + * exchange.IO("wait_instrument"); // 有任何品种更新行情信息时才返回, 可带第二个参数(毫秒数) + * 指定超时, 超时返回空字符串, 正常返回触发事件的品种名称, 只支持实盘 + * + * @param {"api" | "usd" | "cny" | "currency" | string} Api + * @param {string} ApiName + * @param {string} Args + * @return {T} + */ + IO(Api: 'api' | 'usd' | 'cny' | 'currency' | string, ApiName?: string, Args?: string): T; + + /** + * 获取当前持仓信息 + * + * 返回一个Position数组, (BitVC和OKCoin)可以传入一个参数, 指定要获取的合约类型 + * + * @return {botvs.Position[]} + */ + GetPosition(): Position[]; + + /** + * 设置杆杠大小 + * + * 设置Buy(多单)或者Sell(空单)的杆杠大小, MarginLevel有5, 10, 20 三个可选参数 + * 796支持5,10,20,50三个选项, BitVC的LTC不支持20倍杠杆, OKCoin支持10倍和20倍 + * 如: exchange.SetMarginLevel(5) + * + * @param {number} MarginLevel + */ + SetMarginLevel(MarginLevel: number): void; + + /** + * 设置Buy或者Sell下单类型 + * + * Direction可以取buy, closebuy, sell, closesell四个参数, 传统期货多出closebuy_today,与closesell_today, 指平今仓, + * 默认为closebuy/closesell为平咋仓 对于CTP传统期货, 可以设置第二个参数"1"或者"2"或者"3", 分别指"投机", "套利", "套保", + * 不设置默认为投机 股票只支持buy与closebuy, + * 因为股票只能买跟平仓 exchange.SetMarginLevel(5); exchange.SetDirection("buy"); exchange.Buy(1000, 2); + * exchange.SetMarginLevel(5); exchange.SetDirection("closebuy"); exchange.Sell(1000, 2); + * + * 期货交易中Buy, Sell, CancelOrder和现货交易的区别 + * Buy或Sell之前需要调用SetMarginLevel和SetDirection明确操作类型 + * 数字货币796的CancelOrder之前需要调用SetDirection明确订单类型 + * 如: + * exchange.SetDirection("sell"); + * exchange.Sell(1000, 2); + * 如: + * exchange.SetDirection("buy"); + * exchange.CancelOrder(123); + * + * 数字货币BitVC期货交易中Buy, Sell, GetOrder, SetMarginLevel与796的区别 + * GetOrder里面的Amount为订单总金额, DealAmount为订单完成的金额, 不是币的个数 + * 数字货币796的CancelOrder之前需要调用SetDirection明确订单类型 + * Buy或Sell第二个参数不是币的数量而是订单的总金额(100的倍数) + * SetMarginLevel LTC不支持20倍杠杆 + * 如: + * exchange.SetContractType("week"); exchange.SetDirection("sell"); + * exchange.Sell(1000, 100), 就是以1000元一个币的价格开100元的空头 + * + * 数字货币OKCoin期货交易中Buy, Sell, GetOrder, SetMarginLevel与796的区别 + * GetOrder里面的Amount为合约数(一份合约为10$), DealAmount为订单完成的合约数, 不是币的个数 + * Buy或Sell第二个参数不是币的数量而是合约的份数(整数且大于0) + * SetMarginLevel 只支持10倍和20倍的杠杆 + * 如: 以1000元一个币的价格做空一份合约(10$的LTC或者100$的BTC): + * exchange.SetContractType("this_week"); + * exchange.SetDirection("sell"); + * exchange.Sell(1000, 1); + * + * @param {"buy" | "closebuy" | "sell" | "closesell" | "closebuy_today" | "closesell_today"} Direction + * @constructor + */ + SetDirection(Direction: 'buy' | 'closebuy' | 'sell' | 'closesell' | 'closebuy_today' | 'closesell_today'): void; + + /** + * 设置合约类型 + * + * 传统的CTP期货的ContractType就是指的合约ID, 如SetContractType("au1506") 返回合约的详细信息, 如最少一次买多少, 手续费, + * 交割时间等, + * 主力连续合约为代码为000如MA000, 只支持回测, 不支持实盘 股票合约格式为 股票代码.(SH/SZ), SH指上交所, SZ指深交所, + * 如000001.SZ就是指深交所的平安银行 商品期货与股票取消订阅合约, + * 在合约名前加上"-"前缀重新调用即可, 如SetContractType("-au1506"); 成功返回true 数字货币796支持: "week", "weekcny", + * 默认为子账户A, 要指定子账户是A还是B, + * 在合约后加"@A"或"@B", 如: "day@A" 为日合约A子账户 BitVC有week和quarter和next_week三个可选参数, OKCoin期货有this_week, + * next_week, quarter三个参数 exchange.SetContractType("week"); + * + * @param {string} ContractType + */ + SetContractType(ContractType: string): void; + } + } + + namespace TA { + /** + * 指数平滑异同平均线 + * + * MACD(数据, 快周期, 慢周期, 信号周期), 默认参数为(12, 26, 9), 返回二维数组, 分别是[DIF, DEA, MACD] + * + * @param {botvs.Record[]} Records + * @param {number} LongPeriod + * @param {number} ShortPeriod + * @param {number} SignalPeriod + * @return {[number[] , number[] , number[]]} + */ + function MACD( + Records: botvs.Record[], + LongPeriod?: number, + ShortPeriod?: number, + SignalPeriod?: number, + ): [number[], number[], number[]]; + + /** + * 随机指标 + * + * KDJ(数据, 周期1, 周期2, 周期3), 默认参数为(9, 3, 3), 返回二维数组, 分别是[K, D, J] + * + * @param {botvs.Record[]} Records + * @param {number} FirstPeriod + * @param {number} SecondPeriod + * @param {number} ThirdPeriod + * @return {[number[] , number[] , number[]]} + */ + function KDJ( + Records: botvs.Record[], + FirstPeriod?: number, + SecondPeriod?: number, + ThirdPeriod?: number, + ): [number[], number[], number[]]; + + /** + * 强弱指标 + * + * RSI(数据, 周期), 默认参数为14, 返回一个一维数组 + * + * @param {botvs.Record[]} Records + * @param {number} Period + * @return {number[]} + */ + function RSI(Records: botvs.Record[], Period?: number): number[]; + + /** + * 平均真实波幅 + * + * ATR(数据, 周期), 默认参数为14, 返回一个一维数组 + * + * @param {botvs.Record[]} Records + * @param {number} Period + * @return {number[]} + */ + function ATR(Records: botvs.Record[], Period?: number): number[]; + + /** + * 能量潮 + * + * OBV(数据), 返回一个一维数组 + * + * @param {botvs.Record[]} Records + * @return {[number[] , number[]]} + */ + function OBV(Records: botvs.Record[]): [number[], number[]]; + + /** + * 移动平均线 + * + * MA(数据, 周期), 默认参数为9, 返回一个一维数组 + * + * @param {botvs.Record[]} Records + * @param {number} Period + * @return {number[]} + */ + function MA(Records: botvs.Record[], Period?: number): number[]; + + /** + * 指数平均数指标 + * EMA(数据, 周期), 默认参数为9, 返回一个一维数组 + * + * @param {botvs.Record[]} Records + * @param {number} Period + * @return {number[]} + */ + function EMA(Records: botvs.Record[], Period?: number): number[]; + + /** + * Alligator Indicator + * + * Alligator(数据, 下颚周期,牙齿周期,上唇周期), 鳄鱼线指标, 默认参数为(13,8,5) 返回一个二维数组[下颚,牙齿,上唇] + * + * @param {botvs.Record[]} Records + * @param {number} JawPeriod + * @param {number} TeethPeriod + * @param {number} LibsPeriod + * @return {[number[] , number[] , number[]]} + */ + function Alligator( + Records: botvs.Record[], + JawPeriod?: number, + TeethPeriod?: number, + LibsPeriod?: number, + ): [number[], number[], number[]]; + + /** + * Chaikin Money Flow + * + * CMF(数据, 周期), 默认周期参数为20, 返回一个一维数组 + * + * @param {botvs.Record[]} Records + * @param {number} Period + * @return {number[]} + */ + function CMF(Records: botvs.Record[], Period?: number): number[]; + + /** + * 周期最高价 + * + * Highest(数据, 周期, 属性), 返回最近周期内的最大值(不包含当前Bar), + * 如TA.Highest(records, 30, 'High'), 如果周期为0指所有, 如属性不指定则视数据为普通数组 + * + * @param {botvs.Record[]} Records + * @param {number} Period + * @param {keyof botvs.Record} Property + * @return {number} + * @constructor + */ + function Highest(Records: botvs.Record[], Period?: number, Property?: keyof botvs.Record): number; + + /** + * 周期最低价 + * + * Lowest(数据, 周期, 属性), 同上, 求最小值 + * + * @param {botvs.Record[]} Records + * @param {number} Period + * @param {keyof botvs.Record} Property + * @return {number} + */ + function Lowest(Records: botvs.Record[], Period?: number, Property?: keyof botvs.Record): number; + } + + namespace talib { + /** + * 查询指标调用格式 + * + * Log(talib.help('MACD')); // 在回测环境下调用 + * + * @param {string} Func + * @return {string} + */ + function help(Func: string): string; + + /** + * Vector Trigonometric ACos (反余弦函数) + * + * ACOS(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function ACOS(Records: botvs.Record[] | number[]): number[]; + + /** + * Chaikin A/D Line (线随机指标) + * + * AD(Records[High,Low,Close,Volume]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function AD(Records: botvs.Record[]): number[]; + /** + * Chaikin A/D Line (线随机指标) + * + * AD(Records[High,Low,Close,Volume]) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number[]} Volume + * @return {number[]} + */ + function AD(High: number[], Low: number[], Close: number[], Volume: number[]): number[]; + + /** + * Chaikin A/D Oscillator (佳庆指标) + * + * ADOSC(Records[High,Low,Close,Volume],Fast Period = 3,Slow Period = 10) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=3} FastPeriod + * @param {number=10} SlowPeriod + * @return {number[]} + */ + function ADOSC(Records: botvs.Record[], FastPeriod: number, SlowPeriod: number): number[]; + /** + * Chaikin A/D Oscillator (佳庆指标) + * + * ADOSC(Records[High,Low,Close,Volume],Fast Period = 3,Slow Period = 10) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number[]} Volume + * @param {number=3} FastPeriod + * @param {number=10} SlowPeriod + * @return {number[]} + */ + function ADOSC( + High: number[], + Low: number[], + Close: number[], + Volume: number[], + FastPeriod: number, + SlowPeriod: number, + ): number[]; + + /** + * Average Directional Movement Index (平均趋向指数) + * + * ADX(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function ADX(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Average Directional Movement Index (平均趋向指数) + * + * ADX(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function ADX(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Average Directional Movement Index Rating (评估指数) + * + * ADXR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function ADXR(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Average Directional Movement Index Rating (评估指数) + * + * ADXR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function ADXR(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Absolute Price Oscillator (绝对价格振荡指数) + * + * APO(Records[Close],Fast Period = 12,Slow Period = 26,MA Type = 0) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=12} FastPeriod + * @param {number=26} SlowPeriod + * @param {number=0} MAType + * @return {number[]} + */ + function APO( + Records: botvs.Record[] | number[], + FastPeriod: number, + SlowPeriod: number, + MAType: number, + ): number[]; + + /** + * Aroon (阿隆指标) + * + * AROON(Records[High,Low],Time Period = 14) = [Array(outAroonDown),Array(outAroonUp)] + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {[number[], number[]]} + */ + function AROON(Records: botvs.Record[], TimePeriod: number): [number[], number[]]; + /** + * Aroon (阿隆指标) + * + * AROON(Records[High,Low],Time Period = 14) = [Array(outAroonDown),Array(outAroonUp)] + * + * @param {number[]} High + * @param {number[]} Low + * @param {number=14} TimePeriod + * @return {[number[], number[]]} + */ + function AROON(High: number[], Low: number[], TimePeriod: number): [number[], number[]]; + + /** + * Aroon Oscillator (阿隆震荡线) + * + * AROONOSC(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function AROONOSC(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Aroon Oscillator (阿隆震荡线) + * + * AROONOSC(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number=14} TimePeriod + * @return {number[]} + */ + function AROONOSC(High: number[], Low: number[], TimePeriod: number): number[]; + + /** + * Vector Trigonometric ASin (反正弦函数) + * + * ASIN(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function ASIN(Records: botvs.Record[] | number[]): number[]; + + /** + * Vector Trigonometric ATan (反正切函数) + * + * ATAN(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function ATAN(Records: botvs.Record[] | number[]): number[]; + + /** + * Average True Range (平均真实波幅) + * + * ATR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function ATR(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Average True Range (平均真实波幅) + * + * ATR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function ATR(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Average Price (平均价格) + * + * AVGPRICE(Records[Open,High,Low,Close]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function AVGPRICE(Records: botvs.Record[]): number[]; + /** + * Average Price (平均价格) + * + * AVGPRICE(Records[Open,High,Low,Close]) = Array(outReal) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function AVGPRICE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Bollinger Bands (布林带) + * + * BBANDS(Records[Close],Time Period = 5,Deviations up = 2,Deviations down = 2,MA Type = 0) = + * [Array(outRealUpperBand),Array(outRealMiddleBand),Array(outRealLowerBand)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=5} TimePeriod + * @param {number=2} Deviationsup + * @param {number=2} Deviationsdown + * @param {number=0} MAType + * @return {[number[], number[], number[]]} + */ + function BBANDS( + Records: botvs.Record[] | number[], + TimePeriod: number, + Deviationsup: number, + Deviationsdown: number, + MAType: number, + ): [number[], number[], number[]]; + + /** + * Balance Of Power (均势指标) + * + * BOP(Records[Open,High,Low,Close]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function BOP(Records: botvs.Record[]): number[]; + /** + * Balance Of Power (均势指标) + * + * BOP(Records[Open,High,Low,Close]) = Array(outReal) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function BOP(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Commodity Channel Index (顺势指标) + * + * CCI(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function CCI(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Commodity Channel Index (顺势指标) + * + * CCI(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function CCI(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Two Crows (K线图--两只乌鸦) + * + * CDL2CROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDL2CROWS(Records: botvs.Record[]): number[]; + /** + * Two Crows (K线图--两只乌鸦) + * + * CDL2CROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDL2CROWS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Three Black Crows (K线图--3只黑乌鸦) + * + * CDL3BLACKCROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDL3BLACKCROWS(Records: botvs.Record[]): number[]; + /** + * Three Black Crows (K线图--3只黑乌鸦) + * + * CDL3BLACKCROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDL3BLACKCROWS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Three Inside Up/Down (K线图:3内上下震荡) + * + * CDL3INSIDE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDL3INSIDE(Records: botvs.Record[]): number[]; + /** + * Three Inside Up/Down (K线图:3内上下震荡) + * + * CDL3INSIDE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDL3INSIDE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Three-Line Strike (K线图:3线震荡) + * + * CDL3LINESTRIKE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDL3LINESTRIKE(Records: botvs.Record[]): number[]; + /** + * Three-Line Strike (K线图:3线震荡) + * + * CDL3LINESTRIKE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDL3LINESTRIKE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Three Outside Up/Down (K线图:3外下震荡) + * + * CDL3OUTSIDE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDL3OUTSIDE(Records: botvs.Record[]): number[]; + /** + * Three Outside Up/Down (K线图:3外下震荡) + * + * CDL3OUTSIDE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDL3OUTSIDE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Three Stars In The South (K线图:南方三星) + * + * CDL3STARSINSOUTH(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDL3STARSINSOUTH(Records: botvs.Record[]): number[]; + /** + * Three Stars In The South (K线图:南方三星) + * + * CDL3STARSINSOUTH(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDL3STARSINSOUTH(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Three Advancing White Soldiers (K线图:三白兵) + * + * CDL3WHITESOLDIERS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDL3WHITESOLDIERS(Records: botvs.Record[]): number[]; + /** + * Three Advancing White Soldiers (K线图:三白兵) + * + * CDL3WHITESOLDIERS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDL3WHITESOLDIERS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Abandoned Baby (K线图:弃婴) + * + * CDLABANDONEDBABY(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLABANDONEDBABY(Records: botvs.Record[], Penetration: number): number[]; + /** + * Abandoned Baby (K线图:弃婴) + * + * CDLABANDONEDBABY(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLABANDONEDBABY( + Open: number[], + High: number[], + Low: number[], + Close: number[], + Penetration: number, + ): number[]; + + /** + * Advance Block (K线图:推进) + * + * CDLADVANCEBLOCK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLADVANCEBLOCK(Records: botvs.Record[]): number[]; + /** + * Advance Block (K线图:推进) + * + * CDLADVANCEBLOCK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLADVANCEBLOCK(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Belt-hold (K线图:带住) + * + * CDLBELTHOLD(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLBELTHOLD(Records: botvs.Record[]): number[]; + /** + * Belt-hold (K线图:带住) + * + * CDLBELTHOLD(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLBELTHOLD(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Breakaway (K线图:分离) + * + * CDLBREAKAWAY(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLBREAKAWAY(Records: botvs.Record[]): number[]; + /** + * Breakaway (K线图:分离) + * + * CDLBREAKAWAY(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLBREAKAWAY(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Closing Marubozu (K线图:收盘光头光脚) + * + * CDLCLOSINGMARUBOZU(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLCLOSINGMARUBOZU(Records: botvs.Record[]): number[]; + /** + * Closing Marubozu (K线图:收盘光头光脚) + * + * CDLCLOSINGMARUBOZU(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLCLOSINGMARUBOZU(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Concealing Baby Swallow (K线图:藏婴吞没形态) + * + * CDLCONCEALBABYSWALL(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLCONCEALBABYSWALL(Records: botvs.Record[]): number[]; + /** + * Concealing Baby Swallow (K线图:藏婴吞没形态) + * + * CDLCONCEALBABYSWALL(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLCONCEALBABYSWALL(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Counterattack (K线图:反击) + * + * CDLCOUNTERATTACK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLCOUNTERATTACK(Records: botvs.Record[]): number[]; + /** + * Counterattack (K线图:反击) + * + * CDLCOUNTERATTACK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLCOUNTERATTACK(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Dark Cloud Cover (K线图:乌云盖) + * + * CDLDARKCLOUDCOVER(Records[Open,High,Low,Close],Penetration = 0.5) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @param {number=0.5} Penetration + * @return {number[]} + */ + function CDLDARKCLOUDCOVER(Records: botvs.Record[], Penetration: number): number[]; + /** + * Dark Cloud Cover (K线图:乌云盖) + * + * CDLDARKCLOUDCOVER(Records[Open,High,Low,Close],Penetration = 0.5) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=0.5} Penetration + * @return {number[]} + */ + function CDLDARKCLOUDCOVER( + Open: number[], + High: number[], + Low: number[], + Close: number[], + Penetration: number, + ): number[]; + + /** + * Doji (K线图:十字星 ) + * + * CDLDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLDOJI(Records: botvs.Record[]): number[]; + /** + * Doji (K线图:十字星 ) + * + * CDLDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLDOJI(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Doji Star (K线图:十字星) + * + * CDLDOJISTAR(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLDOJISTAR(Records: botvs.Record[]): number[]; + /** + * Doji Star (K线图:十字星) + * + * CDLDOJISTAR(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLDOJISTAR(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Dragonfly Doji (K线图:蜻蜓十字星) + * + * CDLDRAGONFLYDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLDRAGONFLYDOJI(Records: botvs.Record[]): number[]; + /** + * Dragonfly Doji (K线图:蜻蜓十字星) + * + * CDLDRAGONFLYDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLDRAGONFLYDOJI(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Engulfing Pattern (K线图:吞没) + * + * CDLENGULFING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLENGULFING(Records: botvs.Record[]): number[]; + /** + * Engulfing Pattern (K线图:吞没) + * + * CDLENGULFING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLENGULFING(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Evening Doji Star (K线图:黄昏十字星) + * + * CDLEVENINGDOJISTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLEVENINGDOJISTAR(Records: botvs.Record[], Penetration: number): number[]; + /** + * Evening Doji Star (K线图:黄昏十字星) + * + * CDLEVENINGDOJISTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLEVENINGDOJISTAR( + Open: number[], + High: number[], + Low: number[], + Close: number[], + Penetration: number, + ): number[]; + + /** + * Evening Star (K线图:黄昏之星) + * + * CDLEVENINGSTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLEVENINGSTAR(Records: botvs.Record[], Penetration: number): number[]; + /** + * Evening Star (K线图:黄昏之星) + * + * CDLEVENINGSTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLEVENINGSTAR( + Open: number[], + High: number[], + Low: number[], + Close: number[], + Penetration: number, + ): number[]; + + /** + * Up/Down-gap side-by-side white lines (K线图:上/下间隙并排的白色线条) + * + * CDLGAPSIDESIDEWHITE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLGAPSIDESIDEWHITE(Records: botvs.Record[]): number[]; + /** + * Up/Down-gap side-by-side white lines (K线图:上/下间隙并排的白色线条) + * + * CDLGAPSIDESIDEWHITE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLGAPSIDESIDEWHITE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Gravestone Doji (K线图:墓碑十字线) + * + * CDLGRAVESTONEDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLGRAVESTONEDOJI(Records: botvs.Record[]): number[]; + /** + * Gravestone Doji (K线图:墓碑十字线) + * + * CDLGRAVESTONEDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLGRAVESTONEDOJI(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Hammer (K线图:锤) + * + * CDLHAMMER(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHAMMER(Records: botvs.Record[]): number[]; + /** + * Hammer (K线图:锤) + * + * CDLHAMMER(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHAMMER(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Hanging Man (K线图:吊人) + * + * CDLHANGINGMAN(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHANGINGMAN(Records: botvs.Record[]): number[]; + /** + * Hanging Man (K线图:吊人) + * + * CDLHANGINGMAN(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHANGINGMAN(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Harami Pattern (K线图:阴阳线) + * + * CDLHARAMI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHARAMI(Records: botvs.Record[]): number[]; + /** + * Harami Pattern (K线图:阴阳线) + * + * CDLHARAMI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHARAMI(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Harami Cross Pattern (K线图:交叉阴阳线) + * + * CDLHARAMICROSS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHARAMICROSS(Records: botvs.Record[]): number[]; + /** + * Harami Cross Pattern (K线图:交叉阴阳线) + * + * CDLHARAMICROSS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHARAMICROSS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * High-Wave Candle (K线图:长脚十字线 ) + * + * CDLHIGHWAVE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHIGHWAVE(Records: botvs.Record[]): number[]; + /** + * High-Wave Candle (K线图:长脚十字线 ) + * + * CDLHIGHWAVE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHIGHWAVE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Hikkake Pattern (K线图:陷阱) + * + * CDLHIKKAKE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHIKKAKE(Records: botvs.Record[]): number[]; + /** + * Hikkake Pattern (K线图:陷阱) + * + * CDLHIKKAKE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHIKKAKE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Modified Hikkake Pattern (K线图:改良的陷阱) + * + * CDLHIKKAKEMOD(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHIKKAKEMOD(Records: botvs.Record[]): number[]; + /** + * Modified Hikkake Pattern (K线图:改良的陷阱) + * + * CDLHIKKAKEMOD(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHIKKAKEMOD(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Homing Pigeon (K线图:信鸽) + * + * CDLHOMINGPIGEON(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLHOMINGPIGEON(Records: botvs.Record[]): number[]; + /** + * Homing Pigeon (K线图:信鸽) + * + * CDLHOMINGPIGEON(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLHOMINGPIGEON(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Identical Three Crows (K线图:相同的三只乌鸦) + * + * CDLIDENTICAL3CROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLIDENTICAL3CROWS(Records: botvs.Record[]): number[]; + /** + * Identical Three Crows (K线图:相同的三只乌鸦) + * + * CDLIDENTICAL3CROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLIDENTICAL3CROWS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * In-Neck Pattern (K线图:颈纹) + * + * CDLINNECK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLINNECK(Records: botvs.Record[]): number[]; + /** + * In-Neck Pattern (K线图:颈纹) + * + * CDLINNECK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLINNECK(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Inverted Hammer (K线图:倒锤) + * + * CDLINVERTEDHAMMER(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLINVERTEDHAMMER(Records: botvs.Record[]): number[]; + /** + * Inverted Hammer (K线图:倒锤) + * + * CDLINVERTEDHAMMER(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLINVERTEDHAMMER(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Kicking (K线图:踢) + * + * CDLKICKING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLKICKING(Records: botvs.Record[]): number[]; + /** + * Kicking (K线图:踢) + * + * CDLKICKING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLKICKING(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Kicking - bull/bear determined by the longer marubozu (K线图:踢牛/踢熊) + * + * CDLKICKINGBYLENGTH(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLKICKINGBYLENGTH(Records: botvs.Record[]): number[]; + /** + * Kicking - bull/bear determined by the longer marubozu (K线图:踢牛/踢熊) + * + * CDLKICKINGBYLENGTH(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLKICKINGBYLENGTH(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Ladder Bottom (K线图:梯底) + * + * CDLLADDERBOTTOM(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLLADDERBOTTOM(Records: botvs.Record[]): number[]; + /** + * Ladder Bottom (K线图:梯底) + * + * CDLLADDERBOTTOM(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLLADDERBOTTOM(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Long Legged Doji (K线图:长腿十字线) + * + * CDLLONGLEGGEDDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLLONGLEGGEDDOJI(Records: botvs.Record[]): number[]; + /** + * Long Legged Doji (K线图:长腿十字线) + * + * CDLLONGLEGGEDDOJI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLLONGLEGGEDDOJI(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Long Line Candle (K线图:长线) + * + * CDLLONGLINE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLLONGLINE(Records: botvs.Record[]): number[]; + /** + * Long Line Candle (K线图:长线) + * + * CDLLONGLINE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLLONGLINE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Marubozu (K线图:光头光脚 ) + * + * CDLMARUBOZU(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLMARUBOZU(Records: botvs.Record[]): number[]; + /** + * Marubozu (K线图:光头光脚 ) + * + * CDLMARUBOZU(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLMARUBOZU(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Matching Low (K线图:匹配低) + * + * CDLMATCHINGLOW(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLMATCHINGLOW(Records: botvs.Record[]): number[]; + /** + * Matching Low (K线图:匹配低) + * + * CDLMATCHINGLOW(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLMATCHINGLOW(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Mat Hold (K线图:垫住) + * + * CDLMATHOLD(Records[Open,High,Low,Close],Penetration = 0.5) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @param {number=0.5} Penetration + * @return {number[]} + */ + function CDLMATHOLD(Records: botvs.Record[], Penetration: number): number[]; + /** + * Mat Hold (K线图:垫住) + * + * CDLMATHOLD(Records[Open,High,Low,Close],Penetration = 0.5) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=0.5} Penetration + * @return {number[]} + */ + function CDLMATHOLD( + Open: number[], + High: number[], + Low: number[], + Close: number[], + Penetration: number, + ): number[]; + + /** + * Morning Doji Star (K线图:早晨十字星) + * + * CDLMORNINGDOJISTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLMORNINGDOJISTAR(Records: botvs.Record[], Penetration: number): number[]; + /** + * Morning Doji Star (K线图:早晨十字星) + * + * CDLMORNINGDOJISTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLMORNINGDOJISTAR( + Open: number[], + High: number[], + Low: number[], + Close: number[], + Penetration: number, + ): number[]; + + /** + * Morning Star (K线图:晨星) + * + * CDLMORNINGSTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLMORNINGSTAR(Records: botvs.Record[], Penetration: number): number[]; + /** + * Morning Star (K线图:晨星) + * + * CDLMORNINGSTAR(Records[Open,High,Low,Close],Penetration = 0.3) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=0.3} Penetration + * @return {number[]} + */ + function CDLMORNINGSTAR( + Open: number[], + High: number[], + Low: number[], + Close: number[], + Penetration: number, + ): number[]; + + /** + * On-Neck Pattern (K线图:颈型) + * + * CDLONNECK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLONNECK(Records: botvs.Record[]): number[]; + /** + * On-Neck Pattern (K线图:颈型) + * + * CDLONNECK(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLONNECK(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Piercing Pattern (K线图:穿孔模式) + * + * CDLPIERCING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLPIERCING(Records: botvs.Record[]): number[]; + /** + * Piercing Pattern (K线图:穿孔模式) + * + * CDLPIERCING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLPIERCING(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Rickshaw Man (K线图:车夫) + * + * CDLRICKSHAWMAN(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLRICKSHAWMAN(Records: botvs.Record[]): number[]; + /** + * Rickshaw Man (K线图:车夫) + * + * CDLRICKSHAWMAN(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLRICKSHAWMAN(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Rising/Falling Three Methods (K线图:上升/下降三法) + * + * CDLRISEFALL3METHODS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLRISEFALL3METHODS(Records: botvs.Record[]): number[]; + /** + * Rising/Falling Three Methods (K线图:上升/下降三法) + * + * CDLRISEFALL3METHODS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLRISEFALL3METHODS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Separating Lines (K线图:分割线) + * + * CDLSEPARATINGLINES(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLSEPARATINGLINES(Records: botvs.Record[]): number[]; + /** + * Separating Lines (K线图:分割线) + * + * CDLSEPARATINGLINES(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLSEPARATINGLINES(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Shooting Star (K线图:流星) + * + * CDLSHOOTINGSTAR(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLSHOOTINGSTAR(Records: botvs.Record[]): number[]; + /** + * Shooting Star (K线图:流星) + * + * CDLSHOOTINGSTAR(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLSHOOTINGSTAR(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Short Line Candle (K线图:短线) + * + * CDLSHORTLINE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLSHORTLINE(Records: botvs.Record[]): number[]; + /** + * Short Line Candle (K线图:短线) + * + * CDLSHORTLINE(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLSHORTLINE(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Spinning Top (K线图:陀螺) + * + * CDLSPINNINGTOP(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLSPINNINGTOP(Records: botvs.Record[]): number[]; + /** + * Spinning Top (K线图:陀螺) + * + * CDLSPINNINGTOP(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLSPINNINGTOP(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Stalled Pattern (K线图:停滞模式) + * + * CDLSTALLEDPATTERN(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLSTALLEDPATTERN(Records: botvs.Record[]): number[]; + /** + * Stalled Pattern (K线图:停滞模式) + * + * CDLSTALLEDPATTERN(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLSTALLEDPATTERN(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Stick Sandwich (K线图:棍子三明治) + * + * CDLSTICKSANDWICH(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLSTICKSANDWICH(Records: botvs.Record[]): number[]; + /** + * Stick Sandwich (K线图:棍子三明治) + * + * CDLSTICKSANDWICH(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLSTICKSANDWICH(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Takuri (Dragonfly Doji with very long lower shadow) (K线图:托里) + * + * CDLTAKURI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLTAKURI(Records: botvs.Record[]): number[]; + /** + * Takuri (Dragonfly Doji with very long lower shadow) (K线图:托里) + * + * CDLTAKURI(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLTAKURI(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Tasuki Gap (K线图:翼隙) + * + * CDLTASUKIGAP(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLTASUKIGAP(Records: botvs.Record[]): number[]; + /** + * Tasuki Gap (K线图:翼隙) + * + * CDLTASUKIGAP(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLTASUKIGAP(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Thrusting Pattern (K线图:推模式) + * + * CDLTHRUSTING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLTHRUSTING(Records: botvs.Record[]): number[]; + /** + * Thrusting Pattern (K线图:推模式) + * + * CDLTHRUSTING(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLTHRUSTING(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Tristar Pattern (K线图:三星模式) + * + * CDLTRISTAR(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLTRISTAR(Records: botvs.Record[]): number[]; + /** + * Tristar Pattern (K线图:三星模式) + * + * CDLTRISTAR(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLTRISTAR(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Unique 3 River (K线图:独特的3河) + * + * CDLUNIQUE3RIVER(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLUNIQUE3RIVER(Records: botvs.Record[]): number[]; + /** + * Unique 3 River (K线图:独特的3河) + * + * CDLUNIQUE3RIVER(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLUNIQUE3RIVER(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Upside Gap Two Crows (K线图:双飞乌鸦) + * + * CDLUPSIDEGAP2CROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLUPSIDEGAP2CROWS(Records: botvs.Record[]): number[]; + /** + * Upside Gap Two Crows (K线图:双飞乌鸦) + * + * CDLUPSIDEGAP2CROWS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLUPSIDEGAP2CROWS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Upside/Downside Gap Three Methods (K线图:上行/下行缺口三方法) + * + * CDLXSIDEGAP3METHODS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function CDLXSIDEGAP3METHODS(Records: botvs.Record[]): number[]; + /** + * Upside/Downside Gap Three Methods (K线图:上行/下行缺口三方法) + * + * CDLXSIDEGAP3METHODS(Records[Open,High,Low,Close]) = Array(outInteger) + * + * @param {number[]} Open + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function CDLXSIDEGAP3METHODS(Open: number[], High: number[], Low: number[], Close: number[]): number[]; + + /** + * Vector Ceil (取整函数) + * + * CEIL(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function CEIL(Records: botvs.Record[] | number[]): number[]; + + /** + * Chande Momentum Oscillator (钱德动量摆动指标) + * + * CMO(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function CMO(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Vector Trigonometric Cos (余弦函数) + * + * COS(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function COS(Records: botvs.Record[] | number[]): number[]; + + /** + * Vector Trigonometric Cosh (双曲余弦值) + * + * COSH(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function COSH(Records: botvs.Record[] | number[]): number[]; + + /** + * Double Exponential Moving Average (双指数移动平均线) + * + * DEMA(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function DEMA(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Directional Movement Index (动向指数) + * + * DX(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function DX(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Directional Movement Index (动向指数) + * + * DX(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function DX(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Exponential Moving Average (指数移动平均线) + * + * EMA(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function EMA(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Vector Arithmetic Exp (指数函数) + * + * EXP(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function EXP(Records: botvs.Record[] | number[]): number[]; + + /** + * Vector Floor (向下取整) + * + * FLOOR(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function FLOOR(Records: botvs.Record[] | number[]): number[]; + + /** + * Hilbert Transform - Dominant Cycle Period (希尔伯特变换, 主周期) + * + * HT_DCPERIOD(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function HT_DCPERIOD(Records: botvs.Record[] | number[]): number[]; + + /** + * Hilbert Transform - Dominant Cycle Phase (希尔伯特变换,主阶段) + * + * HT_DCPHASE(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function HT_DCPHASE(Records: botvs.Record[] | number[]): number[]; + + /** + * Hilbert Transform - Phasor Components (希尔伯特变换,相成分) + * + * HT_PHASOR(Records[Close]) = [Array(outInPhase),Array(outQuadrature)] + * + * @param {botvs.Record[]|number[]} Records + * @return {[number[], number[]]} + */ + function HT_PHASOR(Records: botvs.Record[] | number[]): [number[], number[]]; + + /** + * Hilbert Transform - SineWave (希尔伯特变换,正弦波) + * + * HT_SINE(Records[Close]) = [Array(outSine),Array(outLeadSine)] + * + * @param {botvs.Record[]|number[]} Records + * @return {[number[], number[]]} + */ + function HT_SINE(Records: botvs.Record[] | number[]): [number[], number[]]; + + /** + * Hilbert Transform - Instantaneous Trendline (希尔伯特变换,瞬时趋势) + * + * HT_TRENDLINE(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function HT_TRENDLINE(Records: botvs.Record[] | number[]): number[]; + + /** + * Hilbert Transform - Trend vs Cycle Mode (希尔伯特变换-趋势与周期模式) + * + * HT_TRENDMODE(Records[Close]) = Array(outInteger) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function HT_TRENDMODE(Records: botvs.Record[] | number[]): number[]; + + /** + * Kaufman Adaptive Moving Average (适应性移动平均线) + * + * KAMA(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function KAMA(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Linear Regression (线性回归) + * + * LINEARREG(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function LINEARREG(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Linear Regression Angle (线性回归的角度) + * + * LINEARREG_ANGLE(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function LINEARREG_ANGLE(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Linear Regression Intercept (线性回归截距) + * + * LINEARREG_INTERCEPT(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function LINEARREG_INTERCEPT(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Linear Regression Slope (线性回归斜率) + * + * LINEARREG_SLOPE(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function LINEARREG_SLOPE(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Vector Log Natural (自然对数) + * + * LN(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function LN(Records: botvs.Record[] | number[]): number[]; + + /** + * Vector Log10 (对数函数) + * + * LOG10(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function LOG10(Records: botvs.Record[] | number[]): number[]; + + /** + * Moving average (移动平均线) + * + * MA(Records[Close],Time Period = 30,MA Type = 0) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @param {number=0} MAType + * @return {number[]} + */ + function MA(Records: botvs.Record[] | number[], TimePeriod: number, MAType: number): number[]; + + /** + * Moving Average Convergence/Divergence (指数平滑移动平均线) + * + * MACD(Records[Close],Fast Period = 12,Slow Period = 26,Signal Period = 9) = + * [Array(outMACD),Array(outMACDSignal),Array(outMACDHist)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=12} FastPeriod + * @param {number=26} SlowPeriod + * @param {number=9} SignalPeriod + * @return {[number[], number[], number[]]} + */ + function MACD( + Records: botvs.Record[] | number[], + FastPeriod: number, + SlowPeriod: number, + SignalPeriod: number, + ): [number[], number[], number[]]; + + /** + * MACD with controllable MA type (MA型可控 MACD) + * + * MACDEXT(Records[Close],Fast Period = 12,Fast MA = 0,Slow Period = 26,Slow MA = 0,Signal Period = 9,Signal MA + * = + * 0) = [Array(outMACD),Array(outMACDSignal),Array(outMACDHist)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=12} FastPeriod + * @param {number=0} FastMA + * @param {number=26} SlowPeriod + * @param {number=0} SlowMA + * @param {number=9} SignalPeriod + * @param {number=0} SignalMA + * @return {[number[], number[], number[]]} + */ + function MACDEXT( + Records: botvs.Record[] | number[], + FastPeriod: number, + FastMA: number, + SlowPeriod: number, + SlowMA: number, + SignalPeriod: number, + SignalMA: number, + ): [number[], number[], number[]]; + + /** + * Moving Average Convergence/Divergence Fix 12/26 (移动平均收敛/发散修复12/26) + * + * MACDFIX(Records[Close],Signal Period = 9) = [Array(outMACD),Array(outMACDSignal),Array(outMACDHist)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=9} SignalPeriod + * @return {[number[], number[], number[]]} + */ + function MACDFIX(Records: botvs.Record[] | number[], SignalPeriod: number): [number[], number[], number[]]; + + /** + * MESA Adaptive Moving Average (MESA 移动平均线) + * + * MAMA(Records[Close],Fast Limit = 0.5,Slow Limit = 0.05) = [Array(outMAMA),Array(outFAMA)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=0.5} FastLimit + * @param {number=0.05} SlowLimit + * @return {[number[], number[]]} + */ + function MAMA(Records: botvs.Record[] | number[], FastLimit: number, SlowLimit: number): [number[], number[]]; + + /** + * Highest value over a specified period (最大值) + * + * MAX(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function MAX(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Index of highest value over a specified period (最大值索引) + * + * MAXINDEX(Records[Close],Time Period = 30) = Array(outInteger) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function MAXINDEX(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Median Price (中位数价格) + * + * MEDPRICE(Records[High,Low]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function MEDPRICE(Records: botvs.Record[]): number[]; + /** + * Median Price (中位数价格) + * + * MEDPRICE(Records[High,Low]) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @return {number[]} + */ + function MEDPRICE(High: number[], Low: number[]): number[]; + + /** + * Money Flow Index (货币流量指数) + * + * MFI(Records[High,Low,Close,Volume],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MFI(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Money Flow Index (货币流量指数) + * + * MFI(Records[High,Low,Close,Volume],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number[]} Volume + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MFI(High: number[], Low: number[], Close: number[], Volume: number[], TimePeriod: number): number[]; + + /** + * MidPoint over period (中点) + * + * MIDPOINT(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MIDPOINT(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Midpoint Price over period (中点价格) + * + * MIDPRICE(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MIDPRICE(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Midpoint Price over period (中点价格) + * + * MIDPRICE(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MIDPRICE(High: number[], Low: number[], TimePeriod: number): number[]; + + /** + * Lowest value over a specified period (最小值) + * + * MIN(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function MIN(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Index of lowest value over a specified period (最小值索引) + * + * MININDEX(Records[Close],Time Period = 30) = Array(outInteger) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function MININDEX(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Lowest and highest values over a specified period (最小最大值) + * + * MINMAX(Records[Close],Time Period = 30) = [Array(outMin),Array(outMax)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {[number[], number[]]} + */ + function MINMAX(Records: botvs.Record[] | number[], TimePeriod: number): [number[], number[]]; + + /** + * Indexes of lowest and highest values over a specified period (最小最大值索引) + * + * MINMAXINDEX(Records[Close],Time Period = 30) = [Array(outMinIdx),Array(outMaxIdx)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {[number[], number[]]} + */ + function MINMAXINDEX(Records: botvs.Record[] | number[], TimePeriod: number): [number[], number[]]; + + /** + * Minus Directional Indicator (负向指标) + * + * MINUS_DI(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MINUS_DI(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Minus Directional Indicator (负向指标) + * + * MINUS_DI(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MINUS_DI(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Minus Directional Movement (负向运动) + * + * MINUS_DM(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MINUS_DM(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Minus Directional Movement (负向运动) + * + * MINUS_DM(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number=14} TimePeriod + * @return {number[]} + */ + function MINUS_DM(High: number[], Low: number[], TimePeriod: number): number[]; + + /** + * Momentum (动量) + * + * MOM(Records[Close],Time Period = 10) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=10} TimePeriod + * @return {number[]} + */ + function MOM(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Normalized Average True Range (归一化平均值范围) + * + * NATR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function NATR(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Normalized Average True Range (归一化平均值范围) + * + * NATR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function NATR(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * On Balance Volume (能量潮) + * + * OBV(Records[Close],Records[Volume]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function OBV(Records: botvs.Record[]): number[]; + + /** + * On Balance Volume (能量潮) + * + * OBV(Records[Close],Records[Volume]) = Array(outReal) + * + * @param {number[]} Close + * @param {number[]} Volume + * @return {number[]} + */ + function OBV(Close: number[], Volume: number[]): number[]; + + /** + * Plus Directional Indicator (更向指示器) + * + * PLUS_DI(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function PLUS_DI(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Plus Directional Indicator (更向指示器) + * + * PLUS_DI(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function PLUS_DI(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Plus Directional Movement (定向运动) + * + * PLUS_DM(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function PLUS_DM(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Plus Directional Movement (定向运动) + * + * PLUS_DM(Records[High,Low],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number=14} TimePeriod + * @return {number[]} + */ + function PLUS_DM(High: number[], Low: number[], TimePeriod: number): number[]; + + /** + * Percentage Price Oscillator (价格振荡百分比) + * + * PPO(Records[Close],Fast Period = 12,Slow Period = 26,MA Type = 0) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=12} FastPeriod + * @param {number=26} SlowPeriod + * @param {number=0} MAType + * @return {number[]} + */ + function PPO( + Records: botvs.Record[] | number[], + FastPeriod: number, + SlowPeriod: number, + MAType: number, + ): number[]; + + /** + * Rate of change : ((price/prevPrice)-1)*100 (变动率指标) + * + * ROC(Records[Close],Time Period = 10) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=10} TimePeriod + * @return {number[]} + */ + function ROC(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Rate of change Percentage: (price-prevPrice)/prevPrice (价格变化率) + * + * ROCP(Records[Close],Time Period = 10) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=10} TimePeriod + * @return {number[]} + */ + function ROCP(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Rate of change ratio: (price/prevPrice) (价格变化率) + * + * ROCR(Records[Close],Time Period = 10) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=10} TimePeriod + * @return {number[]} + */ + function ROCR(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Rate of change ratio 100 scale: (price/prevPrice)*100 (价格变化率) + * + * ROCR100(Records[Close],Time Period = 10) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=10} TimePeriod + * @return {number[]} + */ + function ROCR100(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Relative Strength Index (相对强弱指标) + * + * RSI(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function RSI(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Parabolic SAR (抛物线转向) + * + * SAR(Records[High,Low],Acceleration Factor = 0.02,AF Maximum = 0.2) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=0.02} AccelerationFactor + * @param {number=0.2} AFMaximum + * @return {number[]} + */ + function SAR(Records: botvs.Record[], AccelerationFactor: number, AFMaximum: number): number[]; + /** + * Parabolic SAR (抛物线转向) + * + * SAR(Records[High,Low],Acceleration Factor = 0.02,AF Maximum = 0.2) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number=0.02} AccelerationFactor + * @param {number=0.2} AFMaximum + * @return {number[]} + */ + function SAR(High: number[], Low: number[], AccelerationFactor: number, AFMaximum: number): number[]; + + /** + * Parabolic SAR - Extended (增强型抛物线转向) + * + * SAREXT(Records[High,Low],Start Value = 0,Offset on Reverse = 0,AF Init Long = 0.02,AF Long = 0.02,AF Max + * Long = + * 0.2,AF Init Short = 0.02,AF Short = 0.02,AF Max Short = 0.2) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=0} StartValue + * @param {number=0} OffsetonReverse + * @param {number=0.02} AFInitLong + * @param {number=0.02} AFLong + * @param {number=0.2} AFMaxLong + * @param {number=0.02} AFInitShort + * @param {number=0.02} AFShort + * @param {number=0.2} AFMaxShort + * @return {number[]} + */ + function SAREXT( + Records: botvs.Record[], + StartValue: number, + OffsetonReverse: number, + AFInitLong: number, + AFLong: number, + AFMaxLong: number, + AFInitShort: number, + AFShort: number, + AFMaxShort: number, + ): number[]; + /** + * Parabolic SAR - Extended (增强型抛物线转向) + * + * SAREXT(Records[High,Low],Start Value = 0,Offset on Reverse = 0,AF Init Long = 0.02,AF Long = 0.02,AF Max + * Long = + * 0.2,AF Init Short = 0.02,AF Short = 0.02,AF Max Short = 0.2) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number=0} StartValue + * @param {number=0} OffsetonReverse + * @param {number=0.02} AFInitLong + * @param {number=0.02} AFLong + * @param {number=0.2} AFMaxLong + * @param {number=0.02} AFInitShort + * @param {number=0.02} AFShort + * @param {number=0.2} AFMaxShort + * @return {number[]} + */ + function SAREXT( + High: number[], + Low: number[], + StartValue: number, + OffsetonReverse: number, + AFInitLong: number, + AFLong: number, + AFMaxLong: number, + AFInitShort: number, + AFShort: number, + AFMaxShort: number, + ): number[]; + + /** + * Vector Trigonometric Sin (正弦值) + * + * SIN(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function SIN(Records: botvs.Record[] | number[]): number[]; + + /** + * Vector Trigonometric Sinh (双曲正弦函数) + * + * SINH(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function SINH(Records: botvs.Record[] | number[]): number[]; + + /** + * Simple Moving Average (简单移动平均) + * + * SMA(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function SMA(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Vector Square Root (平方根) + * + * SQRT(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function SQRT(Records: botvs.Record[] | number[]): number[]; + + /** + * Standard Deviation (标准偏差) + * + * STDDEV(Records[Close],Time Period = 5,Deviations = 1) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=5} TimePeriod + * @param {number=1} Deviations + * @return {number[]} + */ + function STDDEV(Records: botvs.Record[] | number[], TimePeriod: number, Deviations: number): number[]; + + /** + * Stochastic (STOCH指标) + * + * STOCH(Records[High,Low,Close],Fast-K Period = 5,Slow-K Period = 3,Slow-K MA = 0,Slow-D Period = 3,Slow-D MA + * = 0) + * = [Array(outSlowK),Array(outSlowD)] + * + * @param {botvs.Record[]} Records + * @param {number=5} Fast_KPeriod + * @param {number=3} Slow_KPeriod + * @param {number=0} Slow_KMA + * @param {number=3} Slow_DPeriod + * @param {number=0} Slow_DMA + * @return {[number[], number[]]} + */ + function STOCH( + Records: botvs.Record[], + Fast_KPeriod: number, + Slow_KPeriod: number, + Slow_KMA: number, + Slow_DPeriod: number, + Slow_DMA: number, + ): [number[], number[]]; + /** + * Stochastic (STOCH指标) + * + * STOCH(Records[High,Low,Close],Fast-K Period = 5,Slow-K Period = 3,Slow-K MA = 0,Slow-D Period = 3,Slow-D MA + * = 0) + * = [Array(outSlowK),Array(outSlowD)] + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=5} Fast_KPeriod + * @param {number=3} Slow_KPeriod + * @param {number=0} Slow_KMA + * @param {number=3} Slow_DPeriod + * @param {number=0} Slow_DMA + * @return {[number[], number[]]} + */ + function STOCH( + High: number[], + Low: number[], + Close: number[], + Fast_KPeriod: number, + Slow_KPeriod: number, + Slow_KMA: number, + Slow_DPeriod: number, + Slow_DMA: number, + ): [number[], number[]]; + + /** + * Stochastic Fast (快速STOCH指标) + * + * STOCHF(Records[High,Low,Close],Fast-K Period = 5,Fast-D Period = 3,Fast-D MA = 0) = + * [Array(outFastK),Array(outFastD)] + * + * @param {botvs.Record[]} Records + * @param {number=5} Fast_KPeriod + * @param {number=3} Fast_DPeriod + * @param {number=0} Fast_DMA + * @return {[number[], number[]]} + */ + function STOCHF( + Records: botvs.Record[], + Fast_KPeriod: number, + Fast_DPeriod: number, + Fast_DMA: number, + ): [number[], number[]]; + /** + * Stochastic Fast (快速STOCH指标) + * + * STOCHF(Records[High,Low,Close],Fast-K Period = 5,Fast-D Period = 3,Fast-D MA = 0) = + * [Array(outFastK),Array(outFastD)] + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=5} Fast_KPeriod + * @param {number=3} Fast_DPeriod + * @param {number=0} Fast_DMA + * @return {[number[], number[]]} + */ + function STOCHF( + High: number[], + Low: number[], + Close: number[], + Fast_KPeriod: number, + Fast_DPeriod: number, + Fast_DMA: number, + ): [number[], number[]]; + + /** + * Stochastic Relative Strength Index (随机强弱指数) + * + * STOCHRSI(Records[Close],Time Period = 14,Fast-K Period = 5,Fast-D Period = 3,Fast-D MA = 0) = + * [Array(outFastK),Array(outFastD)] + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @param {number=5} Fast_KPeriod + * @param {number=3} Fast_DPeriod + * @param {number=0} Fast_DMA + * @return {[number[], number[]]} + */ + function STOCHRSI( + Records: botvs.Record[] | number[], + TimePeriod: number, + Fast_KPeriod: number, + Fast_DPeriod: number, + Fast_DMA: number, + ): [number[], number[]]; + + /** + * Summation (求和) + * + * SUM(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function SUM(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Triple Exponential Moving Average (T3) (三指数移动平均) + * + * T3(Records[Close],Time Period = 5,Volume Factor = 0.7) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=5} TimePeriod + * @param {number=0.7} VolumeFactor + * @return {number[]} + */ + function T3(Records: botvs.Record[] | number[], TimePeriod: number, VolumeFactor: number): number[]; + + /** + * Vector Trigonometric Tan (正切) + * + * TAN(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function TAN(Records: botvs.Record[] | number[]): number[]; + + /** + * Vector Trigonometric Tanh (双曲正切函数) + * + * TANH(Records[Close]) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @return {number[]} + */ + function TANH(Records: botvs.Record[] | number[]): number[]; + + /** + * Triple Exponential Moving Average (三指数移动平均) + * + * TEMA(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function TEMA(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * True Range (真实范围) + * + * TRANGE(Records[High,Low,Close]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function TRANGE(Records: botvs.Record[]): number[]; + /** + * True Range (真实范围) + * + * TRANGE(Records[High,Low,Close]) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function TRANGE(High: number[], Low: number[], Close: number[]): number[]; + + /** + * Triangular Moving Average (三指数移动平均) + * + * TRIMA(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function TRIMA(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA (三重指数平滑平均线) + * + * TRIX(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function TRIX(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Time Series Forecast (时间序列预测) + * + * TSF(Records[Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function TSF(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + + /** + * Typical Price (典型价格) + * + * TYPPRICE(Records[High,Low,Close]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function TYPPRICE(Records: botvs.Record[]): number[]; + /** + * Typical Price (典型价格) + * + * TYPPRICE(Records[High,Low,Close]) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function TYPPRICE(High: number[], Low: number[], Close: number[]): number[]; + + /** + * Ultimate Oscillator (极限振子) + * + * ULTOSC(Records[High,Low,Close],First Period = 7,Second Period = 14,Third Period = 28) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=7} FirstPeriod + * @param {number=14} SecondPeriod + * @param {number=28} ThirdPeriod + * @return {number[]} + */ + function ULTOSC( + Records: botvs.Record[], + FirstPeriod: number, + SecondPeriod: number, + ThirdPeriod: number, + ): number[]; + /** + * Ultimate Oscillator (极限振子) + * + * ULTOSC(Records[High,Low,Close],First Period = 7,Second Period = 14,Third Period = 28) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=7} FirstPeriod + * @param {number=14} SecondPeriod + * @param {number=28} ThirdPeriod + * @return {number[]} + */ + function ULTOSC( + High: number[], + Low: number[], + Close: number[], + FirstPeriod: number, + SecondPeriod: number, + ThirdPeriod: number, + ): number[]; + + /** + * Variance (变量定义) + * + * VAR(Records[Close],Time Period = 5,Deviations = 1) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=5} TimePeriod + * @param {number=1} Deviations + * @return {number[]} + */ + function VAR(Records: botvs.Record[] | number[], TimePeriod: number, Deviations: number): number[]; + + /** + * Weighted Close Price (加权收盘价) + * + * WCLPRICE(Records[High,Low,Close]) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @return {number[]} + */ + function WCLPRICE(Records: botvs.Record[]): number[]; + /** + * Weighted Close Price (加权收盘价) + * + * WCLPRICE(Records[High,Low,Close]) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @return {number[]} + */ + function WCLPRICE(High: number[], Low: number[], Close: number[]): number[]; + + /** + * Williams' %R (威廉指标) + * + * WILLR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {botvs.Record[]} Records + * @param {number=14} TimePeriod + * @return {number[]} + */ + function WILLR(Records: botvs.Record[], TimePeriod: number): number[]; + /** + * Williams' %R (威廉指标) + * + * WILLR(Records[High,Low,Close],Time Period = 14) = Array(outReal) + * + * @param {number[]} High + * @param {number[]} Low + * @param {number[]} Close + * @param {number=14} TimePeriod + * @return {number[]} + */ + function WILLR(High: number[], Low: number[], Close: number[], TimePeriod: number): number[]; + + /** + * Weighted Moving Average (加权移动平均) + * + * WMA(Records[Close],Time Period = 30) = Array(outReal) + * + * @param {botvs.Record[]|number[]} Records + * @param {number=30} TimePeriod + * @return {number[]} + */ + function WMA(Records: botvs.Record[] | number[], TimePeriod: number): number[]; + } + + /** + * 订单的状态: 未完成 + */ + const ORDER_STATE_PENDING: botvs.VOrderState; + + /** + * 订单的状态: 已关闭 + */ + const ORDER_STATE_CLOSED: botvs.VOrderState; + + /** + * 订单的状态: 已取消 + */ + const ORDER_STATE_CANCELED: botvs.VOrderState; + + /** + * 订单的类型: 买单 + */ + const ORDER_TYPE_BUY: botvs.VOrderType; + + /** + * 订单的类型: 卖单 + */ + const ORDER_TYPE_SELL: botvs.VOrderType; + + /** + * 多头仓位(CTP中用closebuy_today平仓) + */ + const PD_LONG: botvs.VPositionType; + + /** + * 空头仓位(CTP用closesell_today)平仓 + */ + const PD_SHORT: botvs.VPositionType; + + /** + * (CTP期货中)PD_LONG_YD为咋日多头仓位(用closebuy平 + */ + const PD_LONG_YD: botvs.VPositionType; + + /** + * 咋日空头仓位(用closesell平) + */ + const PD_SHORT_YD: botvs.VPositionType; + + /** + * 1分钟 + */ + const PERIOD_M1: botvs.VPeriod; + + /** + * 5分钟 + */ + const PERIOD_M5: botvs.VPeriod; + + /** + * 15分钟 + */ + const PERIOD_M15: botvs.VPeriod; + + /** + * 30分钟 + */ + const PERIOD_M30: botvs.VPeriod; + + /** + * 1小时 + */ + const PERIOD_H1: botvs.VPeriod; + + /** + * 1天 + */ + const PERIOD_D1: botvs.VPeriod; + + /** + * 买单日志 + */ + const LOG_TYPE_BUY: botvs.VLogType; + + /** + * 卖单日志 + */ + const LOG_TYPE_SELL: botvs.VLogType; + + /** + * 取消日志 + */ + const LOG_TYPE_CANCEL: botvs.VLogType; + + /** + * 默认主交易所对像, 添加交易平台时排列第一的交易所 + */ + const exchange: botvs.Exchange; + + /** + * 交易所数组, 如果添加多个交易所, 可以访问此变量获取交易所对像 + */ + const exchanges: botvs.Exchange[]; + + /** + * 保存一条信息到日志列表 + * + * 如果在字符串后面加上@字符则消息会进入推送队列, 推送到使用绑定的微信账号上(账户安全里绑定)(50条/小时, 1条/5秒 限制) + * 如: Log("微信你好 !@"); 或Log("微信你好, #ff0000@"); + * Log支持打印base64编码后的图片, 以"`"开头, 以"`"结尾, 如Log("`data:image/png;base64,AAAA`") + * Log支持直接打印Python的matplotlib.pyplot对象, 只要对象包含savefig方法就可以直接Log打印, 如: + * import matplotlib.pyplot as plt + * def main(): + * plt.plot([3,6,2,4,7,1]) + * Log(plt) + * + * @param {string} arg + */ + function Log(arg: string): void; + + /** + * 休眠函数 + * + * 参数为毫秒数,如Sleep(1000)为休眠一秒 + * + * @param {number} Millisecond + */ + function Sleep(Millisecond: number): void; + + /** + * 判断是否是模拟回测 + * + * 模拟回测状态返回true,实盘返回false + * + * @return {boolean} + */ + function IsVirtual(): boolean; + + /** + * 记录盈利值,这个为总盈利的值,参数类型为浮点数 + * + * @param {number} Profit + */ + function LogProfit(Profit: number): void; + + /** + * 清空所有收益日志, 可以带一个数字参数, 指定保留的条数 + * + * @param {number} reserve + */ + function LogProfitReset(reserve?: number): void; + + /** + * 清空所有日志, 可以带一个数字参数, 指定保留的条数 + * + * @param {number} reserve + */ + function LogReset(reserve?: number): void; + + /** + * 此信息不保存到日志列表里, 只更新当前机器人的状态信息, 在日志上方显示, 可多次调用, 更新状态 + * + * * LogStatus('这是一个普通的状态提示'); + * LogStatus('这是一个红色字体的状态提示 #ff0000'); + * LogStatus('这是一个多行的状态信息\n我是第二行'); + * LogStatus支持打印base64编码后的图片, 以"`"开头, 以"`"结尾, 如LogStatus("`data:image/png;base64,AAAA`") + * LogStatus支持直接传入Python的matplotlib.pyplot对象, 只要对象包含savefig方法就可以传入LogStatus, 如: + * import matplotlib.pyplot as plt + * def main(): + * plt.plot([3,6,2,4,7,1]) + * LogStatus(plt) + * var table = {type: 'table', title: '持仓信息', cols: ['列1', '列2'], rows: [ ['abc', 'def'], ['ABC', 'support color + * #ff0000']]}; LogStatus('`' + JSON.stringify(table)+'`'); // JSON序列化后两边加上`字符, 视为一个复杂消息格式(当前支持表格) + * LogStatus('第一行消息\n`' + JSON.stringify(table)+'`\n第三行消息'); + * // 表格信息也可以在多行中出现 LogStatus('`' + JSON.stringify([table, + * table])+'`'); // 支持多个表格同时显示, 将以TAB显示到一组里 + * // 也可以构造一个按钮在表格中, 策略用GetCommand接收cmd属性的内容 + * var table = { + * type: 'table', + * title: '持仓操作', + * cols: ['列1', '列2', 'Action'], + * rows: [ + * ['abc', 'def', {'type':'button', 'cmd': 'coverAll', 'name': '平仓'}], + * ] + * }; + * LogStatus('`' + JSON.stringify(table) + '`') + * // 或者构造一单独的按钮 + * LogStatus('`' + JSON.stringify({'type':'button', 'cmd': 'coverAll', 'name': '平仓'}) + '`') + * // 可以自定义按钮风格(bootstrap的按钮属性) + * LogStatus('`' + JSON.stringify({'type':'button', 'class': 'btn btn-xs btn-danger', 'cmd': 'coverAll', 'name': + * '平仓'}) + '`') + * + * @param {string} Msg + */ + function LogStatus(Msg: string): void; + + /** + * 打开或者关闭定单和出错信息的日志记录 + * + * @param {boolean} IsEnable + */ + function EnableLog(IsEnable: boolean): void; + + /** + * 图表绘图函数 + * + * 参数为可以JSON序列化的HighStocks的Highcharts.StockChart参数, 比原生的参数增加一个 + * __isStock属性, 如果指定__isStock: false, 则显示为普通图表 + * 返回对像可以调用add([series索引(如0), 数据])向指定索引的series添加数据, 调用reset() + * 清空图表数据, reset可以带一个数字参数, 指定保留的条数 + * 可以调用add([series索引(如0), 数据, 此数据在series中的索引])来更改数据 + * 可以为负数, -1指最后一个, -2是倒数第二个, 如: + * chart.add([0, 13.5, -1]), 更改series[0].data的倒数第一个点的数据 + * 支持显示多个图表, 配置时只需传入数组参数即可如: var chart = Chart([{...}, {...}, {...}]), + * 比如图表一有两个series, 图表二有一个series, 图表三有一个series, + * 那么add时指定0与1序列ID代表更新图表1的两个序列的数据, add时指定序列ID为2指图表2的第一个 + * series的数据, 指定序列3指的是图表3的第一个series的数据 HighStocks: + * http://api.highcharts.com/highstock + * + * @param {botvs.ChartOptions} options + * @return {botvs.RChart} + */ + function Chart(...options: botvs.ChartOptions[]): botvs.RChart; + + /** + * 发送邮件函数 + * + * Mail(smtpServer, smtpUsername, smtpPassword, mailTo, title, body); ret true or false + * Mail("smtp.163.com", "asdf@163.com", "password", "111@163.com", "title", "body") + * + * @param {string} smtpServer + * @param {string} smtpUsername + * @param {string} smtpPassword + * @param {string} mailTo + * @param {string} title + * @param {string} body + * @return {boolean} + */ + function Mail( + smtpServer: string, + smtpUsername: string, + smtpPassword: string, + mailTo: string, + title: string, + body: string, + ): boolean; + + /** + * 错误信息过滤 + * + * 被此正则表达式匹配的错误将不上传到日志系统, 可多次调用设置多个 + * SetErrorFilter("502:|503:|tcp|character|unexpected|network|timeout|WSARecv|Connect|GetAddr|no + * such|reset|http|received|EOF|reused"); + * + * @param {string} RegEx + */ + function SetErrorFilter(RegEx: string): void; + + /** + * 返回机器人进程ID + * + * @return {number} + */ + function GetPid(): number; + + /** + * 获取最近一次出错信息,一般无需使用,因为程序会把出错信息自动上传到日志系统 + * + * @return {string} + */ + function GetLastError(): string; + + /** + * 可保存的全局字典表 + * + * KV表, 永久保存在本地文件, 每个机器人单独一个数据库, 重启或者托管者退出后一直存在 + * K必须为数字或者字符串, 不区分大小写, V可以为任何可以JSON序列化的内容 + * _G("num", 1); // 设置一个全局变量num, 值为1 + * _G("num", "ok"); // 更改一个全局变量num, 值为字符串ok + * _G("num", null); // 删除全局变量 num + * _G("num"); // 返回全局变量num的值 + * _G(); // 返回当前机器人的ID + * _G(null); // 删除所有全局变量 + * + * @param {string} K + * @param {T} V + */ + function _G(K: string, V: T): void; + + /** + * 获取交互命令(utf-8) + * + * 获取策略交互界面发来的命令并清空, 没有命令则返回null, 返回的命令格式为 "按钮名称:参数", 如果没有参数, 则命令就是按钮名称 + * while (true) { + * var cmd = GetCommand(); + * if (cmd) { + * Log(cmd); + * } + * Sleep(1000); + * } + * + * @return {string} + */ + function GetCommand(): string | null; + + /** + * 原始的Socket访问, 支持tcp, udp, tls, unix 协议 + * + * @example + * + * ``` + * var client = Dial("tls://www.baidu.com:443"); // Dial支持tcp://, udp://, tls://, unix:// 协议, 可加一个参数指定超时的秒数 + * if (client) { + * client.write("GET / HTTP/1.1\nConnection: Closed\n\n"); // write可再跟一个数字参数指定超时, write返回成功发送的字节数 + * while (true) { + * var buf = client.read();// read可再跟一个数字参数指定超时, 返回null指出错或者超时或者socket已经关闭 + * if (!buf) { + * break; + * } + * Log(buf); + * } + * client.close(); + * } + * ``` + * + * @param {string} Address + * @param {number} Timeout + * @return {botvs.Socket} + */ + function Dial(Address: string, Timeout?: number): botvs.Socket | void; + + /** + * 网络URL访问 + * + * HttpQuery(Url, PostData, Cookies, Headers, IsReturnHeader) + * 获取一个Url的返回内容, 如果第二个参数PostData为字符串就以POST方式提交 + * 第二个参数PostData可以自定义方法比如HttpQuery('http://www.abc.com', {method:'PUT', data:'xx'}) + * 传递Cookie字符串需要第三个参数, 但不需要POST请将第二个参数置为null + * 模拟测试的时候因为无法模拟访问URL, 函数就返回固定字符串 Dummy Data + * 可以用此接口发送短信, 或者与其它API进行交互 + * HttpQuery("http://www.baidu.com/"); // Get + * HttpQuery("http://www.163.com", "xxx"); // Post + * HttpQuery("http://www.baidu.com/", null, "a=10; b=20", "User-Agent: Mobile\nContent-Type: text/html", true); + * // will return {Header: HTTP Header, Body: HTML} + * + * @param {string} Url + * @param {string | null | {method: string; data?: string}} PostData + * @param {string} Cookies + * @param {string} Headers + * @return {string} + */ + function HttpQuery( + Url: string, + PostData: string | null | { method: string, data?: string }, + Cookies: string, + Headers: string, + ): string; + function HttpQuery( + Url: string, + PostData: string | null | { method: string, data?: string }, + Cookies: string, + Headers: string, + IsReturnHeader: true, + ): { Header: string, Body: string }; + + /** + * 支持 md5/sha256/sha512/sha1 的哈希计算, 只支持实盘 + * + * 第二个参数可设置为raw/hex/base64, 分别指输出加密后的 原始内容/hex编码过的/base64编码过的 + * Log(Hash('md5', 'hex', 'hello')); + * Log(Hash('sha512', 'base64', 'hello')); + * + * @param {"md5" | "sha256" | "sha512" | "sha1"} Algo + * @param {"hex" | "base64"} OutputAlgo + * @param {string} Data + * @return {string} + */ + function Hash( + Algo: 'md5' | 'sha256' | 'sha512' | 'sha1', + OutputAlgo: 'hex' | 'base64' | 'raw', + Data: string, + ): string; + + /** + * 支持 md5/sha256/sha512/sha1 的HMAC加密计算, 只支持实盘 + * + * 第二个参数可设置为raw/hex/base64, 分别指输出加密后的 原始内容/hex编码过的/base64编码过的 + * Log(HMAC('md5', 'hex', 'hello', 'pass')); + * Log(HMAC('sha512', 'base64', 'hello', 'pass')); + * + * @param {"md5" | "sha256" | "sha512" | "sha1"} Algo + * @param {"hex" | "base64" | "raw"} OutputAlgo + * @param {string} Data + * @param {string} password + * @return {string} + */ + function HMAC( + Algo: 'md5' | 'sha256' | 'sha512' | 'sha1', + OutputAlgo: 'hex' | 'base64' | 'raw', + Data: string, + password: string, + ): string; + + /** + * 返回指定时间戳(ms)字符串, 不传任何参数就返回当前时间, + * 如_D(),或者_D(1478570053241), 默认格式为yyyy-MM-dd hh:mm:ss + * + * @param {string} timestamp + * @param {string} format + * @return {string} + */ + function _D(timestamp: string, format: string): string; + + /** + * 格式化一个浮点函数 + * + * @param {number} num + * @param {number=4} precision + * @return {string} + */ + function _N(num: number, precision?: number): string; + + /** + * 重试函数, 会一直调用指定函数到成功返回(函数返回null或者false会重试), + * 比如_C(exchange.GetTicker), 默认重试间隔为3秒, 可以调用_CDelay函数来控制重试间隔 + * 比如_CDelay(1000), 指改变_C函数重试间隔为1秒 + * + * @param {(...args: any[]) => T} func + * @param args + * @return {T} + */ + function _C(func: (...args: any[]) => T, ...args: any[]): T; + + /** + * 比如_CDelay(1000), 指改变_C函数重试间隔为1秒, 默认为3秒 + * + * @param {number} delay + */ + function _CDelay(delay: number): void; +} diff --git a/types/botvs/tsconfig.json b/types/botvs/tsconfig.json new file mode 100644 index 0000000000..a20db9c8e9 --- /dev/null +++ b/types/botvs/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "botvs-tests.ts" + ] +} diff --git a/types/botvs/tslint.json b/types/botvs/tslint.json new file mode 100644 index 0000000000..71ee04c4e1 --- /dev/null +++ b/types/botvs/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/bufferstream/postbuffer.d.ts b/types/bufferstream/postbuffer.d.ts index bd348b84db..1ca73b3064 100644 --- a/types/bufferstream/postbuffer.d.ts +++ b/types/bufferstream/postbuffer.d.ts @@ -7,6 +7,4 @@ declare class PostBuffer extends BufferStream { constructor(req: http.IncomingMessage); /** set a callback to get all post data from a http server request */ onEnd(callback: (data: any) => void): void; - /** pumps data into another stream to allow incoming streams given options will be passed to Stream.pipe */ - pipe(stream: NodeJS.WritableStream, options?: { end?: boolean }): NodeJS.ReadableStream; } diff --git a/types/bunnymq/tslint.json b/types/bunnymq/tslint.json index f93cf8562a..71ee04c4e1 100644 --- a/types/bunnymq/tslint.json +++ b/types/bunnymq/tslint.json @@ -1,3 +1,6 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } } diff --git a/types/business-rules-engine/package.json b/types/business-rules-engine/package.json index d33ff913ce..fce08a048d 100644 --- a/types/business-rules-engine/package.json +++ b/types/business-rules-engine/package.json @@ -1,5 +1,6 @@ { + "private": true, "dependencies": { "moment": ">=2.14.0" } -} +} \ No newline at end of file diff --git a/types/chai-http/chai-http-tests.ts b/types/chai-http/chai-http-tests.ts index 7c1c7a6b42..f4f65cae7b 100644 --- a/types/chai-http/chai-http-tests.ts +++ b/types/chai-http/chai-http-tests.ts @@ -41,6 +41,16 @@ chai.request(app) .get('/search') .query({ name: 'foo', limit: 10 }); +chai.request(app) + .get('/download') + .buffer() + .parse((res, cb) => { + let data = ''; + res.setEncoding('binary'); + res.on('data', (chunk: any) => { data += chunk; }); + res.on('end', () => { cb(undefined, new Buffer(data, 'binary')); }); + }); + chai.request(app) .put('/user/me') .send({ passsword: '123', confirmPassword: '123' }) diff --git a/types/chai-http/index.d.ts b/types/chai-http/index.d.ts index f0957cc454..6a9404c9da 100644 --- a/types/chai-http/index.d.ts +++ b/types/chai-http/index.d.ts @@ -49,6 +49,8 @@ declare global { type: string; status: number; text: string; + setEncoding(encoding: string): void; + on(event: string, fn: (...args: any[]) => void): void; } interface Request extends FinishedRequest { @@ -59,6 +61,7 @@ declare global { auth(user: string, name: string): Request; field(name: string, val: string): Request; buffer(): Request; + parse(fn: (res: Response, cb: (e?: Error, r?: any) => void) => void): Request; end(callback?: (err: any, res: Response) => void): FinishedRequest; } diff --git a/types/chart.js/index.d.ts b/types/chart.js/index.d.ts index f04fbc1119..607f6924f8 100644 --- a/types/chart.js/index.d.ts +++ b/types/chart.js/index.d.ts @@ -4,15 +4,14 @@ // Fabien Lavocat // KentarouTakeda // Larry Bahr +// Daniel Luz // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -/// - declare class Chart { static readonly Chart: typeof Chart; constructor( - context: string | JQuery | CanvasRenderingContext2D | HTMLCanvasElement | string[] | CanvasRenderingContext2D[] | HTMLCanvasElement[], + context: string | CanvasRenderingContext2D | HTMLCanvasElement | ArrayLike, options: Chart.ChartConfiguration ); config: Chart.ChartConfiguration; @@ -83,6 +82,8 @@ declare namespace Chart { type ScaleType = 'category' | 'linear' | 'logarithmic' | 'time' | 'radialLinear'; + type PointStyle = 'circle' | 'cross' | 'crossRot' | 'dash' | 'line' | 'rect' | 'rectRounded' | 'rectRot' | 'star' | 'triangle'; + type PositionType = 'left' | 'right' | 'top' | 'bottom'; interface ChartArea { @@ -175,7 +176,7 @@ declare namespace Chart { interface ChartTitleOptions { display?: boolean; - position?: string; + position?: PositionType; fullWdith?: boolean; fontSize?: number; fontFamily?: string; @@ -187,10 +188,12 @@ declare namespace Chart { interface ChartLegendOptions { display?: boolean; - position?: string; + position?: PositionType; fullWidth?: boolean; - onClick?(event: any, legendItem: any): void; + onClick?(event: MouseEvent, legendItem: ChartLegendItem): void; + onHover?(event: MouseEvent, legendItem: ChartLegendItem): void; labels?: ChartLegendLabelOptions; + reverse?: boolean; } interface ChartLegendLabelOptions { @@ -293,7 +296,7 @@ declare namespace Chart { interface ChartPointOptions { radius?: number; - pointStyle?: string; + pointStyle?: PointStyle; backgroundColor?: ChartColor; borderWidth?: number; borderColor?: ChartColor; @@ -332,6 +335,7 @@ declare namespace Chart { interface TickOptions { autoSkip?: boolean; + autoSkipPadding?: boolean; callback?(value: any, index: any, values: any): string|number; display?: boolean; fontColor?: ChartColor; @@ -386,7 +390,7 @@ declare namespace Chart { type ChartColor = string | CanvasGradient | CanvasPattern | string[]; interface ChartDataSets { - cubicInterpolationMode?: string; + cubicInterpolationMode?: 'default' | 'monotone'; backgroundColor?: ChartColor | ChartColor[]; borderWidth?: number; borderColor?: ChartColor; @@ -394,10 +398,15 @@ declare namespace Chart { borderDash?: number[]; borderDashOffset?: number; borderJoinStyle?: string; + borderSkipped?: PositionType; data?: number[] | ChartPoint[]; - fill?: boolean; + fill?: boolean | number | string; + hoverBackgroundColor?: string | string[]; + hoverBorderColor?: string | string[]; + hoverBorderWidth?: number | number[]; label?: string; lineTension?: number; + steppedLine?: 'before' | 'after' | boolean; pointBorderColor?: ChartColor | ChartColor[]; pointBackgroundColor?: ChartColor | ChartColor[]; pointBorderWidth?: number | number[]; @@ -407,14 +416,15 @@ declare namespace Chart { pointHoverBackgroundColor?: ChartColor | ChartColor[]; pointHoverBorderColor?: ChartColor | ChartColor[]; pointHoverBorderWidth?: number | number[]; - pointStyle?: string | string[] | HTMLImageElement | HTMLImageElement[]; + pointStyle?: PointStyle | HTMLImageElement | Array; xAxisID?: string; yAxisID?: string; type?: string; hidden?: boolean; hideInLegendAndTooltip?: boolean; + showLine?: boolean; stack?: string; - spanGaps?: string; + spanGaps?: boolean; } interface ChartScales { diff --git a/types/check-sum/tslint.json b/types/check-sum/tslint.json index 3db14f85ea..d9d49e375e 100644 --- a/types/check-sum/tslint.json +++ b/types/check-sum/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false + } +} diff --git a/types/chocolatechipjs/tslint.json b/types/chocolatechipjs/tslint.json index 04f74b7c27..ce367ade18 100644 --- a/types/chocolatechipjs/tslint.json +++ b/types/chocolatechipjs/tslint.json @@ -5,6 +5,8 @@ "adjacent-overload-signatures": false, "ban-types": false, "dt-header": false, - "unified-signatures": false + "no-any-union": false, + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/ckeditor/ckeditor-tests.ts b/types/ckeditor/ckeditor-tests.ts index 289e97168a..b6471ddab6 100644 --- a/types/ckeditor/ckeditor-tests.ts +++ b/types/ckeditor/ckeditor-tests.ts @@ -407,3 +407,85 @@ function test_sharedSpace() { function test_specifying_editor_path() { window.CKEDITOR_BASEPATH = '/ckeditor/'; } + +function test_editor_instance_event() { + var textarea = document.createElement('textarea'); + var instance = CKEDITOR.replace(textarea, { + on: { + activeEnterModeChange: function() {}, + activeFilterChange: function() {}, + afterCommandExec: function() {}, + afterInsertHtml: function() {}, + afterPaste: function() {}, + afterPasteFromWord: function() {}, + afterSetData: function() {}, + afterUndoImage: function() {}, + ariaEditorHelpLabel: function() {}, + ariaWidget: function() {}, + autogrow: function() {}, + beforeCommandExec: function() {}, + beforeDestroy: function() {}, + beforeModeUnload: function() {}, + beforeSetMode: function() {}, + beforeUndoImage: function() {}, + blur: function() {}, + change: function() {}, + configLoaded: function() {}, + contentDirChanged: function() {}, + contentDom: function() {}, + contentDomInvalidated: function() {}, + contentDomUnload: function() {}, + customConfigLoaded: function() {}, + dataFiltered: function() {}, + dataReady: function() {}, + destroy: function() {}, + dialogHide: function() {}, + dialogShow: function() {}, + dirChanged: function() {}, + doubleclick: function() {}, + dragend: function() {}, + dragstart: function() {}, + drop: function() {}, + elementsPathUpdate: function() {}, + fileUploadRequest: function() {}, + fileUploadResponse: function() {}, + floatingSpaceLayout: function() {}, + focus: function() {}, + getData: function() {}, + getSnapshot: function() {}, + insertElement: function() {}, + insertHtml: function() {}, + insertText: function() {}, + instanceReady: function() {}, + key: function() {}, + langLoaded: function() {}, + loadSnapshot: function() {}, + loaded: function() {}, + lockSnapshot: function() {}, + maximize: function() {}, + menuShow: function() {}, + mode: function() {}, + notificationHide: function() {}, + notificationShow: function() {}, + notificationUpdate: function() {}, + paste: function() {}, + pasteFromWord: function() {}, + pluginsLoaded: function() {}, + readOnly: function() {}, + removeFormatCleanup: function() {}, + required: function() {}, + resize: function() {}, + save: function() {}, + saveSnapshot: function() {}, + selectionChange: function() {}, + setData: function() {}, + stylesSet: function() {}, + template: function() {}, + toDataFormat: function() {}, + toHtml: function() {}, + unlockSnapshot: function() {}, + updateSnapshot: function() {}, + widgetDefinition: function() {} + } + }); +} diff --git a/types/ckeditor/index.d.ts b/types/ckeditor/index.d.ts index c158678c6e..24ff341b38 100644 --- a/types/ckeditor/index.d.ts +++ b/types/ckeditor/index.d.ts @@ -1163,6 +1163,7 @@ declare namespace CKEDITOR { afterCommandExec?: (evt: CKEDITOR.eventInfo) => void; afterInsertHtml?: (evt: CKEDITOR.eventInfo) => void; afterPaste?: (evt: CKEDITOR.eventInfo) => void; + afterPasteFromWord?: (evt: CKEDITOR.eventInfo) => void; afterSetData?: (evt: CKEDITOR.eventInfo) => void; afterUndoImage?: (evt: CKEDITOR.eventInfo) => void; ariaEditorHelpLabel?: (evt: CKEDITOR.eventInfo) => void; @@ -1170,9 +1171,11 @@ declare namespace CKEDITOR { autogrow?: (evt: CKEDITOR.eventInfo) => void; beforeCommandExec?: (evt: CKEDITOR.eventInfo) => void; + beforeDestroy?: (evt: CKEDITOR.eventInfo) => void; beforeGetData?: (evt: CKEDITOR.eventInfo) => void; - beforeModuleUnload?: (evt: CKEDITOR.eventInfo) => void; + beforeModeUnload?: (evt: CKEDITOR.eventInfo) => void; beforeSetMode?: (evt: CKEDITOR.eventInfo) => void; + beforeUndoImage?: (evt: CKEDITOR.eventInfo) => void; blur?: (evt: CKEDITOR.eventInfo) => void; change?: (evt: CKEDITOR.eventInfo) => void; @@ -1189,7 +1192,7 @@ declare namespace CKEDITOR { dialogHide?: (evt: CKEDITOR.eventInfo) => void; dialogShow?: (evt: CKEDITOR.eventInfo) => void; dirChanged?: (evt: CKEDITOR.eventInfo) => void; - doubleckick?: (evt: CKEDITOR.eventInfo) => void; + doubleclick?: (evt: CKEDITOR.eventInfo) => void; dragend?: (evt: CKEDITOR.eventInfo) => void; dragstart?: (evt: CKEDITOR.eventInfo) => void; drop?: (evt: CKEDITOR.eventInfo) => void; @@ -1207,7 +1210,7 @@ declare namespace CKEDITOR { insertElement?: (evt: CKEDITOR.eventInfo) => void; insertHtml?: (evt: CKEDITOR.eventInfo) => void; insertText?: (evt: CKEDITOR.eventInfo) => void; - insanceReady?: (evt: CKEDITOR.eventInfo) => void; + instanceReady?: (evt: CKEDITOR.eventInfo) => void; key?: (evt: CKEDITOR.eventInfo) => void; @@ -1224,6 +1227,7 @@ declare namespace CKEDITOR { notificationUpdate?: (evt: CKEDITOR.eventInfo) => void; paste?: (evt: CKEDITOR.eventInfo) => void; + pasteFromWord?: (evt: CKEDITOR.eventInfo) => void; pluginsLoaded?: (evt: CKEDITOR.eventInfo) => void; readOnly?: (evt: CKEDITOR.eventInfo) => void; @@ -1851,4 +1855,3 @@ declare namespace CKEDITOR { function detect(defaultLanguage: string, probeLanguage: string): string; } } - diff --git a/types/clndr/package.json b/types/clndr/package.json index 21243d59df..770614d9be 100644 --- a/types/clndr/package.json +++ b/types/clndr/package.json @@ -1,4 +1,5 @@ { + "private": true, "dependencies": { "moment": ">=2.8.3" } diff --git a/types/collections/tsconfig.json b/types/collections/tsconfig.json index 6b5293a242..e547d4914d 100644 --- a/types/collections/tsconfig.json +++ b/types/collections/tsconfig.json @@ -1,16 +1,22 @@ { - "files": [ - "collections-tests.ts", - "index.d.ts" - ], "compilerOptions": { - "module": "commonjs", - "target": "es6", - "lib": ["es6"], - "forceConsistentCasingInFileNames": true, - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "noEmit": true - } -} + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "collections-tests.ts" + ] +} \ No newline at end of file diff --git a/types/connect-flash/connect-flash-tests.ts b/types/connect-flash/connect-flash-tests.ts index 0f22c0cdd5..2b75c4ed77 100644 --- a/types/connect-flash/connect-flash-tests.ts +++ b/types/connect-flash/connect-flash-tests.ts @@ -13,4 +13,5 @@ app.use(flash({ app.use(function(req: Express.Request, res: Express.Response, next: Function) { req.flash('Message'); req.flash('info', 'Message'); + req.flash(); }); diff --git a/types/connect-flash/index.d.ts b/types/connect-flash/index.d.ts index edee056b1a..cb7d460623 100644 --- a/types/connect-flash/index.d.ts +++ b/types/connect-flash/index.d.ts @@ -7,6 +7,7 @@ declare namespace Express { export interface Request { + flash(): { [key: string]: string[] }; flash(message: string): any; flash(event: string, message: string): any; } diff --git a/types/continuation-local-storage/tsconfig.json b/types/continuation-local-storage/tsconfig.json index 130110c3b9..0bf318d3e8 100644 --- a/types/continuation-local-storage/tsconfig.json +++ b/types/continuation-local-storage/tsconfig.json @@ -1,7 +1,6 @@ { "compilerOptions": { "module": "commonjs", - "moduleResolution": "node", "lib": [ "es6" ], diff --git a/types/continuation-local-storage/tslint.json b/types/continuation-local-storage/tslint.json index 4b7077d438..0c26acc12f 100644 --- a/types/continuation-local-storage/tslint.json +++ b/types/continuation-local-storage/tslint.json @@ -7,6 +7,7 @@ "one-variable-per-declaration": false, "space-before-function-paren": false, "no-var": false, - "interface-over-type-literal": false + "interface-over-type-literal": false, + "no-unnecessary-generics": false } } diff --git a/types/cordova-plugin-battery-status/tsconfig.json b/types/cordova-plugin-battery-status/tsconfig.json index cac92776c8..dc873349a3 100644 --- a/types/cordova-plugin-battery-status/tsconfig.json +++ b/types/cordova-plugin-battery-status/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-camera/tsconfig.json b/types/cordova-plugin-camera/tsconfig.json index d0afcc73be..e54cb67d89 100644 --- a/types/cordova-plugin-camera/tsconfig.json +++ b/types/cordova-plugin-camera/tsconfig.json @@ -5,9 +5,14 @@ "es6", "dom" ], - "noImplicitAny": false, + "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-contacts/tsconfig.json b/types/cordova-plugin-contacts/tsconfig.json index b582025b43..76ef345600 100644 --- a/types/cordova-plugin-contacts/tsconfig.json +++ b/types/cordova-plugin-contacts/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-device-motion/tsconfig.json b/types/cordova-plugin-device-motion/tsconfig.json index a7dab35ed9..7330314961 100644 --- a/types/cordova-plugin-device-motion/tsconfig.json +++ b/types/cordova-plugin-device-motion/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-device/tsconfig.json b/types/cordova-plugin-device/tsconfig.json index 1ef065998e..3265c8b5b8 100644 --- a/types/cordova-plugin-device/tsconfig.json +++ b/types/cordova-plugin-device/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-dialogs/tsconfig.json b/types/cordova-plugin-dialogs/tsconfig.json index 0e77b0519a..1f11e8d304 100644 --- a/types/cordova-plugin-dialogs/tsconfig.json +++ b/types/cordova-plugin-dialogs/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-globalization/tsconfig.json b/types/cordova-plugin-globalization/tsconfig.json index 790fa07cb9..d9317cc455 100644 --- a/types/cordova-plugin-globalization/tsconfig.json +++ b/types/cordova-plugin-globalization/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-inappbrowser/tsconfig.json b/types/cordova-plugin-inappbrowser/tsconfig.json index 7375c17d5e..fc11c3516e 100644 --- a/types/cordova-plugin-inappbrowser/tsconfig.json +++ b/types/cordova-plugin-inappbrowser/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-keyboard/tsconfig.json b/types/cordova-plugin-keyboard/tsconfig.json index f779a05b7a..d5003a2452 100644 --- a/types/cordova-plugin-keyboard/tsconfig.json +++ b/types/cordova-plugin-keyboard/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-media/tsconfig.json b/types/cordova-plugin-media/tsconfig.json index 31ca665ed4..75eb223a75 100644 --- a/types/cordova-plugin-media/tsconfig.json +++ b/types/cordova-plugin-media/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-splashscreen/tsconfig.json b/types/cordova-plugin-splashscreen/tsconfig.json index c3c3c5836a..20313323c0 100644 --- a/types/cordova-plugin-splashscreen/tsconfig.json +++ b/types/cordova-plugin-splashscreen/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-statusbar/tsconfig.json b/types/cordova-plugin-statusbar/tsconfig.json index daeea4a492..0518e44a96 100644 --- a/types/cordova-plugin-statusbar/tsconfig.json +++ b/types/cordova-plugin-statusbar/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-vibration/tsconfig.json b/types/cordova-plugin-vibration/tsconfig.json index d0752c4764..0ea0850540 100644 --- a/types/cordova-plugin-vibration/tsconfig.json +++ b/types/cordova-plugin-vibration/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/cordova-plugin-websql/tsconfig.json b/types/cordova-plugin-websql/tsconfig.json index 7f66d4fe25..190c2aa2fb 100644 --- a/types/cordova-plugin-websql/tsconfig.json +++ b/types/cordova-plugin-websql/tsconfig.json @@ -8,6 +8,11 @@ "noImplicitAny": false, "noImplicitThis": true, "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/core-js/tslint.json b/types/core-js/tslint.json index a62d0d4e68..deb0a8f9b2 100644 --- a/types/core-js/tslint.json +++ b/types/core-js/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "ban-types": false + "ban-types": false, + "no-unnecessary-generics": false } } diff --git a/types/cote/package.json b/types/cote/package.json index ce4365fc69..951fb5721e 100644 --- a/types/cote/package.json +++ b/types/cote/package.json @@ -1,5 +1,6 @@ { - "dependencies": { - "eventemitter2": "^4.1.0" - } -} + "private": true, + "dependencies": { + "eventemitter2": "^4.1.0" + } +} \ No newline at end of file diff --git a/types/cote/tslint.json b/types/cote/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/cote/tslint.json +++ b/types/cote/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/csv-stringify/tslint.json b/types/csv-stringify/tslint.json index 11584e5acd..963be749a2 100644 --- a/types/csv-stringify/tslint.json +++ b/types/csv-stringify/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { + "no-any-union": false, "prefer-method-signature": false } } diff --git a/types/cucumber/tslint.json b/types/cucumber/tslint.json index 3db14f85ea..215db37b37 100644 --- a/types/cucumber/tslint.json +++ b/types/cucumber/tslint.json @@ -1 +1,8 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "no-any-union": false, + "rules": { + "no-any-union": false, + "no-unnecessary-generics": false + } +} diff --git a/types/cucumber/v1/tslint.json b/types/cucumber/v1/tslint.json index 3db14f85ea..3fe527d08f 100644 --- a/types/cucumber/v1/tslint.json +++ b/types/cucumber/v1/tslint.json @@ -1 +1,7 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false, + "no-unnecessary-generics": false + } +} diff --git a/types/cwise-parser/tslint.json b/types/cwise-parser/tslint.json index 531fb4ef87..71ee04c4e1 100644 --- a/types/cwise-parser/tslint.json +++ b/types/cwise-parser/tslint.json @@ -1,3 +1,6 @@ { - "extends": "dtslint/dt.json" -} \ No newline at end of file + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/cwise/tslint.json b/types/cwise/tslint.json index 531fb4ef87..bee01cfc64 100644 --- a/types/cwise/tslint.json +++ b/types/cwise/tslint.json @@ -1,3 +1,6 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false + } } \ No newline at end of file diff --git a/types/d3-array/tslint.json b/types/d3-array/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-array/tslint.json +++ b/types/d3-array/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-axis/tslint.json b/types/d3-axis/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-axis/tslint.json +++ b/types/d3-axis/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-brush/tslint.json b/types/d3-brush/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-brush/tslint.json +++ b/types/d3-brush/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-chord/tslint.json b/types/d3-chord/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-chord/tslint.json +++ b/types/d3-chord/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-collection/tslint.json b/types/d3-collection/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-collection/tslint.json +++ b/types/d3-collection/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-contour/tslint.json b/types/d3-contour/tslint.json index 08016de61a..54efb0b84e 100644 --- a/types/d3-contour/tslint.json +++ b/types/d3-contour/tslint.json @@ -1,6 +1,7 @@ { - "extends": "dtslint/dt.json", - "rules": { - "unified-signatures": false - } + "extends": "dtslint/dt.json", + "rules": { + "unified-signatures": false, + "no-unnecessary-generics": false + } } diff --git a/types/d3-dispatch/tslint.json b/types/d3-dispatch/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-dispatch/tslint.json +++ b/types/d3-dispatch/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-drag/tslint.json b/types/d3-drag/tslint.json index b8825c1674..26ee29cf50 100644 --- a/types/d3-drag/tslint.json +++ b/types/d3-drag/tslint.json @@ -3,6 +3,7 @@ "rules": { // TODO "no-this-assignment": false, - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-force/tslint.json b/types/d3-force/tslint.json index b8825c1674..26ee29cf50 100644 --- a/types/d3-force/tslint.json +++ b/types/d3-force/tslint.json @@ -3,6 +3,7 @@ "rules": { // TODO "no-this-assignment": false, - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-geo/tslint.json b/types/d3-geo/tslint.json index 680a816ce2..3020672011 100644 --- a/types/d3-geo/tslint.json +++ b/types/d3-geo/tslint.json @@ -4,6 +4,10 @@ // TODO "no-this-assignment": false, "unified-signatures": false, - "max-line-length": [false, 200] + "max-line-length": [ + false, + 200 + ], + "no-unnecessary-generics": false } } diff --git a/types/d3-quadtree/tslint.json b/types/d3-quadtree/tslint.json index 38aa3fb5b3..9e3df4b94a 100644 --- a/types/d3-quadtree/tslint.json +++ b/types/d3-quadtree/tslint.json @@ -2,6 +2,7 @@ "extends": "dtslint/dt.json", "rules": { "unified-signatures": false, - "no-empty-interface": false + "no-empty-interface": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-queue/tslint.json b/types/d3-queue/tslint.json index b8825c1674..c3beb085cb 100644 --- a/types/d3-queue/tslint.json +++ b/types/d3-queue/tslint.json @@ -2,6 +2,7 @@ "extends": "dtslint/dt.json", "rules": { // TODO + "no-any-union": false, "no-this-assignment": false, "unified-signatures": false } diff --git a/types/d3-request/tslint.json b/types/d3-request/tslint.json index 70edbfa511..a965459d61 100644 --- a/types/d3-request/tslint.json +++ b/types/d3-request/tslint.json @@ -1,8 +1,10 @@ { "extends": "dtslint/dt.json", "rules": { - // TODO + // TODOs + "no-any-union": false, "no-this-assignment": false, + "no-unnecessary-generics": false, "unified-signatures": false, "max-line-length": [false, 145] } diff --git a/types/d3-sankey/tslint.json b/types/d3-sankey/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-sankey/tslint.json +++ b/types/d3-sankey/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-scale/tslint.json b/types/d3-scale/tslint.json index 604d5950cf..9846c79a4d 100644 --- a/types/d3-scale/tslint.json +++ b/types/d3-scale/tslint.json @@ -2,6 +2,7 @@ "extends": "dtslint/dt.json", "rules": { "unified-signatures": false, - "callable-types": false + "callable-types": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-selection/tslint.json b/types/d3-selection/tslint.json index b8825c1674..26ee29cf50 100644 --- a/types/d3-selection/tslint.json +++ b/types/d3-selection/tslint.json @@ -3,6 +3,7 @@ "rules": { // TODO "no-this-assignment": false, - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-shape/tslint.json b/types/d3-shape/tslint.json index 108ab49c45..b1ba182ba6 100644 --- a/types/d3-shape/tslint.json +++ b/types/d3-shape/tslint.json @@ -4,6 +4,7 @@ // TODO "no-this-assignment": false, "unified-signatures": false, - "callable-types": false + "callable-types": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-transition/tslint.json b/types/d3-transition/tslint.json index b8825c1674..26ee29cf50 100644 --- a/types/d3-transition/tslint.json +++ b/types/d3-transition/tslint.json @@ -3,6 +3,7 @@ "rules": { // TODO "no-this-assignment": false, - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-voronoi/tslint.json b/types/d3-voronoi/tslint.json index 08b1465cd6..54efb0b84e 100644 --- a/types/d3-voronoi/tslint.json +++ b/types/d3-voronoi/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/d3-zoom/tslint.json b/types/d3-zoom/tslint.json index b8825c1674..26ee29cf50 100644 --- a/types/d3-zoom/tslint.json +++ b/types/d3-zoom/tslint.json @@ -3,6 +3,7 @@ "rules": { // TODO "no-this-assignment": false, - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/daterangepicker/package.json b/types/daterangepicker/package.json index 4c6d24a445..fce08a048d 100644 --- a/types/daterangepicker/package.json +++ b/types/daterangepicker/package.json @@ -1,4 +1,5 @@ { + "private": true, "dependencies": { "moment": ">=2.14.0" } diff --git a/types/delay/tslint.json b/types/delay/tslint.json index 21fecfef93..bf610ae17f 100644 --- a/types/delay/tslint.json +++ b/types/delay/tslint.json @@ -1,7 +1,8 @@ { - "extends": "dtslint/dt.json", - "rules": { - // TODO - "await-promise": false - } + "extends": "dtslint/dt.json", + "rules": { + // TODO + "await-promise": false, + "no-unnecessary-generics": false + } } diff --git a/types/documentdb/tslint.json b/types/documentdb/tslint.json index 2750cc0197..71ee04c4e1 100644 --- a/types/documentdb/tslint.json +++ b/types/documentdb/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } \ No newline at end of file +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/dotenv-safe/tsconfig.json b/types/dotenv-safe/tsconfig.json index a3c86013c6..6c134db7bf 100644 --- a/types/dotenv-safe/tsconfig.json +++ b/types/dotenv-safe/tsconfig.json @@ -6,7 +6,6 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "noImplicitReturns": true, "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ diff --git a/types/draft-js/index.d.ts b/types/draft-js/index.d.ts index 5516e43559..af97b6d676 100644 --- a/types/draft-js/index.d.ts +++ b/types/draft-js/index.d.ts @@ -798,8 +798,8 @@ declare namespace Draft { "undo" ) - interface BlockMapBuilder { - createFromArray(blocks: Array): BlockMap; + class BlockMapBuilder { + static createFromArray(blocks: Array): BlockMap; } const DefaultDraftBlockRenderMap: Immutable.Map; diff --git a/types/draft-js/package.json b/types/draft-js/package.json index 617790d310..9b1e26b353 100644 --- a/types/draft-js/package.json +++ b/types/draft-js/package.json @@ -1,5 +1,6 @@ { - "dependencies": { - "immutable": "^3.8.1" - } -} + "private": true, + "dependencies": { + "immutable": "^3.8.1" + } +} \ No newline at end of file diff --git a/types/electron-json-storage/package.json b/types/electron-json-storage/package.json index b68da5cd37..73c77d2608 100644 --- a/types/electron-json-storage/package.json +++ b/types/electron-json-storage/package.json @@ -1,5 +1,6 @@ { + "private": true, "dependencies": { "electron": "^1.7.5" } -} +} \ No newline at end of file diff --git a/types/electron-notifications/package.json b/types/electron-notifications/package.json index b68da5cd37..73c77d2608 100644 --- a/types/electron-notifications/package.json +++ b/types/electron-notifications/package.json @@ -1,5 +1,6 @@ { + "private": true, "dependencies": { "electron": "^1.7.5" } -} +} \ No newline at end of file diff --git a/types/electron-notify/package.json b/types/electron-notify/package.json index b68da5cd37..73c77d2608 100644 --- a/types/electron-notify/package.json +++ b/types/electron-notify/package.json @@ -1,5 +1,6 @@ { + "private": true, "dependencies": { "electron": "^1.7.5" } -} +} \ No newline at end of file diff --git a/types/electron-window-state/package.json b/types/electron-window-state/package.json index b68da5cd37..73c77d2608 100644 --- a/types/electron-window-state/package.json +++ b/types/electron-window-state/package.json @@ -1,5 +1,6 @@ { + "private": true, "dependencies": { "electron": "^1.7.5" } -} +} \ No newline at end of file diff --git a/types/ember-testing-helpers/tsconfig.json b/types/ember-testing-helpers/tsconfig.json index aaf474ecba..cd7634bd25 100644 --- a/types/ember-testing-helpers/tsconfig.json +++ b/types/ember-testing-helpers/tsconfig.json @@ -14,7 +14,8 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true }, "files": [ "index.d.ts", diff --git a/types/ember/tsconfig.json b/types/ember/tsconfig.json index d2f27dfec9..fbc4052a08 100644 --- a/types/ember/tsconfig.json +++ b/types/ember/tsconfig.json @@ -14,10 +14,11 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true + "forceConsistentCasingInFileNames": true, + "allowSyntheticDefaultImports": true }, "files": [ "index.d.ts", "ember-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/ember/tslint.json b/types/ember/tslint.json index 7c941bb9c6..309f39a5d1 100644 --- a/types/ember/tslint.json +++ b/types/ember/tslint.json @@ -4,9 +4,11 @@ // Heavy use of Function type in this older package. "ban-types": false, "jsdoc-format": false, + "no-any-union": false, "no-misused-new": false, // not sure what this means "no-single-declare-module": false, + "no-unnecessary-generics": false, "no-unnecessary-qualifier": false } } diff --git a/types/engine.io-client/tsconfig.json b/types/engine.io-client/tsconfig.json index aacd3365c5..e98b3db085 100644 --- a/types/engine.io-client/tsconfig.json +++ b/types/engine.io-client/tsconfig.json @@ -8,8 +8,6 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "noImplicitReturns": true, - "strict": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/types/engine.io-client/tslint.json b/types/engine.io-client/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/engine.io-client/tslint.json +++ b/types/engine.io-client/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/engine.io/tsconfig.json b/types/engine.io/tsconfig.json index 4ec2d12abc..b003e2f8e4 100644 --- a/types/engine.io/tsconfig.json +++ b/types/engine.io/tsconfig.json @@ -7,7 +7,6 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "strict": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/types/enzyme/index.d.ts b/types/enzyme/index.d.ts index 878dc2c082..8ebb11ce94 100644 --- a/types/enzyme/index.d.ts +++ b/types/enzyme/index.d.ts @@ -56,7 +56,7 @@ export interface CommonWrapper

{ * Returns whether or not the current wrapper has a node anywhere in it's render tree that looks like the one passed in. * @param node */ - contains(node: ReactElement): boolean; + contains(node: ReactElement | string): boolean; /** * Returns whether or not a given react element exists in the shallow render tree. diff --git a/types/enzyme/tslint.json b/types/enzyme/tslint.json index 1c1a051bd3..67c3be0ed0 100644 --- a/types/enzyme/tslint.json +++ b/types/enzyme/tslint.json @@ -1,8 +1,9 @@ { - "extends": "dtslint/dt.json", - "rules": { - // TODOs - "dt-header": false, - "no-duplicate-imports": false - } + "extends": "dtslint/dt.json", + "rules": { + // TODOs + "dt-header": false, + "no-duplicate-imports": false, + "no-unnecessary-generics": false + } } diff --git a/types/eonasdan-bootstrap-datetimepicker/package.json b/types/eonasdan-bootstrap-datetimepicker/package.json index 4c6d24a445..fce08a048d 100644 --- a/types/eonasdan-bootstrap-datetimepicker/package.json +++ b/types/eonasdan-bootstrap-datetimepicker/package.json @@ -1,4 +1,5 @@ { + "private": true, "dependencies": { "moment": ">=2.14.0" } diff --git a/types/eonasdan-bootstrap-datetimepicker/tsconfig.json b/types/eonasdan-bootstrap-datetimepicker/tsconfig.json index 6970636ceb..2f6f00a099 100644 --- a/types/eonasdan-bootstrap-datetimepicker/tsconfig.json +++ b/types/eonasdan-bootstrap-datetimepicker/tsconfig.json @@ -10,8 +10,7 @@ "strictNullChecks": false, "baseUrl": "../", "typeRoots": [ - "../", - "./node_modules" + "../" ], "types": [], "noEmit": true, diff --git a/types/esprima/esprima-tests.ts b/types/esprima/esprima-tests.ts index 60b54e0679..c7a9b796c6 100644 --- a/types/esprima/esprima-tests.ts +++ b/types/esprima/esprima-tests.ts @@ -1,28 +1,44 @@ import esprima = require('esprima'); import * as ESTree from 'estree'; -var token: esprima.Token; -var comment: ESTree.Comment; -var program: ESTree.Program; -var string: string; +let token: esprima.Token; +let program: ESTree.Program; +let string: string; // esprima string = esprima.version; -program = esprima.parse('code'); -program = esprima.parse('code', {range: true}); -program = esprima.parse('import * as code from "code"', {sourceType: 'module'}) + +// Parse Module & Parse Script +program = esprima.parseScript('answer = 42'); +program = esprima.parseModule('import { sqrt } from "math.js"'); + +// Parsing Options +const title = 'Hello World!'; +program = esprima.parseScript(`var el= ${title}`, { jsx: true }); +program = esprima.parseScript('if (x) function y() {}'); +program = esprima.parseScript('"use strict"; with (x) {}', { tolerant: true }); +program = esprima.parseScript('answer = 42', { range: true }); +program = esprima.parseScript('answer = 42', { range: true }); +program = esprima.parseScript('const answer = 42', { tokens: true }); +program = esprima.parseScript('answer = 42 // TODO: why', { comment: true }); +program = esprima.parseScript('answer = 42 // TODO: why', { comment: true, range: true }); + +// Tokenizing token = esprima.tokenize('code')[0]; token = esprima.tokenize('code', {range: true})[0]; +// Syntax Delegate +esprima.parseScript('answer = 42', {}, (node) => { + if (node.type === esprima.Syntax.VariableDeclaration) { + } +}); + // Token string = token.type; string = token.value; -// Comment -string = comment.value; - // Type narrowing -var node: ESTree.Node; -if(node.type === esprima.Syntax.IfStatement){ +const node: ESTree.Node = program.body[0]; +if (node.type === esprima.Syntax.IfStatement) { node.consequent = node; } diff --git a/types/esprima/index.d.ts b/types/esprima/index.d.ts index 2d5f933cad..627d72df73 100644 --- a/types/esprima/index.d.ts +++ b/types/esprima/index.d.ts @@ -1,104 +1,102 @@ -// Type definitions for Esprima v2.1.0 +// Type definitions for Esprima 4.0 // Project: http://esprima.org -// Definitions by: teppeis , RReverser +// Definitions by: teppeis , RReverser , peter-scott // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - -export = esprima; -export as namespace esprima; import * as ESTree from 'estree'; -declare namespace esprima { +export const version: string; - const version: string; - - function parse(code: string, options?: Options, delegate?: (node: ESTree.Node, meta: any) => void): ESTree.Program; - function tokenize(code: string, options?: Options): Array; - - interface Token { - type: string; - value: string; - } - - interface Options { - loc?: boolean; - range?: boolean; - raw?: boolean; - tokens?: boolean; - comment?: boolean; - attachComment?: boolean; - tolerant?: boolean; - source?: boolean; - sourceType?: 'script' | 'module'; - } - - const Syntax: { - AssignmentExpression: 'AssignmentExpression', - AssignmentPattern: 'AssignmentPattern', - ArrayExpression: 'ArrayExpression', - ArrayPattern: 'ArrayPattern', - ArrowFunctionExpression: 'ArrowFunctionExpression', - BlockStatement: 'BlockStatement', - BinaryExpression: 'BinaryExpression', - BreakStatement: 'BreakStatement', - CallExpression: 'CallExpression', - CatchClause: 'CatchClause', - ClassBody: 'ClassBody', - ClassDeclaration: 'ClassDeclaration', - ClassExpression: 'ClassExpression', - ConditionalExpression: 'ConditionalExpression', - ContinueStatement: 'ContinueStatement', - DoWhileStatement: 'DoWhileStatement', - DebuggerStatement: 'DebuggerStatement', - EmptyStatement: 'EmptyStatement', - ExportAllDeclaration: 'ExportAllDeclaration', - ExportDefaultDeclaration: 'ExportDefaultDeclaration', - ExportNamedDeclaration: 'ExportNamedDeclaration', - ExportSpecifier: 'ExportSpecifier', - ExpressionStatement: 'ExpressionStatement', - ForStatement: 'ForStatement', - ForOfStatement: 'ForOfStatement', - ForInStatement: 'ForInStatement', - FunctionDeclaration: 'FunctionDeclaration', - FunctionExpression: 'FunctionExpression', - Identifier: 'Identifier', - IfStatement: 'IfStatement', - ImportDeclaration: 'ImportDeclaration', - ImportDefaultSpecifier: 'ImportDefaultSpecifier', - ImportNamespaceSpecifier: 'ImportNamespaceSpecifier', - ImportSpecifier: 'ImportSpecifier', - Literal: 'Literal', - LabeledStatement: 'LabeledStatement', - LogicalExpression: 'LogicalExpression', - MemberExpression: 'MemberExpression', - MetaProperty: 'MetaProperty', - MethodDefinition: 'MethodDefinition', - NewExpression: 'NewExpression', - ObjectExpression: 'ObjectExpression', - ObjectPattern: 'ObjectPattern', - Program: 'Program', - Property: 'Property', - RestElement: 'RestElement', - ReturnStatement: 'ReturnStatement', - SequenceExpression: 'SequenceExpression', - SpreadElement: 'SpreadElement', - Super: 'Super', - SwitchCase: 'SwitchCase', - SwitchStatement: 'SwitchStatement', - TaggedTemplateExpression: 'TaggedTemplateExpression', - TemplateElement: 'TemplateElement', - TemplateLiteral: 'TemplateLiteral', - ThisExpression: 'ThisExpression', - ThrowStatement: 'ThrowStatement', - TryStatement: 'TryStatement', - UnaryExpression: 'UnaryExpression', - UpdateExpression: 'UpdateExpression', - VariableDeclaration: 'VariableDeclaration', - VariableDeclarator: 'VariableDeclarator', - WhileStatement: 'WhileStatement', - WithStatement: 'WithStatement', - YieldExpression: 'YieldExpression' - }; +export function parseScript(input: string, config?: ParseOptions, delegate?: (node: ESTree.Node, meta: any) => void): ESTree.Program; +export function parseModule(input: string, config?: ParseOptions, delegate?: (node: ESTree.Node, meta: any) => void): ESTree.Program; +export function tokenize(input: string, config?: TokenizeOptions): Token[]; +export interface Token { + type: string; + value: string; } + +export interface ParseOptions { + jsx?: boolean; + range?: boolean; + loc?: boolean; + tolerant?: boolean; + tokens?: boolean; + comment?: boolean; +} + +export interface TokenizeOptions { + range?: boolean; + loc?: boolean; + comment?: boolean; +} + +export const Syntax: { + ArrayExpression: 'ArrayExpression', + ArrayPattern: 'ArrayPattern', + ArrowFunctionExpression: 'ArrowFunctionExpression', + AssignmentExpression: 'AssignmentExpression', + AssignmentPattern: 'AssignmentPattern', + AwaitExpression: 'AwaitExpression', + BinaryExpression: 'BinaryExpression', + BlockStatement: 'BlockStatement', + BreakStatement: 'BreakStatement', + CallExpression: 'CallExpression', + CatchClause: 'CatchClause', + ClassBody: 'ClassBody', + ClassDeclaration: 'ClassDeclaration', + ClassExpression: 'ClassExpression', + ConditionalExpression: 'ConditionalExpression', + ContinueStatement: 'ContinueStatement', + DebuggerStatement: 'DebuggerStatement', + DoWhileStatement: 'DoWhileStatement', + EmptyStatement: 'EmptyStatement', + ExportAllDeclaration: 'ExportAllDeclaration', + ExportDefaultDeclaration: 'ExportDefaultDeclaration', + ExportNamedDeclaration: 'ExportNamedDeclaration', + ExportSpecifier: 'ExportSpecifier', + ExpressionStatement: 'ExpressionStatement', + ForInStatement: 'ForInStatement', + ForOfStatement: 'ForOfStatement', + ForStatement: 'ForStatement', + FunctionDeclaration: 'FunctionDeclaration', + FunctionExpression: 'FunctionExpression', + Identifier: 'Identifier', + IfStatement: 'IfStatement', + Import: 'Import', + ImportDeclaration: 'ImportDeclaration', + ImportDefaultSpecifier: 'ImportDefaultSpecifier', + ImportNamespaceSpecifier: 'ImportNamespaceSpecifier', + ImportSpecifier: 'ImportSpecifier', + LabeledStatement: 'LabeledStatement', + Literal: 'Literal', + LogicalExpression: 'LogicalExpression', + MemberExpression: 'MemberExpression', + MetaProperty: 'MetaProperty', + MethodDefinition: 'MethodDefinition', + NewExpression: 'NewExpression', + ObjectExpression: 'ObjectExpression', + ObjectPattern: 'ObjectPattern', + Program: 'Program', + Property: 'Property', + RestElement: 'RestElement', + ReturnStatement: 'ReturnStatement', + SequenceExpression: 'SequenceExpression', + SpreadElement: 'SpreadElement', + Super: 'Super', + SwitchCase: 'SwitchCase', + SwitchStatement: 'SwitchStatement', + TaggedTemplateExpression: 'TaggedTemplateExpression', + TemplateElement: 'TemplateElement', + TemplateLiteral: 'TemplateLiteral', + ThisExpression: 'ThisExpression', + ThrowStatement: 'ThrowStatement', + TryStatement: 'TryStatement', + UnaryExpression: 'UnaryExpression', + UpdateExpression: 'UpdateExpression', + VariableDeclaration: 'VariableDeclaration', + VariableDeclarator: 'VariableDeclarator', + WhileStatement: 'WhileStatement', + WithStatement: 'WithStatement', + YieldExpression: 'YieldExpression' +}; diff --git a/types/esprima/tsconfig.json b/types/esprima/tsconfig.json index b94d0875ed..e70c3e04a4 100644 --- a/types/esprima/tsconfig.json +++ b/types/esprima/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/types/esprima/tslint.json b/types/esprima/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/esprima/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/esprima/v2/esprima-tests.ts b/types/esprima/v2/esprima-tests.ts new file mode 100644 index 0000000000..376a9a7562 --- /dev/null +++ b/types/esprima/v2/esprima-tests.ts @@ -0,0 +1,28 @@ +import esprima = require('esprima'); +import * as ESTree from 'estree'; + +var token: esprima.Token; +var comment: ESTree.Comment; +var program: ESTree.Program; +var string: string; + +// esprima +string = esprima.version; +program = esprima.parse('code'); +program = esprima.parse('code', {range: true}); +program = esprima.parse('import * as code from "code"', {sourceType: 'module'}) +token = esprima.tokenize('code')[0]; +token = esprima.tokenize('code', {range: true})[0]; + +// Token +string = token.type; +string = token.value; + +// Comment +string = comment.value; + +// Type narrowing +var node: ESTree.Node; +if(node.type === esprima.Syntax.IfStatement){ + node.consequent = node; +} \ No newline at end of file diff --git a/types/esprima/v2/index.d.ts b/types/esprima/v2/index.d.ts new file mode 100644 index 0000000000..d602f72d30 --- /dev/null +++ b/types/esprima/v2/index.d.ts @@ -0,0 +1,104 @@ +// Type definitions for Esprima v2.1.0 +// Project: http://esprima.org +// Definitions by: teppeis , RReverser +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export = esprima; +export as namespace esprima; +import * as ESTree from 'estree'; + +declare namespace esprima { + + const version: string; + + function parse(code: string, options?: Options, delegate?: (node: ESTree.Node, meta: any) => void): ESTree.Program; + function tokenize(code: string, options?: Options): Array; + + interface Token { + type: string; + value: string; + } + + interface Options { + loc?: boolean; + range?: boolean; + raw?: boolean; + tokens?: boolean; + comment?: boolean; + attachComment?: boolean; + tolerant?: boolean; + source?: boolean; + sourceType?: 'script' | 'module'; + } + + const Syntax: { + AssignmentExpression: 'AssignmentExpression', + AssignmentPattern: 'AssignmentPattern', + ArrayExpression: 'ArrayExpression', + ArrayPattern: 'ArrayPattern', + ArrowFunctionExpression: 'ArrowFunctionExpression', + BlockStatement: 'BlockStatement', + BinaryExpression: 'BinaryExpression', + BreakStatement: 'BreakStatement', + CallExpression: 'CallExpression', + CatchClause: 'CatchClause', + ClassBody: 'ClassBody', + ClassDeclaration: 'ClassDeclaration', + ClassExpression: 'ClassExpression', + ConditionalExpression: 'ConditionalExpression', + ContinueStatement: 'ContinueStatement', + DoWhileStatement: 'DoWhileStatement', + DebuggerStatement: 'DebuggerStatement', + EmptyStatement: 'EmptyStatement', + ExportAllDeclaration: 'ExportAllDeclaration', + ExportDefaultDeclaration: 'ExportDefaultDeclaration', + ExportNamedDeclaration: 'ExportNamedDeclaration', + ExportSpecifier: 'ExportSpecifier', + ExpressionStatement: 'ExpressionStatement', + ForStatement: 'ForStatement', + ForOfStatement: 'ForOfStatement', + ForInStatement: 'ForInStatement', + FunctionDeclaration: 'FunctionDeclaration', + FunctionExpression: 'FunctionExpression', + Identifier: 'Identifier', + IfStatement: 'IfStatement', + ImportDeclaration: 'ImportDeclaration', + ImportDefaultSpecifier: 'ImportDefaultSpecifier', + ImportNamespaceSpecifier: 'ImportNamespaceSpecifier', + ImportSpecifier: 'ImportSpecifier', + Literal: 'Literal', + LabeledStatement: 'LabeledStatement', + LogicalExpression: 'LogicalExpression', + MemberExpression: 'MemberExpression', + MetaProperty: 'MetaProperty', + MethodDefinition: 'MethodDefinition', + NewExpression: 'NewExpression', + ObjectExpression: 'ObjectExpression', + ObjectPattern: 'ObjectPattern', + Program: 'Program', + Property: 'Property', + RestElement: 'RestElement', + ReturnStatement: 'ReturnStatement', + SequenceExpression: 'SequenceExpression', + SpreadElement: 'SpreadElement', + Super: 'Super', + SwitchCase: 'SwitchCase', + SwitchStatement: 'SwitchStatement', + TaggedTemplateExpression: 'TaggedTemplateExpression', + TemplateElement: 'TemplateElement', + TemplateLiteral: 'TemplateLiteral', + ThisExpression: 'ThisExpression', + ThrowStatement: 'ThrowStatement', + TryStatement: 'TryStatement', + UnaryExpression: 'UnaryExpression', + UpdateExpression: 'UpdateExpression', + VariableDeclaration: 'VariableDeclaration', + VariableDeclarator: 'VariableDeclarator', + WhileStatement: 'WhileStatement', + WithStatement: 'WithStatement', + YieldExpression: 'YieldExpression' + }; + +} \ No newline at end of file diff --git a/types/esprima/v2/tsconfig.json b/types/esprima/v2/tsconfig.json new file mode 100644 index 0000000000..7de8cc1403 --- /dev/null +++ b/types/esprima/v2/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "esprima": [ + "esprima/v2" + ] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "esprima-tests.ts" + ] +} \ No newline at end of file diff --git a/types/esri-leaflet-geocoder/esri-leaflet-geocoder-tests.ts b/types/esri-leaflet-geocoder/esri-leaflet-geocoder-tests.ts index a79e8f068f..09b6c94288 100644 --- a/types/esri-leaflet-geocoder/esri-leaflet-geocoder-tests.ts +++ b/types/esri-leaflet-geocoder/esri-leaflet-geocoder-tests.ts @@ -1,4 +1,5 @@ -import * as L from 'esri-leaflet-geocoder'; +import * as L from 'leaflet'; +import 'esri-leaflet-geocoder'; const map = L.map('map').setView([45.5165, -122.6764], 12); const tiles = L.esri.basemapLayer("Streets").addTo(map); diff --git a/types/esri-leaflet-geocoder/index.d.ts b/types/esri-leaflet-geocoder/index.d.ts index 50c1ff779b..593f7cbb0b 100644 --- a/types/esri-leaflet-geocoder/index.d.ts +++ b/types/esri-leaflet-geocoder/index.d.ts @@ -4,13 +4,11 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 -import * as leaflet from 'leaflet'; -import * as esriLeaflet from 'esri-leaflet'; +import * as L from 'leaflet'; +import 'esri-leaflet'; -export = L; - -declare global { - namespace L.esri.Geocoding { +declare module 'leaflet' { + namespace esri.Geocoding { type GeosearchConstructor = new (options?: GeosearchObject) => Geosearch; type Geosearch = GeosearchControl & Evented; diff --git a/types/esri-leaflet-geocoder/tslint.json b/types/esri-leaflet-geocoder/tslint.json index fd2834499c..48743df77b 100644 --- a/types/esri-leaflet-geocoder/tslint.json +++ b/types/esri-leaflet-geocoder/tslint.json @@ -1,6 +1,8 @@ { "extends": "dtslint/dt.json", "rules": { + // TODOs + "no-any-union": false, "no-object-literal-type-assertion": false } } diff --git a/types/esri-leaflet/esri-leaflet-tests.ts b/types/esri-leaflet/esri-leaflet-tests.ts index d0f1249232..89520101a3 100644 --- a/types/esri-leaflet/esri-leaflet-tests.ts +++ b/types/esri-leaflet/esri-leaflet-tests.ts @@ -4,14 +4,17 @@ // tslint:disable:only-arrow-functions // tslint:disable:space-before-function-paren -let latlng: L.LatLng = new L.LatLng(0, 0); -let latlngbounds: L.LatLngBounds = new L.LatLngBounds(latlng, latlng); -let map: L.Map = new L.Map('map'); +import * as L from 'leaflet'; +import 'esri-leaflet'; -let marker: L.Marker = new L.Marker(latlng); -let polygon: L.Polygon = new L.Polygon([latlng, latlng]); -let polyline: L.Polyline = new L.Polyline([latlng, latlng]); -let geojson: L.GeoJSON = new L.GeoJSON(); +const latlng: L.LatLng = new L.LatLng(0, 0); +const latlngbounds: L.LatLngBounds = new L.LatLngBounds(latlng, latlng); +const map: L.Map = new L.Map('map'); + +const marker: L.Marker = new L.Marker(latlng); +const polygon: L.Polygon = new L.Polygon([latlng, latlng]); +const polyline: L.Polyline = new L.Polyline([latlng, latlng]); +const geojson: L.GeoJSON = new L.GeoJSON(); let basemapLayer: L.esri.BasemapLayer; basemapLayer = L.esri.basemapLayer('Streets'); diff --git a/types/esri-leaflet/index.d.ts b/types/esri-leaflet/index.d.ts index a79322983e..07cab832e0 100644 --- a/types/esri-leaflet/index.d.ts +++ b/types/esri-leaflet/index.d.ts @@ -2,10 +2,11 @@ // Project: http://esri.github.io/esri-leaflet // Definitions by: strajuser // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -/// +import * as L from 'leaflet'; -declare namespace L { +declare module 'leaflet' { namespace esri { type CallbackHandler = (error: any, metadata: any) => void; @@ -834,11 +835,7 @@ declare namespace L { * @returns {FeatureLayer} */ function featureLayer(options: FeatureLayerOptions): FeatureLayer; - } -} -declare namespace L { - namespace esri { type FeatureCallbackHandler = (error?: any, featureCollection?: any, response?: any) => void; type ResponseCallbackHandler = (error?: any, response?: any) => void; @@ -1621,7 +1618,3 @@ declare namespace L { function find(options: FindOptions | MapService): Find; } } - -declare module 'esri-leaflet' { - export = L.esri; -} diff --git a/types/exceljs/tslint.json b/types/exceljs/tslint.json index 3db14f85ea..d9d49e375e 100644 --- a/types/exceljs/tslint.json +++ b/types/exceljs/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false + } +} diff --git a/types/expect/tslint.json b/types/expect/tslint.json index 420d80e8f3..00e5a6b547 100644 --- a/types/expect/tslint.json +++ b/types/expect/tslint.json @@ -1,8 +1,9 @@ { - "extends": "dtslint/dt.json", - "rules": { - // TODO - "no-void-expression": false, - "no-duplicate-imports": false - } + "extends": "dtslint/dt.json", + "rules": { + // TODO + "no-void-expression": false, + "no-duplicate-imports": false, + "no-unnecessary-generics": false + } } diff --git a/types/fabric/tslint.json b/types/fabric/tslint.json index 8697a364c3..17bb596f5d 100644 --- a/types/fabric/tslint.json +++ b/types/fabric/tslint.json @@ -5,6 +5,7 @@ "adjacent-overload-signatures": false, "ban-types": false, "interface-name": false, + "no-any-union": false, "no-empty-interface": false, "space-within-parens": false, "strict-export-declare-modifiers": false, diff --git a/types/faker/v3/tsconfig.json b/types/faker/v3/tsconfig.json index 052493a9c7..b95cdea472 100644 --- a/types/faker/v3/tsconfig.json +++ b/types/faker/v3/tsconfig.json @@ -7,9 +7,9 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, - "baseUrl": "../", + "baseUrl": "../../", "typeRoots": [ - "../" + "../../" ], "paths": { "faker": [ "faker/v3" ] diff --git a/types/falcor/tslint.json b/types/falcor/tslint.json index 3db14f85ea..3393f9dcca 100644 --- a/types/falcor/tslint.json +++ b/types/falcor/tslint.json @@ -1 +1,8 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + // TODOs + "no-any-union": false, + "no-unnecessary-generics": false + } +} diff --git a/types/fast-list/tslint.json b/types/fast-list/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/fast-list/tslint.json +++ b/types/fast-list/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/firebird/tslint.json b/types/firebird/tslint.json index b63c1c3846..188dc816e2 100644 --- a/types/firebird/tslint.json +++ b/types/firebird/tslint.json @@ -2,6 +2,7 @@ "extends": "dtslint/dt.json", "rules": { // TODO - "no-boolean-literal-compare": false + "no-boolean-literal-compare": false, + "no-unnecessary-generics": false } } diff --git a/types/fluent-ffmpeg/tslint.json b/types/fluent-ffmpeg/tslint.json index d88586e5bd..6338577095 100644 --- a/types/fluent-ffmpeg/tslint.json +++ b/types/fluent-ffmpeg/tslint.json @@ -1,3 +1,7 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + // TODO + "no-any-union": false + } } diff --git a/types/fluxxor/package.json b/types/fluxxor/package.json index 6cf370b12a..26741e77bf 100644 --- a/types/fluxxor/package.json +++ b/types/fluxxor/package.json @@ -1,5 +1,6 @@ { - "dependencies": { - "eventemitter3": "^2.0.3" - } -} + "private": true, + "dependencies": { + "eventemitter3": "^2.0.3" + } +} \ No newline at end of file diff --git a/types/from2/tslint.json b/types/from2/tslint.json index 3db14f85ea..d9d49e375e 100644 --- a/types/from2/tslint.json +++ b/types/from2/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false + } +} diff --git a/types/fs-extra-promise/fs-extra-promise-tests.ts b/types/fs-extra-promise/fs-extra-promise-tests.ts index 6b69bfec3c..75fa32f876 100644 --- a/types/fs-extra-promise/fs-extra-promise-tests.ts +++ b/types/fs-extra-promise/fs-extra-promise-tests.ts @@ -47,9 +47,9 @@ let writeStream: stream.Writable; let isDirectory: boolean; fs.copy(src, dest, errorCallback); -fs.copy(src, dest, { filter: (src: string) => false }, errorCallback); +fs.copy(src, dest, { filter: (src: string, dest: string) => false }, errorCallback); fs.copySync(src, dest); -fs.copySync(src, dest, { filter: (src: string) => false }); +fs.copySync(src, dest, { filter: (src: string, dest: string) => false }); fs.createFile(file, errorCallback); fs.createFileSync(file); diff --git a/types/fs-extra/fs-extra-tests.ts b/types/fs-extra/fs-extra-tests.ts index 22232bc297..f405486adb 100644 --- a/types/fs-extra/fs-extra-tests.ts +++ b/types/fs-extra/fs-extra-tests.ts @@ -14,7 +14,7 @@ const fd = 0; const modeNum = 0; const modeStr = ""; const object = {}; -const errorCallback = (err: Error) => { }; +const errorCallback = (err: Error | null) => { }; const readOptions: fs.ReadOptions = { reviver: {} }; @@ -43,12 +43,12 @@ fs.copy(src, dest, { overwrite: true }).then(() => { // stub }); fs.copy(src, dest, errorCallback); -fs.copy(src, dest, { filter: src => false }, errorCallback); +fs.copy(src, dest, { filter: (src: string, dest: string) => false }, errorCallback); fs.copy(src, dest, { overwrite: true, preserveTimestamps: true, - filter: (src: string) => false + filter: (src: string, dest: string) => false }, errorCallback ); @@ -61,13 +61,13 @@ fs.copy(src, dest, errorCallback ); fs.copySync(src, dest); -fs.copySync(src, dest, { filter: src => false }); +fs.copySync(src, dest, { filter: (src: string, dest: string) => false }); fs.copySync(src, dest, { filter: /.*/ }); fs.copySync(src, dest, { overwrite: true, preserveTimestamps: true, - filter: (src: string) => false + filter: (src: string, dest: string) => false } ); fs.copySync(src, dest, diff --git a/types/fs-extra/index.d.ts b/types/fs-extra/index.d.ts index 0231cac2d2..60c112c68b 100644 --- a/types/fs-extra/index.d.ts +++ b/types/fs-extra/index.d.ts @@ -14,140 +14,141 @@ import { Stats } from "fs"; export * from "fs"; export function copy(src: string, dest: string, options?: CopyOptions): Promise; -export function copy(src: string, dest: string, callback: (err: Error) => void): void; -export function copy(src: string, dest: string, options: CopyOptions, callback: (err: Error) => void): void; +export function copy(src: string, dest: string, callback: (err: Error | null) => void): void; +export function copy(src: string, dest: string, options: CopyOptions, callback: (err: Error | null) => void): void; export function copySync(src: string, dest: string, options?: CopyOptions): void; export function move(src: string, dest: string, options?: MoveOptions): Promise; -export function move(src: string, dest: string, callback: (err: Error) => void): void; -export function move(src: string, dest: string, options: MoveOptions, callback: (err: Error) => void): void; +export function move(src: string, dest: string, callback: (err: Error | null) => void): void; +export function move(src: string, dest: string, options: MoveOptions, callback: (err: Error | null) => void): void; export function moveSync(src: string, dest: string, options?: MoveOptions): void; export function createFile(file: string): Promise; -export function createFile(file: string, callback: (err: Error) => void): void; +export function createFile(file: string, callback: (err: Error | null) => void): void; export function createFileSync(file: string): void; export function ensureDir(path: string): Promise; -export function ensureDir(path: string, callback: (err: Error) => void): void; +export function ensureDir(path: string, callback: (err: Error | null) => void): void; export function ensureDirSync(path: string): void; export function mkdirs(dir: string): Promise; -export function mkdirs(dir: string, callback: (err: Error) => void): void; +export function mkdirs(dir: string, callback: (err: Error | null) => void): void; export function mkdirp(dir: string): Promise; -export function mkdirp(dir: string, callback: (err: Error) => void): void; +export function mkdirp(dir: string, callback: (err: Error | null) => void): void; export function mkdirsSync(dir: string): void; export function mkdirpSync(dir: string): void; export function outputFile(file: string, data: any): Promise; -export function outputFile(file: string, data: any, callback: (err: Error) => void): void; +export function outputFile(file: string, data: any, callback: (err: Error | null) => void): void; export function outputFileSync(file: string, data: any): void; export function readJson(file: string, options?: ReadOptions): Promise; -export function readJson(file: string, callback: (err: Error, jsonObject: any) => void): void; -export function readJson(file: string, options: ReadOptions, callback: (err: Error, jsonObject: any) => void): void; +export function readJson(file: string, callback: (err: Error | null, jsonObject: any) => void): void; +export function readJson(file: string, options: ReadOptions, callback: (err: Error | null, jsonObject: any) => void): void; export function readJSON(file: string, options?: ReadOptions): Promise; -export function readJSON(file: string, callback: (err: Error, jsonObject: any) => void): void; -export function readJSON(file: string, options: ReadOptions, callback: (err: Error, jsonObject: any) => void): void; +export function readJSON(file: string, callback: (err: Error | null, jsonObject: any) => void): void; +export function readJSON(file: string, options: ReadOptions, callback: (err: Error | null, jsonObject: any) => void): void; export function readJsonSync(file: string, options?: ReadOptions): any; export function readJSONSync(file: string, options?: ReadOptions): any; export function remove(dir: string): Promise; -export function remove(dir: string, callback: (err: Error) => void): void; +export function remove(dir: string, callback: (err: Error | null) => void): void; export function removeSync(dir: string): void; export function outputJSON(file: string, data: any, options?: WriteOptions): Promise; -export function outputJSON(file: string, data: any, options: WriteOptions, callback: (err: Error) => void): void; -export function outputJSON(file: string, data: any, callback: (err: Error) => void): void; +export function outputJSON(file: string, data: any, options: WriteOptions, callback: (err: Error | null) => void): void; +export function outputJSON(file: string, data: any, callback: (err: Error | null) => void): void; export function outputJson(file: string, data: any, options?: WriteOptions): Promise; -export function outputJson(file: string, data: any, options: WriteOptions, callback: (err: Error) => void): void; -export function outputJson(file: string, data: any, callback: (err: Error) => void): void; +export function outputJson(file: string, data: any, options: WriteOptions, callback: (err: Error | null) => void): void; +export function outputJson(file: string, data: any, callback: (err: Error | null) => void): void; export function outputJsonSync(file: string, data: any, options?: WriteOptions): void; export function outputJSONSync(file: string, data: any, options?: WriteOptions): void; export function writeJSON(file: string, object: any, options?: WriteOptions): Promise; -export function writeJSON(file: string, object: any, callback: (err: Error) => void): void; -export function writeJSON(file: string, object: any, options: WriteOptions, callback: (err: Error) => void): void; +export function writeJSON(file: string, object: any, callback: (err: Error | null) => void): void; +export function writeJSON(file: string, object: any, options: WriteOptions, callback: (err: Error | null) => void): void; export function writeJson(file: string, object: any, options?: WriteOptions): Promise; -export function writeJson(file: string, object: any, callback: (err: Error) => void): void; -export function writeJson(file: string, object: any, options: WriteOptions, callback: (err: Error) => void): void; +export function writeJson(file: string, object: any, callback: (err: Error | null) => void): void; +export function writeJson(file: string, object: any, options: WriteOptions, callback: (err: Error | null) => void): void; export function writeJsonSync(file: string, object: any, options?: WriteOptions): void; export function writeJSONSync(file: string, object: any, options?: WriteOptions): void; export function ensureFile(path: string): Promise; -export function ensureFile(path: string, callback: (err: Error) => void): void; +export function ensureFile(path: string, callback: (err: Error | null) => void): void; export function ensureFileSync(path: string): void; export function ensureLink(src: string, dest: string): Promise; -export function ensureLink(src: string, dest: string, callback: (err: Error) => void): void; +export function ensureLink(src: string, dest: string, callback: (err: Error | null) => void): void; export function ensureLinkSync(src: string, dest: string): void; export function ensureSymlink(src: string, dest: string, type?: SymlinkType): Promise; -export function ensureSymlink(src: string, dest: string, type: SymlinkType, callback: (err: Error) => void): void; -export function ensureSymlink(src: string, dest: string, callback: (err: Error) => void): void; +export function ensureSymlink(src: string, dest: string, type: SymlinkType, callback: (err: Error | null) => void): void; +export function ensureSymlink(src: string, dest: string, callback: (err: Error | null) => void): void; export function ensureSymlinkSync(src: string, dest: string, type?: SymlinkType): void; export function emptyDir(path: string): Promise; -export function emptyDir(path: string, callback: (err: Error) => void): void; +export function emptyDir(path: string, callback: (err: Error | null) => void): void; export function emptyDirSync(path: string): void; export function pathExists(path: string): Promise; -export function pathExists(path: string, callback: (err: Error, exists: boolean) => void): void; +export function pathExists(path: string, callback: (err: Error | null, exists: boolean) => void): void; export function pathExistsSync(path: string): boolean; // fs async methods // copied from https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v6/index.d.ts /** Tests a user's permissions for the file specified by path. */ -export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException) => void): void; -export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException) => void): void; +export function access(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null) => void): void; +export function access(path: string | Buffer, mode: number, callback: (err: NodeJS.ErrnoException | null) => void): void; export function access(path: string | Buffer, mode?: number): Promise; -export function appendFile(file: string | Buffer | number, data: any, options: { encoding?: string; mode?: number | string; flag?: string; }, callback: (err: NodeJS.ErrnoException) => void): void; -export function appendFile(file: string | Buffer | number, data: any, callback: (err: NodeJS.ErrnoException) => void): void; +export function appendFile(file: string | Buffer | number, data: any, options: { encoding?: string; mode?: number | string; flag?: string; }, + callback: (err: NodeJS.ErrnoException | null) => void): void; +export function appendFile(file: string | Buffer | number, data: any, callback: (err: NodeJS.ErrnoException | null) => void): void; export function appendFile(file: string | Buffer | number, data: any, options?: { encoding?: string; mode?: number | string; flag?: string; }): Promise; -export function chmod(path: string | Buffer, mode: string | number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function chmod(path: string | Buffer, mode: string | number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function chmod(path: string | Buffer, mode: string | number): Promise; export function chown(path: string | Buffer, uid: number, gid: number): Promise; -export function chown(path: string | Buffer, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function chown(path: string | Buffer, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; -export function close(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function close(fd: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function close(fd: number): Promise; -export function fchmod(fd: number, mode: string | number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function fchmod(fd: number, mode: string | number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function fchmod(fd: number, mode: string | number): Promise; -export function fchown(fd: number, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function fchown(fd: number, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function fchown(fd: number, uid: number, gid: number): Promise; export function fdatasync(fd: number, callback: () => void): void; export function fdatasync(fd: number): Promise; -export function fstat(fd: number, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void; +export function fstat(fd: number, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => any): void; export function fstat(fd: number): Promise; -export function fsync(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function fsync(fd: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function fsync(fd: number): Promise; -export function ftruncate(fd: number, callback: (err?: NodeJS.ErrnoException) => void): void; -export function ftruncate(fd: number, len: number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function ftruncate(fd: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; +export function ftruncate(fd: number, len: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function ftruncate(fd: number, len?: number): Promise; -export function futimes(fd: number, atime: number, mtime: number, callback: (err?: NodeJS.ErrnoException) => void): void; -export function futimes(fd: number, atime: Date, mtime: Date, callback: (err?: NodeJS.ErrnoException) => void): void; +export function futimes(fd: number, atime: number, mtime: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; +export function futimes(fd: number, atime: Date, mtime: Date, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function futimes(fd: number, atime: number, mtime: number): Promise; export function futimes(fd: number, atime: Date, mtime: Date): Promise; -export function lchown(path: string | Buffer, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function lchown(path: string | Buffer, uid: number, gid: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function lchown(path: string | Buffer, uid: number, gid: number): Promise; -export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; +export function link(srcpath: string | Buffer, dstpath: string | Buffer, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function link(srcpath: string | Buffer, dstpath: string | Buffer): Promise; -export function lstat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void; +export function lstat(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => any): void; export function lstat(path: string | Buffer): Promise; /** @@ -156,7 +157,7 @@ export function lstat(path: string | Buffer): Promise; * @param path * @param callback No arguments other than a possible exception are given to the completion callback. */ -export function mkdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; +export function mkdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoException | null) => void): void; /** * Asynchronous mkdir - creates the directory specified in {path}. Parameter {mode} defaults to 0777. * @@ -164,35 +165,36 @@ export function mkdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoExcept * @param mode * @param callback No arguments other than a possible exception are given to the completion callback. */ -export function mkdir(path: string | Buffer, mode: number | string, callback: (err?: NodeJS.ErrnoException) => void): void; +export function mkdir(path: string | Buffer, mode: number | string, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function mkdir(path: string | Buffer): Promise; -export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; -export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException, fd: number) => void): void; +export function open(path: string | Buffer, flags: string | number, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; +export function open(path: string | Buffer, flags: string | number, mode: number, callback: (err: NodeJS.ErrnoException | null, fd: number) => void): void; export function open(path: string | Buffer, flags: string | number, mode?: number): Promise; -export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number | null, callback: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; +export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number | null, + callback: (err: NodeJS.ErrnoException | null, bytesRead: number, buffer: Buffer) => void): void; export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number | null): Promise; -export function readFile(file: string | Buffer | number, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; -export function readFile(file: string | Buffer | number, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; +export function readFile(file: string | Buffer | number, callback: (err: NodeJS.ErrnoException | null, data: Buffer) => void): void; +export function readFile(file: string | Buffer | number, encoding: string, callback: (err: NodeJS.ErrnoException | null, data: string) => void): void; export function readFile(file: string | Buffer | number, options: { flag?: string; } | { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; export function readFile(file: string | Buffer | number, options: { flag?: string; } | { encoding: string; flag?: string; }): Promise; // tslint:disable-next-line:unified-signatures export function readFile(file: string | Buffer | number, encoding: string): Promise; export function readFile(file: string | Buffer | number): Promise; -export function readdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException, files: string[]) => void): void; +export function readdir(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, files: string[]) => void): void; export function readdir(path: string | Buffer): Promise; -export function readlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException, linkString: string) => any): void; +export function readlink(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, linkString: string) => any): void; export function readlink(path: string | Buffer): Promise; -export function realpath(path: string | Buffer, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; -export function realpath(path: string | Buffer, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; +export function realpath(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => any): void; +export function realpath(path: string | Buffer, cache: { [path: string]: string }, callback: (err: NodeJS.ErrnoException | null, resolvedPath: string) => any): void; export function realpath(path: string | Buffer, cache?: { [path: string]: string }): Promise; -export function rename(oldPath: string, newPath: string, callback: (err?: NodeJS.ErrnoException) => void): void; +export function rename(oldPath: string, newPath: string, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function rename(oldPath: string, newPath: string): Promise; /** @@ -201,17 +203,17 @@ export function rename(oldPath: string, newPath: string): Promise; * @param path * @param callback No arguments other than a possible exception are given to the completion callback. */ -export function rmdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; +export function rmdir(path: string | Buffer, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function rmdir(path: string | Buffer): Promise; -export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException, stats: Stats) => any): void; +export function stat(path: string | Buffer, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => any): void; export function stat(path: string | Buffer): Promise; -export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type: string, callback: (err?: NodeJS.ErrnoException) => void): void; +export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type: string, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function symlink(srcpath: string | Buffer, dstpath: string | Buffer, type?: string): Promise; -export function truncate(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; -export function truncate(path: string | Buffer, len: number, callback: (err?: NodeJS.ErrnoException) => void): void; +export function truncate(path: string | Buffer, callback: (err?: NodeJS.ErrnoException | null) => void): void; +export function truncate(path: string | Buffer, len: number, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function truncate(path: string | Buffer, len?: number): Promise; /** @@ -220,25 +222,25 @@ export function truncate(path: string | Buffer, len?: number): Promise; * @param path * @param callback No arguments other than a possible exception are given to the completion callback. */ -export function unlink(path: string | Buffer, callback: (err?: NodeJS.ErrnoException) => void): void; +export function unlink(path: string | Buffer, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function unlink(path: string | Buffer): Promise; export function utimes(path: string | Buffer, atime: number, mtime: number, callback: (err?: NodeJS.ErrnoException) => void): void; -export function utimes(path: string | Buffer, atime: Date, mtime: Date, callback: (err?: NodeJS.ErrnoException) => void): void; +export function utimes(path: string | Buffer, atime: Date, mtime: Date, callback: (err?: NodeJS.ErrnoException | null) => void): void; export function utimes(path: string | Buffer, atime: number, mtime: number): Promise; export function utimes(path: string | Buffer, atime: Date, mtime: Date): Promise; export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number | null, callback: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; -export function write(fd: number, buffer: Buffer, offset: number, length: number, callback: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; -export function write(fd: number, data: any, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; -export function write(fd: number, data: any, offset: number, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; -export function write(fd: number, data: any, offset: number, encoding: string, callback: (err: NodeJS.ErrnoException, written: number, str: string) => void): void; +export function write(fd: number, buffer: Buffer, offset: number, length: number, callback: (err: NodeJS.ErrnoException | null, written: number, buffer: Buffer) => void): void; +export function write(fd: number, data: any, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void; +export function write(fd: number, data: any, offset: number, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void; +export function write(fd: number, data: any, offset: number, encoding: string, callback: (err: NodeJS.ErrnoException | null, written: number, str: string) => void): void; export function write(fd: number, buffer: Buffer, offset: number, length: number, position?: number | null): Promise; export function write(fd: number, data: any, offset: number, encoding?: string): Promise; -export function writeFile(file: string | Buffer | number, data: any, callback: (err: NodeJS.ErrnoException) => void): void; +export function writeFile(file: string | Buffer | number, data: any, callback: (err: NodeJS.ErrnoException | null) => void): void; export function writeFile(file: string | Buffer | number, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): Promise; -export function writeFile(file: string | Buffer | number, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback: (err: NodeJS.ErrnoException) => void): void; +export function writeFile(file: string | Buffer | number, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback: (err: NodeJS.ErrnoException | null) => void): void; /** * Asynchronous mkdtemp - Creates a unique temporary directory. Generates six random characters to be appended behind a required prefix to create a unique temporary directory. @@ -247,7 +249,7 @@ export function writeFile(file: string | Buffer | number, data: any, options: { * @param callback The created folder path is passed as a string to the callback's second parameter. */ export function mkdtemp(prefix: string): Promise; -export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException, folder: string) => void): void; +export function mkdtemp(prefix: string, callback: (err: NodeJS.ErrnoException | null, folder: string) => void): void; export interface PathEntry { path: string; @@ -258,7 +260,7 @@ export interface PathEntryStream { read(): PathEntry | null; } -export type CopyFilter = ((src: string) => boolean) | RegExp; +export type CopyFilter = ((src: string, dest: string) => boolean) | RegExp; export type SymlinkType = "dir" | "file"; diff --git a/types/fs-readdir-recursive/fs-readdir-recursive-tests.ts b/types/fs-readdir-recursive/fs-readdir-recursive-tests.ts new file mode 100644 index 0000000000..34564333b5 --- /dev/null +++ b/types/fs-readdir-recursive/fs-readdir-recursive-tests.ts @@ -0,0 +1,7 @@ +import readdirRecursive = require("fs-readdir-recursive"); + +const unfilteredPaths: string[] = readdirRecursive("path"); +const filteredPaths: string[] = readdirRecursive( + "path", + (path: string) => path[0] !== "." +); diff --git a/types/fs-readdir-recursive/index.d.ts b/types/fs-readdir-recursive/index.d.ts new file mode 100644 index 0000000000..1187822121 --- /dev/null +++ b/types/fs-readdir-recursive/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for fs-readdir-recursive 1.0 +// Project: https://github.com/fs-utils/fs-readdir-recursive +// Definitions by: Paolo Scanferla +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function readdirRecursive( + path: string, + filter?: (path: string) => boolean +): string[]; + +export = readdirRecursive; diff --git a/types/fs-readdir-recursive/tsconfig.json b/types/fs-readdir-recursive/tsconfig.json new file mode 100644 index 0000000000..8578708856 --- /dev/null +++ b/types/fs-readdir-recursive/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "fs-readdir-recursive-tests.ts" + ] +} diff --git a/types/fs-readdir-recursive/tslint.json b/types/fs-readdir-recursive/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/fs-readdir-recursive/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/fullcalendar/package.json b/types/fullcalendar/package.json index d33ff913ce..fce08a048d 100644 --- a/types/fullcalendar/package.json +++ b/types/fullcalendar/package.json @@ -1,5 +1,6 @@ { + "private": true, "dependencies": { "moment": ">=2.14.0" } -} +} \ No newline at end of file diff --git a/types/fullcalendar/v1/package.json b/types/fullcalendar/v1/package.json index d33ff913ce..fce08a048d 100644 --- a/types/fullcalendar/v1/package.json +++ b/types/fullcalendar/v1/package.json @@ -1,5 +1,6 @@ { + "private": true, "dependencies": { "moment": ">=2.14.0" } -} +} \ No newline at end of file diff --git a/types/get-stream/tslint.json b/types/get-stream/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/get-stream/tslint.json +++ b/types/get-stream/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/google-protobuf/tslint.json b/types/google-protobuf/tslint.json index a88c66859c..b04385bb7a 100644 --- a/types/google-protobuf/tslint.json +++ b/types/google-protobuf/tslint.json @@ -1,16 +1,17 @@ { - "extends": "dtslint/dt.json", - "rules": { - "align": false, - "array-type": false, - "new-parens": false, - "no-consecutive-blank-lines": false, - "interface-over-type-literal": false, - "no-relative-import-in-test": false, - "no-var": false, - "prefer-declare-function": false, - "semicolon": false, - "strict-export-declare-modifiers": false, - "trim-file": false - } + "extends": "dtslint/dt.json", + "rules": { + "align": false, + "array-type": false, + "new-parens": false, + "no-consecutive-blank-lines": false, + "interface-over-type-literal": false, + "no-relative-import-in-test": false, + "no-var": false, + "prefer-declare-function": false, + "semicolon": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "no-unnecessary-generics": false + } } diff --git a/types/google.analytics/tslint.json b/types/google.analytics/tslint.json index 57e94004d5..d802652174 100644 --- a/types/google.analytics/tslint.json +++ b/types/google.analytics/tslint.json @@ -3,6 +3,7 @@ "rules": { "dt-header": false, "ban-types": false, - "unified-signatures": false + "unified-signatures": false, + "no-unnecessary-generics": false } } diff --git a/types/graphene-pk11/package.json b/types/graphene-pk11/package.json index 12b23851cd..517ccdb420 100644 --- a/types/graphene-pk11/package.json +++ b/types/graphene-pk11/package.json @@ -1,5 +1,6 @@ { - "dependencies": { - "pkcs11js": "^1.0.8" - } -} + "private": true, + "dependencies": { + "pkcs11js": "^1.0.8" + } +} \ No newline at end of file diff --git a/types/graphql-relay/tslint.json b/types/graphql-relay/tslint.json index 3db14f85ea..d9d49e375e 100644 --- a/types/graphql-relay/tslint.json +++ b/types/graphql-relay/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false + } +} diff --git a/types/graphql/UNUSED_FILES.txt b/types/graphql/UNUSED_FILES.txt deleted file mode 100644 index df0fadfe79..0000000000 --- a/types/graphql/UNUSED_FILES.txt +++ /dev/null @@ -1 +0,0 @@ -execution/values.d.ts \ No newline at end of file diff --git a/types/graphql/execution/index.d.ts b/types/graphql/execution/index.d.ts index be3038be95..82d6bce853 100644 --- a/types/graphql/execution/index.d.ts +++ b/types/graphql/execution/index.d.ts @@ -4,3 +4,5 @@ export { responsePathAsArray, ExecutionResult } from './execute'; + +export { getDirectiveValues } from './values'; diff --git a/types/graphql/execution/values.d.ts b/types/graphql/execution/values.d.ts index 3f6e909ed7..79a0176f8d 100644 --- a/types/graphql/execution/values.d.ts +++ b/types/graphql/execution/values.d.ts @@ -23,3 +23,16 @@ export function getArgumentValues( node: FieldNode | DirectiveNode, variableValues?: { [key: string]: any } ): { [key: string]: any }; + +/** + * Prepares an object map of argument values given a directive definition + * and a AST node which may contain directives. Optionally also accepts a map + * of variable values. + * + * If the directive does not exist on the node, returns undefined. + */ +export function getDirectiveValues( + directiveDef: GraphQLDirective, + node: { directives?: Array }, + variableValues?: { [key: string]: any } +): void | { [key: string]: any }; diff --git a/types/graphql/index.d.ts b/types/graphql/index.d.ts index 971ae5945b..e85060bab5 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for graphql 0.10 +// Type definitions for graphql 0.11 // Project: https://www.npmjs.com/package/graphql // Definitions by: TonyYang // Caleb Meredith @@ -6,6 +6,7 @@ // Firede // Kepennar // Mikhail Novikov +// Ivan Goncharov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -27,6 +28,7 @@ export { execute, defaultFieldResolver, responsePathAsArray, + getDirectiveValues, ExecutionResult, } from './execution'; @@ -34,7 +36,37 @@ export { export { validate, ValidationContext, + + // All validation rules in the GraphQL Specification. specifiedRules, + + // Individual validation rules. + ArgumentsOfCorrectTypeRule, + DefaultValuesOfCorrectTypeRule, + FieldsOnCorrectTypeRule, + FragmentsOnCompositeTypesRule, + KnownArgumentNamesRule, + KnownDirectivesRule, + KnownFragmentNamesRule, + KnownTypeNamesRule, + LoneAnonymousOperationRule, + NoFragmentCyclesRule, + NoUndefinedVariablesRule, + NoUnusedFragmentsRule, + NoUnusedVariablesRule, + OverlappingFieldsCanBeMergedRule, + PossibleFragmentSpreadsRule, + ProvidedNonNullArgumentsRule, + ScalarLeafsRule, + SingleFieldSubscriptionsRule, + UniqueArgumentNamesRule, + UniqueDirectivesPerLocationRule, + UniqueFragmentNamesRule, + UniqueInputFieldNamesRule, + UniqueOperationNamesRule, + UniqueVariableNamesRule, + VariablesAreInputTypesRule, + VariablesInAllowedPositionRule, } from './validation'; // Create and format GraphQL errors. diff --git a/types/graphql/validation/index.d.ts b/types/graphql/validation/index.d.ts index a3ebc6a208..7f897fe78d 100644 --- a/types/graphql/validation/index.d.ts +++ b/types/graphql/validation/index.d.ts @@ -1,2 +1,132 @@ export { validate, ValidationContext } from './validate'; export { specifiedRules } from './specifiedRules'; + +// Spec Section: "Argument Values Type Correctness" +export { + ArgumentsOfCorrectType as ArgumentsOfCorrectTypeRule +} from './rules/ArgumentsOfCorrectType'; + +// Spec Section: "Variable Default Values Are Correctly Typed" +export { + DefaultValuesOfCorrectType as DefaultValuesOfCorrectTypeRule +} from './rules/DefaultValuesOfCorrectType'; + +// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types" +export { + FieldsOnCorrectType as FieldsOnCorrectTypeRule +} from './rules/FieldsOnCorrectType'; + +// Spec Section: "Fragments on Composite Types" +export { + FragmentsOnCompositeTypes as FragmentsOnCompositeTypesRule +} from './rules/FragmentsOnCompositeTypes'; + +// Spec Section: "Argument Names" +export { + KnownArgumentNames as KnownArgumentNamesRule +} from './rules/KnownArgumentNames'; + +// Spec Section: "Directives Are Defined" +export { + KnownDirectives as KnownDirectivesRule +} from './rules/KnownDirectives'; + +// Spec Section: "Fragment spread target defined" +export { + KnownFragmentNames as KnownFragmentNamesRule +} from './rules/KnownFragmentNames'; + +// Spec Section: "Fragment Spread Type Existence" +export { + KnownTypeNames as KnownTypeNamesRule +} from './rules/KnownTypeNames'; + +// Spec Section: "Lone Anonymous Operation" +export { + LoneAnonymousOperation as LoneAnonymousOperationRule +} from './rules/LoneAnonymousOperation'; + +// Spec Section: "Fragments must not form cycles" +export { + NoFragmentCycles as NoFragmentCyclesRule +} from './rules/NoFragmentCycles'; + +// Spec Section: "All Variable Used Defined" +export { + NoUndefinedVariables as NoUndefinedVariablesRule +} from './rules/NoUndefinedVariables'; + +// Spec Section: "Fragments must be used" +export { + NoUnusedFragments as NoUnusedFragmentsRule +} from './rules/NoUnusedFragments'; + +// Spec Section: "All Variables Used" +export { + NoUnusedVariables as NoUnusedVariablesRule +} from './rules/NoUnusedVariables'; + +// Spec Section: "Field Selection Merging" +export { + OverlappingFieldsCanBeMerged as OverlappingFieldsCanBeMergedRule +} from './rules/OverlappingFieldsCanBeMerged'; + +// Spec Section: "Fragment spread is possible" +export { + PossibleFragmentSpreads as PossibleFragmentSpreadsRule +} from './rules/PossibleFragmentSpreads'; + +// Spec Section: "Argument Optionality" +export { + ProvidedNonNullArguments as ProvidedNonNullArgumentsRule +} from './rules/ProvidedNonNullArguments'; + +// Spec Section: "Leaf Field Selections" +export { + ScalarLeafs as ScalarLeafsRule +} from './rules/ScalarLeafs'; + +// Spec Section: "Subscriptions with Single Root Field" +export { + SingleFieldSubscriptions as SingleFieldSubscriptionsRule +} from './rules/SingleFieldSubscriptions'; + +// Spec Section: "Argument Uniqueness" +export { + UniqueArgumentNames as UniqueArgumentNamesRule +} from './rules/UniqueArgumentNames'; + +// Spec Section: "Directives Are Unique Per Location" +export { + UniqueDirectivesPerLocation as UniqueDirectivesPerLocationRule +} from './rules/UniqueDirectivesPerLocation'; + +// Spec Section: "Fragment Name Uniqueness" +export { + UniqueFragmentNames as UniqueFragmentNamesRule +} from './rules/UniqueFragmentNames'; + +// Spec Section: "Input Object Field Uniqueness" +export { + UniqueInputFieldNames as UniqueInputFieldNamesRule +} from './rules/UniqueInputFieldNames'; + +// Spec Section: "Operation Name Uniqueness" +export { + UniqueOperationNames as UniqueOperationNamesRule +} from './rules/UniqueOperationNames'; + +// Spec Section: "Variable Uniqueness" +export { + UniqueVariableNames as UniqueVariableNamesRule +} from './rules/UniqueVariableNames'; + +// Spec Section: "Variables are Input Types" +export { + VariablesAreInputTypes as VariablesAreInputTypesRule +} from './rules/VariablesAreInputTypes'; + +// Spec Section: "All Variable Usages Are Allowed" +export { + VariablesInAllowedPosition as VariablesInAllowedPositionRule +} from './rules/VariablesInAllowedPosition'; diff --git a/types/graphql/validation/rules/ArgumentsOfCorrectType.d.ts b/types/graphql/validation/rules/ArgumentsOfCorrectType.d.ts new file mode 100644 index 0000000000..f7247d0a9c --- /dev/null +++ b/types/graphql/validation/rules/ArgumentsOfCorrectType.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * Argument values of correct type + * + * A GraphQL document is only valid if all field argument literal values are + * of the type expected by their position. + */ +export function ArgumentsOfCorrectType(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/DefaultValuesOfCorrectType.d.ts b/types/graphql/validation/rules/DefaultValuesOfCorrectType.d.ts new file mode 100644 index 0000000000..88b3a824f2 --- /dev/null +++ b/types/graphql/validation/rules/DefaultValuesOfCorrectType.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * Variable default values of correct type + * + * A GraphQL document is only valid if all variable default values are of the + * type expected by their definition. + */ +export function DefaultValuesOfCorrectType(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/FieldsOnCorrectType.d.ts b/types/graphql/validation/rules/FieldsOnCorrectType.d.ts new file mode 100644 index 0000000000..19609b2b65 --- /dev/null +++ b/types/graphql/validation/rules/FieldsOnCorrectType.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * Fields on correct type + * + * A GraphQL document is only valid if all fields selected are defined by the + * parent type, or are an allowed meta field such as __typename. + */ +export function FieldsOnCorrectType(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/FragmentsOnCompositeTypes.d.ts b/types/graphql/validation/rules/FragmentsOnCompositeTypes.d.ts new file mode 100644 index 0000000000..d6fffd4337 --- /dev/null +++ b/types/graphql/validation/rules/FragmentsOnCompositeTypes.d.ts @@ -0,0 +1,10 @@ +import { ValidationContext } from '../index'; + +/** + * Fragments on composite type + * + * Fragments use a type condition to determine if they apply, since fragments + * can only be spread into a composite type (object, interface, or union), the + * type condition must also be a composite type. + */ +export function FragmentsOnCompositeTypes(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/KnownArgumentNames.d.ts b/types/graphql/validation/rules/KnownArgumentNames.d.ts new file mode 100644 index 0000000000..4477b62a75 --- /dev/null +++ b/types/graphql/validation/rules/KnownArgumentNames.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * Known argument names + * + * A GraphQL field is only valid if all supplied arguments are defined by + * that field. + */ +export function KnownArgumentNames(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/KnownDirectives.d.ts b/types/graphql/validation/rules/KnownDirectives.d.ts new file mode 100644 index 0000000000..68c6acf549 --- /dev/null +++ b/types/graphql/validation/rules/KnownDirectives.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * Known directives + * + * A GraphQL document is only valid if all `@directives` are known by the + * schema and legally positioned. + */ +export function KnownDirectives(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/KnownFragmentNames.d.ts b/types/graphql/validation/rules/KnownFragmentNames.d.ts new file mode 100644 index 0000000000..b904f22d89 --- /dev/null +++ b/types/graphql/validation/rules/KnownFragmentNames.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * Known fragment names + * + * A GraphQL document is only valid if all `...Fragment` fragment spreads refer + * to fragments defined in the same document. + */ +export function KnownFragmentNames(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/KnownTypeNames.d.ts b/types/graphql/validation/rules/KnownTypeNames.d.ts new file mode 100644 index 0000000000..48b15318da --- /dev/null +++ b/types/graphql/validation/rules/KnownTypeNames.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * Known type names + * + * A GraphQL document is only valid if referenced types (specifically + * variable definitions and fragment conditions) are defined by the type schema. + */ +export function KnownTypeNames(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/LoneAnonymousOperation.d.ts b/types/graphql/validation/rules/LoneAnonymousOperation.d.ts new file mode 100644 index 0000000000..4ce6abcba9 --- /dev/null +++ b/types/graphql/validation/rules/LoneAnonymousOperation.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * Lone anonymous operation + * + * A GraphQL document is only valid if when it contains an anonymous operation + * (the query short-hand) that it contains only that one operation definition. + */ +export function LoneAnonymousOperation(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/NoFragmentCycles.d.ts b/types/graphql/validation/rules/NoFragmentCycles.d.ts new file mode 100644 index 0000000000..fed5982fc8 --- /dev/null +++ b/types/graphql/validation/rules/NoFragmentCycles.d.ts @@ -0,0 +1,3 @@ +import { ValidationContext } from '../index'; + +export function NoFragmentCycles(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/NoUndefinedVariables.d.ts b/types/graphql/validation/rules/NoUndefinedVariables.d.ts new file mode 100644 index 0000000000..51d30b8fd1 --- /dev/null +++ b/types/graphql/validation/rules/NoUndefinedVariables.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * No undefined variables + * + * A GraphQL operation is only valid if all variables encountered, both directly + * and via fragment spreads, are defined by that operation. + */ +export function NoUndefinedVariables(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/NoUnusedFragments.d.ts b/types/graphql/validation/rules/NoUnusedFragments.d.ts new file mode 100644 index 0000000000..7f4d431299 --- /dev/null +++ b/types/graphql/validation/rules/NoUnusedFragments.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * No unused fragments + * + * A GraphQL document is only valid if all fragment definitions are spread + * within operations, or spread within other fragments spread within operations. + */ +export function NoUnusedFragments(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/NoUnusedVariables.d.ts b/types/graphql/validation/rules/NoUnusedVariables.d.ts new file mode 100644 index 0000000000..6eb2d984aa --- /dev/null +++ b/types/graphql/validation/rules/NoUnusedVariables.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * No unused variables + * + * A GraphQL operation is only valid if all variables defined by an operation + * are used, either directly or within a spread fragment. + */ +export function NoUnusedVariables(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/OverlappingFieldsCanBeMerged.d.ts b/types/graphql/validation/rules/OverlappingFieldsCanBeMerged.d.ts new file mode 100644 index 0000000000..f21edbd2cb --- /dev/null +++ b/types/graphql/validation/rules/OverlappingFieldsCanBeMerged.d.ts @@ -0,0 +1,10 @@ +import { ValidationContext } from '../index'; + +/** + * Overlapping fields can be merged + * + * A selection set is only valid if all fields (including spreading any + * fragments) either correspond to distinct response names or can be merged + * without ambiguity. + */ +export function OverlappingFieldsCanBeMerged(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/PossibleFragmentSpreads.d.ts b/types/graphql/validation/rules/PossibleFragmentSpreads.d.ts new file mode 100644 index 0000000000..8defb47721 --- /dev/null +++ b/types/graphql/validation/rules/PossibleFragmentSpreads.d.ts @@ -0,0 +1,10 @@ +import { ValidationContext } from '../index'; + +/** + * Possible fragment spread + * + * A fragment spread is only valid if the type condition could ever possibly + * be true: if there is a non-empty intersection of the possible parent types, + * and possible types which pass the type condition. + */ +export function PossibleFragmentSpreads(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/ProvidedNonNullArguments.d.ts b/types/graphql/validation/rules/ProvidedNonNullArguments.d.ts new file mode 100644 index 0000000000..4d5334b9fb --- /dev/null +++ b/types/graphql/validation/rules/ProvidedNonNullArguments.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * Provided required arguments + * + * A field or directive is only valid if all required (non-null) field arguments + * have been provided. + */ +export function ProvidedNonNullArguments(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/ScalarLeafs.d.ts b/types/graphql/validation/rules/ScalarLeafs.d.ts new file mode 100644 index 0000000000..afdc575671 --- /dev/null +++ b/types/graphql/validation/rules/ScalarLeafs.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * Scalar leafs + * + * A GraphQL document is valid only if all leaf fields (fields without + * sub selections) are of scalar or enum types. + */ +export function ScalarLeafs(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/SingleFieldSubscriptions.d.ts b/types/graphql/validation/rules/SingleFieldSubscriptions.d.ts new file mode 100644 index 0000000000..01a2654a16 --- /dev/null +++ b/types/graphql/validation/rules/SingleFieldSubscriptions.d.ts @@ -0,0 +1,8 @@ +import { ValidationContext } from '../index'; + +/** + * Subscriptions must only include one field. + * + * A GraphQL subscription is valid only if it contains a single root field. + */ +export function SingleFieldSubscriptions(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/UniqueArgumentNames.d.ts b/types/graphql/validation/rules/UniqueArgumentNames.d.ts new file mode 100644 index 0000000000..8cc166d07a --- /dev/null +++ b/types/graphql/validation/rules/UniqueArgumentNames.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * Unique argument names + * + * A GraphQL field or directive is only valid if all supplied arguments are + * uniquely named. + */ +export function UniqueArgumentNames(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/UniqueDirectivesPerLocation.d.ts b/types/graphql/validation/rules/UniqueDirectivesPerLocation.d.ts new file mode 100644 index 0000000000..70ea02cd9c --- /dev/null +++ b/types/graphql/validation/rules/UniqueDirectivesPerLocation.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * Unique directive names per location + * + * A GraphQL document is only valid if all directives at a given location + * are uniquely named. + */ +export function UniqueDirectivesPerLocation(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/UniqueFragmentNames.d.ts b/types/graphql/validation/rules/UniqueFragmentNames.d.ts new file mode 100644 index 0000000000..c505968f6a --- /dev/null +++ b/types/graphql/validation/rules/UniqueFragmentNames.d.ts @@ -0,0 +1,8 @@ +import { ValidationContext } from '../index'; + +/** + * Unique fragment names + * + * A GraphQL document is only valid if all defined fragments have unique names. + */ +export function UniqueFragmentNames(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/UniqueInputFieldNames.d.ts b/types/graphql/validation/rules/UniqueInputFieldNames.d.ts new file mode 100644 index 0000000000..cebd71b79b --- /dev/null +++ b/types/graphql/validation/rules/UniqueInputFieldNames.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * Unique input field names + * + * A GraphQL input object value is only valid if all supplied fields are + * uniquely named. + */ +export function UniqueInputFieldNames(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/UniqueOperationNames.d.ts b/types/graphql/validation/rules/UniqueOperationNames.d.ts new file mode 100644 index 0000000000..5b12cc0eed --- /dev/null +++ b/types/graphql/validation/rules/UniqueOperationNames.d.ts @@ -0,0 +1,8 @@ +import { ValidationContext } from '../index'; + +/** + * Unique operation names + * + * A GraphQL document is only valid if all defined operations have unique names. + */ +export function UniqueOperationNames(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/UniqueVariableNames.d.ts b/types/graphql/validation/rules/UniqueVariableNames.d.ts new file mode 100644 index 0000000000..ef8712fbc1 --- /dev/null +++ b/types/graphql/validation/rules/UniqueVariableNames.d.ts @@ -0,0 +1,8 @@ +import { ValidationContext } from '../index'; + +/** + * Unique variable names + * + * A GraphQL operation is only valid if all its variables are uniquely named. + */ +export function UniqueVariableNames(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/VariablesAreInputTypes.d.ts b/types/graphql/validation/rules/VariablesAreInputTypes.d.ts new file mode 100644 index 0000000000..df079e52f9 --- /dev/null +++ b/types/graphql/validation/rules/VariablesAreInputTypes.d.ts @@ -0,0 +1,9 @@ +import { ValidationContext } from '../index'; + +/** + * Variables are input types + * + * A GraphQL operation is only valid if all the variables it defines are of + * input types (scalar, enum, or input object). + */ +export function VariablesAreInputTypes(context: ValidationContext): any; diff --git a/types/graphql/validation/rules/VariablesInAllowedPosition.d.ts b/types/graphql/validation/rules/VariablesInAllowedPosition.d.ts new file mode 100644 index 0000000000..6d3e513876 --- /dev/null +++ b/types/graphql/validation/rules/VariablesInAllowedPosition.d.ts @@ -0,0 +1,6 @@ +import { ValidationContext } from '../index'; + +/** + * Variables passed to field arguments conform to type + */ +export function VariablesInAllowedPosition(context: ValidationContext): any; diff --git a/types/handsontable/tslint.json b/types/handsontable/tslint.json index 40e100fc9e..5f3a731336 100644 --- a/types/handsontable/tslint.json +++ b/types/handsontable/tslint.json @@ -4,6 +4,7 @@ // TODOs "ban-types": false, "dt-header": false, + "no-any-union": false, "no-single-declare-module": false } } diff --git a/types/hasha/tslint.json b/types/hasha/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/hasha/tslint.json +++ b/types/hasha/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/hedron/tsconfig.json b/types/hedron/tsconfig.json index a0fbe944b9..bc9aa5b828 100644 --- a/types/hedron/tsconfig.json +++ b/types/hedron/tsconfig.json @@ -1,20 +1,24 @@ { - "files": ["index.d.ts", "hedron-tests.tsx"], - "compilerOptions": { - "module": "commonjs", - "lib": ["es6", "dom"], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "strict": true, - "noImplicitReturns": true, - "noUnusedLocals": true, - "noUnusedParameters": true, - "baseUrl": "../", - "typeRoots": ["../"], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "jsx": "preserve" - } -} + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "preserve" + }, + "files": [ + "index.d.ts", + "hedron-tests.tsx" + ] +} \ No newline at end of file diff --git a/types/hellojs/tslint.json b/types/hellojs/tslint.json index 2750cc0197..d9d49e375e 100644 --- a/types/hellojs/tslint.json +++ b/types/hellojs/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } \ No newline at end of file +{ + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false + } +} diff --git a/types/heredatalens/tslint.json b/types/heredatalens/tslint.json index e60c15844f..d9d49e375e 100644 --- a/types/heredatalens/tslint.json +++ b/types/heredatalens/tslint.json @@ -1,3 +1,6 @@ { - "extends": "dtslint/dt.json" -} \ No newline at end of file + "extends": "dtslint/dt.json", + "rules": { + "no-any-union": false + } +} diff --git a/types/hexo-fs/hexo-fs-tests.ts b/types/hexo-fs/hexo-fs-tests.ts new file mode 100644 index 0000000000..71e6d99e1b --- /dev/null +++ b/types/hexo-fs/hexo-fs-tests.ts @@ -0,0 +1,991 @@ +import fs = require('hexo-fs'); +import path = require('path'); +import mocha = require('mocha'); +import chai = require('chai'); +import Promise = require('bluebird'); + +const should = chai.should(); +const { join } = path; + +function createDummyFolder(path: string) { + return Promise.all([ + // Normal files in a hidden folder + fs.writeFile(join(path, '.hidden', 'a.txt'), 'a'), + fs.writeFile(join(path, '.hidden', 'b.js'), 'b'), + // Normal folder in a hidden folder + fs.writeFile(join(path, '.hidden', 'c', 'd'), 'd'), + // Top-class files + fs.writeFile(join(path, 'e.txt'), 'e'), + fs.writeFile(join(path, 'f.js'), 'f'), + // A hidden file + fs.writeFile(join(path, '.g'), 'g'), + // Files in a normal folder + fs.writeFile(join(path, 'folder', 'h.txt'), 'h'), + fs.writeFile(join(path, 'folder', 'i.js'), 'i'), + // A hidden files in a normal folder + fs.writeFile(join(path, 'folder', '.j'), 'j') + ]); +} + +const tmpDir = join(__dirname, 'fs_tmp'); + +before(() => fs.mkdirs(tmpDir)); + +after((done) => { + fs.rmdir(tmpDir); + done(); +}); + +it('exists()', () => { + return fs.exists(tmpDir).then((exist) => { + exist.should.be.true; + }); +}); + +it('exists() - callback', (callback) => { + fs.exists(tmpDir, (exist) => { + exist.should.be.true; + callback(); + }); +}); + +it('mkdirs()', () => { + const target = join(tmpDir, 'a', 'b', 'c'); + + return fs.mkdirs(target).then(() => { + return fs.exists(target); + }).then((exist) => { + exist.should.be.true; + return fs.rmdir(join(tmpDir, 'a')); + }); +}); + +it('mkdirs() - callback', (callback) => { + const target = join(tmpDir, 'a', 'b', 'c'); + + fs.mkdirs(target, (err) => { + should.not.exist(err); + + fs.exists(target, (exist) => { + exist.should.be.true; + fs.rmdir(join(tmpDir, 'a'), callback); + }); + }); +}); + +it('mkdirsSync()', () => { + const target = join(tmpDir, 'a', 'b', 'c'); + + fs.mkdirsSync(target); + + return fs.exists(target).then((exist) => { + exist.should.be.true; + return fs.rmdir(join(tmpDir, 'a')); + }); +}); + +it('writeFile()', () => { + const target = join(tmpDir, 'a', 'b', 'test.txt'); + const body = 'foo'; + + return fs.writeFile(target, body).then(() => { + return fs.readFile(target); + }).then((content) => { + content.should.eql(body); + return fs.rmdir(join(tmpDir, 'a')); + }); +}); + +it('writeFile() - callback', (callback) => { + const target = join(tmpDir, 'a', 'b', 'test.txt'); + const body = 'foo'; + + fs.writeFile(target, body, (err) => { + should.not.exist(err); + + fs.readFile(target, (_, content) => { + content!.should.eql(body); + fs.rmdir(join(tmpDir, 'a'), callback); + }); + }); +}); + +it('writeFileSync()', () => { + const target = join(tmpDir, 'a', 'b', 'test.txt'); + const body = 'foo'; + + fs.writeFileSync(target, body); + + return fs.readFile(target).then((content) => { + content.should.eql(body); + return fs.rmdir(join(tmpDir, 'a')); + }); +}); + +it('appendFile()', () => { + const target = join(tmpDir, 'a', 'b', 'test.txt'); + const body = 'foo'; + const body2 = 'bar'; + + return fs.writeFile(target, body).then(() => { + return fs.appendFile(target, body2); + }).then(() => { + return fs.readFile(target); + }).then((content) => { + content.should.eql(body + body2); + return fs.rmdir(join(tmpDir, 'a')); + }); +}); + +it('appendFile() - callback', (callback) => { + const target = join(tmpDir, 'a', 'b', 'test.txt'); + const body = 'foo'; + const body2 = 'bar'; + + fs.writeFile(target, body, () => { + fs.appendFile(target, body2, (err) => { + should.not.exist(err); + + fs.readFile(target, (_, content) => { + content!.should.eql(body + body2); + fs.rmdir(join(tmpDir, 'a'), callback); + }); + }); + }); +}); + +it('appendFileSync()', () => { + const target = join(tmpDir, 'a', 'b', 'test.txt'); + const body = 'foo'; + const body2 = 'bar'; + + return fs.writeFile(target, body).then(() => { + fs.appendFileSync(target, body2); + return fs.readFile(target); + }).then((content) => { + content.should.eql(body + body2); + return fs.rmdir(join(tmpDir, 'a')); + }); +}); + +it('copyFile()', () => { + const src = join(tmpDir, 'test.txt'); + const dest = join(tmpDir, 'a', 'b', 'test.txt'); + const body = 'foo'; + + return fs.writeFile(src, body).then(() => { + return fs.copyFile(src, dest); + }).then(() => { + return fs.readFile(dest); + }).then((content) => { + content.should.eql(body); + + return Promise.all([ + fs.unlink(src), + fs.rmdir(join(tmpDir, 'a')) + ]); + }); +}); + +it('copyFile() - callback', (callback) => { + const src = join(tmpDir, 'test.txt'); + const dest = join(tmpDir, 'a', 'b', 'test.txt'); + const body = 'foo'; + + fs.writeFile(src, body, (err) => { + if (err) return callback(err); + + fs.copyFile(src, dest, (err) => { + if (err) return callback(err); + + fs.readFile(dest, (err, content) => { + if (err) return callback(err); + content!.should.eql(body); + + Promise.all([ + fs.unlink(src), + fs.rmdir(join(tmpDir, 'a')) + ]).asCallback(callback); + }); + }); + }); +}); + +it('copyDir()', () => { + const src = join(tmpDir, 'a'); + const dest = join(tmpDir, 'b'); + + return createDummyFolder(src).then(() => { + return fs.copyDir(src, dest); + }).then((files) => { + files.should.have.members([ + 'e.txt', + 'f.js', + join('folder', 'h.txt'), + join('folder', 'i.js') + ]); + + return Promise.all([ + fs.readFile(join(dest, 'e.txt')), + fs.readFile(join(dest, 'f.js')), + fs.readFile(join(dest, 'folder', 'h.txt')), + fs.readFile(join(dest, 'folder', 'i.js')) + ]); + }).then((result) => { + result.should.eql(['e', 'f', 'h', 'i']); + }).then(() => { + return Promise.all([ + fs.rmdir(src), + fs.rmdir(dest) + ]); + }); +}); + +it('copyDir() - callback', (callback) => { + const src = join(tmpDir, 'a'); + const dest = join(tmpDir, 'b'); + + createDummyFolder(src).then(() => { + fs.copyDir(src, dest, (err, files) => { + should.not.exist(err); + files!.should.have.members([ + 'e.txt', + 'f.js', + join('folder', 'h.txt'), + join('folder', 'i.js') + ]); + + Promise.all([ + fs.readFile(join(dest, 'e.txt')), + fs.readFile(join(dest, 'f.js')), + fs.readFile(join(dest, 'folder', 'h.txt')), + fs.readFile(join(dest, 'folder', 'i.js')) + ]).then((result) => { + result.should.eql(['e', 'f', 'h', 'i']); + }).then(() => { + return Promise.all([ + fs.rmdir(src), + fs.rmdir(dest) + ]); + }).asCallback(callback); + }); + }); +}); + +it('copyDir() - ignoreHidden off', () => { + const src = join(tmpDir, 'a'); + const dest = join(tmpDir, 'b'); + + return createDummyFolder(src).then(() => { + return fs.copyDir(src, dest, { ignoreHidden: false }); + }).then((files) => { + files.should.have.members([ + join('.hidden', 'a.txt'), + join('.hidden', 'b.js'), + join('.hidden', 'c', 'd'), + 'e.txt', + 'f.js', + '.g', + join('folder', 'h.txt'), + join('folder', 'i.js'), + join('folder', '.j') + ]); + + return Promise.all([ + fs.readFile(join(dest, '.hidden', 'a.txt')), + fs.readFile(join(dest, '.hidden', 'b.js')), + fs.readFile(join(dest, '.hidden', 'c', 'd')), + fs.readFile(join(dest, 'e.txt')), + fs.readFile(join(dest, 'f.js')), + fs.readFile(join(dest, '.g')), + fs.readFile(join(dest, 'folder', 'h.txt')), + fs.readFile(join(dest, 'folder', 'i.js')), + fs.readFile(join(dest, 'folder', '.j')) + ]); + }).then((result) => { + result.should.eql(['a', 'b', 'd', 'e', 'f', 'g', 'h', 'i', 'j']); + }).then(() => { + return Promise.all([ + fs.rmdir(src), + fs.rmdir(dest) + ]); + }); +}); + +it('copyDir() - ignorePattern', () => { + const src = join(tmpDir, 'a'); + const dest = join(tmpDir, 'b'); + + return createDummyFolder(src).then(() => { + return fs.copyDir(src, dest, { ignorePattern: /\.js/ }); + }).then((files) => { + files.should.have.members(['e.txt', join('folder', 'h.txt')]); + + return Promise.all([ + fs.readFile(join(dest, 'e.txt')), + fs.readFile(join(dest, 'folder', 'h.txt')) + ]); + }).then((result) => { + result.should.eql(['e', 'h']); + }).then(() => { + return Promise.all([ + fs.rmdir(src), + fs.rmdir(dest) + ]); + }); +}); + +it('listDir()', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then(() => { + return fs.listDir(target); + }).then((files) => { + files.should.have.members([ + 'e.txt', + 'f.js', + join('folder', 'h.txt'), + join('folder', 'i.js') + ]); + + return fs.rmdir(target); + }); +}); + +it('listDir() - callback', (callback) => { + const target = join(tmpDir, 'test'); + + createDummyFolder(target).then(() => { + fs.listDir(target, (err, files) => { + if (err) return callback(err); + + files!.should.have.members([ + 'e.txt', + 'f.js', + join('folder', 'h.txt'), + join('folder', 'i.js') + ]); + + fs.rmdir(target, callback); + }); + }); +}); + +it('listDir() - ignoreHidden off', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then(() => { + return fs.listDir(target, { ignoreHidden: false }); + }).then((files) => { + files.should.have.members([ + join('.hidden', 'a.txt'), + join('.hidden', 'b.js'), + join('.hidden', 'c', 'd'), + 'e.txt', + 'f.js', + '.g', + join('folder', 'h.txt'), + join('folder', 'i.js'), + join('folder', '.j') + ]); + + return fs.rmdir(target); + }); +}); + +it('listDir() - ignorePattern', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then(() => { + return fs.listDir(target, { ignorePattern: /\.js/ }); + }).then((files) => { + files.should.have.members(['e.txt', join('folder', 'h.txt')]); + return fs.rmdir(target); + }); +}); + +it('listDirSync()', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then(() => { + const files = fs.listDirSync(target); + files.should.have.members([ + 'e.txt', + 'f.js', + join('folder', 'h.txt'), + join('folder', 'i.js') + ]); + + return fs.rmdir(target); + }); +}); + +it('listDirSync() - ignoreHidden off', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then(() => { + const files = fs.listDirSync(target, { ignoreHidden: false }); + files.should.have.members([ + join('.hidden', 'a.txt'), + join('.hidden', 'b.js'), + join('.hidden', 'c', 'd'), + 'e.txt', + 'f.js', + '.g', + join('folder', 'h.txt'), + join('folder', 'i.js'), + join('folder', '.j') + ]); + + return fs.rmdir(target); + }); +}); + +it('listDirSync() - ignorePattern', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then(() => { + const files = fs.listDirSync(target, { ignorePattern: /\.js/ }); + files.should.have.members(['e.txt', join('folder', 'h.txt')]); + return fs.rmdir(target); + }); +}); + +it('readFile()', () => { + const target = join(tmpDir, 'test.txt'); + const body = 'test'; + + return fs.writeFile(target, body).then(() => { + return fs.readFile(target); + }).then((content) => { + content.should.eql(body); + return fs.unlink(target); + }); +}); + +it('readFile() - callback', (callback) => { + const target = join(tmpDir, 'test.txt'); + const body = 'test'; + + fs.writeFile(target, body, (err) => { + if (err) return callback(err); + + fs.readFile(target, (err, content) => { + if (err) return callback(err); + + content!.should.eql(body); + + fs.unlink(target).asCallback(callback); + }); + }); +}); + +it('readFile() - escape BOM', () => { + const target = join(tmpDir, 'test.txt'); + const body = '\ufefffoo'; + + return fs.writeFile(target, body).then(() => { + return fs.readFile(target); + }).then((content) => { + content.should.eql('foo'); + return fs.unlink(target); + }); +}); + +it('readFile() - escape Windows line ending', () => { + const target = join(tmpDir, 'test.txt'); + const body = 'foo\r\nbar'; + + return fs.writeFile(target, body).then(() => { + return fs.readFile(target); + }).then((content) => { + content.should.eql('foo\nbar'); + return fs.unlink(target); + }); +}); + +it('readFileSync()', () => { + const target = join(tmpDir, 'test.txt'); + const body = 'test'; + + return fs.writeFile(target, body).then(() => { + fs.readFileSync(target).should.eql(body); + return fs.unlink(target); + }); +}); + +it('readFileSync() - escape BOM', () => { + const target = join(tmpDir, 'test.txt'); + const body = '\ufefffoo'; + + return fs.writeFile(target, body).then(() => { + fs.readFileSync(target).should.eql('foo'); + return fs.unlink(target); + }); +}); + +it('readFileSync() - escape Windows line ending', () => { + const target = join(tmpDir, 'test.txt'); + const body = 'foo\r\nbar'; + + return fs.writeFile(target, body).then(() => { + fs.readFileSync(target).should.eql('foo\nbar'); + return fs.unlink(target); + }); +}); + +it('unlink()', () => { + const target = join(tmpDir, 'test-unlink'); + + return fs.writeFile(target, '').then(() => { + return fs.exists(target); + }).then((exist) => { + exist.should.eql(true); + return fs.unlink(target); + }).then(() => { + return fs.exists(target); + }).then((exist) => { + exist.should.eql(false); + }); +}); + +it('emptyDir()', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then(() => { + return fs.emptyDir(target); + }).then>((files) => { + files.should.have.members([ + 'e.txt', + 'f.js', + join('folder', 'h.txt'), + join('folder', 'i.js') + ]); + + return [ + [join(target, '.hidden', 'a.txt'), true], + [join(target, '.hidden', 'b.js'), true], + [join(target, '.hidden', 'c', 'd'), true], + [join(target, 'e.txt'), false], + [join(target, 'f.js'), false], + [join(target, '.g'), true], + [join(target, 'folder', 'h.txt'), false], + [join(target, 'folder', 'i.js'), false], + [join(target, 'folder', '.j'), true] + ]; + }).map((data: [string, boolean]) => { + return fs.exists(data[0]).then((exist) => { + exist.should.eql(data[1]); + }); + }).then(() => { + return fs.rmdir(target); + }); +}); + +it('emptyDir() - callback', (callback) => { + const target = join(tmpDir, 'test'); + + createDummyFolder(target).then(() => { + fs.emptyDir(target, (err, files) => { + if (err) return callback(err); + + files!.should.have.members([ + 'e.txt', + 'f.js', + join('folder', 'h.txt'), + join('folder', 'i.js') + ]); + + Promise.map<[string, boolean], void>([ + [join(target, '.hidden', 'a.txt'), true], + [join(target, '.hidden', 'b.js'), true], + [join(target, '.hidden', 'c', 'd'), true], + [join(target, 'e.txt'), false], + [join(target, 'f.js'), false], + [join(target, '.g'), true], + [join(target, 'folder', 'h.txt'), false], + [join(target, 'folder', 'i.js'), false], + [join(target, 'folder', '.j'), true] + ], (data: [string, boolean]) => { + return fs.exists(data[0]).then((exist) => { + exist.should.eql(data[1]); + }); + }).then(() => { + return fs.rmdir(target); + }).asCallback(callback); + }); + }); +}); + +it('emptyDir() - ignoreHidden off', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then(() => { + return fs.emptyDir(target, { ignoreHidden: false }); + }).then>((files) => { + files.should.have.members([ + join('.hidden', 'a.txt'), + join('.hidden', 'b.js'), + join('.hidden', 'c', 'd'), + 'e.txt', + 'f.js', + '.g', + join('folder', 'h.txt'), + join('folder', 'i.js'), + join('folder', '.j') + ]); + + return [ + [join(target, '.hidden', 'a.txt'), false], + [join(target, '.hidden', 'b.js'), false], + [join(target, '.hidden', 'c', 'd'), false], + [join(target, 'e.txt'), false], + [join(target, 'f.js'), false], + [join(target, '.g'), false], + [join(target, 'folder', 'h.txt'), false], + [join(target, 'folder', 'i.js'), false], + [join(target, 'folder', '.j'), false] + ]; + }).map((data: [string, boolean]) => { + return fs.exists(data[0]).then((exist) => { + exist.should.eql(data[1]); + }); + }).then(() => { + return fs.rmdir(target); + }); +}); + +it('emptyDir() - ignorePattern', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then(() => { + return fs.emptyDir(target, { ignorePattern: /\.js/ }); + }).then>((files) => { + files.should.have.members(['e.txt', join('folder', 'h.txt')]); + + return [ + [join(target, '.hidden', 'a.txt'), true], + [join(target, '.hidden', 'b.js'), true], + [join(target, '.hidden', 'c', 'd'), true], + [join(target, 'e.txt'), false], + [join(target, 'f.js'), true], + [join(target, '.g'), true], + [join(target, 'folder', 'h.txt'), false], + [join(target, 'folder', 'i.js'), true], + [join(target, 'folder', '.j'), true] + ]; + }).map((data: [string, boolean]) => { + return fs.exists(data[0]).then((exist) => { + exist.should.eql(data[1]); + }); + }).then(() => { + return fs.rmdir(target); + }); +}); + +it('emptyDir() - exclude', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then(() => { + return fs.emptyDir(target, { exclude: ['e.txt', join('folder', 'i.js')] }); + }).then>((files) => { + files.should.have.members(['f.js', join('folder', 'h.txt')]); + + return [ + [join(target, '.hidden', 'a.txt'), true], + [join(target, '.hidden', 'b.js'), true], + [join(target, '.hidden', 'c', 'd'), true], + [join(target, 'e.txt'), true], + [join(target, 'f.js'), false], + [join(target, '.g'), true], + [join(target, 'folder', 'h.txt'), false], + [join(target, 'folder', 'i.js'), true], + [join(target, 'folder', '.j'), true] + ]; + }).map((data: [string, boolean]) => { + return fs.exists(data[0]).then((exist) => { + exist.should.eql(data[1]); + }); + }).then(() => { + return fs.rmdir(target); + }); +}); + +it('emptyDirSync()', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then>(() => { + const files = fs.emptyDirSync(target); + files.should.have.members([ + 'e.txt', + 'f.js', + join('folder', 'h.txt'), + join('folder', 'i.js') + ]); + + return [ + [join(target, '.hidden', 'a.txt'), true], + [join(target, '.hidden', 'b.js'), true], + [join(target, '.hidden', 'c', 'd'), true], + [join(target, 'e.txt'), false], + [join(target, 'f.js'), false], + [join(target, '.g'), true], + [join(target, 'folder', 'h.txt'), false], + [join(target, 'folder', 'i.js'), false], + [join(target, 'folder', '.j'), true] + ]; + }).map((data: [string, boolean]) => { + return fs.exists(data[0]).then((exist) => { + exist.should.eql(data[1]); + }); + }).then(() => { + return fs.rmdir(target); + }); +}); + +it('emptyDirSync() - ignoreHidden off', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then>(() => { + const files = fs.emptyDirSync(target, { ignoreHidden: false }); + files.should.have.members([ + join('.hidden', 'a.txt'), + join('.hidden', 'b.js'), + join('.hidden', 'c', 'd'), + 'e.txt', + 'f.js', + '.g', + join('folder', 'h.txt'), + join('folder', 'i.js'), + join('folder', '.j') + ]); + + return [ + [join(target, '.hidden', 'a.txt'), false], + [join(target, '.hidden', 'b.js'), false], + [join(target, '.hidden', 'c', 'd'), false], + [join(target, 'e.txt'), false], + [join(target, 'f.js'), false], + [join(target, '.g'), false], + [join(target, 'folder', 'h.txt'), false], + [join(target, 'folder', 'i.js'), false], + [join(target, 'folder', '.j'), false] + ]; + }).map((data: [string, boolean]) => { + return fs.exists(data[0]).then((exist) => { + exist.should.eql(data[1]); + }); + }).then(() => { + return fs.rmdir(target); + }); +}); + +it('emptyDirSync() - ignorePattern', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then>(() => { + const files = fs.emptyDirSync(target, { ignorePattern: /\.js/ }); + files.should.have.members(['e.txt', join('folder', 'h.txt')]); + + return [ + [join(target, '.hidden', 'a.txt'), true], + [join(target, '.hidden', 'b.js'), true], + [join(target, '.hidden', 'c', 'd'), true], + [join(target, 'e.txt'), false], + [join(target, 'f.js'), true], + [join(target, '.g'), true], + [join(target, 'folder', 'h.txt'), false], + [join(target, 'folder', 'i.js'), true], + [join(target, 'folder', '.j'), true] + ]; + }).map((data: [string, boolean]) => { + return fs.exists(data[0]).then((exist) => { + exist.should.eql(data[1]); + }); + }).then(() => { + return fs.rmdir(target); + }); +}); + +it('emptyDirSync() - exclude', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then>(() => { + const files = fs.emptyDirSync(target, { exclude: ['e.txt', join('folder', 'i.js')] }); + files.should.have.members(['f.js', join('folder', 'h.txt')]); + + return [ + [join(target, '.hidden', 'a.txt'), true], + [join(target, '.hidden', 'b.js'), true], + [join(target, '.hidden', 'c', 'd'), true], + [join(target, 'e.txt'), true], + [join(target, 'f.js'), false], + [join(target, '.g'), true], + [join(target, 'folder', 'h.txt'), false], + [join(target, 'folder', 'i.js'), true], + [join(target, 'folder', '.j'), true] + ]; + }).map((data: [string, boolean]) => { + return fs.exists(data[0]).then((exist) => { + exist.should.eql(data[1]); + }); + }).then(() => { + return fs.rmdir(target); + }); +}); + +it('rmdir()', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then(() => { + return fs.rmdir(target); + }).then(() => { + return fs.exists(target); + }).then((exist) => { + exist.should.be.false; + }); +}); + +it('rmdir() - callback', (callback) => { + const target = join(tmpDir, 'test'); + + createDummyFolder(target).then(() => { + fs.rmdir(target, (err) => { + should.not.exist(err); + + fs.exists(target, (exist) => { + exist.should.be.false; + callback(); + }); + }); + }); +}); + +it('rmdirSync()', () => { + const target = join(tmpDir, 'test'); + + return createDummyFolder(target).then(() => { + fs.rmdirSync(target); + return fs.exists(target); + }).then((exist) => { + exist.should.be.false; + }); +}); + +import { FSWatcher } from 'chokidar'; + +it('watch()', () => { + let watcher: FSWatcher; + + return fs.watch(tmpDir).then((watcher_) => { + watcher = watcher_; + + return new Promise((resolve, reject) => { + const path = join(tmpDir, 'test.txt'); + + watcher.on('add', (path_) => { + path_.should.eql(path); + resolve(); + }); + + fs.writeFile(path, 'test').catch(reject); + }); + }).finally(() => { + if (watcher) watcher.close(); + }); +}); + +it('ensurePath() - file exists', () => { + const target = join(tmpDir, 'test'); + + return Promise.all([ + fs.writeFile(join(target, 'foo.txt'), ''), + fs.writeFile(join(target, 'foo-1.txt'), ''), + fs.writeFile(join(target, 'foo-2.md'), ''), + fs.writeFile(join(target, 'bar.txt'), '') + ]).then(() => { + return fs.ensurePath(join(target, 'foo.txt')); + }).then((path) => { + path.should.eql(join(target, 'foo-2.txt')); + return fs.rmdir(target); + }); +}); + +it('ensurePath() - file not exist', () => { + const target = join(tmpDir, 'foo.txt'); + + return fs.ensurePath(target).then((path) => { + path.should.eql(target); + }); +}); + +it('ensurePath() - callback', (callback) => { + const target = join(tmpDir, 'test'); + + Promise.all([ + fs.writeFile(join(target, 'foo.txt'), ''), + fs.writeFile(join(target, 'foo-1.txt'), ''), + fs.writeFile(join(target, 'foo-2.md'), ''), + fs.writeFile(join(target, 'bar.txt'), '') + ]).then(() => { + fs.ensurePath(join(target, 'foo.txt'), (err, path) => { + should.not.exist(err); + path!.should.eql(join(target, 'foo-2.txt')); + fs.rmdir(target, callback); + }); + }); +}); + +it('ensurePathSync() - file exists', () => { + const target = join(tmpDir, 'test'); + + return Promise.all([ + fs.writeFile(join(target, 'foo.txt'), ''), + fs.writeFile(join(target, 'foo-1.txt'), ''), + fs.writeFile(join(target, 'foo-2.md'), ''), + fs.writeFile(join(target, 'bar.txt'), '') + ]).then(() => { + const path = fs.ensurePathSync(join(target, 'foo.txt')); + path.should.eql(join(target, 'foo-2.txt')); + + return fs.rmdir(target); + }); +}); + +it('ensurePathSync() - file not exist', () => { + const target = join(tmpDir, 'foo.txt'); + const path = fs.ensurePathSync(target); + + path.should.eql(target); +}); + +it('ensureWriteStream()', () => { + const target = join(tmpDir, 'foo', 'bar.txt'); + + return fs.ensureWriteStream(target).then((stream) => { + stream.path.should.eql(target); + stream.on('finish', () => { + return fs.unlink(target); + }); + }); +}); + +it('ensureWriteStream() - callback', (callback) => { + const target = join(tmpDir, 'foo', 'bar.txt'); + + fs.ensureWriteStream(target, (err, stream) => { + should.not.exist(err); + stream!.path.should.eql(target); + callback(); + }); +}); + +it('ensureWriteStreamSync()', () => { + const target = join(tmpDir, 'foo', 'bar.txt'); + const stream = fs.ensureWriteStreamSync(target); + + stream.path.should.eql(target); + stream.on('finish', () => { + return fs.rmdir(path.dirname(target)); + }); +}); diff --git a/types/hexo-fs/index.d.ts b/types/hexo-fs/index.d.ts new file mode 100644 index 0000000000..896fbc24eb --- /dev/null +++ b/types/hexo-fs/index.d.ts @@ -0,0 +1,436 @@ +// Type definitions for hexo-fs 0.2 +// Project: http://hexo.io/ +// Definitions by: segayuu +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import Promise = require('bluebird'); +import { + PathLike, + Stats, + ReadStream, + WriteStream, + // chmod, + chmodSync, + // fchmod, + fchmodSync, + // lchmod, + lchmodSync, + // chown, + chownSync, + // fchown, + fchownSync, + // lchown, + lchownSync, + // close, + closeSync, + createReadStream, + createWriteStream, + // fsync, + fsyncSync, + // link, + linkSync, + // mkdir, + mkdirSync, + // open, + openSync, + // symlink, + symlinkSync, + // read, + readSync, + // readdir, + readdirSync, + // readlink, + readlinkSync, + // realpath, + realpathSync, + // rename, + renameSync, + // stat, + statSync, + // fstat, + fstatSync, + // lstat, + lstatSync, + // truncate, + truncateSync, + // ftruncate, + ftruncateSync, + // unlink, + unlinkSync, + // utimes, + utimesSync, + // futimes, + futimesSync, + watchFile, + unwatchFile, + // write, + writeSync +} from 'graceful-fs'; + +export interface DirectoryOptions { + ignoreHidden?: boolean; + ignorePattern?: RegExp; +} + +export interface AppendFileOptions { + encoding?: string | null; + mode?: string | number; + flag?: string; +} + +// access +export let F_OK: number | undefined; +export let R_OK: number | undefined; +export let W_OK: number | undefined; +export let X_OK: number | undefined; + +export let access: ((path: PathLike, mode?: number) => Promise) | undefined; // promisify +export let accessSync: ((path: PathLike, mode?: number) => void) | undefined; // promisify + +// appendFile +/** + * Appends data to a file. + * @param path + * @param data + * @param callback + */ +export function appendFile(path: string, data: any, callback?: (err: any) => void): Promise; +/** + * Appends data to a file. + * @param path + * @param data + * @param options + * @param callback + */ +export function appendFile(path: string, data: any, options: string | AppendFileOptions, callback?: (err: any) => void): Promise; +/** + * Synchronous version of fs.appendFile. + * @param path + * @param data + * @param options + */ +export function appendFileSync(path: string, data: any, options?: string | AppendFileOptions): void; + +// chmod +export function chmod(path: PathLike, mode: string | number): Promise; // promisify +export function fchmod(fd: number, mode: string | number): Promise; // promisify +export function lchmod(path: PathLike, mode: string | number): Promise; // promisify +export { chmodSync, fchmodSync, lchmodSync }; + +// chown +export function chown(path: PathLike, uid: number, gid: number): Promise; // promisify +export function fchown(fd: number, uid: number, gid: number): Promise; // promisify +export function lchown(path: PathLike, uid: number, gid: number): Promise; // promisify +export { chownSync, fchownSync, lchownSync }; + +// close +export function close(fd: number): Promise; // promisify +export { closeSync }; + +// copy +/** + * Copies a directory from src to dest. It returns an array of copied files. + * @param src + * @param dest + * @param callback + */ +export function copyDir(src: string, dest: string, callback?: (err: any, value?: string[]) => void): Promise; +/** + * Copies a directory from src to dest. It returns an array of copied files. + * @param dest + * @param options + * @param callback + */ +export function copyDir(src: string, dest: string, options?: DirectoryOptions, callback?: (err: any, value?: string[]) => void): Promise; +/** + * Copies a file from src to dest. + * @param src + * @param dest + * @param callback + */ +export function copyFile(src: PathLike, dest: string, callback?: (err: any) => void): Promise; + +// createStream +export { createReadStream, createWriteStream }; + +// emptyDir +/** + * Deletes all files in a directory. It returns an array of deleted files. + * @param path + * @param callback + */ +export function emptyDir(path: string, callback?: (err: any, value?: string | string[]) => void): Promise; +export function emptyDir( + path: string, + options?: DirectoryOptions & { exclude?: string[] }, + callback?: (err: any, value?: string | string[]) => void +): Promise; +export function emptyDirSync(path: string, options?: DirectoryOptions & { exclude?: string[] }, parent?: string): string | string[]; + +// ensurePath +/** + * Ensures the given path is available to use or appends a number to the path. + * @param path + * @param callback + */ +export function ensurePath(path: string, callback?: (err: any, value?: string) => void): Promise; +/** + * Synchronous version of `fs.ensurePath`. + * @param path + */ +export function ensurePathSync(path: string): string; + +// ensureWriteStream +/** + * Creates the parent directories if they does not exist and returns a writable stream. + * @param path + * @param callback + */ +export function ensureWriteStream(path: string, callback?: (err: any, value?: WriteStream) => void): Promise; +/** + * Creates the parent directories if they does not exist and returns a writable stream. + * @param path + * @param options + * @param callback + */ +export function ensureWriteStream( + path: string, + options?: string | { + flags?: string; + defaultEncoding?: string; + fd?: number; + mode?: number; + autoClose?: boolean; + start?: number; + }, + callback?: (err: any, value?: WriteStream) => void +): Promise; +/** + * Synchronous version of fs.ensureWriteStream. + * @param path + * @param options + */ +export function ensureWriteStreamSync(path: string, options?: string | { + flags?: string; + defaultEncoding?: string; + fd?: number; + mode?: number; + autoClose?: boolean; + start?: number; +}): WriteStream; + +// exists +/** + * Test whether or not the given `path` exists by checking with the file system. + * @param path checking if exists. + * @param callback + */ +export function exists(path: PathLike, callback?: (exist: boolean) => void): Promise; +/** + * Synchronous version of `fs.exists`. + * @param path + */ +export function existsSync(path: PathLike): boolean; + +// fsync +export function fsync(fd: number): Promise; // promisify +export { fsyncSync }; + +// link +export function link(existingPath: PathLike, newPath: PathLike): Promise; // promisify +export { linkSync }; + +// listDir +/** + * Lists files in a directory. + * @param path + * @param callback + */ +export function listDir(path: string, callback?: (err: any, value?: string[]) => void): Promise; +/** + * Lists files in a directory. + * @param path + * @param options + * @param callback + */ +export function listDir(path: string, options?: DirectoryOptions, callback?: (err: any, value?: string[]) => void): Promise; +/** + * Synchronous version of `fs.listDir`. + * @param path + * @param options + * @param parent + */ +export function listDirSync(path: string, options?: DirectoryOptions, parent?: string): string | string[]; + +// mkdir +export function mkdir(path: PathLike, mode?: string | number): Promise; // promisify +export { mkdirSync }; + +// mkdirs +/** + * Creates a directory and its parent directories if they does not exist. + * @param path + * @param callback + */ +export function mkdirs(path: PathLike, callback?: (err: any) => void): Promise; +/** + * Synchronous version of `fs.mkdirs`. + * @param path + */ +export function mkdirsSync(path: string): void; + +// open +export function open(path: PathLike, flags: string | number, mode?: string | number | null): Promise; // promisify +export { openSync }; + +// symlink +export function symlink(target: PathLike, path: PathLike, type?: string | null): Promise; // promisify +export { symlinkSync }; + +// read +export function read( + fd: number, + buffer: TBuffer, + offset: number, + length: number, + position: number | null +): Promise<{ bytesRead: number, buffer: TBuffer }>; // promisify +export { readSync }; + +// readdir +export function readdir(path: PathLike, options?: { encoding: BufferEncoding | null } | BufferEncoding | null): Promise; // promisify +export function readdir(path: PathLike, options: "buffer" | { encoding: "buffer" }): Promise; // promisify +export function readdir(path: PathLike, options?: { encoding?: string | null } | string | null): Promise>; // promisify +export { readdirSync }; + +// readFile +/** + * Reads the entire contents of a file. + * @param path + * @param callback + */ +export function readFile(path: PathLike | number, callback?: (err: any, value?: string) => void): Promise; +/** + * Reads the entire contents of a file. + * @param path + * @param options + * @param callback + */ +export function readFile( + path: PathLike | number, + options?: { encoding?: string; flag?: string; escape?: boolean; }, + callback?: (err: any, value?: string) => void +): Promise; +/** + * Synchronous version of `fs.readFile`. + * @param path + * @param options + */ +export function readFileSync(path: PathLike | number, options?: { encoding?: string; flag?: string; escape?: boolean; }): string; + +// readlink +export function readlink(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise; // promisify +export function readlink(path: PathLike, options: { encoding: 'buffer' } | 'buffer'): Promise; // promisify +export function readlink(path: PathLike, options?: { encoding?: string | null } | string | null): Promise; // promisify +export { readlinkSync }; + +// realpath +export function realpath(path: PathLike, options?: { encoding?: BufferEncoding | null } | BufferEncoding | null): Promise; // promisify +export function realpath(path: PathLike, options: { encoding: 'buffer' } | 'buffer'): Promise; // promisify +export function realpath(path: PathLike, options?: { encoding?: string | null } | string | null): Promise; // promisify +export { realpathSync }; + +// rename +export function rename(oldPath: PathLike, newPath: PathLike): Promise; // promisify +export { renameSync }; + +// rmdir +export function rmdir(path: string, callback?: (err: any) => void): Promise; +export function rmdirSync(path: string): void; + +// stat +export function stat(path: PathLike): Promise; // promisify +export function fstat(fd: number): Promise; // promisify +export function lstat(path: PathLike): Promise; // promisify +export { statSync, fstatSync, lstatSync }; + +// truncate +export function truncate(path: PathLike, len?: number | null): Promise; // promisify +export function ftruncate(fd: number, len?: number | null): Promise; // promisify +export { truncateSync, ftruncateSync }; + +// unlink +export function unlink(path: PathLike): Promise; // promisify +export { unlinkSync }; + +// utimes +export function utimes(path: PathLike, atime: string | number | Date, mtime: string | number | Date): Promise; // promisify +export function futimes(fd: number, atime: string | number | Date, mtime: string | number | Date): Promise; // promisify +export { utimesSync, futimesSync }; + +// watch +import { FSWatcher, WatchOptions } from 'chokidar'; +/** + * Watches changes of a file or a directory. + * + * See Chokidar API for more info. + * @param path + * @param options + * @param callback + */ +export function watch(path: string | string[], options?: WatchOptions, callback?: (err: any, value?: FSWatcher) => void): Promise; +export { watchFile, unwatchFile }; + +// write +export function write( + fd: number, + buffer?: TBuffer, + offset?: number, + length?: number, + position?: number | null +): Promise<{ bytesWritten: number, buffer: TBuffer }>; // promisify +export function write( + fd: number, + string: any, + position?: number | null, + encoding?: string | null +): Promise<{ bytesWritten: number, buffer: string }>; // promisify +export { writeSync }; + +// writeFile +/** + * Writes data to a file. + * @param path + * @param data + * @param callback + */ +export function writeFile(path: string, data: any, callback?: (err: any) => void): Promise; +/** + * Writes data to a file. + * @param path + * @param data + * @param options + * @param callback + */ +export function writeFile( + path: string, + data: any, + options?: string | { encoding?: string | null; mode?: string | number; flag?: string }, + callback?: (err: any) => void +): Promise; +/** + * Synchronous version of `fs.writeFile`. + * @param path + * @param data + * @param options + */ +export function writeFileSync(path: string, data: any, options?: string | { encoding?: string | null; mode?: string | number; flag?: string }): void; + +// Static classes +export let Stats: Stats; +export let ReadStream: ReadStream; +export let WriteStream: WriteStream; + +// util +export function escapeEOL(str: string): string; +export function escapeBOM(str: string): string; diff --git a/types/hexo-fs/tsconfig.json b/types/hexo-fs/tsconfig.json new file mode 100644 index 0000000000..fe667f65e4 --- /dev/null +++ b/types/hexo-fs/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "hexo-fs-tests.ts" + ] +} diff --git a/types/hexo-fs/tslint.json b/types/hexo-fs/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/hexo-fs/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/highcharts/test/index.ts b/types/highcharts/test/index.ts index 8652ad7ec0..a004778ed9 100644 --- a/types/highcharts/test/index.ts +++ b/types/highcharts/test/index.ts @@ -2516,7 +2516,7 @@ function test_NumericSymbolMagnitude() { }] }); - chart.update( { + chart.update({ lang: { numericSymbols: ['万', '億'], numericSymbolMagnitude: 10000 diff --git a/types/highcharts/tslint.json b/types/highcharts/tslint.json index d8b67d5d1f..df5c6f4ca0 100644 --- a/types/highcharts/tslint.json +++ b/types/highcharts/tslint.json @@ -1,10 +1,11 @@ { - "extends": "dtslint/dt.json", - "rules": { - "ban-types": false, - "unified-signatures": false, - "no-empty-interface": false, - "dt-header": false, - "no-object-literal-type-assertion": false - } + "extends": "dtslint/dt.json", + "rules": { + "ban-types": false, + "unified-signatures": false, + "no-empty-interface": false, + "dt-header": false, + "no-object-literal-type-assertion": false, + "no-unnecessary-generics": false + } } diff --git a/types/http-aws-es/package.json b/types/http-aws-es/package.json index e4fd5a5e97..7952b2931b 100644 --- a/types/http-aws-es/package.json +++ b/types/http-aws-es/package.json @@ -1,5 +1,6 @@ { + "private": true, "dependencies": { "aws-sdk": "^2.7.0" } -} +} \ No newline at end of file diff --git a/types/http-errors/http-errors-tests.ts b/types/http-errors/http-errors-tests.ts index c90c360610..c3677fd5f9 100644 --- a/types/http-errors/http-errors-tests.ts +++ b/types/http-errors/http-errors-tests.ts @@ -71,10 +71,6 @@ err = create(404, 'LOL', {id: 1}); // create(status, msg, { expose: false }) err = create(404, 'LOL', {expose: false}); -// new create.HttpError() should throw: cannot construct abstract class -// $ExpectType never -new create.HttpError(); - err = new create.NotFound(); err = new create.InternalServerError(); err = new create[404](); @@ -91,9 +87,16 @@ err = new create[404]('This might be a problem'); err = new create.MisdirectedRequest(); err = new create.MisdirectedRequest('Where should this go?'); +// $ExpectType HttpError +new create.HttpError(); + // $ExpectType boolean new Error() instanceof create.HttpError; +if (err instanceof create.HttpError) { + err.statusCode; +} + // should support err instanceof Error create(404) instanceof Error; (new create['404']()) instanceof Error; diff --git a/types/http-errors/index.d.ts b/types/http-errors/index.d.ts index 5db6e497e7..376c140d90 100644 --- a/types/http-errors/index.d.ts +++ b/types/http-errors/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Tanguy Krotoff // BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.3 +// TypeScript Version: 2.2 export = createHttpError; @@ -26,7 +26,7 @@ declare namespace createHttpError { type NamedConstructors = { [code: string]: HttpErrorConstructor; - HttpError: new (msg?: string) => never; + HttpError: HttpErrorConstructor; } & Record<'BadRequest' | 'Unauthorized' | 'PaymentRequired' | diff --git a/types/i18n/tslint.json b/types/i18n/tslint.json index bd50eb1958..eb3e5cc86e 100644 --- a/types/i18n/tslint.json +++ b/types/i18n/tslint.json @@ -1,7 +1,9 @@ { "extends": "dtslint/dt.json", "rules": { - "prefer-method-signature": false, - "no-single-declare-module": false + // TODOs + "no-any-union": false, + "no-single-declare-module": false, + "prefer-method-signature": false } } diff --git a/types/i18next/i18next-tests.ts b/types/i18next/i18next-tests.ts index afdd59d538..1a425084e8 100644 --- a/types/i18next/i18next-tests.ts +++ b/types/i18next/i18next-tests.ts @@ -435,21 +435,21 @@ interface CustomOptions { myVar: string; } -i18next.t("friend"); -i18next.t(["friend", "tree"]); -i18next.t("friend", { myVar: "someValue" }); -i18next.t(["friend", "tree"], { myVar: "someValue" }); -i18next.t("friend", { myVar: "someValue" }); -i18next.t(["friend", "tree"], { myVar: "someValue" }); +i18next.t("friend"); +i18next.t(["friend", "tree"]); +i18next.t("friend", { myVar: "someValue" }); +i18next.t(["friend", "tree"], { myVar: "someValue" }); +i18next.t("friend", { myVar: "someValue" }); +i18next.t(["friend", "tree"], { myVar: "someValue" }); const t1: i18next.TranslationFunction = (key: string, options: i18next.TranslationOptions) => ""; const t2: i18next.TranslationFunction<{ value: string }> = (key: string, options: i18next.TranslationOptions) => ({ value: "asd" }); const t3: i18next.TranslationFunction = (key: string | string[], options: i18next.TranslationOptions) => ""; const t4: i18next.TranslationFunction = (key: KeyList | KeyList[], options: i18next.TranslationOptions) => ""; -i18next.exists("friend"); -i18next.exists(["friend", "tree"]); -i18next.exists("friend", { myVar: "someValue" }); -i18next.exists(["friend", "tree"], { myVar: "someValue" }); -i18next.exists("friend", { myVar: "someValue" }); -i18next.exists(["friend", "tree"], { myVar: "someValue" }); +i18next.exists("friend"); +i18next.exists(["friend", "tree"]); +i18next.exists("friend", { myVar: "someValue" }); +i18next.exists(["friend", "tree"], { myVar: "someValue" }); +i18next.exists("friend", { myVar: "someValue" }); +i18next.exists(["friend", "tree"], { myVar: "someValue" }); diff --git a/types/i18next/index.d.ts b/types/i18next/index.d.ts index 5ddad0b6e1..c510d824eb 100644 --- a/types/i18next/index.d.ts +++ b/types/i18next/index.d.ts @@ -396,8 +396,7 @@ declare namespace i18next { type Callback = (error: any, t: TranslationFunction) => void; type TranslationFunction = - - (key: TMethodKeys | TMethodKeys[], options?: TranslationOptions) => TMethodResult; + (key: TKeys | TKeys[], options?: TranslationOptions) => TResult; interface Resource { [language: string]: ResourceLanguage; diff --git a/types/i18next/v2/i18next-tests.ts b/types/i18next/v2/i18next-tests.ts index 32b2fa7971..626cf12f93 100644 --- a/types/i18next/v2/i18next-tests.ts +++ b/types/i18next/v2/i18next-tests.ts @@ -34,7 +34,7 @@ i18n.init({ saveMissing: true, saveMissingTo: 'all', missingKeyHandler: (lng: string, ns: string, key: string, fallbackValue: string) => { - console.log('Lng: ' + lng + ', ns: ' + ns + ', key' + key + ', fallbackValue: ' + fallbackValue); + console.log(`Lng: ${lng}, ns: ${ns}, key: ${key}, fallbackValue: ${fallbackValue}`); }, parseMissingKeyHandler: (key: string) => { console.log(key); @@ -49,7 +49,7 @@ i18n.init({ overloadTranslationOptionHandler: (args: any[]) => { return translationOptions; }, - interpolation: translationOptions, + interpolation: { prefix: "foo-" }, detection: null, backend: null, cache: null, @@ -71,21 +71,21 @@ i18n.init({ i18n.t('helloWorld', { defaultValue: 'default', count: 10 -} as i18n.TranslationOptions); +}); i18n.t('helloWorldInterpolated', { defaultValue: 'default', count: 10, name: "world" -} as i18n.TranslationOptions); +}); i18n.t('helloSingleFallbackLng', { fallbackLng: 'en' -} as i18n.TranslationOptions); +}); i18n.t('helloMultiFallbackLng', { fallbackLng: ['en', 'ru'] -} as i18n.TranslationOptions); +}); i18n.t('helloObjectFallbackLng', { fallbackLng: { @@ -93,7 +93,7 @@ i18n.t('helloObjectFallbackLng', { 'zh-HANT': ['zh-HANS', 'en'], default: ['en'] }, -} as i18n.TranslationOptions); +}); i18n.exists("helloWorld"); diff --git a/types/i18next/v2/index.d.ts b/types/i18next/v2/index.d.ts index afcd9993cb..f9bd900e77 100644 --- a/types/i18next/v2/index.d.ts +++ b/types/i18next/v2/index.d.ts @@ -135,7 +135,7 @@ declare namespace i18n { cloneInstance(options?: Options, callback?: (err: any, t: TranslationFunction) => void): I18n; on(event: string, listener: () => void): void; - on(initialized: 'initialized', listener: (options: i18n.Options) => void): void; + on(initialized: 'initialized', listener: (options: Options) => void): void; on(loaded: 'loaded', listener: (loaded: any) => void): void; on(failedLoading: 'failedLoading', listener: (lng: string, ns: string, msg: string) => void): void; on(missingKey: 'missingKey', listener: (lngs: any, namespace: string, key: string, res: any) => void): void; diff --git a/types/ibm_db/tsconfig.json b/types/ibm_db/tsconfig.json index a2944f53d3..4d653705a2 100644 --- a/types/ibm_db/tsconfig.json +++ b/types/ibm_db/tsconfig.json @@ -1,6 +1,5 @@ { "compilerOptions": { - "allowSyntheticDefaultImports": true, "module": "commonjs", "lib": [ "es6" diff --git a/types/inversify-devtools/package.json b/types/inversify-devtools/package.json index 2ec416e55c..91ec52f25a 100644 --- a/types/inversify-devtools/package.json +++ b/types/inversify-devtools/package.json @@ -1,4 +1,5 @@ { + "private": true, "dependencies": { "inversify": "^2.0.1" } diff --git a/types/is-number/is-number-tests.ts b/types/is-number/is-number-tests.ts index 52ecb3d7cd..2d9ac9f1ad 100644 --- a/types/is-number/is-number-tests.ts +++ b/types/is-number/is-number-tests.ts @@ -1,6 +1,6 @@ /// -import isNumber from 'is-number'; +import isNumber = require('is-number'); const numberTest: boolean = isNumber(-1.1); const stringTest: boolean = isNumber('-1.1'); diff --git a/types/is-number/tsconfig.json b/types/is-number/tsconfig.json index 25b9ea6910..7ccd892bf8 100644 --- a/types/is-number/tsconfig.json +++ b/types/is-number/tsconfig.json @@ -13,8 +13,7 @@ ], "types": [], "noEmit": true, - "forceConsistentCasingInFileNames": true, - "allowSyntheticDefaultImports": true + "forceConsistentCasingInFileNames": true }, "files": [ "index.d.ts", diff --git a/types/isomorphic-fetch/tslint.json b/types/isomorphic-fetch/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/isomorphic-fetch/tslint.json +++ b/types/isomorphic-fetch/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/istanbul-lib-coverage/index.d.ts b/types/istanbul-lib-coverage/index.d.ts new file mode 100644 index 0000000000..67203308de --- /dev/null +++ b/types/istanbul-lib-coverage/index.d.ts @@ -0,0 +1,104 @@ +// Type definitions for istanbul-lib-coverage 1.1 +// Project: https://github.com/istanbuljs/istanbuljs +// Definitions by: Jason Cheatham +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +export interface CoverageSummary { + lines: Totals; + statements: Totals; + branches: Totals; + functions: Totals; +} + +export interface CoverageMapData { + [key: string]: FileCoverage; +} + +export class CoverageMap { + constructor(data: CoverageMapData); + addFileCoverage(pathOrObject: string | FileCoverageData): void; + files(): string[]; + fileCoverageFor(filename: string): FileCoverage; + filter(callback: (key: string) => boolean): void; + merge(data: CoverageMapData | CoverageMap): void; + toJSON(): object; + data: CoverageMapData; +} + +export interface Location { + line: number; + column: number; +} + +export interface Range { + start: Location; + end: Location; +} + +export interface BranchMapping { + loc: Range; + type: string; + locations: Range[]; + line: number; +} + +export interface FunctionMapping { + name: string; + decl: Range; + loc: Range; + line: number; +} + +export interface FileCoverageData { + path: string; + statementMap: { [key: string]: Range }; + fnMap: { [key: string]: FunctionMapping }; + branchMap: { [key: string]: BranchMapping }; + s: { [key: string]: number }; + f: { [key: string]: number }; + b: { [key: string]: number[] }; +} + +export interface Totals { + total: number; + covered: number; + skipped: number; + pct: number; +} + +export interface Coverage { + covered: number; + total: number; + coverage: number; +} + +export class FileCoverage implements FileCoverageData { + constructor(data: string | FileCoverageData); + merge(other: FileCoverageData): void; + getBranchCoverageByLine(): { [line: number]: Coverage }; + getLineCoverage(): { [line: number]: number }; + getUncoveredLines(): number[]; + resetHits(): void; + computeBranchTotals(): Totals; + computeSimpleTotals(): Totals; + toSummary(): CoverageSummary; + toJSON(): object; + + data: FileCoverageData; + path: string; + statementMap: { [key: string]: Range }; + fnMap: { [key: string]: FunctionMapping }; + branchMap: { [key: string]: BranchMapping }; + s: { [key: string]: number }; + f: { [key: string]: number }; + b: { [key: string]: number[] }; +} + +export const classes: { + FileCoverage: FileCoverage; +}; + +export function createCoverageMap(data?: CoverageMap | CoverageMapData): CoverageMap; +export function createCoverageSummary(obj?: CoverageSummary): CoverageSummary; +export function createFileCoverage(pathOrObject: string | FileCoverageData): FileCoverage; diff --git a/types/istanbul-lib-coverage/istanbul-lib-coverage-tests.ts b/types/istanbul-lib-coverage/istanbul-lib-coverage-tests.ts new file mode 100644 index 0000000000..a9b694b7b9 --- /dev/null +++ b/types/istanbul-lib-coverage/istanbul-lib-coverage-tests.ts @@ -0,0 +1,65 @@ +import { + CoverageMapData, + CoverageSummary, + FileCoverageData, + createCoverageSummary, + createCoverageMap, + createFileCoverage +} from 'istanbul-lib-coverage'; + +const summaryData: CoverageSummary = { + lines: { total: 0, covered: 0, skipped: 0, pct: 0 }, + statements: { total: 0, covered: 0, skipped: 0, pct: 0 }, + functions: { total: 0, covered: 0, skipped: 0, pct: 0 }, + branches: { total: 0, covered: 0, skipped: 0, pct: 0 } +}; + +const coverageMapData: CoverageMapData = {}; + +const fileCoverageData: FileCoverageData = { + path: 'foo', + statementMap: {}, + fnMap: {}, + branchMap: {}, + s: {}, + f: {}, + b: {} +}; + +const summary = createCoverageSummary(summaryData); +summary.branches; +summary.lines; +summary.functions; +summary.statements; + +const map1 = createCoverageMap(coverageMapData); +map1.data; +const map2 = createCoverageMap(map1); +map2.data; + +const fileCoverage1 = createFileCoverage('path/to/foo'); +fileCoverage1.data; +const fileCoverage2 = createFileCoverage(fileCoverage1.data); +fileCoverage2.data; +const fileCoverage3 = createFileCoverage(fileCoverageData); +fileCoverage3.data; + +// CoverageMap methods and properties +map1.addFileCoverage('foo.js'); +map1.addFileCoverage(fileCoverageData); +map1.files()[0]; +map1.fileCoverageFor('foo').path; +map1.filter(name => false); +map1.merge(map2); +map1.merge(coverageMapData); + +// FileCoverage methods and properties +fileCoverage1.merge(fileCoverageData); +fileCoverage1.merge(fileCoverage2.data); +fileCoverage1.getBranchCoverageByLine()[5].covered; +isNaN(fileCoverage1.getLineCoverage()[5]); +isNaN(fileCoverage1.getUncoveredLines()[5]); +fileCoverage1.resetHits(); +fileCoverage1.computeBranchTotals().skipped; +fileCoverage1.computeSimpleTotals().skipped; +isNaN(fileCoverage1.toSummary().branches.total); diff --git a/types/istanbul-lib-coverage/tsconfig.json b/types/istanbul-lib-coverage/tsconfig.json new file mode 100644 index 0000000000..fd839f63f8 --- /dev/null +++ b/types/istanbul-lib-coverage/tsconfig.json @@ -0,0 +1,22 @@ +{ + "files": [ + "index.d.ts", + "istanbul-lib-coverage-tests.ts" + ], + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/types/istanbul-lib-coverage/tslint.json b/types/istanbul-lib-coverage/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/istanbul-lib-coverage/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/istanbul-lib-hook/index.d.ts b/types/istanbul-lib-hook/index.d.ts new file mode 100644 index 0000000000..e4cbe0cd97 --- /dev/null +++ b/types/istanbul-lib-hook/index.d.ts @@ -0,0 +1,41 @@ +// Type definitions for istanbul-lib-hook 1.0 +// Project: https://github.com/istanbuljs/istanbuljs +// Definitions by: Jason Cheatham +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +export interface Options { + verbose: boolean; +} + +export interface HookRequireOptions extends Options { + extensions: string[]; + postLoadHook(filename: string): void; +} + +export function hookRequire( + matcher: Matcher, + transformer: Transformer, + options?: Partial +): () => void; + +export function hookCreateScript( + matcher: Matcher, + transformer: Transformer, + options?: Partial +): void; + +export function unhookCreateScript(): void; + +export function hookRunInThisContext( + matcher: Matcher, + transformer: Transformer, + options?: Partial +): void; + +export function unhookRunInThisContext(): void; + +export function unloadRequireCache(matcher: Matcher): void; + +export type Matcher = (filename: string) => boolean; +export type Transformer = (code: string, filepath: string) => string; diff --git a/types/istanbul-lib-hook/istanbul-lib-hook-tests.ts b/types/istanbul-lib-hook/istanbul-lib-hook-tests.ts new file mode 100644 index 0000000000..27f71344c5 --- /dev/null +++ b/types/istanbul-lib-hook/istanbul-lib-hook-tests.ts @@ -0,0 +1,33 @@ +import { + hookRequire, + hookCreateScript, + unhookCreateScript, + hookRunInThisContext, + unhookRunInThisContext, + unloadRequireCache +} from 'istanbul-lib-hook'; + +const matcher = (filename: string) => true; +const transformer = (code: string, filepath: string) => 'foo'; + +hookRequire(matcher, transformer); +hookRequire(matcher, transformer, {}); +hookRequire(matcher, transformer, { verbose: true }); + +const retVal = hookRequire(matcher, transformer, { + extensions: ['.js'], + postLoadHook: (filename: string) => {} +}); +retVal(); + +hookCreateScript(matcher, transformer, {}); +hookCreateScript(matcher, transformer, { verbose: true }); + +unhookCreateScript(); + +hookRunInThisContext(matcher, transformer, {}); +hookRunInThisContext(matcher, transformer, { verbose: true }); + +unhookRunInThisContext(); + +unloadRequireCache(matcher); diff --git a/types/istanbul-lib-hook/tsconfig.json b/types/istanbul-lib-hook/tsconfig.json new file mode 100644 index 0000000000..824b360999 --- /dev/null +++ b/types/istanbul-lib-hook/tsconfig.json @@ -0,0 +1,22 @@ +{ + "files": [ + "index.d.ts", + "istanbul-lib-hook-tests.ts" + ], + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/types/istanbul-lib-hook/tslint.json b/types/istanbul-lib-hook/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/istanbul-lib-hook/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/istanbul-lib-instrument/index.d.ts b/types/istanbul-lib-instrument/index.d.ts new file mode 100644 index 0000000000..e1d4e813f9 --- /dev/null +++ b/types/istanbul-lib-instrument/index.d.ts @@ -0,0 +1,77 @@ +// Type definitions for istanbul-lib-instrument 1.7 +// Project: https://github.com/istanbuljs/istanbuljs +// Definitions by: Jason Cheatham +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import { FileCoverage, FileCoverageData, Range } from 'istanbul-lib-coverage'; +import { RawSourceMap } from 'source-map'; +import * as babelTypes from 'babel-types'; + +export interface InstrumenterOptions { + coverageVariable: string; + preserveComments: boolean; + compact: boolean; + esModules: boolean; + autoWrap: boolean; + produceSourceMap: boolean; + sourceMapUrlCallback(filename: string, url: string): void; + debug: boolean; +} + +export type InstrumenterCallback = (error: Error | null, code: string) => void; + +export class Instrumenter { + fileCoverage: FileCoverage; + sourceMap: RawSourceMap | null; + opts: InstrumenterOptions; + + constructor(options?: Partial); + + normalizeOpts(options?: Partial): InstrumenterOptions; + + instrumentSync( + code: string, + filename: string, + inputSourceMap?: RawSourceMap + ): string; + + instrument( + code: string, + filenameOrCallback: string | InstrumenterCallback, + callback?: InstrumenterCallback, + inputSourceMap?: RawSourceMap + ): void; + + lastFileCoverage(): FileCoverageData; + lastSourceMap(): RawSourceMap; +} + +export function createInstrumenter( + options?: Partial +): Instrumenter; + +export interface InitialCoverage { + path: string; + hash: string; + gcv: any; + coverageData: any; +} + +export function readInitialCoverage(code: string): InitialCoverage; + +export interface Visitor { + enter(path: string): void; + exit(path: string): { fileCoverage: FileCoverage; sourceMappingURL: string }; +} + +export interface VisitorOptions { + coverageVariable: string; + inputSourceMap: RawSourceMap; +} + +export function programVisitor( + types: typeof babelTypes, + sourceFilePath?: string, + opts?: Partial +): Visitor; diff --git a/types/istanbul-lib-instrument/istanbul-lib-instrument-tests.ts b/types/istanbul-lib-instrument/istanbul-lib-instrument-tests.ts new file mode 100644 index 0000000000..54d66314d4 --- /dev/null +++ b/types/istanbul-lib-instrument/istanbul-lib-instrument-tests.ts @@ -0,0 +1,72 @@ +import { + createInstrumenter, + readInitialCoverage, + programVisitor +} from 'istanbul-lib-instrument'; + +import * as babelTypes from 'babel-types'; + +const code = 'foo'; +const filename = 'bar.txt'; + +createInstrumenter(); +createInstrumenter({}); +createInstrumenter({ + coverageVariable: 'coverage' +}); +const instrumenter = createInstrumenter({ + preserveComments: true, + compact: false, + esModules: true, + autoWrap: false, + produceSourceMap: true, + sourceMapUrlCallback: (filename: string, url: string) => {}, + debug: false +}); + +const sourceMap = { + version: 1, + sources: ['foo', 'bar'], + names: ['foo', 'bar'], + mappings: 'foo', + file: 'foo' +}; +instrumenter.instrumentSync(code, filename); +const newCode = instrumenter.instrumentSync(code, filename, sourceMap); +code.trim(); + +// instrument with all args +instrumenter.instrument(code, filename, (error, code) => { + if (error) { + error.stack; + } else { + code.trim(); + } +}, sourceMap); + +// instrument without a filename +instrumenter.instrument(code, (error, code) => { + if (error) { + error.stack; + } else { + code.trim(); + } +}); + +const cov = instrumenter.lastFileCoverage(); +Object.create(cov); + +const map = instrumenter.lastSourceMap(); +Object.create(map); + +const initialCov = readInitialCoverage(code); +initialCov.gcv; + +programVisitor(babelTypes); +programVisitor(babelTypes, filename); +programVisitor(babelTypes, filename, { coverageVariable: 'coverage' }); +const visitor = programVisitor(babelTypes, filename, { inputSourceMap: sourceMap }); + +visitor.enter(filename); +const data = visitor.exit(filename); +Object.create(data.fileCoverage); diff --git a/types/istanbul-lib-instrument/tsconfig.json b/types/istanbul-lib-instrument/tsconfig.json new file mode 100644 index 0000000000..1f44277fc1 --- /dev/null +++ b/types/istanbul-lib-instrument/tsconfig.json @@ -0,0 +1,22 @@ +{ + "files": [ + "index.d.ts", + "istanbul-lib-instrument-tests.ts" + ], + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/types/istanbul-lib-instrument/tslint.json b/types/istanbul-lib-instrument/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/istanbul-lib-instrument/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/istanbul-lib-report/index.d.ts b/types/istanbul-lib-report/index.d.ts new file mode 100644 index 0000000000..709bc8030b --- /dev/null +++ b/types/istanbul-lib-report/index.d.ts @@ -0,0 +1,82 @@ +// Type definitions for istanbul-lib-report 1.1 +// Project: https://github.com/istanbuljs/istanbuljs +// Definitions by: Jason Cheatham +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import { CoverageMap, FileCoverage, CoverageSummary } from 'istanbul-lib-coverage'; + +export function createContext(options?: Partial): Context; +export function getDefaultWatermarks(): Watermarks; + +export const summarizers: { + flat(coverageMap: CoverageMap): Tree; + nested(coverageMap: CoverageMap): Tree; + pkg(coverageMap: CoverageMap): Tree; +}; + +export interface ContextOptions { + dir: string; + watermarks: Watermarks; + sourceFinder(filepath: string): string; +} + +export interface Context extends ContextOptions { + data: any; + writer: FileWriter; +} + +export interface ContentWriter { + write(str: string): void; + colorize(str: string, cls?: string): string; + println(str: string): void; + close(): void; +} + +export interface FileWriter { + writeForDir(subdir: string): FileWriter; + copyFile(source: string, dest: string): void; + writeFile(file: string | null): ContentWriter; +} + +export interface Watermarks { + statements: number[]; + functions: number[]; + branches: number[]; + lines: number[]; +} + +export interface Node { + getQualifiedName(): string; + getRelativeName(): string; + isRoot(): boolean; + getParent(): Node; + getChildren(): Node[]; + isSummary(): boolean; + getCoverageSummary(filesOnly: boolean): CoverageSummary; + getFileCoverage(): FileCoverage; + visit(visitor: Visitor, state: any): void; +} + +export interface ReportNode extends Node { + path: string; + parent: ReportNode | null; + fileCoverage: FileCoverage; + children: ReportNode[]; + addChild(child: ReportNode): void; + asRelative(p: string): string; + visit(visitor: Visitor, state: any): void; +} + +export interface Visitor { + onStart(root: N, state: any): void; + onSummary(root: N, state: any): void; + onDetail(root: N, state: any): void; + onSummaryEnd(root: N, state: any): void; + onEnd(root: N, state: any): void; +} + +export interface Tree { + getRoot(): N; + visit(visitor: Partial>, state: any): void; +} diff --git a/types/istanbul-lib-report/istanbul-lib-report-tests.ts b/types/istanbul-lib-report/istanbul-lib-report-tests.ts new file mode 100644 index 0000000000..7107c14db8 --- /dev/null +++ b/types/istanbul-lib-report/istanbul-lib-report-tests.ts @@ -0,0 +1,33 @@ +import { + createContext, + getDefaultWatermarks, + summarizers, + Watermarks +} from 'istanbul-lib-report'; + +import { CoverageMap } from 'istanbul-lib-coverage'; + +const watermarks: Watermarks = { + statements: [], + branches: [], + functions: [], + lines: [] +}; + +createContext(); +createContext({}); +const context = createContext({ + dir: 'foo', + watermarks, + sourceFinder: (filepath: string) => '' +}); + +context.watermarks; +context.sourceFinder('foo').trim(); + +const defaultMarks: Watermarks = getDefaultWatermarks(); + +const map = new CoverageMap({}); +summarizers.flat(map).getRoot(); +summarizers.nested(map).getRoot(); +summarizers.pkg(map).getRoot(); diff --git a/types/istanbul-lib-report/tsconfig.json b/types/istanbul-lib-report/tsconfig.json new file mode 100644 index 0000000000..960c160e83 --- /dev/null +++ b/types/istanbul-lib-report/tsconfig.json @@ -0,0 +1,22 @@ +{ + "files": [ + "index.d.ts", + "istanbul-lib-report-tests.ts" + ], + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/types/istanbul-lib-report/tslint.json b/types/istanbul-lib-report/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/istanbul-lib-report/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/istanbul-lib-source-maps/index.d.ts b/types/istanbul-lib-source-maps/index.d.ts new file mode 100644 index 0000000000..71ae7f0dec --- /dev/null +++ b/types/istanbul-lib-source-maps/index.d.ts @@ -0,0 +1,43 @@ +// Type definitions for istanbul-lib-source-maps 1.2 +// Project: https://github.com/istanbuljs/istanbuljs +// Definitions by: Jason Cheatham +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import { CoverageMap } from 'istanbul-lib-coverage'; +import { RawSourceMap } from 'source-map'; + +export function createSourceMapStore( + options?: Partial +): MapStore; + +export interface MapStoreOptions { + verbose: boolean; + baseDir: string; + sourceStore: 'memory' | 'file'; + tmpdir: string; +} + +export interface MapStore { + baseDir: string | null; + verbose: boolean; + sourceStore: SourceStore; + data: { + [filepath: string]: { + type: string; + data: any; + }; + }; + + registerURL(transformedFilePath: string, sourceMapUrl: string): void; + registerMap(filename: string, sourceMap: RawSourceMap): void; + transformCoverage( + coverageMap: CoverageMap + ): { map: CoverageMap; sourceFinder(path: string): string }; + dispose(): void; +} + +export class SourceStore { + getSource(filepath: string): string | null; + registerSource(filepath: string, sourceText: string): void; +} diff --git a/types/istanbul-lib-source-maps/istanbul-lib-source-maps-tests.ts b/types/istanbul-lib-source-maps/istanbul-lib-source-maps-tests.ts new file mode 100644 index 0000000000..be03e785fc --- /dev/null +++ b/types/istanbul-lib-source-maps/istanbul-lib-source-maps-tests.ts @@ -0,0 +1,37 @@ +import { createSourceMapStore } from 'istanbul-lib-source-maps'; +import { CoverageMap } from 'istanbul-lib-coverage'; + +createSourceMapStore(); +createSourceMapStore({}); +const store = createSourceMapStore({ + verbose: false, + baseDir: 'foo', + sourceStore: 'memory', + tmpdir: 'foo' +}); + +store.data['foo'].type.trim(); + +const sourceMap = { + version: 1, + sources: ['foo', 'bar'], + names: ['foo', 'bar'], + mappings: 'foo', + file: 'foo' +}; +store.registerMap('foo', sourceMap); + +store.registerURL('foo', 'foo'); + +const map = new CoverageMap({}); +const transformed = store.transformCoverage(map); +transformed.map.data; +transformed.sourceFinder('foo').trim(); + +store.dispose(); + +store.sourceStore.registerSource('foo', 'bar'); +const source = store.sourceStore.getSource('foo'); +if (source != null) { + source.trim(); +} diff --git a/types/istanbul-lib-source-maps/tsconfig.json b/types/istanbul-lib-source-maps/tsconfig.json new file mode 100644 index 0000000000..5693013057 --- /dev/null +++ b/types/istanbul-lib-source-maps/tsconfig.json @@ -0,0 +1,22 @@ +{ + "files": [ + "index.d.ts", + "istanbul-lib-source-maps-tests.ts" + ], + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/types/istanbul-lib-source-maps/tslint.json b/types/istanbul-lib-source-maps/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/istanbul-lib-source-maps/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/istanbul-reports/index.d.ts b/types/istanbul-reports/index.d.ts new file mode 100644 index 0000000000..699163b4dd --- /dev/null +++ b/types/istanbul-reports/index.d.ts @@ -0,0 +1,50 @@ +// Type definitions for istanbul-reports 1.1 +// Project: https://github.com/istanbuljs/istanbuljs +// Definitions by: Jason Cheatham +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +import { Context, Node, FileWriter, Visitor } from 'istanbul-lib-report'; +import { CoverageSummary } from 'istanbul-lib-coverage'; + +export function create( + name: T, + options?: Partial +): Visitor; + +export interface ReportOptions { + clover: RootedOptions; + cobertura: RootedOptions; + html: HtmlOptions; + json: Options; + 'json-summary': Options; + lcov: never; + lcovonly: Options; + none: RootedOptions; + teamcity: Options & { blockName: string }; + text: Options & { maxCols: number }; + 'text-lcov': Options; + 'text-summary': Options; +} + +export type ReportType = keyof ReportOptions; + +export interface Options { + file: string; +} + +export interface RootedOptions extends Options { + projectRoot: string; +} + +export interface HtmlOptions { + verbose: boolean; + linkMapper: LinkMapper; + subdir: string; +} + +export interface LinkMapper { + getPath(node: string | Node): string; + relativePath(source: string | Node, target: string | Node): string; + assetPath(node: Node, name: string): string; +} diff --git a/types/istanbul-reports/istanbul-reports-tests.ts b/types/istanbul-reports/istanbul-reports-tests.ts new file mode 100644 index 0000000000..b6a3c15ca9 --- /dev/null +++ b/types/istanbul-reports/istanbul-reports-tests.ts @@ -0,0 +1,44 @@ +import { create } from 'istanbul-reports'; + +create('clover'); +create('clover', { file: 'foo', projectRoot: 'bar' }); + +create('cobertura'); +create('cobertura', { file: 'foo', projectRoot: 'bar' }); + +create('html'); +create('html', { verbose: false, subdir: 'foo' }); +create('html', { + linkMapper: { + getPath: () => 'foo', + relativePath: () => 'foo', + assetPath: () => 'foo' + } +}); + +create('json'); +create('json', { file: 'foo' }); + +create('json-summary'); +create('json-summary', { file: 'foo' }); + +create('lcov'); + +create('lcovonly'); +create('lcovonly', { file: 'foo' }); + +create('none'); + +create('teamcity'); +create('teamcity', { file: 'foo' }); +create('teamcity', { file: 'foo', blockName: 'bar' }); + +create('text'); +create('text', { file: 'foo' }); +create('text', { file: 'foo', maxCols: 3 }); + +create('text-lcov'); +create('text-lcov', { file: 'foo' }); + +create('text-summary'); +create('text-summary', { file: 'foo' }); diff --git a/types/istanbul-reports/tsconfig.json b/types/istanbul-reports/tsconfig.json new file mode 100644 index 0000000000..6235d65f52 --- /dev/null +++ b/types/istanbul-reports/tsconfig.json @@ -0,0 +1,22 @@ +{ + "files": [ + "index.d.ts", + "istanbul-reports-tests.ts" + ], + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} diff --git a/types/istanbul-reports/tslint.json b/types/istanbul-reports/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/istanbul-reports/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/jasminewd2/index.d.ts b/types/jasminewd2/index.d.ts index 3b8760709c..d19b929fa7 100644 --- a/types/jasminewd2/index.d.ts +++ b/types/jasminewd2/index.d.ts @@ -15,11 +15,6 @@ declare function beforeAll(action: () => Promise, timeout?: number): void; declare function afterAll(action: () => Promise, timeout?: number): void; declare namespace jasmine { - // The global `Promise` type is too strict and kinda wrong - interface Promise { - then(onFulfill?: (value: T) => U | Promise, onReject?: (error: any) => U | Promise): Promise; - } - interface Matchers { toBe(expected: any, expectationFailOutput?: any): Promise; toEqual(expected: any, expectationFailOutput?: any): Promise; diff --git a/types/jest/tslint.json b/types/jest/tslint.json index a839e8aa9f..86d51194e9 100644 --- a/types/jest/tslint.json +++ b/types/jest/tslint.json @@ -4,6 +4,7 @@ // TODOs "dt-header": false, "no-mergeable-namespace": false, - "no-void-expression": false + "no-void-expression": false, + "no-unnecessary-generics": false } } diff --git a/types/jfs/tslint.json b/types/jfs/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/jfs/tslint.json +++ b/types/jfs/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/jpeg-js/index.d.ts b/types/jpeg-js/index.d.ts new file mode 100644 index 0000000000..b3525b5449 --- /dev/null +++ b/types/jpeg-js/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for jpeg-js 0.3 +// Project: https://github.com/eugeneware/jpeg-js#readme +// Definitions by: Daniel Rosenwasser +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export interface RawImageData { + data: D; + width: number; + height: number; +} + +export function decode(jpegData: ArrayLike | Iterable | ArrayBuffer, useTypedArray: true): RawImageData; +export function decode(jpegData: ArrayLike | Iterable | ArrayBuffer, useTypedArray?: false): RawImageData; +export function decode(jpegData: ArrayLike | Iterable | ArrayBuffer, useTypedArray: boolean): RawImageData; + +export function encode(imgData: RawImageData, qu?: number): RawImageData; diff --git a/types/jpeg-js/jpeg-js-tests.ts b/types/jpeg-js/jpeg-js-tests.ts new file mode 100644 index 0000000000..17bbc4fd5f --- /dev/null +++ b/types/jpeg-js/jpeg-js-tests.ts @@ -0,0 +1,15 @@ +import jpeg = require("jpeg-js"); +import fs = require("fs"); + +const x = fs.readFileSync("hello.jpg"); +const decoded = jpeg.decode(x, true); + +const { width, height } = decoded; + +width; // $ExpectType number +height; // $ExpectType number +decoded.data; // $ExpectType Uint8Array + +fs.writeFileSync("re-encoded.jpg", jpeg.encode({ + width, height, data: decoded.data +}, 50)); diff --git a/types/jpeg-js/tsconfig.json b/types/jpeg-js/tsconfig.json new file mode 100644 index 0000000000..1e3c116f4f --- /dev/null +++ b/types/jpeg-js/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es2015" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jpeg-js-tests.ts" + ] +} diff --git a/types/jpeg-js/tslint.json b/types/jpeg-js/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/jpeg-js/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/jquery.filtertable/index.d.ts b/types/jquery.filtertable/index.d.ts new file mode 100644 index 0000000000..71b2a26a12 --- /dev/null +++ b/types/jquery.filtertable/index.d.ts @@ -0,0 +1,143 @@ +// Type definitions for jquery.filterTable v1.5.7 +// Project: https://github.com/sunnywalker/jQuery.FilterTable +// Definitions by: TotPeRo +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +declare namespace FilterTable { + interface FilterTableOptions { + /** + * Makes the filter input field autofocused (not recommended for accessibility reasons) + * Default: 'false' + */ + autofocus?: boolean; + /** + * Callback function after a filter is performed. + * Default: 'null' + * @param term filter term (string) + * @param table table being filtered (JQuery object) + * @returns {void} + */ + callback?: (term:string, table:JQuery) => void; + /** + * Class applied to the main filter input container + * Default: 'filter-table' + */ + containerClass?: string; + /** + * Tag name of the main filter input container + * Default: 'p' + */ + containerTag?: string; + /** + * Controls whether the table's tfoot(s) will be hidden when the table is filtered + * Default: 'false' + */ + hideTFootOnFilter?: boolean; + /** + * Class applied to cells containing the filter term + * Default: 'alt' + */ + highlightClass?: string; + /** + * Ignore these columns (0-indexed) when filtering + * Default: '[]' + */ + ignoreColumns?: number[]; + /** + * Use this selector to find the filter input instead of creating a new one (only works if selector returns a single element) + * Default: 'null' + */ + inputSelector?: string; + /** + * Name attribute of the filter input field + * Default: 'filter-table' + */ + inputName?: string; + /** + * Tag name of the filter input itself + * Default: 'search' + */ + inputType?: string; + /** + * Text to precede the filter input + * Default: 'Filter:' + */ + label?: string; + /** + * Filter only when at least this number of characters are in the filter input field + * Default: '1' + */ + minChars?: number; + /** + * Only show the filter on tables with this number of rows or more + * Default: '8' + */ + minRows?: number; + /** + * HTML5 placeholder text for the filter input + * Default: 'search this table' + */ + placeholder?: string; + /** + * Trap the return key in the filter input field to prevent form submission + * Default: 'true' + */ + preventReturnKey?: boolean; + /** + * List of clickable phrases to quick fill the search + * Default: '[]' + */ + quickList?: string[]; + /** + * Class of each quick list item + * Default: 'quick' + */ + quickListClass?: string; + /** + * Label for the clear filtering quick list item (or none if blank) + * Default: '' + */ + quickListClear?: string; + /** + * Tag name surrounding quick list items (e.g., ul) + * Default: '' + */ + quickListGroupTag?: string; + /** + * Tag name of each quick list item (e.g., a or li) + * Default: 'a' + */ + quickListTag?: string; // "a" | "li" + /** + * Class applied to visible rows + * Default: 'visible' + */ + visibleClass?: string; + } + + interface FilterTableStatic { + /** + * init with default options + * @returns {JQuery} + */ + (): JQuery; + + /** + * init with custom options + * @param options + * @returns {JQuery} + */ + (options: FilterTableOptions): JQuery; + } +} + +interface JQuery { + /** + * if this code appears after your tables; otherwise, include it in your document.ready() code. + * $('table').filterTable() + */ + filterTable: FilterTable.FilterTableStatic; +} diff --git a/types/jquery.filtertable/jquery.filtertable-tests.ts b/types/jquery.filtertable/jquery.filtertable-tests.ts new file mode 100644 index 0000000000..d6290f491f --- /dev/null +++ b/types/jquery.filtertable/jquery.filtertable-tests.ts @@ -0,0 +1,9 @@ +$('table').filterTable(); + +$('table').filterTable({ quickList: ['class', 'tag'] }); + +$('table').filterTable({ + callback(term, table) { + table.find('tr').removeClass('striped').filter(':visible:even').addClass('striped'); + } +}); diff --git a/types/jquery.filtertable/tsconfig.json b/types/jquery.filtertable/tsconfig.json new file mode 100644 index 0000000000..6f114e37d7 --- /dev/null +++ b/types/jquery.filtertable/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "jquery.filtertable-tests.ts" + ] +} diff --git a/types/jquery.livestampjs/package.json b/types/jquery.livestampjs/package.json index d33ff913ce..fce08a048d 100644 --- a/types/jquery.livestampjs/package.json +++ b/types/jquery.livestampjs/package.json @@ -1,5 +1,6 @@ { + "private": true, "dependencies": { "moment": ">=2.14.0" } -} +} \ No newline at end of file diff --git a/types/jquery.tools/tslint.json b/types/jquery.tools/tslint.json index 26a0c302a8..9d0759ec89 100644 --- a/types/jquery.tools/tslint.json +++ b/types/jquery.tools/tslint.json @@ -1,7 +1,8 @@ { - "extends": "dtslint/dt.json", - "rules": { - // TODO - "no-void-expression": false - } + "extends": "dtslint/dt.json", + "rules": { + // TODO + "no-void-expression": false, + "no-unnecessary-generics": false + } } diff --git a/types/js-cookie/js-cookie-tests.ts b/types/js-cookie/js-cookie-tests.ts index dbc3306a1a..7b68951c87 100644 --- a/types/js-cookie/js-cookie-tests.ts +++ b/types/js-cookie/js-cookie-tests.ts @@ -32,12 +32,8 @@ Cookies.getJSON(); document.cookie = 'escaped=%u5317'; document.cookie = 'default=%E5%8C%97'; -const cookies = Cookies.withConverter((value, name) => { - if ( name === 'escaped' ) { - return decodeURIComponent(value); - } - return value; -}); +const cookies = Cookies.withConverter((value, name) => + name === 'escaped' ? decodeURIComponent(value) : value); cookies.get('escaped'); diff --git a/types/js-quantities/index.d.ts b/types/js-quantities/index.d.ts index ab76433c0d..e90fe72d87 100644 --- a/types/js-quantities/index.d.ts +++ b/types/js-quantities/index.d.ts @@ -69,4 +69,4 @@ declare namespace Qty { type UnitSource = Qty | string; } -export default Qty; +export = Qty; diff --git a/types/js-quantities/js-quantities-tests.ts b/types/js-quantities/js-quantities-tests.ts index 786a9f1a3f..ae171f6da1 100644 --- a/types/js-quantities/js-quantities-tests.ts +++ b/types/js-quantities/js-quantities-tests.ts @@ -1,4 +1,4 @@ -import Qty from "js-quantities"; +import Qty = require("js-quantities"); declare function describe(desc: string, fn: () => void): void; declare function it(desc: string, fn: () => void): void; diff --git a/types/js-to-java/tslint.json b/types/js-to-java/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/js-to-java/tslint.json +++ b/types/js-to-java/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/jsdom/package.json b/types/jsdom/package.json index 3d840a49e2..8f98c6256e 100644 --- a/types/jsdom/package.json +++ b/types/jsdom/package.json @@ -1,5 +1,6 @@ { + "private": true, "dependencies": { "parse5": "^3.0.2" } -} +} \ No newline at end of file diff --git a/types/jsforce/tslint.json b/types/jsforce/tslint.json index a62d0d4e68..5fdd35f19c 100644 --- a/types/jsforce/tslint.json +++ b/types/jsforce/tslint.json @@ -1,6 +1,9 @@ { "extends": "dtslint/dt.json", "rules": { - "ban-types": false + // TODOs + "ban-types": false, + "no-any-union": false, + "no-unnecessary-generics": false } } diff --git a/types/jsnox/tslint.json b/types/jsnox/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/jsnox/tslint.json +++ b/types/jsnox/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/json-rpc-ws/tslint.json b/types/json-rpc-ws/tslint.json index e60c15844f..3393f9dcca 100644 --- a/types/json-rpc-ws/tslint.json +++ b/types/json-rpc-ws/tslint.json @@ -1,3 +1,8 @@ { - "extends": "dtslint/dt.json" -} \ No newline at end of file + "extends": "dtslint/dt.json", + "rules": { + // TODOs + "no-any-union": false, + "no-unnecessary-generics": false + } +} diff --git a/types/jsonata/tsconfig.json b/types/jsonata/tsconfig.json index f6e64f5569..e7ca21b6c6 100644 --- a/types/jsonata/tsconfig.json +++ b/types/jsonata/tsconfig.json @@ -6,7 +6,6 @@ "es6" ], "target": "es6", - "moduleResolution": "node", "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, diff --git a/types/jsonrpc-serializer/tslint.json b/types/jsonrpc-serializer/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/jsonrpc-serializer/tslint.json +++ b/types/jsonrpc-serializer/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/jui-grid/tslint.json b/types/jui-grid/tslint.json index a62d0d4e68..e39908ae45 100644 --- a/types/jui-grid/tslint.json +++ b/types/jui-grid/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "ban-types": false + "ban-types": false, + "no-any-union": false } } diff --git a/types/jui/tslint.json b/types/jui/tslint.json index 3db14f85ea..c92fd86792 100644 --- a/types/jui/tslint.json +++ b/types/jui/tslint.json @@ -1 +1,7 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + // TODOs + "no-any-union": false + } +} diff --git a/types/jwt-decode/tslint.json b/types/jwt-decode/tslint.json index f93cf8562a..71ee04c4e1 100644 --- a/types/jwt-decode/tslint.json +++ b/types/jwt-decode/tslint.json @@ -1,3 +1,6 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } } diff --git a/types/jwt-decode/v1/tslint.json b/types/jwt-decode/v1/tslint.json index f93cf8562a..71ee04c4e1 100644 --- a/types/jwt-decode/v1/tslint.json +++ b/types/jwt-decode/v1/tslint.json @@ -1,3 +1,6 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } } diff --git a/types/kafka-node/tslint.json b/types/kafka-node/tslint.json index d88586e5bd..b1439230db 100644 --- a/types/kafka-node/tslint.json +++ b/types/kafka-node/tslint.json @@ -1,3 +1,7 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", + "rules": { + // TODO + "no-any-union": false + } } diff --git a/types/kendo-ui/index.d.ts b/types/kendo-ui/index.d.ts index aed1919103..4f5f6b5bf5 100644 --- a/types/kendo-ui/index.d.ts +++ b/types/kendo-ui/index.d.ts @@ -1563,11 +1563,11 @@ declare namespace kendo.ui { } - interface AlertMessages { + interface AlertMessages extends DialogMessages { okText?: string; } - interface AlertOptions { + interface AlertOptions extends DialogOptions { name?: string; messages?: AlertMessages; } @@ -2081,12 +2081,12 @@ declare namespace kendo.ui { } - interface ConfirmMessages { + interface ConfirmMessages extends DialogMessages { okText?: string; cancel?: string; } - interface ConfirmOptions { + interface ConfirmOptions extends DialogOptions { name?: string; messages?: ConfirmMessages; } @@ -5479,12 +5479,12 @@ declare namespace kendo.ui { } - interface PromptMessages { + interface PromptMessages extends DialogMessages { okText?: string; cancel?: string; } - interface PromptOptions { + interface PromptOptions extends DialogOptions { name?: string; messages?: PromptMessages; } diff --git a/types/kii-cloud-sdk/tslint.json b/types/kii-cloud-sdk/tslint.json index 65c83fb1e3..c4fd1ce0bb 100644 --- a/types/kii-cloud-sdk/tslint.json +++ b/types/kii-cloud-sdk/tslint.json @@ -1,6 +1,7 @@ { "extends": "dtslint/dt.json", "rules": { - "dt-header": false + "dt-header": false, + "no-unnecessary-generics": false } } diff --git a/types/klaw-sync/index.d.ts b/types/klaw-sync/index.d.ts index 23eb661174..1bdd409dfc 100644 --- a/types/klaw-sync/index.d.ts +++ b/types/klaw-sync/index.d.ts @@ -5,32 +5,36 @@ /// -import * as fs from "fs" +import * as fs from 'fs' -export interface Item { - path: string - stats: fs.Stats +declare namespace klawSync { + interface Item { + path: string + stats: fs.Stats + } + + interface Options { + /** + * any paths or `micromatch` patterns to ignore. + * + * For more information on micromatch patterns: https://github.com/jonschlinkert/micromatch#features + */ + ignore?: string | string[] + /** + * True to only return files (ignore directories). + * + * Defaults to false if not specified. + */ + nodir?: boolean + /** + * True to only return directories (ignore files). + * + * Defaults to false if not specified. + */ + nofile?: boolean + } } -export interface Options { - /** - * any paths or `micromatch` patterns to ignore. - * - * For more information on micromatch patterns: https://github.com/jonschlinkert/micromatch#features - */ - ignore?: string | string[] - /** - * True to only return files (ignore directories). - * - * Defaults to false if not specified. - */ - nodir?: boolean - /** - * True to only return directories (ignore files). - * - * Defaults to false if not specified. - */ - nofile?: boolean -} +declare function klawSync(root: string, options?: klawSync.Options): ReadonlyArray -export function klawSync(root: string, options?: Options): ReadonlyArray +export = klawSync diff --git a/types/klaw-sync/klaw-sync-tests.ts b/types/klaw-sync/klaw-sync-tests.ts index 5c2b806108..4808146882 100644 --- a/types/klaw-sync/klaw-sync-tests.ts +++ b/types/klaw-sync/klaw-sync-tests.ts @@ -1,20 +1,20 @@ -import { klawSync, Item } from "klaw-sync" -import * as path from "path" +import * as path from 'path' +import klawSync = require('klaw-sync') -const outputMessage = (result: Item) => { +const outputMessage = (result: klawSync.Item) => { console.log(`file: ${result.path} has size '${result.stats.size}'`) } klawSync('/some/dir').forEach(outputMessage) -const defaultOptions = { } +const defaultOptions = {} klawSync('/some/dir', defaultOptions).forEach(outputMessage) const options = { - ignore: [ '.exe' ], + ignore: ['.exe'], nodir: true, - nofile: false + nofile: false, } klawSync('/some/dir', options).forEach(outputMessage) diff --git a/types/knex/index.d.ts b/types/knex/index.d.ts index 5ea34bfaeb..8b7f1b6601 100644 --- a/types/knex/index.d.ts +++ b/types/knex/index.d.ts @@ -429,7 +429,6 @@ declare namespace Knex { } interface AlterTableBuilder extends TableBuilder { - alter(): ColumnBuilder; } interface MySqlAlterTableBuilder extends AlterTableBuilder { @@ -447,6 +446,7 @@ declare namespace Knex { notNullable(): ColumnBuilder; nullable(): ColumnBuilder; comment(value: string): ColumnBuilder; + alter(): ColumnBuilder; } interface ForeignConstraintBuilder { diff --git a/types/koa-pino-logger/index.d.ts b/types/koa-pino-logger/index.d.ts new file mode 100644 index 0000000000..2ea66937b6 --- /dev/null +++ b/types/koa-pino-logger/index.d.ts @@ -0,0 +1,27 @@ +// Type definitions for koa-pino-logger 2.1 +// Project: https://github.com/pinojs/koa-pino-logger +// Definitions by: Cameron Yan +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { Middleware } from 'koa'; +import { LoggerOptions, Logger, Level } from 'pino'; +import * as stream from 'stream'; +import * as http from 'http'; + +export = logger; + +declare function logger( + opts?: logger.HttpLoggerOptions, + stream?: stream.Writable | stream.Duplex | stream.Transform +): Middleware; + +declare namespace logger { + interface HttpLoggerOptions extends LoggerOptions { + logger?: Logger; + genReqId?(req: http.IncomingMessage): number; + useLevel?: Level; + stream?: stream.Writable | stream.Duplex | stream.Transform; + } +} diff --git a/types/koa-pino-logger/koa-pino-logger-tests.ts b/types/koa-pino-logger/koa-pino-logger-tests.ts new file mode 100644 index 0000000000..68f5dd1331 --- /dev/null +++ b/types/koa-pino-logger/koa-pino-logger-tests.ts @@ -0,0 +1,5 @@ +import * as koa from 'koa'; +import * as logger from 'koa-pino-logger'; + +const app = new koa(); +app.use(logger()); diff --git a/types/koa-pino-logger/tsconfig.json b/types/koa-pino-logger/tsconfig.json new file mode 100644 index 0000000000..ddfc0c7e95 --- /dev/null +++ b/types/koa-pino-logger/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "koa-pino-logger-tests.ts" + ] +} \ No newline at end of file diff --git a/types/koa-pino-logger/tslint.json b/types/koa-pino-logger/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/koa-pino-logger/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/koa-route/package.json b/types/koa-route/package.json index 1bac4155dc..9842b1ee29 100644 --- a/types/koa-route/package.json +++ b/types/koa-route/package.json @@ -1,5 +1,6 @@ { + "private": true, "dependencies": { "path-to-regexp": "^1.7.0" } -} +} \ No newline at end of file diff --git a/types/kurento-utils/index.d.ts b/types/kurento-utils/index.d.ts new file mode 100644 index 0000000000..8074661881 --- /dev/null +++ b/types/kurento-utils/index.d.ts @@ -0,0 +1,101 @@ +// Type definitions for kurento-utils 6.6 +// Project: https://github.com/Kurento/kurento-utils-js +// Definitions by: Miloslav NenadĂĄl +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 + +export class WebRtcPeer { + /** + * Using this property the user can get the peerConnection and use it directly. + */ + peerConnection: RTCPeerConnection; + + constructor( + mode: 'recv' | 'send' | 'sendRecv', + options?: object, + callback?: (error: string | undefined) => void + ); + + /** + * Use this method for showing the local video. + */ + showLocalVideo: () => void; + /** + * Using this method the user can get the local stream. You can use muted property to silence the audio, if this property is true. + */ + getLocalStream: () => MediaStream; + /** + * Using this method the user can get the remote stream. + */ + getRemoteStream: () => MediaStream; + /** + * Callback function invoked when a SDP answer is received. Developers are expected to invoke this function in order to complete the SDP negotiation. This method has two parameters: + * + * @param sdpAnswer Description of sdpAnswer + * @param callback It is a function with error like parameter. It is called when the remote description has been set successfully. + */ + processAnswer: ( + sdpAnswer: string, + callback?: (error: string | undefined) => void + ) => void; + /** + * Callback function invoked when a SDP offer is received. Developers are expected to invoke this function in order to complete the SDP negotiation. This method has two parameters: + * + * @param sdpOffer Description of sdpOffer + * @param callback It is a function with error and sdpAnswer like parameters. It is called when the remote description has been set successfully. + */ + processOffer: ( + sdpOffer: string, + callback?: (error: string | undefined, sdp: string) => void + ) => void; + /** + * This method frees the resources used by WebRtcPeer. + */ + dispose: () => void; + /** + * Callback function invoked when an ICE candidate is received. Developers are expected to invoke this function in order to complete the SDP negotiation. This method has two parameters: + * + * @param iceCandidate Literal object with the ICE candidate description + * @param callback It is a function with error like parameter. It is called when the ICE candidate has been added. + */ + addIceCandidate: ( + iceCandidate: RTCIceCandidate, + callback?: () => void + ) => void; + /** + * Using this method the user can get peerconnection’s local session descriptor. + */ + getLocalSessionDescriptor: () => RTCSessionDescription; + /** + * Using this method the user can get peerconnection’s remote session descriptor. + */ + getRemoteSessionDescriptor: () => RTCSessionDescription; + /** + * Creates an offer that is a request to find a remote peer with a specific configuration. + */ + generateOffer: (error: string | undefined, sdp: string) => void; + + /** + * Create a WebRtcPeer as receive only. + */ + static WebRtcPeerRecvonly: ( + options: object, + callback: (error: string | undefined) => void + ) => WebRtcPeer; + + /** + * Create a WebRtcPeer as send only. + */ + static WebRtcPeerSendonly: ( + options: object, + callback: (error: string | undefined) => void + ) => WebRtcPeer; + + /** + * Create a WebRtcPeer as send and receive. + */ + static WebRtcPeerSendrecv: ( + options: object, + callback: (error: string | undefined) => void + ) => WebRtcPeer; +} diff --git a/types/kurento-utils/kurento-utils-tests.ts b/types/kurento-utils/kurento-utils-tests.ts new file mode 100644 index 0000000000..5866a2e157 --- /dev/null +++ b/types/kurento-utils/kurento-utils-tests.ts @@ -0,0 +1,12 @@ +import * as kurentoUtils from 'kurento-utils'; + +() => { + const peer = kurentoUtils.WebRtcPeer.WebRtcPeerSendrecv({}, error => {}); + peer.showLocalVideo(); + peer.getLocalStream().getAudioTracks(); + peer.getRemoteStream().getAudioTracks(); + peer.processAnswer('answer', error => {}); + peer.processOffer('offer', (error, {}) => {}); + const rtcPeerConnection = peer.peerConnection; + peer.dispose(); +}; diff --git a/types/kurento-utils/tsconfig.json b/types/kurento-utils/tsconfig.json new file mode 100644 index 0000000000..5cf0b9a383 --- /dev/null +++ b/types/kurento-utils/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "kurento-utils-tests.ts" + ] +} \ No newline at end of file diff --git a/types/kurento-utils/tslint.json b/types/kurento-utils/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/kurento-utils/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/leaflet-areaselect/index.d.ts b/types/leaflet-areaselect/index.d.ts index 7c3fe5a476..50b0202f6a 100644 --- a/types/leaflet-areaselect/index.d.ts +++ b/types/leaflet-areaselect/index.d.ts @@ -3,9 +3,9 @@ // Definitions by: AndrĂŠ Wallat // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import * as L from 'leaflet'; -declare namespace L { +declare module 'leaflet' { function areaSelect(box: AreaSelectOptions): AreaSelect; interface AreaSelectOptions { diff --git a/types/leaflet-areaselect/leaflet-areaselect-tests.ts b/types/leaflet-areaselect/leaflet-areaselect-tests.ts index b5d4785257..e285a17432 100644 --- a/types/leaflet-areaselect/leaflet-areaselect-tests.ts +++ b/types/leaflet-areaselect/leaflet-areaselect-tests.ts @@ -1,6 +1,9 @@ +import * as L from 'leaflet'; +import 'leaflet-areaselect'; + const map = L.map('map', {center: L.latLng(-37.7772, 175.2756), zoom: 15 }); let area: L.AreaSelect; -let dim: L.Dimension = { width: 1, height: 2 }; +const dim: L.Dimension = { width: 1, height: 2 }; area = L.areaSelect({}); diff --git a/types/leaflet-areaselect/tslint.json b/types/leaflet-areaselect/tslint.json index d88586e5bd..4e88071852 100644 --- a/types/leaflet-areaselect/tslint.json +++ b/types/leaflet-areaselect/tslint.json @@ -1,3 +1 @@ -{ - "extends": "dtslint/dt.json" -} +{"extends": "dtslint/dt.json"} diff --git a/types/leaflet-curve/index.d.ts b/types/leaflet-curve/index.d.ts index b15f701f81..58e4551dec 100644 --- a/types/leaflet-curve/index.d.ts +++ b/types/leaflet-curve/index.d.ts @@ -1,13 +1,13 @@ -// Type definitions for leaflet-curve 0.0.1 +// Type definitions for leaflet-curve 0.1 // Project: https://github.com/onikiienko/Leaflet.curve // Definitions by: Onikiienko // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import * as L from 'leaflet'; -declare namespace L { +declare module 'leaflet' { /** * Drawing Bezier curves and other complex shapes. */ - function curve(path: any[], options?: L.PathOptions): Path; + function curve(path: any[], options?: PathOptions): Path; } diff --git a/types/leaflet-curve/leaflet-curve-tests.ts b/types/leaflet-curve/leaflet-curve-tests.ts index 3d8b319e63..7390f82b9d 100644 --- a/types/leaflet-curve/leaflet-curve-tests.ts +++ b/types/leaflet-curve/leaflet-curve-tests.ts @@ -1,29 +1,31 @@ -var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - osmAttrib = '© OpenStreetMap contributors', - osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), - map = new L.Map('map', {layers: [osm], center: new L.LatLng(-37.7772, 175.2756), zoom: 15 }), - objectToSetOnMap = { - "color": "black", - start: { - x: 37.64903402157866, - y: -3.6474609375000004 - }, - vertex: { - x: 38.839707613545144, - y: -1.9555664062500002 - }, - end: { - x: 39.977120098439634, - y: -3.6474609375000004 - } - }; +import * as L from 'leaflet'; +import 'leaflet-curve'; +const osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; +const osmAttrib = '© OpenStreetMap contributors'; +const osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}); +const map = new L.Map('map', {layers: [osm], center: new L.LatLng(-37.7772, 175.2756), zoom: 15 }); +const objectToSetOnMap = { + color: 'black', + start: { + x: 37.64903402157866, + y: -3.6474609375000004 + }, + vertex: { + x: 38.839707613545144, + y: -1.9555664062500002 + }, + end: { + x: 39.977120098439634, + y: -3.6474609375000004 + } +}; L.curve( [ - 'M',[objectToSetOnMap.start.x, objectToSetOnMap.start.y], - 'C',[objectToSetOnMap.start.x, objectToSetOnMap.start.y], [objectToSetOnMap.vertex.x, objectToSetOnMap.vertex.y], [objectToSetOnMap.end.x, objectToSetOnMap.end.y], - 'T',[objectToSetOnMap.end.x, objectToSetOnMap.end.y] + 'M', [objectToSetOnMap.start.x, objectToSetOnMap.start.y], + 'C', [objectToSetOnMap.start.x, objectToSetOnMap.start.y], [objectToSetOnMap.vertex.x, objectToSetOnMap.vertex.y], [objectToSetOnMap.end.x, objectToSetOnMap.end.y], + 'T', [objectToSetOnMap.end.x, objectToSetOnMap.end.y] ], {color: objectToSetOnMap.color} ).addTo(map); diff --git a/types/leaflet-curve/tslint.json b/types/leaflet-curve/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/leaflet-curve/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/leaflet-draw/index.d.ts b/types/leaflet-draw/index.d.ts index 7d791f62ae..5ae8c81605 100644 --- a/types/leaflet-draw/index.d.ts +++ b/types/leaflet-draw/index.d.ts @@ -2,10 +2,11 @@ // Project: https://github.com/Leaflet/Leaflet.draw // Definitions by: Matt Guest , Ryan Blace // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -/// +import * as L from 'leaflet'; -declare namespace L { +declare module 'leaflet' { interface MapOptions { drawControl?: boolean; } diff --git a/types/leaflet-draw/leaflet-draw-tests.ts b/types/leaflet-draw/leaflet-draw-tests.ts index 80e175732f..e63006edce 100644 --- a/types/leaflet-draw/leaflet-draw-tests.ts +++ b/types/leaflet-draw/leaflet-draw-tests.ts @@ -1,3 +1,6 @@ +import * as L from 'leaflet'; +import 'leaflet-draw'; + const osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; const osmAttrib = '© OpenStreetMap contributors'; const osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}); @@ -42,8 +45,8 @@ map.on(L.Draw.Event.CREATED, (e: L.DrawEvents.Created) => { drawnItems.addLayer(layer); }); -let examplePolygon: L.LatLngLiteral[] = [{lng: 0, lat: 0}, {lng: 10, lat: 0}, {lng: 10, lat: 10}, {lng: 0, lat: 10}, {lng: 0, lat: 0}]; -let examplePolygonArea: number = L.GeometryUtil.geodesicArea(examplePolygon); +const examplePolygon: L.LatLngLiteral[] = [{lng: 0, lat: 0}, {lng: 10, lat: 0}, {lng: 10, lat: 10}, {lng: 0, lat: 10}, {lng: 0, lat: 0}]; +const examplePolygonArea: number = L.GeometryUtil.geodesicArea(examplePolygon); L.GeometryUtil.readableArea(examplePolygonArea, true); function testBooleanControlOptions() { @@ -104,7 +107,7 @@ function testExampleControlOptions() { circle: false, // Turns off this drawing tool rectangle: { shapeOptions: { - clickable: false + // clickable: false // clickabkle is not a polyline option according to leaflet docs } }, marker: { diff --git a/types/leaflet-editable/index.d.ts b/types/leaflet-editable/index.d.ts index f66b45a9b8..ee42cb1fb1 100644 --- a/types/leaflet-editable/index.d.ts +++ b/types/leaflet-editable/index.d.ts @@ -2,38 +2,39 @@ // Project: https://github.com/yohanboniface/Leaflet.Editable // Definitions by: Dominic Alie // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 -import * as Leaflet from "leaflet"; +import * as Leaflet from 'leaflet'; -declare global { namespace L { +declare module 'leaflet' { /** * Make geometries editable in Leaflet. * * This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to * control editing of geometries. So you can easily build your own UI with your own needs and choices. */ - export interface EditableStatic { + interface EditableStatic { new (map: Map, options: EditOptions): Editable; } /** * Options to pass to L.Editable when instanciating. */ - export interface EditOptions { + interface EditOptions { /** * Class to be used when creating a new Polyline. */ - polylineClass?: Object; + polylineClass?: object; /** * Class to be used when creating a new Polygon. */ - polygonClass?: Object; + polygonClass?: object; /** * Class to be used when creating a new Marker. */ - markerClass?: Object; + markerClass?: object; /** * CSS class to be added to the map container while drawing. @@ -43,42 +44,42 @@ declare global { namespace L { /** * Layer used to store edit tools (vertex, line guide…). */ - editLayer?: Leaflet.LayerGroup; + editLayer?: LayerGroup; /** * Default layer used to store drawn features (marker, polyline…). */ - featuresLayer?: Leaflet.LayerGroup; + featuresLayer?: LayerGroup; /** * Class to be used as vertex, for path editing. */ - vertexMarkerClass?: Object; + vertexMarkerClass?: object; /** * Class to be used as middle vertex, pulled by the user to create a new point in the middle of a path. */ - middleMarkerClass?: Object; + middleMarkerClass?: object; /** * Class to be used as Polyline editor. */ - polylineEditorClass?: Object; + polylineEditorClass?: object; /** * Class to be used as Polygon editor. */ - polygonEditorClass?: Object; + polygonEditorClass?: object; /** * Class to be used as Marker editor. */ - markerEditorClass?: Object; + markerEditorClass?: object; /** * Options to be passed to the line guides. */ - lineGuideOptions?: Object; + lineGuideOptions?: object; /** * Set this to true if you don't want middle markers. @@ -92,7 +93,7 @@ declare global { namespace L { * This is not a plug and play UI, and will not. This is a minimal, lightweight, and fully extendable API to * control editing of geometries. So you can easily build your own UI with your own needs and choices. */ - export interface Editable extends Mixin.LeafletMixinEvents { + interface Editable extends Mixin.LeafletMixinEvents { /** * Options to pass to L.Editable when instanciating. */ @@ -104,20 +105,20 @@ declare global { namespace L { * Start drawing a polyline. If latlng is given, a first point will be added. In any case, continuing on user * click. If options is given, it will be passed to the polyline class constructor. */ - startPolyline(latLng?: LatLng, options?: Leaflet.PolylineOptions): L.Polyline; + startPolyline(latLng?: LatLng, options?: PolylineOptions): Polyline; /** * Start drawing a polygon. If latlng is given, a first point will be added. In any case, continuing on user * click. If options is given, it will be passed to the polygon class constructor. */ - startPolygon(latLng?: LatLng, options?: Leaflet.PolylineOptions): L.Polygon; + startPolygon(latLng?: LatLng, options?: PolylineOptions): Polygon; /** * Start adding a marker. If latlng is given, the marker will be shown first at this point. In any case, it * will follow the user mouse, and will have a final latlng on next click (or touch). If options is given, * it will be passed to the marker class constructor. */ - startMarker(latLng?: LatLng, options?: Leaflet.MarkerOptions): L.Marker; + startMarker(latLng?: LatLng, options?: MarkerOptions): Marker; /** * When you need to stop any ongoing drawing, without needing to know which editor is active. @@ -125,14 +126,14 @@ declare global { namespace L { stopDrawing(): void; } - export var Editable: EditableStatic; + let Editable: EditableStatic; /** * EditableMixin is included to L.Polyline, L.Polygon and L.Marker. It adds the following methods to them. * * When editing is enabled, the editor is accessible on the instance with the editor property. */ - export interface EditableMixin { + interface EditableMixin { /** * Enable editing, by creating an editor if not existing, and then calling enable on it. */ @@ -154,7 +155,7 @@ declare global { namespace L { editEnabled(): boolean; } - export interface Map { + interface Map { /** * Whether to create a L.Editable instance at map init or not. */ @@ -171,11 +172,11 @@ declare global { namespace L { editTools: Editable; } - export interface Polyline extends EditableMixin { - } + // tslint:disable-next-line:no-empty-interface + interface Polyline extends EditableMixin {} namespace Map { - export interface MapOptions { + interface MapOptions { /** * Whether to create a L.Editable instance at map init or not. */ @@ -192,7 +193,7 @@ declare global { namespace L { * When editing a feature (marker, polyline…), an editor is attached to it. This editor basically knows * how to handle the edition. */ - export interface BaseEditor { + interface BaseEditor { /** * Set up the drawing tools for the feature to be editable. */ @@ -208,7 +209,7 @@ declare global { namespace L { * Inherit from L.Editable.BaseEditor. * Inherited by L.Editable.PolylineEditor and L.Editable.PolygonEditor. */ - export interface PathEditor extends BaseEditor { + interface PathEditor extends BaseEditor { /** * Rebuild edit elements (vertex, middlemarker, etc.). */ @@ -218,7 +219,7 @@ declare global { namespace L { /** * Inherit from L.Editable.PathEditor. */ - export interface PolylineEditor extends PathEditor { + interface PolylineEditor extends PathEditor { /** * Set up drawing tools to continue the line forward. */ @@ -233,7 +234,7 @@ declare global { namespace L { /** * Inherit from L.Editable.PathEditor. */ - export interface PolygonEditor extends PathEditor { + interface PolygonEditor extends PathEditor { /** * Set up drawing tools for creating a new hole on the polygon. If the latlng param is given, a first * point is created. @@ -244,15 +245,12 @@ declare global { namespace L { /** * Inherit from L.Editable.BaseEditor. */ - export interface MarkerEditor extends BaseEditor { - } + // tslint:disable-next-line:no-empty-interface + interface MarkerEditor extends BaseEditor {} - export interface Marker extends EditableMixin, MarkerEditor { - } + interface Marker extends EditableMixin, MarkerEditor {} - export interface Polyline extends EditableMixin, PolylineEditor { - } + interface Polyline extends EditableMixin, PolylineEditor {} - export interface Polygon extends EditableMixin, PolygonEditor { - } -} } + interface Polygon extends EditableMixin, PolygonEditor {} +} diff --git a/types/leaflet-editable/leaflet-editable-tests.ts b/types/leaflet-editable/leaflet-editable-tests.ts index 09728add47..23bcc988fb 100644 --- a/types/leaflet-editable/leaflet-editable-tests.ts +++ b/types/leaflet-editable/leaflet-editable-tests.ts @@ -1,3 +1,6 @@ +import * as L from 'leaflet'; +import 'leaflet-editable'; + class MarkerClass { } class MarkerEditorClass { } class MiddleMarkerClass { } @@ -7,7 +10,7 @@ class PolylineClass { } class PolylineEditorClass { } class VertexMarkerClass { } -var map: L.Map = L.map('div', { +const map: L.Map = L.map('div', { editable: true, editOptions: { drawingCSSClass: 'css-class', @@ -26,16 +29,16 @@ var map: L.Map = L.map('div', { } }); -var currentPoly: L.Polygon|L.Polyline| L.Marker = map.editTools.currentPolygon; +const currentPoly: L.Polygon|L.Polyline| L.Marker = map.editTools.currentPolygon; map.editTools.stopDrawing(); -var marker: L.Marker = map.editTools.startMarker(L.latLng(0, 0), { draggable: true }); +const marker: L.Marker = map.editTools.startMarker(L.latLng(0, 0), { draggable: true }); marker.disable(); marker.enable(); marker.toggleEdit(); -var enabled: boolean = marker.editEnabled(); +let enabled: boolean = marker.editEnabled(); -var polyline: L.Polyline = map.editTools.startPolyline(L.latLng(0, 0), { noClip: true }); +const polyline: L.Polyline = map.editTools.startPolyline(L.latLng(0, 0), { noClip: true }); polyline.continueBackward(); polyline.continueForward(); polyline.disable(); @@ -44,7 +47,7 @@ enabled = polyline.editEnabled(); polyline.reset(); polyline.toggleEdit(); -var polygon: L.Polygon = map.editTools.startPolygon(L.latLng(0, 0), { noClip: true }); +const polygon: L.Polygon = map.editTools.startPolygon(L.latLng(0, 0), { noClip: true }); polygon.continueBackward(); polygon.continueForward(); polygon.disable(); diff --git a/types/leaflet-editable/tslint.json b/types/leaflet-editable/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/leaflet-editable/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/leaflet-fullscreen/index.d.ts b/types/leaflet-fullscreen/index.d.ts index 168fae8a28..bf354e9155 100644 --- a/types/leaflet-fullscreen/index.d.ts +++ b/types/leaflet-fullscreen/index.d.ts @@ -3,9 +3,9 @@ // Definitions by: Denis Carriere // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import * as L from 'leaflet'; -declare namespace L { +declare module 'leaflet' { interface MapOptions { fullscreenControl?: true | {pseudoFullscreen: boolean}; } diff --git a/types/leaflet-fullscreen/leaflet-fullscreen-tests.ts b/types/leaflet-fullscreen/leaflet-fullscreen-tests.ts index 661f1bc208..efc611c193 100644 --- a/types/leaflet-fullscreen/leaflet-fullscreen-tests.ts +++ b/types/leaflet-fullscreen/leaflet-fullscreen-tests.ts @@ -1,3 +1,5 @@ +import * as L from 'leaflet'; + const map = L.map('map', { center: [51.505, -0.09], zoom: 13, diff --git a/types/leaflet-fullscreen/tslint.json b/types/leaflet-fullscreen/tslint.json index f93cf8562a..4e88071852 100644 --- a/types/leaflet-fullscreen/tslint.json +++ b/types/leaflet-fullscreen/tslint.json @@ -1,3 +1 @@ -{ - "extends": "dtslint/dt.json" -} +{"extends": "dtslint/dt.json"} diff --git a/types/leaflet-geocoder-mapzen/index.d.ts b/types/leaflet-geocoder-mapzen/index.d.ts index 390a751360..d4f8b445d9 100644 --- a/types/leaflet-geocoder-mapzen/index.d.ts +++ b/types/leaflet-geocoder-mapzen/index.d.ts @@ -1,23 +1,24 @@ -// Type definitions for leaflet-geocoder-mapzen v1.6.3 +// Type definitions for leaflet-geocoder-mapzen 1.6 // Project: https://github.com/mapzen/leaflet-geocoder -// Definitions by: Leonard Lausen +// Definitions by: Leonard Lausen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 -import * as Leaflet from "leaflet"; +import * as L from 'leaflet'; -declare global { namespace L { +declare module 'leaflet' { namespace Control { - export interface GeocoderStatic extends Leaflet.ClassStatic { + interface GeocoderStatic extends ClassStatic { /** * Creates a geocoder control. */ new (options?: GeocoderOptions): Geocoder; } - export interface Geocoder extends Leaflet.Control { - } + // tslint:disable-next-line:no-empty-interface + interface Geocoder extends Control {} - export interface GeocoderOptions { + interface GeocoderOptions { /** * Host endpoint for a Pelias-compatible search API. * @@ -32,7 +33,7 @@ declare global { namespace L { * * Default value: false. */ - bounds?: Leaflet.LatLngBounds | boolean; + bounds?: LatLngBounds | boolean; /** * If true, search and autocomplete prioritizes results near the center @@ -42,7 +43,7 @@ declare global { namespace L { * * Default value: 'true'. */ - focus?: Leaflet.LatLng | boolean; + focus?: LatLng | boolean; /** * Filters results by layers (documentation). @@ -69,7 +70,7 @@ declare global { namespace L { * * Default value: null. */ - params?: Object; + params?: object; /** * The position of the control (one of the map corners). @@ -77,7 +78,7 @@ declare global { namespace L { * * Default value: 'topleft'. */ - position?: Leaflet.PositionString; + position?: PositionString; /** * Attribution text to include. @@ -126,7 +127,7 @@ declare global { namespace L { * * Default value: true */ - markers?: Leaflet.MarkerOptions | boolean; + markers?: MarkerOptions | boolean; /** * If true, the input box will expand to take up the full width of the map container. @@ -166,11 +167,10 @@ declare global { namespace L { } } - export namespace control { - + namespace control { /** * Creates a geocoder control. */ - export function geocoder(api_key: string, options?: Control.GeocoderOptions): L.Control.Geocoder; + function geocoder(api_key: string, options?: Control.GeocoderOptions): Control.Geocoder; } -} } +} diff --git a/types/leaflet-geocoder-mapzen/leaflet-geocoder-mapzen-tests.ts b/types/leaflet-geocoder-mapzen/leaflet-geocoder-mapzen-tests.ts index daf6d20bd6..92bb68f1a9 100644 --- a/types/leaflet-geocoder-mapzen/leaflet-geocoder-mapzen-tests.ts +++ b/types/leaflet-geocoder-mapzen/leaflet-geocoder-mapzen-tests.ts @@ -1,7 +1,10 @@ -var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', - osmAttrib = '© OpenStreetMap contributors', - osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}), - map = new L.Map('map', {layers: [osm], center: new L.LatLng(-37.7772, 175.2756), zoom: 15 }); +import * as L from 'leaflet'; +import 'leaflet-geocoder-mapzen'; + +const osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'; +const osmAttrib = '© OpenStreetMap contributors'; +const osm = L.tileLayer(osmUrl, {maxZoom: 18, attribution: osmAttrib}); +const map = new L.Map('map', {layers: [osm], center: new L.LatLng(-37.7772, 175.2756), zoom: 15 }); // Add geocoding plugin L.control.geocoder('search-MKZrG6M').addTo(map); diff --git a/types/leaflet-geocoder-mapzen/tslint.json b/types/leaflet-geocoder-mapzen/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/leaflet-geocoder-mapzen/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/leaflet-imageoverlay-rotated/index.d.ts b/types/leaflet-imageoverlay-rotated/index.d.ts index 89dde5e375..6a37345ca5 100644 --- a/types/leaflet-imageoverlay-rotated/index.d.ts +++ b/types/leaflet-imageoverlay-rotated/index.d.ts @@ -3,11 +3,11 @@ // Definitions by: Thomas Kleinke // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import * as L from 'leaflet'; -declare namespace L { +declare module 'leaflet' { namespace ImageOverlay { - interface Rotated extends L.ImageOverlay { + interface Rotated extends ImageOverlay { reposition( topleft: LatLngExpression, topright: LatLngExpression, @@ -21,6 +21,6 @@ declare namespace L { topleft: LatLngExpression, topright: LatLngExpression, bottomleft: LatLngExpression, - options?: ImageOverlayOptions): L.ImageOverlay.Rotated; + options?: ImageOverlayOptions): ImageOverlay.Rotated; } } diff --git a/types/leaflet-imageoverlay-rotated/leaflet-imageoverlay-rotated-tests.ts b/types/leaflet-imageoverlay-rotated/leaflet-imageoverlay-rotated-tests.ts index 50db445f79..22b4a54ec1 100644 --- a/types/leaflet-imageoverlay-rotated/leaflet-imageoverlay-rotated-tests.ts +++ b/types/leaflet-imageoverlay-rotated/leaflet-imageoverlay-rotated-tests.ts @@ -1,3 +1,6 @@ +import * as L from 'leaflet'; +import 'leaflet-imageoverlay-rotated'; + const topleft = L.latLng(40.52256691873593, -3.7743186950683594); const topright = L.latLng(40.5210255066156, -3.7734764814376835); const bottomleft = L.latLng(40.52180437272552, -3.7768453359603886); diff --git a/types/leaflet-label/index.d.ts b/types/leaflet-label/index.d.ts index e1e96b717a..60f2b6b398 100644 --- a/types/leaflet-label/index.d.ts +++ b/types/leaflet-label/index.d.ts @@ -3,83 +3,79 @@ // Definitions by: Wim Looman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -import * as Leaflet from "leaflet"; +import * as L from 'leaflet'; -declare global { - namespace L { - interface IconOptions { - labelAnchor?: Point; - } +declare module 'leaflet' { + interface IconOptions { + labelAnchor?: Point; + } - interface PathOptions { - labelAnchor?: Point; - } + interface PathOptions { + labelAnchor?: Point; + } - interface CircleMarkerOptions { - labelAnchor?: Point; - } + interface CircleMarkerOptions { + labelAnchor?: Point; + } - interface Marker { - showLabel(): Marker; - hideLabel(): Marker; - setLabelNoHide(noHide: boolean): void; - bindLabel(content: string, options?: LabelOptions): Marker; - unbindLabel(): Marker; - updateLabelContent(content: string): void; - getLabel(): Label; - setOpacity(opacity: number, labelHasSemiTransparency: boolean): void; - } + interface Marker { + showLabel(): Marker; + hideLabel(): Marker; + setLabelNoHide(noHide: boolean): void; + bindLabel(content: string, options?: LabelOptions): Marker; + unbindLabel(): Marker; + updateLabelContent(content: string): void; + getLabel(): Label; + setOpacity(opacity: number, labelHasSemiTransparency: boolean): void; + } - interface CircleMarker { - showLabel(): CircleMarker; - hideLabel(): CircleMarker; - setLabelNoHide(noHide: boolean): void; - bindLabel(content: string, options?: LabelOptions): CircleMarker; - unbindLabel(): CircleMarker; - updateLabelContent(content: string): void; - getLabel(): Label; - } + interface CircleMarker { + showLabel(): CircleMarker; + hideLabel(): CircleMarker; + setLabelNoHide(noHide: boolean): void; + bindLabel(content: string, options?: LabelOptions): CircleMarker; + unbindLabel(): CircleMarker; + updateLabelContent(content: string): void; + getLabel(): Label; + } - interface FeatureGroup { - clearLayers(): FeatureGroup; - bindLabel(content: string, options?: LabelOptions): FeatureGroup; - unbindLabel(): FeatureGroup; - updateLabelContent(content: string): FeatureGroup; - } + interface FeatureGroup { + clearLayers(): FeatureGroup; + bindLabel(content: string, options?: LabelOptions): FeatureGroup; + unbindLabel(): FeatureGroup; + updateLabelContent(content: string): FeatureGroup; + } - interface Path { - bindLabel(content: string, options?: LabelOptions): Path; - unbindLabel(): Path; - updateLabelContent(content: string): void; - } + interface Path { + bindLabel(content: string, options?: LabelOptions): Path; + unbindLabel(): Path; + updateLabelContent(content: string): void; + } - interface LabelOptions { - className?: string; - clickable?: boolean; - direction?: string; // 'left' | 'right' | 'auto'; - pane?: string; - noHide?: boolean; - offset?: Point; - opacity?: number; - zoomAnimation?: boolean; - } + interface LabelOptions { + className?: string; + clickable?: boolean; + direction?: string; // 'left' | 'right' | 'auto'; + pane?: string; + noHide?: boolean; + offset?: Point; + opacity?: number; + zoomAnimation?: boolean; + } - interface LabelStatic extends ClassStatic { - new(options?: LabelOptions): Label; - } + interface LabelStatic extends ClassStatic { + new(options?: LabelOptions): Label; + } - const Label: LabelStatic; + const Label: LabelStatic; - interface Label extends IEventPowered