diff --git a/scripts/material-ui/generate.js b/scripts/material-ui/generate.js deleted file mode 100644 index 06e6983a44..0000000000 --- a/scripts/material-ui/generate.js +++ /dev/null @@ -1,147 +0,0 @@ -const {get} = require('https') -const {readdir, readFile, writeFile} = require('fs') -const {join, extname, basename, dirname, relative} = require('path') - -const token = process.env.GITHUB_ACCESS_TOKEN || '' - -const toMixedCase = (name) => { - let dist = name[0].toUpperCase() - for (let i = 1; i < name.length; i++) { - const c = name[i] - if (c !== '-') { - dist += c - continue - } - i++ - dist += name[i].toUpperCase() - } - return dist -} - -const github = (path) => new Promise((resolve, reject) => { - get({ - headers: {'user-agent': 'DefinitelyTyped/material-ui/generate'}, - host: 'api.github.com', - path, - }, (res) => { - if ((res.statusCode / 100 >> 0) != 2) { - reject(`GitHub response: ${res.statusCode} ${res.statusMessage}`) - return - } - let data = ''; - res - .on('data', (chunk) => data += chunk) - .on('end', () => resolve(JSON.parse(data))) - }).on('error', reject) -}) - -const categories = () => github(`/repos/callemall/material-ui/contents/src/svg-icons?ref=master&access_token=${token}`) - -const contents = (path) => github(`/repos/callemall/material-ui/contents/${path}?ref=master&access_token=${token}`) - -const collator = new Intl.Collator() - -const resolvePath = (filename) => join(__dirname, '../../types/material-ui', filename) - -const readText = (filename) => new Promise((resolve, reject) => { - readFile(resolvePath(filename), 'utf8', (err, data) => { - if (err != null) { - reject(err) - return - } - resolve(data) - }) -}) - -const writeText = (filename, text) => new Promise((resolve, reject) => { - writeFile(resolvePath(filename), text, 'utf8', (err) => { - if (err != null) { - reject(err) - return - } - resolve() - }) -}) - -const inject = (content) => { - content.category = this.name - return content -} - -const rMark = /(\/{2} \{{3})[\s\S]*?(\/{2} \}{3})/g - -categories() - .then((cats) => Promise.all(Array.prototype.map.call(cats, (cat) => contents(cat.path) - .then((cons) => Array.prototype.map.call(cons, (con) => { - con.category = cat.name - return con - })) - ))) - .then((contentsList) => Array.prototype.concat.apply([], contentsList) - .map((content) => { - const {path} = content - const name = basename(path, extname(path)) - content.id = join(relative('src', dirname(path)), name) - content.className = toMixedCase(content.category) + toMixedCase(name) - return content - }) - .sort((a, b) => collator.compare(a.id, b.id)) - .reduce((prev, content) => { - const {dts, test} = prev - dts.individuals.push(`declare module 'material-ui/${content.id}' { - export import ${content.className} = __MaterialUI.SvgIcon; - export default ${content.className}; -}`) - dts.summarizeds.push(` export import ${content.className} = __MaterialUI.SvgIcon; // require('material-ui/${content.id}');`) - - test.individuals.push(`import _${content.className} from 'material-ui/${content.id}';`) - test.summarizeds.push(` ${content.className},`) - return prev - }, { - dts: {individuals: [], summarizeds: []}, - test: {individuals: [], summarizeds: []}, - }) -) - .then(({dts, test}) => { - return Promise.all([ - (() => { - const {individuals, summarizeds} = dts - const file = 'index.d.ts' - let index = 0 - return readText(file) - .then((script) => writeText(file, script.replace(rMark, (_, p1, p2) => { - let text = '' - switch (index) { - case 0: - text = individuals.join('\n\n') - break - case 1: - text = summarizeds.join('\n') - break - } - index++ - return p1 + '\n' + text + '\n' + p2 - }))) - })(), - (() => { - const {individuals, summarizeds} = test - const file = join('material-ui-tests.tsx') - let index = 0 - return readText(file) - .then((script) => writeText(file, script.replace(rMark, (_, p1, p2) => { - let text = '' - switch (index) { - case 0: - text = individuals.join('\n') - break - case 1: - text = summarizeds.join('\n') - break - } - index++ - return p1 + '\n' + text + '\n' + p2 - }))) - })(), - ]) - }) - .catch((err) => console.error(err)) diff --git a/types/aframe/tslint.json b/types/aframe/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/aframe/tslint.json +++ b/types/aframe/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} 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/botvs/tslint.json b/types/botvs/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/botvs/tslint.json +++ b/types/botvs/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/bunnymq/tslint.json b/types/bunnymq/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/bunnymq/tslint.json +++ b/types/bunnymq/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} 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/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/cucumber/tslint.json b/types/cucumber/tslint.json index a9ae3a3856..215db37b37 100644 --- a/types/cucumber/tslint.json +++ b/types/cucumber/tslint.json @@ -1,4 +1,8 @@ { "extends": "dtslint/dt.json", - "no-any-union": false + "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 3db14f85ea..71ee04c4e1 100644 --- a/types/cwise-parser/tslint.json +++ b/types/cwise-parser/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/dockerode/index.d.ts b/types/dockerode/index.d.ts index aa6c03bf29..199fe1de75 100644 --- a/types/dockerode/index.d.ts +++ b/types/dockerode/index.d.ts @@ -488,6 +488,7 @@ declare namespace Dockerode { CpusetCpus: string; CpusetMems: string; Devices?: any; + DiskQuota: number; KernelMemory: number; Memory: number; MemoryReservation: number; diff --git a/types/documentdb/tslint.json b/types/documentdb/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/documentdb/tslint.json +++ b/types/documentdb/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} 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/engine.io-client/tsconfig.json b/types/engine.io-client/tsconfig.json index 257ae8bb42..e98b3db085 100644 --- a/types/engine.io-client/tsconfig.json +++ b/types/engine.io-client/tsconfig.json @@ -8,7 +8,6 @@ "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": 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/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/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/fluent-ffmpeg/index.d.ts b/types/fluent-ffmpeg/index.d.ts index e1380dc78e..87bdbfe15c 100644 --- a/types/fluent-ffmpeg/index.d.ts +++ b/types/fluent-ffmpeg/index.d.ts @@ -105,6 +105,11 @@ declare namespace Ffmpeg { size?: string; } + interface AudioVideoFilter { + filter: string; + options: string | string[] | {}; + } + class FfmpegCommand extends events.EventEmitter { constructor(options?: FfmpegCommandOptions); constructor(input?: string | stream.Readable, options?: FfmpegCommandOptions); @@ -144,10 +149,10 @@ declare namespace Ffmpeg { audioFrequency(freq: number): FfmpegCommand; withAudioQuality(quality: number): FfmpegCommand; audioQuality(quality: number): FfmpegCommand; - withAudioFilter(filters: { filter: string, options: any }): FfmpegCommand; - withAudioFilters(filters: { filter: string, options: any }): FfmpegCommand; - audioFilter(filters: { filter: string, options: any }): FfmpegCommand; - audioFilters(filters: { filter: string, options: any }): FfmpegCommand; + withAudioFilter(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + withAudioFilters(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + audioFilter(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + audioFilters(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; // options/video; withNoVideo(): FfmpegCommand; @@ -156,10 +161,10 @@ declare namespace Ffmpeg { videoCodec(codec: string): FfmpegCommand; withVideoBitrate(bitrate: string | number): FfmpegCommand; videoBitrate(bitrate: string | number): FfmpegCommand; - withVideoFilter(filters: { filter: string, options: any }): FfmpegCommand; - withVideoFilters(filters: { filter: string, options: any }): FfmpegCommand; - videoFilter(filters: { filter: string, options: any }): FfmpegCommand; - videoFilters(filters: { filter: string, options: any }): FfmpegCommand; + withVideoFilter(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + withVideoFilters(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + videoFilter(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; + videoFilters(filters: string | string[] | AudioVideoFilter[]): FfmpegCommand; withOutputFps(fps: number): FfmpegCommand; withOutputFPS(fps: number): FfmpegCommand; withFpsOutput(fps: number): FfmpegCommand; diff --git a/types/fs-extra/fs-extra-tests.ts b/types/fs-extra/fs-extra-tests.ts index 1af094260d..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: {} }; diff --git a/types/fs-extra/index.d.ts b/types/fs-extra/index.d.ts index df3324aca5..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; 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/graphql/index.d.ts b/types/graphql/index.d.ts index e85060bab5..905dcbdd7b 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -7,6 +7,7 @@ // Kepennar // Mikhail Novikov // Ivan Goncharov +// Hagai Cohen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 diff --git a/types/graphql/subscription/subscribe.d.ts b/types/graphql/subscription/subscribe.d.ts index b7b40076bf..30efc010ec 100644 --- a/types/graphql/subscription/subscribe.d.ts +++ b/types/graphql/subscription/subscribe.d.ts @@ -14,7 +14,7 @@ export function subscribe( operationName?: string, fieldResolver?: GraphQLFieldResolver, subscribeFieldResolver?: GraphQLFieldResolver -): AsyncIterator; +): Promise | ExecutionResult>; export function createSourceEventStream( schema: GraphQLSchema, @@ -26,4 +26,4 @@ export function createSourceEventStream( }, operationName?: string, fieldResolver?: GraphQLFieldResolver -): AsyncIterable; +): Promise>; 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/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/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/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/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/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/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/jwt-decode/tslint.json b/types/jwt-decode/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/jwt-decode/tslint.json +++ b/types/jwt-decode/tslint.json @@ -1 +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 3db14f85ea..71ee04c4e1 100644 --- a/types/jwt-decode/v1/tslint.json +++ b/types/jwt-decode/v1/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/lru-cache/tslint.json b/types/lru-cache/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/lru-cache/tslint.json +++ b/types/lru-cache/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/map-obj/tslint.json b/types/map-obj/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/map-obj/tslint.json +++ b/types/map-obj/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/markdown-it/index.d.ts b/types/markdown-it/index.d.ts index 31605f32b3..5f5129e8b0 100644 --- a/types/markdown-it/index.d.ts +++ b/types/markdown-it/index.d.ts @@ -14,6 +14,7 @@ interface MarkdownItStatic { declare var MarkdownIt: MarkdownItStatic; export = MarkdownIt; +export as namespace markdownit; declare module MarkdownIt { interface MarkdownIt { diff --git a/scripts/material-ui/README.md b/types/material-ui/scripts/README.md similarity index 100% rename from scripts/material-ui/README.md rename to types/material-ui/scripts/README.md diff --git a/types/material-ui/scripts/generate.ts b/types/material-ui/scripts/generate.ts new file mode 100644 index 0000000000..f8024d5805 --- /dev/null +++ b/types/material-ui/scripts/generate.ts @@ -0,0 +1,151 @@ +// Usage: ts-node generate.ts + +/// + +import {get} from 'https'; +import {readdir, readFile, writeFile} from 'fs'; +import {join, extname, basename, dirname, relative} from 'path'; + +const token = process.env.GITHUB_ACCESS_TOKEN || '' + +const toMixedCase = (name) => { + let dist = name[0].toUpperCase() + for (let i = 1; i < name.length; i++) { + const c = name[i] + if (c !== '-') { + dist += c + continue + } + i++ + dist += name[i].toUpperCase() + } + return dist +} + +const github = (path) => new Promise((resolve, reject) => { + get({ + headers: {'user-agent': 'DefinitelyTyped/material-ui/generate'}, + host: 'api.github.com', + path, + }, (res) => { + if ((res.statusCode / 100 >> 0) != 2) { + reject(`GitHub response: ${res.statusCode} ${res.statusMessage}`) + return + } + let data = ''; + res + .on('data', (chunk) => data += chunk) + .on('end', () => resolve(JSON.parse(data))) + }).on('error', reject) +}) + +const categories = () => github(`/repos/callemall/material-ui/contents/src/svg-icons?ref=master&access_token=${token}`) + +const contents = (path) => github(`/repos/callemall/material-ui/contents/${path}?ref=master&access_token=${token}`) + +const collator = new Intl.Collator() + +const resolvePath = (filename) => join(__dirname, '..', filename) + +const readText = (filename) => new Promise((resolve, reject) => { + readFile(resolvePath(filename), 'utf8', (err, data) => { + if (err != null) { + reject(err) + return + } + resolve(data) + }) +}) + +const writeText = (filename, text) => new Promise((resolve, reject) => { + writeFile(resolvePath(filename), text, 'utf8', (err) => { + if (err != null) { + reject(err) + return + } + resolve() + }) +}) + +const inject = (content) => { + content.category = this.name + return content +} + +const rMark = /(\/{2} \{{3})[\s\S]*?(\/{2} \}{3})/g + +main().catch((err) => console.error(err)); + +async function main() { + const cats = await categories(); + const contentsList = await Promise.all(Array.prototype.map.call(cats, (cat) => contents(cat.path) + .then((cons) => Array.prototype.map.call(cons, (con) => { + con.category = cat.name + return con + })) + )); + const { dts, test } = await Array.prototype.concat.apply([], contentsList) + .map((content) => { + const {path} = content + const name = basename(path, extname(path)) + content.id = join(relative('src', dirname(path)), name) + content.className = toMixedCase(content.category) + toMixedCase(name) + return content + }) + .sort((a, b) => collator.compare(a.id, b.id)) + .reduce((prev, content) => { + const {dts, test} = prev + dts.individuals.push(`declare module 'material-ui/${content.id}' { + export import ${content.className} = __MaterialUI.SvgIcon; + export default ${content.className}; +}`) + dts.summarizeds.push(` export import ${content.className} = __MaterialUI.SvgIcon; // require('material-ui/${content.id}');`) + + test.individuals.push(`import _${content.className} from 'material-ui/${content.id}';`) + test.summarizeds.push(` ${content.className},`) + return prev + }, { + dts: {individuals: [], summarizeds: []}, + test: {individuals: [], summarizeds: []}, + }); + + { + const {individuals, summarizeds} = dts + const file = 'index.d.ts' + let index = 0 + const script = await readText(file) + await writeText(file, script.replace(rMark, (_, p1, p2) => { + let text = '' + switch (index) { + case 0: + text = individuals.join('\n\n') + break + case 1: + text = summarizeds.join('\n') + break + } + index++ + return p1 + '\n' + text + '\n' + p2 + })) + } + + { + const {individuals, summarizeds} = test + const file = 'material-ui-tests.tsx' + let index = 0 + const script = await readText(file) + await writeText(file, script.replace(rMark, (_, p1, p2) => { + let text = '' + switch (index) { + case 0: + text = individuals.join('\n') + break + case 1: + text = summarizeds.join('\n') + break + } + index++ + return p1 + '\n' + text + '\n' + p2 + })) + } +} diff --git a/types/material-ui/scripts/tsconfig.json b/types/material-ui/scripts/tsconfig.json new file mode 100644 index 0000000000..a06b8ed24f --- /dev/null +++ b/types/material-ui/scripts/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "es6", + "baseUrl": "../..", + "typeRoots": [ + "../../" + ], + "types": [] + } +} \ No newline at end of file diff --git a/types/mem/tslint.json b/types/mem/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/mem/tslint.json +++ b/types/mem/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/meteor/ejson.d.ts b/types/meteor/ejson.d.ts index 45ae2627c0..a6294fb8be 100644 --- a/types/meteor/ejson.d.ts +++ b/types/meteor/ejson.d.ts @@ -5,10 +5,10 @@ interface EJSONableCustomType { typeName(): string; } interface EJSONable { - [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | Date | Uint8Array | EJSONableCustomType; + [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | Date | Uint8Array | EJSONableCustomType | undefined | null; } interface JSONable { - [key: string]: number | string | boolean | Object | number[] | string[] | Object[]; + [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | undefined | null; } interface EJSON extends EJSONable { } @@ -44,10 +44,10 @@ declare module "meteor/ejson" { typeName(): string; } interface EJSONable { - [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | Date | Uint8Array | EJSONableCustomType; + [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | Date | Uint8Array | EJSONableCustomType | undefined | null; } interface JSONable { - [key: string]: number | string | boolean | Object | number[] | string[] | Object[]; + [key: string]: number | string | boolean | Object | number[] | string[] | Object[] | undefined | null; } interface EJSON extends EJSONable { } diff --git a/types/meteor/mongo.d.ts b/types/meteor/mongo.d.ts index af632bdab1..99f931ec28 100644 --- a/types/meteor/mongo.d.ts +++ b/types/meteor/mongo.d.ts @@ -214,7 +214,10 @@ declare module "meteor/mongo" { interface ObjectIDStatic { new (hexString?: string): ObjectID; } - interface ObjectID { } + interface ObjectID { + toHexString(): string; + equals(otherID: ObjectID): boolean; + } function setConnectionOptions(options: any): void; } diff --git a/types/moonjs/tslint.json b/types/moonjs/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/moonjs/tslint.json +++ b/types/moonjs/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/msgpack-lite/tslint.json b/types/msgpack-lite/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/msgpack-lite/tslint.json +++ b/types/msgpack-lite/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/nano/index.d.ts b/types/nano/index.d.ts index ab80e563d4..b95eecd8ea 100644 --- a/types/nano/index.d.ts +++ b/types/nano/index.d.ts @@ -1,14 +1,17 @@ // Type definitions for nano 6.2 // Project: https://github.com/apache/couchdb-nano // Definitions by: Tim Jacobi +// Kovács Vince // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + import { EventEmitter } from "events"; -import { Request, CoreOptions } from "request"; +import { CoreOptions, Request } from "request"; declare function nano( config: nano.Configuration | string -): nano.ServerScope | nano.DocumentScope; +): nano.ServerScope | nano.DocumentScope; declare namespace nano { interface Configuration { @@ -19,169 +22,279 @@ declare namespace nano { request?(params: any): void; } - type Callback = (error: any, result: any, headers?: any) => void; + type Callback = (error: any, response: R, headers?: any) => void; interface ServerScope { readonly config: ServerConfig; db: DatabaseScope; - use(db: string): DocumentScope; - scope(db: string): DocumentScope; + use(db: string): DocumentScope; + scope(db: string): DocumentScope; request: RequestFunction; relax: RequestFunction; dinosaur: RequestFunction; - auth(username: string, userpass: string, callback?: Callback): Request; - session(callback?: Callback): Request; - updates(params?: UpdatesParams, callback?: Callback): Request; - followUpdates(params?: any, callback?: Callback): EventEmitter; - uuids(num: number, callback: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/authn.html#cookie-authentication + auth(username: string, userpass: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/authn.html#get--_session + session(callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates + updates(callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates + updates(params: UpdatesParams, callback?: Callback): Request; + followUpdates(callback?: Callback): EventEmitter; + followUpdates(params: any, callback?: Callback): EventEmitter; + uuids(num: number, callback: Callback): Request; } interface DatabaseScope { - create(name: string, callback?: Callback): Request; - get(name: string, callback?: Callback): Request; - destroy(name: string, callback?: Callback): Request; - list(callback?: Callback): Request; - use(db: string): DocumentScope; - compact(name: string, designname?: string, callback?: Callback): Request; - replicate( - source: string | DocumentScope, - target: string | DocumentScope, - options?: any, - callback?: Callback + // http://docs.couchdb.org/en/latest/api/database/common.html#put--db + create(name: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/common.html#get--db + get(name: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/common.html#delete--db + destroy(name: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_all_dbs + list(callback?: Callback): Request; + use(db: string): DocumentScope; + compact(name: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/compact.html#post--db-_compact + compact(name: string, designname: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate + replicate( + source: string | DocumentScope, + target: string | DocumentScope, + callback?: Callback ): Request; - changes(name: string, params?: any, callback?: Callback): Request; - follow( - source: string, - params?: DatabaseScopeFollowUpdatesParams, - callback?: Callback - ): EventEmitter; - followUpdates(params?: any, callback?: Callback): EventEmitter; - updates(params?: UpdatesParams, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate + replicate( + source: string | DocumentScope, + target: string | DocumentScope, + options: DatabaseReplicateOptions, + callback?: Callback + ): Request; + // http://docs.couchdb.org/en/latest/api/database/changes.html#get--db-_changes + changes(name: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/compact.html#post--db-_compact + changes(name: string, params: DatabaseChangesParams, callback?: Callback): Request; + follow(source: string, callback?: Callback): EventEmitter; + follow(source: string, params: DatabaseScopeFollowUpdatesParams, callback?: Callback): EventEmitter; + followUpdates(params?: any, callback?: Callback): EventEmitter; + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates + updates(callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates + updates(params: UpdatesParams, callback?: Callback): Request; } - interface DocumentScope { + interface DocumentScope { readonly config: ServerConfig; - info(callback?: Callback): Request; - replicate( - target: string | DocumentScope, - options?: any, - callback?: Callback + // http://docs.couchdb.org/en/latest/api/database/common.html#get--db + info(callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate + replicate( + target: string | DocumentScope, + callback?: Callback ): Request; - compact(callback?: Callback): Request; - changes(params?: any, callback?: Callback): Request; - follow( - params?: DocumentScopeFollowUpdatesParams, - callback?: Callback - ): EventEmitter; - auth(username: string, userpass: string, callback?: Callback): Request; - session(callback?: Callback): Request; - insert(document: any, params?: any, callback?: Callback): Request; - get(docname: string, params?: any, callback?: Callback): Request; - head(docname: string, callback: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate + replicate( + target: string | DocumentScope, + options: any, + callback?: Callback + ): Request; + // http://docs.couchdb.org/en/latest/api/database/compact.html#post--db-_compact + compact(callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/changes.html#get--db-_changes + changes(callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/changes.html#get--db-_changes + changes(params: DatabaseChangesParams, callback?: Callback): Request; + follow(callback?: Callback): EventEmitter; + follow(params: DocumentScopeFollowUpdatesParams, callback?: Callback): EventEmitter; + // http://docs.couchdb.org/en/latest/api/server/authn.html#cookie-authentication + auth(username: string, userpass: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/server/authn.html#get--_session + session(callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/common.html#post--db + // http://docs.couchdb.org/en/latest/api/document/common.html#put--db-docid + insert(document: ViewDocument | D & MaybeDocument, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/common.html#post--db + // http://docs.couchdb.org/en/latest/api/document/common.html#put--db-docid + insert( + document: ViewDocument | D & MaybeDocument, + params: DocumentInsertParams | string | null, + callback?: Callback + ): Request; + // http://docs.couchdb.org/en/latest/api/document/common.html#get--db-docid + get(docname: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/document/common.html#get--db-docid + get(docname: string, params?: DocumentGetParams, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/document/common.html#head--db-docid + head(docname: string, callback: Callback): Request; + // http://docs.couchdb.org/en/latest/api/document/common.html#copy--db-docid + copy(src_document: string, dst_document: string, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/document/common.html#copy--db-docid copy( src_document: string, dst_document: string, - options: any, - callback?: Callback + options: DocumentCopyOptions, + callback?: Callback ): Request; - destroy(docname: string, rev: string, callback?: Callback): Request; - bulk( - docs: BulkModifyDocsWrapper, - params?: any, - callback?: Callback - ): Request; - list(params?: any, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/document/common.html#delete--db-docid + destroy(docname: string, rev: string, callback?: Callback): Request; + bulk(docs: BulkModifyDocsWrapper, callback?: Callback): Request; + bulk(docs: BulkModifyDocsWrapper, params: any, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#get--db-_all_docs + list(callback?: Callback>): Request; + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#get--db-_all_docs + list(params: DocumentListParams, callback?: Callback>): Request; + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs + fetch(docnames: BulkFetchDocsWrapper, callback?: Callback>): Request; + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs fetch( docnames: BulkFetchDocsWrapper, - params?: any, - callback?: Callback + params: DocumentFetchParams, + callback?: Callback> ): Request; + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs + fetchRevs(docnames: BulkFetchDocsWrapper, callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#post--db-_all_docs fetchRevs( docnames: BulkFetchDocsWrapper, - params?: any, - callback?: Callback + params: DocumentFetchParams, + callback?: Callback ): Request; - multipart: Multipart; + multipart: Multipart; attachment: Attachment; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#get--db-_design-ddoc-_show-func show( designname: string, showname: string, doc_id: string, - params?: any, - callback?: Callback + callback?: Callback ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#get--db-_design-ddoc-_show-func + show( + designname: string, + showname: string, + doc_id: string, + params: any, + callback?: Callback + ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#put--db-_design-ddoc-_update-func-docid atomic( designname: string, updatename: string, docname: string, - body?: any, - callback?: Callback + callback?: Callback ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#put--db-_design-ddoc-_update-func-docid + atomic( + designname: string, + updatename: string, + docname: string, + body: any, + callback?: Callback + ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#put--db-_design-ddoc-_update-func-docid updateWithHandler( designname: string, updatename: string, docname: string, - body?: any, - callback?: Callback + callback?: Callback + ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#put--db-_design-ddoc-_update-func-docid + updateWithHandler( + designname: string, + updatename: string, + docname: string, + body: any, + callback?: Callback ): Request; search( designname: string, searchname: string, - params?: any, - callback?: Callback + callback?: Callback + ): Request; + search( + designname: string, + searchname: string, + params: any, + callback?: Callback ): Request; spatial( ddoc: string, viewname: string, - params?: any, - callback?: Callback + callback?: Callback ): Request; - view( + spatial( + ddoc: string, + viewname: string, + params: any, + callback?: Callback + ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/views.html#get--db-_design-ddoc-_view-view + // http://docs.couchdb.org/en/latest/api/ddoc/views.html#post--db-_design-ddoc-_view-view + view( designname: string, viewname: string, - params?: any, - callback?: Callback + callback?: Callback> ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/views.html#get--db-_design-ddoc-_view-view + // http://docs.couchdb.org/en/latest/api/ddoc/views.html#post--db-_design-ddoc-_view-view + view( + designname: string, + viewname: string, + params: DocumentViewParams, + callback?: Callback> + ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#db-design-design-doc-list-list-name-view-name viewWithList( designname: string, viewname: string, listname: string, - params?: any, - callback?: Callback + callback?: Callback + ): Request; + // http://docs.couchdb.org/en/latest/api/ddoc/render.html#db-design-design-doc-list-list-name-view-name + viewWithList( + designname: string, + viewname: string, + listname: string, + params: DocumentViewParams, + callback?: Callback ): Request; server: ServerScope; } - interface Multipart { - insert( - doc: any, - attachments: any[], - params: string | any, - callback?: Callback - ): Request; - get(docname: string, params?: string | any, callback?: Callback): Request; + interface Multipart { + // http://docs.couchdb.org/en/latest/api/document/common.html#creating-multiple-attachments + insert(doc: D, attachments: any[], callback?: Callback): Request; + // http://docs.couchdb.org/en/latest/api/document/common.html#creating-multiple-attachments + insert(doc: D, attachments: any[], params: any, callback?: Callback): Request; + get(docname: string, callback?: Callback): Request; + get(docname: string, params: any, callback?: Callback): Request; } interface Attachment { + insert(docname: string, attname: string, att: null, contenttype: string, params?: any): NodeJS.WritableStream; + insert(docname: string, attname: string, att: any, contenttype: string, callback?: Callback): Request; insert( docname: string, attname: string, att: any, contenttype: string, - params?: any, - callback?: Callback + params: any, + callback?: Callback ): Request; + get(docname: string, attname: string, callback?: Callback): Request; get( docname: string, attname: string, - params?: any, - callback?: Callback + params: any, + callback?: Callback ): Request; + destroy(docname: string, attname: string, callback?: Callback): Request; destroy( docname: string, attname: string, - params?: any, - callback?: Callback + params: any, + callback?: Callback ): Request; } @@ -192,7 +305,7 @@ declare namespace nano { type RequestFunction = ( options?: RequestOptions | string, - callback?: Callback + callback?: Callback ) => void; interface RequestOptions { @@ -209,10 +322,12 @@ declare namespace nano { multipart?: any[]; } + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates interface UpdatesParams { feed: "longpoll" | "continuous" | "eventsource"; timeout: number; heartbeat: boolean; + since: string; } interface DocumentScopeFollowUpdatesParams { @@ -243,6 +358,677 @@ declare namespace nano { interface BulkFetchDocsWrapper { keys: string[]; } + + // ------------------------------------- + // Document + // ------------------------------------- + + interface MaybeIdentifiedDocument { + _id?: string; + } + + interface IdentifiedDocument { + _id: string; + } + + interface MaybeRevisionedDocument { + _rev?: string; + } + + interface RevisionedDocument { + _rev: string; + } + + interface MaybeDocument extends MaybeIdentifiedDocument, MaybeRevisionedDocument { + } + + interface Document extends IdentifiedDocument, RevisionedDocument { + } + + // ------------------------------------- + // View + // ------------------------------------- + + interface View { + map?(doc: D & Document): void; + reduce?(doc: D & Document): void; + } + + interface ViewDocument extends IdentifiedDocument { + views: { + [name: string]: View + }; + } + + // ------------------------------------- + // Database scope request and response + // ------------------------------------- + + // http://docs.couchdb.org/en/latest/api/database/common.html#put--db + interface DatabaseCreateResponse { + // Operation status. Available in case of success + ok?: boolean; + + // Error type. Available if response code is 4xx + error?: string; + + // Error description. Available if response code is 4xx + reason?: string; + } + + // http://docs.couchdb.org/en/latest/api/database/common.html#get--db + interface DatabaseGetResponse { + // Set to true if the database compaction routine is operating on this database. + compact_running: boolean; + + // The name of the database. + db_name: string; + + // The version of the physical format used for the data when it is stored on disk. + disk_format_version: number; + + // The number of bytes of live data inside the database file. + data_size: number; + + // The length of the database file on disk. Views indexes are not included in the calculation. + disk_size: number; + + // A count of the documents in the specified database. + doc_count: number; + + // Number of deleted documents + doc_del_count: number; + + // Timestamp of when the database was opened, expressed in microseconds since the epoch. + instance_start_time: string; + + // The number of purge operations on the database. + purge_seq: number; + + sizes: { + // The size of live data inside the database, in bytes. + active: number; + + // The uncompressed size of database contents in bytes. + external: number; + + // The size of the database file on disk in bytes. Views indexes + file: number; + }; + + // The current number of updates to the database. + update_seq: number; + } + + // http://docs.couchdb.org/en/latest/api/database/common.html#delete--db + // http://docs.couchdb.org/en/latest/api/database/compact.html#post--db-_compact + interface OkResponse { + // Operation status + ok: boolean; + } + + // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate + interface DatabaseReplicateOptions { + // Cancels the replication + cancel?: boolean; + + // Configure the replication to be continuous + continuous?: boolean; + + // Creates the target database. Required administrator’s privileges on target server. + create_target?: boolean; + + // Array of document IDs to be synchronized + doc_ids?: string[]; + + // The name of a filter function. + filter ?: string; + + // Address of a proxy server through which replication should occur (protocol can be “http” or “socks5”) + proxy ?: string; + + // Source database name or URL + source?: string; + + // Target database name or URL + target?: string; + } + + // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate + interface DatabaseReplicationHistoryItem { + // Number of document write failures + doc_write_failures: number; + + // Number of documents read + docs_read: number; + + // Number of documents written to target + docs_written: number; + + // Last sequence number in changes stream + end_last_seq: number; + + // Date/Time replication operation completed in RFC 2822 format + end_time: string; + + // Number of missing documents checked + missing_checked: number; + + // Number of missing documents found + missing_found: number; + + // Last recorded sequence number + recorded_seq: number; + + // Session ID for this replication operation + session_id: string; + + // First sequence number in changes stream + start_last_seq: number; + + // Date/Time replication operation started in RFC 2822 format + start_time: string; + } + + // http://docs.couchdb.org/en/latest/api/server/common.html#post--_replicate + interface DatabaseReplicateResponse { + // Replication history + history: DatabaseReplicationHistoryItem[]; + + // Replication status + ok: boolean; + + // Replication protocol version + replication_id_version: number; + + // Unique session ID + session_id: string; + + // Last sequence number read from source database + source_last_seq: number; + } + + // http://docs.couchdb.org/en/latest/api/database/changes.html#get--db-_changes + interface DatabaseChangesParams { + // List of document IDs to filter the changes feed as valid JSON array. Used with _doc_ids filter. Since length of + // URL is limited, it is better to use POST /{db}/_changes instead. + doc_ids?: string[]; + + // Includes conflicts information in response. Ignored if include_docs isn’t true. Default is false. + conflicts?: boolean; + + // Return the change results in descending sequence order (most recent change first). Default is false. + descending?: boolean; + + // - normal Specifies Normal Polling Mode. All past changes are returned immediately. Default. + // - longpoll Specifies Long Polling Mode. Waits until at least one change has occurred, sends the change, then + // closes the connection. Most commonly used in conjunction with since=now, to wait for the next change. + // - continuous Sets Continuous Mode. Sends a line of JSON per event. Keeps the socket open until timeout. + // - eventsource Sets Event Source Mode. Works the same as Continuous Mode, but sends the events in EventSource + // format. + feed?: "normal" | "longpoll" | "continuous" | "eventsource"; + + // Reference to a filter function from a design document that will filter whole stream emitting only filtered + // events. See the section Change Notifications in the book CouchDB The Definitive Guide for more information. + filter?: string; + + // Period in milliseconds after which an empty line is sent in the results. Only applicable for longpoll, + // continuous, and eventsource feeds. Overrides any timeout to keep the feed alive indefinitely. Default is 60000. + // May be true to use default value. + heartbeat?: number; + + // Include the associated document with each result. If there are conflicts, only the winning revision is returned. + // Default is false. + include_docs?: boolean; + + // Include the Base64-encoded content of attachments in the documents that are included if include_docs is true. + // Ignored if include_docs isn’t true. Default is false. + attachments?: boolean; + + // Include encoding information in attachment stubs if include_docs is true and the particular attachment is + // compressed. Ignored if include_docs isn’t true. Default is false. + att_encoding_info?: boolean; + + // Limit number of result rows to the specified value (note that using 0 here has the same effect as 1). + limit?: number; + + // Start the results from the change immediately after the given update sequence. Can be valid update sequence or + // now value. Default is 0. + since?: number; + + // Specifies how many revisions are returned in the changes array. The default, main_only, will only return the + // current “winning” revision; all_docs will return all leaf revisions (including conflicts and deleted former + // conflicts). + style?: string; + + // Maximum period in milliseconds to wait for a change before the response is sent, even if there are no results. + // Only applicable for longpoll or continuous feeds. Default value is specified by httpd/changes_timeout + // configuration option. Note that 60000 value is also the default maximum timeout to prevent undetected dead + // connections. + timeout?: number; + + // Allows to use view functions as filters. Documents counted as “passed” for view filter in case if map function + // emits at least one record for them. See _view for more info. + view?: string; + } + + // http://docs.couchdb.org/en/latest/api/database/changes.html#get--db-_changes + interface DatabaseChangesResultItem { + // List of document’s leaves with single field rev. + changes: Array<{ rev: string }>; + + // Document ID. + id: string; + + // Update sequence. + seq: any; + + // true if the document is deleted. + deleted: boolean; + } + + // http://docs.couchdb.org/en/latest/api/database/changes.html#get--db-_changes + interface DatabaseChangesResponse { + // Last change update sequence + last_seq: any; + + // Count of remaining items in the feed + pending: number; + + // Changes made to a database + results: DatabaseChangesResultItem[]; + } + + // http://docs.couchdb.org/en/latest/api/server/authn.html#cookie-authentication + interface DatabaseAuthResponse { + // Operation status + ok: boolean; + + // Username + name: string; + + // List of user roles + roles: string[]; + } + + // http://docs.couchdb.org/en/latest/api/server/authn.html#get--_session + interface DatabaseSessionResponse { + // Operation status + ok: boolean; + + // User context for the current user + userCtx: any; + + // Server authentication configuration + info: any; + } + + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates + interface DatabaseUpdatesResultItem { + // Database name. + db_name: string; + + // A database event is one of created, updated, deleted. + type: string; + + // Update sequence of the event. + seq: any; + } + + // http://docs.couchdb.org/en/latest/api/server/common.html#get--_db_updates + interface DatabaseUpdatesResponse { + // An array of database events. For longpoll and continuous modes, the entire response is the contents of the + // results array. + results: DatabaseUpdatesResultItem[]; + + // The last sequence ID reported. + last_seq: string; + } + + // ------------------------------------- + // Document scope request and response + // ------------------------------------- + + interface DocumentResponseRowMeta { + id: string; + key: string; + value: { + rev: string; + }; + } + + interface DocumentResponseRow extends DocumentResponseRowMeta { + doc?: D & Document; + } + + // http://docs.couchdb.org/en/latest/api/database/common.html#post--db + // http://docs.couchdb.org/en/latest/api/document/common.html#put--db-docid + interface DocumentInsertParams { + // Document’s revision if updating an existing document. Alternative to If-Match header or document key. + rev?: string; + + // Stores document in batch mode. + batch?: "ok"; + + // Prevents insertion of a conflicting document. Possible values: true (default) and false. If false, a + // well-formed _rev must be included in the document. new_edits=false is used by the replicator to insert + // documents into the target database even if that leads to the creation of conflicts. + new_edits?: boolean; + } + + // http://docs.couchdb.org/en/latest/api/database/common.html#post--db + // http://docs.couchdb.org/en/latest/api/document/common.html#put--db-docid + interface DocumentInsertResponse { + // Document ID + id: string; + + // Operation status + ok: boolean; + + // Revision MVCC token + rev: string; + } + + // http://docs.couchdb.org/en/latest/api/document/common.html#delete--db-docid + interface DocumentDestroyResponse { + // Document ID + id: string; + + // Operation status + ok: boolean; + + // Revision MVCC token + rev: string; + } + + // http://docs.couchdb.org/en/latest/api/document/common.html#get--db-docid + interface DocumentGetParams { + // Includes attachments bodies in response. Default is false. + attachments?: boolean; + + // Includes encoding information in attachment stubs if the particular attachment is compressed. Default is + // false. + att_encoding_info?: boolean; + + // Includes attachments only since specified revisions. Doesn’t includes attachments for specified revisions. + atts_since?: any[]; + + // Includes information about conflicts in document. Default is false. + conflicts?: boolean; + + // Includes information about deleted conflicted revisions. Default is false. + deleted_conflicts?: boolean; + + // Forces retrieving latest “leaf” revision, no matter what rev was requested. Default is false. + latest?: boolean; + + // Includes last update sequence for the document. Default is false. + local_seq?: boolean; + + // Acts same as specifying all conflicts, deleted_conflicts and revs_info query parameters. Default is false. + meta?: boolean; + + // Retrieves documents of specified leaf revisions. Additionally, it accepts value as all to return all leaf + // revisions. + open_revs?: any[]; + + // Retrieves document of specified revision. + rev?: string; + + // Includes list of all known document revisions. + revs?: boolean; + + // Includes detailed information for all known document revisions. Default is false. + revs_info?: boolean; + } + + // http://docs.couchdb.org/en/latest/api/document/common.html#get--db-docid + interface DocumentGetResponse { + // Document ID. + _id: string; + + // Revision MVCC token. + _rev: string; + + // Deletion flag. Available if document was removed. + _deleted?: boolean; + + // Attachment’s stubs. Available if document has any attachments. + _attachments?: any; + + // List of conflicted revisions. Available if requested with conflicts=true query parameter. + _conflicts?: any[]; + + // List of deleted conflicted revisions. Available if requested with deleted_conflicts=true query parameter. + _deleted_conflicts?: any[]; + + // Document’s update sequence in current database. Available if requested with local_seq=true query parameter. + _local_seq?: string; + + // List of objects with information about local revisions and their status. Available if requested with + // open_revs query parameter. + _revs_info?: any[]; + + // List of local revision tokens without. Available if requested with revs=true query parameter. + _revisions?: any; + } + + interface DocumentCopyOptions { + overwrite?: boolean; + } + + // http://docs.couchdb.org/en/latest/api/document/common.html#copy--db-docid + interface DocumentCopyResponse { + // Document ID + id: string; + + // Operation status + ok: boolean; + + // Revision MVCC token + rev: string; + } + + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#get--db-_all_docs + interface DocumentListParams { + // Includes conflicts information in response. Ignored if include_docs isn’t true. Default is false. + conflicts?: boolean; + + // Return the documents in descending by key order. Default is false. + descending?: boolean; + + // Stop returning records when the specified key is reached. + end_key?: string; + + // Stop returning records when the specified document ID is reached. + end_key_doc_id?: string; + + // Include the full content of the documents in the return. Default is false. + include_docs?: boolean; + + // Specifies whether the specified end key should be included in the result. Default is true. + inclusive_end?: boolean; + + // Return only documents that match the specified key. + key?: string; + + // Return only documents that match the specified keys. + keys?: string; // This can be string[] too ??? + + // Limit the number of the returned documents to the specified number. + limit?: number; + + // Skip this number of records before starting to return the results. Default is 0. + skip?: number; + + // Allow the results from a stale view to be used, without triggering a rebuild of all views within the + // encompassing design doc. Supported values: ok and update_after. + stale?: string; + + // Return records starting with the specified key. + start_key?: string; + + // Return records starting with the specified document ID. + start_key_doc_id?: string; + + // Response includes an update_seq value indicating which sequence id of the underlying database the view + // reflects. Default is false. + update_seq?: boolean; + } + + // http://docs.couchdb.org/en/latest/api/database/bulk-api.html#get--db-_all_docs + interface DocumentListResponse { + // Offset where the document list started. + offset: number; + + // Array of view row objects. By default the information returned contains only the document ID and revision. + rows: Array>; + + // Number of documents in the database/view. Note that this is not the number of rows returned in the actual + // query. + total_rows: number; + + // Current update sequence for the database. + update_seq?: number; + } + + interface DocumentFetchParams { + conflicts?: boolean; + descending?: boolean; + end_key?: string; + end_key_doc_id?: string; + inclusive_end?: boolean; + key?: string; + keys?: string; // This can be string[] too ??? + limit?: number; + skip?: number; + stale?: string; + start_key?: string; + start_key_doc_id?: string; + update_seq?: boolean; + } + + interface DocumentFetchResponse { + offset: number; + rows: Array>; + total_rows: number; + update_seq?: number; + } + + interface DocumentFetchRevsResponse { + offset: number; + rows: DocumentResponseRowMeta[]; + total_rows: number; + update_seq?: number; + } + + // http://docs.couchdb.org/en/latest/api/ddoc/views.html#get--db-_design-ddoc-_view-view + interface DocumentViewParams { + // Includes conflicts information in response. Ignored if include_docs isn’t true. Default is false. + conflicts?: boolean; + + // Return the documents in descending by key order. Default is false. + descending?: boolean; + + // Stop returning records when the specified key is reached. + endkey?: any; + + // Alias for endkey param. + end_key?: any; + + // Stop returning records when the specified document ID is reached. Requires endkey to be specified for this + // to have any effect. + endkey_docid?: string; + + // Alias for endkey_docid param. + end_key_doc_id?: string; + + // Group the results using the reduce function to a group or single row. Default is false. + group?: boolean; + + // Specify the group level to be used. + group_level?: number; + + // Include the associated document with each row. Default is false. + include_docs?: boolean; + + // Include the Base64-encoded content of attachments in the documents that are included if include_docs is + // true. Ignored if include_docs isn’t true. Default is false. + attachments?: boolean; + + // Include encoding information in attachment stubs if include_docs is true and the particular attachment is + // compressed. Ignored if include_docs isn’t true. Default is false. + att_encoding_info?: boolean; + + // Specifies whether the specified end key should be included in the result. Default is true. + inclusive_end?: boolean; + + // Return only documents that match the specified key. + key?: any; + + // Return only documents where the key matches one of the keys specified in the array. + keys?: any[]; + + // Limit the number of the returned documents to the specified number. + limit?: number; + + // Use the reduction function. Default is true. + reduce?: boolean; + + // Skip this number of records before starting to return the results. Default is 0. + skip?: number; + + // Sort returned rows. Setting this to false offers a performance boost. The total_rows and offset fields are + // not available when this is set to false. Default is true. + sorted?: boolean; + + // Whether or not the view results should be returned from a stable set of shards. Default is false. + stable?: boolean; + // Allow the results from a stale view to be used. Supported values: ok, update_after and false. ok is + // equivalent to stable=true&update=false. update_after is equivalent to stable=true&update=lazy. false is + // equivalent to stable=false&update=true. + stale?: string; + + // Return records starting with the specified key. + startkey?: any; + + // Alias for startkey param + start_key?: any; + + // Return records starting with the specified document ID. Requires startkey to be specified for this to have + // any effect. + startkey_docid?: string; + + // Alias for startkey_docid param + start_key_doc_id?: string; + + // Whether or not the view in question should be updated prior to responding to the user. Supported values: + // true, false, lazy. Default is true. + update?: string; + + // Response includes an update_seq value indicating which sequence id of the database the view reflects. + // Default is false. + update_seq?: boolean; + } + + // http://docs.couchdb.org/en/latest/api/ddoc/views.html#get--db-_design-ddoc-_view-view + interface DocumentViewResponse { + // Offset where the document list started. + offset: number; + + // Array of view row objects. By default the information returned contains only the document ID and revision. + rows: Array<{ + id: string; + key: string; + value: V; + }>; + + // Number of documents in the database/view. + total_rows: number; + + // Current update sequence for the database + update_seq: any; + } } export = nano; diff --git a/types/nano/nano-tests.ts b/types/nano/nano-tests.ts index 33cfe4534d..2184ed822f 100644 --- a/types/nano/nano-tests.ts +++ b/types/nano/nano-tests.ts @@ -1,6 +1,5 @@ -import * as nano from "nano"; import * as fs from "fs"; -import * as path from "path"; +import * as nano from "nano"; /* * Instantiate with configuration object @@ -67,10 +66,15 @@ db.replicate("a", "b", (error: any) => {}); /* * Document Scope */ -const mydb: nano.DocumentScope = instance.use("mydb"); +interface SomeDocument { + name: string; +} -mydb.insert({ foo: "baz" }, null, (err, response) => {}); -mydb.insert({ foo: "baz" }, "foobar", (error, foo) => {}); +const mydb: nano.DocumentScope = instance.use("mydb"); + +mydb.insert({ name: "baz" }, null, (err, response) => {}); +mydb.insert({ name: "baz" }, "foobar", (error, foo) => {}); +mydb.insert({ name: "baz" }, { new_edits: true }, (error, foo) => {}); mydb.get("foobaz", { revs_info: true }, (error, foobaz) => {}); mydb.head("foobaz", (error, body, headers) => {}); mydb.copy( @@ -129,7 +133,7 @@ mydb.attachment.get("new_string", "att", (error: any, helloWorld: any) => {}); /* * Multipart */ -mydb.multipart.insert({ foo: "baz" }, [{}], "foobaz", (error, foo) => {}); +mydb.multipart.insert({ name: "baz" }, [{}], "foobaz", (error, foo) => {}); mydb.multipart.get("foobaz", (error: any, foobaz: any, headers: any) => {}); /* diff --git a/types/navigation/index.d.ts b/types/navigation/index.d.ts index 6f05956a8a..fdc729f11c 100644 --- a/types/navigation/index.d.ts +++ b/types/navigation/index.d.ts @@ -347,6 +347,10 @@ export class StateContext { * Gets the NavigationData for the last displayed State */ oldData: any; + /** + * Gets the Url for the last displayed State + */ + oldUrl: string; /** * Gets the State of the last Crumb in the crumb trail */ @@ -355,6 +359,10 @@ export class StateContext { * Gets the NavigationData of the last Crumb in the crumb trail */ previousData: any; + /** + * Gets the Url of the last Crumb in the crumb trail + */ + previousUrl: string; /** * Gets the current State */ diff --git a/types/navigation/navigation-tests.ts b/types/navigation/navigation-tests.ts index f710670953..37e597f841 100644 --- a/types/navigation/navigation-tests.ts +++ b/types/navigation/navigation-tests.ts @@ -83,12 +83,14 @@ link = stateNavigator.fluent() // State Context let state: State = stateNavigator.stateContext.state; -const url: string = stateNavigator.stateContext.url; +let url: string = stateNavigator.stateContext.url; const title: string = stateNavigator.stateContext.title; let page: number = stateNavigator.stateContext.data.page; state = stateNavigator.stateContext.oldState; +url = stateNavigator.stateContext.oldUrl; page = stateNavigator.stateContext.oldData.page; state = stateNavigator.stateContext.previousState; +url = stateNavigator.stateContext.previousUrl; page = stateNavigator.stateContext.previousData.page; // Navigation Data diff --git a/types/nedb/tslint.json b/types/nedb/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/nedb/tslint.json +++ b/types/nedb/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/nes/index.d.ts b/types/nes/index.d.ts index aab6827ed7..c5526049de 100644 --- a/types/nes/index.d.ts +++ b/types/nes/index.d.ts @@ -91,7 +91,7 @@ declare module nes { id: string; app: Object; auth: nes.SocketAuthObject; - disconect(callback?: () => void): void; + disconnect(callback?: () => void): void; send(message: any, callback?: (err?: any) => void): void; publish(path: string, message: any, callback?: (err?: any) => void): void; revoke(path: string, message: any, callback?: (err?: any) => void): void; diff --git a/types/nes/test/socket.ts b/types/nes/test/socket.ts new file mode 100644 index 0000000000..7f7617d462 --- /dev/null +++ b/types/nes/test/socket.ts @@ -0,0 +1,16 @@ +// from https://github.com/hapijs/nes/blob/v6.4.3/lib/socket.js + +import Nes = require('nes'); + +const socket: Nes.Socket = undefined; + +const cb = () => { }; +socket.disconnect(cb); +const s: string = socket.id; +const o: Object = socket.app; +const auth: Nes.SocketAuthObject = socket.auth; + +const cb2 = (err?: any) => { }; +socket.send('message', (err?: any) => { }); +socket.publish('path', 'message', cb2); +socket.revoke('path', 'message', cb2); diff --git a/types/nes/tsconfig.json b/types/nes/tsconfig.json index cb28129b71..c03d7c22ee 100644 --- a/types/nes/tsconfig.json +++ b/types/nes/tsconfig.json @@ -26,9 +26,10 @@ "test/route-authentication-server.ts", "test/route-invocation-client.ts", "test/route-invocation-server.ts", + "test/socket.ts", "test/subscription-filter-client.ts", "test/subscription-filter-server.ts", "test/subscriptions-client.ts", "test/subscriptions-server.ts" ] -} \ No newline at end of file +} diff --git a/types/next-redux-wrapper/tslint.json b/types/next-redux-wrapper/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/next-redux-wrapper/tslint.json +++ b/types/next-redux-wrapper/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/ngstorage/tslint.json b/types/ngstorage/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/ngstorage/tslint.json +++ b/types/ngstorage/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/node-rsa/tslint.json b/types/node-rsa/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/node-rsa/tslint.json +++ b/types/node-rsa/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/node/index.d.ts b/types/node/index.d.ts index 9c222b5350..4e8e3cf8c0 100644 --- a/types/node/index.d.ts +++ b/types/node/index.d.ts @@ -93,10 +93,17 @@ interface NodeRequireFunction { interface NodeRequire extends NodeRequireFunction { resolve(id: string): string; cache: any; - extensions: any; + extensions: NodeExtensions; main: NodeModule | undefined; } +interface NodeExtensions { + '.js': (m: NodeModule, filename: string) => any; + '.json': (m: NodeModule, filename: string) => any; + '.node': (m: NodeModule, filename: string) => any; + [ext: string]: (m: NodeModule, filename: string) => any; +} + declare var require: NodeRequire; interface NodeModule { @@ -1632,6 +1639,9 @@ declare module "repl" { export interface REPLServer extends readline.ReadLine { context: any; + inputStream: NodeJS.ReadableStream; + outputStream: NodeJS.WritableStream; + defineCommand(keyword: string, cmd: Function | { help: string, action: Function }): void; displayPrompt(preserveCursor?: boolean): void; @@ -1667,6 +1677,12 @@ declare module "repl" { } export function start(options?: string | ReplOptions): REPLServer; + + export class Recoverable extends SyntaxError { + err: Error; + + constructor(err: Error); + } } declare module "readline" { @@ -5592,6 +5608,26 @@ declare module "constants" { export var ALPN_ENABLED: number; } +declare module "module" { + class Module implements NodeModule { + static runMain(): void; + static wrap(code: string): string; + + exports: any; + require: NodeRequireFunction; + id: string; + filename: string; + loaded: boolean; + parent: NodeModule | null; + children: NodeModule[]; + paths: string[]; + + constructor(id: string, parent?: Module); + } + + export = Module; +} + declare module "process" { export = process; } diff --git a/types/node/node-tests.ts b/types/node/node-tests.ts index 62ff37522d..2d60e9fb98 100644 --- a/types/node/node-tests.ts +++ b/types/node/node-tests.ts @@ -28,6 +28,7 @@ import * as v8 from "v8"; import * as dns from "dns"; import * as async_hooks from "async_hooks"; import * as http2 from "http2"; +import Module = require("module"); // Specifically test buffer module regression. import { Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer } from "buffer"; @@ -2532,6 +2533,11 @@ namespace repl_tests { _server = _server.prependOnceListener("exit", () => { }); _server = _server.prependOnceListener("reset", () => { }); + + _server.outputStream.write("test"); + let line = _server.inputStream.read(); + + throw new repl.Recoverable(new Error("test")); } } @@ -3380,3 +3386,16 @@ namespace http2_tests { str = constants.HTTP2_METHOD_VERSION_CONTROL; } } + +//////////////////////////////////////////////////// +/// module tests : http://nodejs.org/api/modules.html +//////////////////////////////////////////////////// + +namespace module_tests { + require.extensions[".ts"] = () => ""; + + Module.runMain(); + Module.wrap("some code"); + + const m1 = new Module("moduleId"); +} diff --git a/types/node/v0/tslint.json b/types/node/v0/tslint.json index 3e842be21f..f4eb951ec6 100644 --- a/types/node/v0/tslint.json +++ b/types/node/v0/tslint.json @@ -23,6 +23,7 @@ "no-namespace": false, "no-padding": false, "no-string-throw": false, + "no-unnecessary-generics": false, "no-unnecessary-qualifier": false, "no-var-keyword": false, "object-literal-shorthand": false, diff --git a/types/numjs/tslint.json b/types/numjs/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/numjs/tslint.json +++ b/types/numjs/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/openlayers/index.d.ts b/types/openlayers/index.d.ts index 7a6ca787f7..d149ef18bc 100644 --- a/types/openlayers/index.d.ts +++ b/types/openlayers/index.d.ts @@ -12578,11 +12578,15 @@ declare module olx { /** - * @typedef {{duration: (number|undefined), + * @typedef {{constrainResolution: (boolean|undefined), + * duration: (number|undefined), + * timeout: (number|undefined), * useAnchor: (boolean|undefined)}} */ interface MouseWheelZoomOptions { + constrainResolution?: boolean; duration?: number; + timeout?: number; useAnchor?: boolean; } @@ -12598,9 +12602,11 @@ declare module olx { /** - * @typedef {{duration: (number|undefined)}} + * @typedef {{constrainResolution: (boolean|undefined) + * duration: (number|undefined)}} */ interface PinchZoomOptions { + constrainResolution?: boolean; duration?: number; } diff --git a/types/openlayers/openlayers-tests.ts b/types/openlayers/openlayers-tests.ts index f0abcf28ce..f35c0adc98 100644 --- a/types/openlayers/openlayers-tests.ts +++ b/types/openlayers/openlayers-tests.ts @@ -717,6 +717,17 @@ const select: ol.interaction.Select = new ol.interaction.Select({ layers: (layer: ol.layer.Layer) => true, }); +let pinchZoom: ol.interaction.PinchZoom = new ol.interaction.PinchZoom({ + constrainResolution: booleanValue, + duration: numberValue +}); + +let mouseWheelZoom: ol.interaction.MouseWheelZoom = new ol.interaction.MouseWheelZoom({ + constrainResolution: booleanValue, + duration: numberValue, + timeout: numberValue, + useAnchor: booleanValue +}); // // ol.style.RegularShape // diff --git a/types/p-defer/tslint.json b/types/p-defer/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/p-defer/tslint.json +++ b/types/p-defer/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/p-props/tslint.json b/types/p-props/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/p-props/tslint.json +++ b/types/p-props/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/pg-query-stream/pg-query-stream-tests.ts b/types/pg-query-stream/pg-query-stream-tests.ts index 6c4c034102..1df78ea648 100644 --- a/types/pg-query-stream/pg-query-stream-tests.ts +++ b/types/pg-query-stream/pg-query-stream-tests.ts @@ -8,7 +8,8 @@ const options: QueryStream.Options = { const query = new QueryStream('SELECT * FROM generate_series(0, $1) num', [1000000], options); -pg.connect('', (err, client, done) => { +const pool = new pg.Pool(); +pool.connect((err, client, done) => { const stream = client.query(query); stream.on('end', () => { client.end(); @@ -17,3 +18,4 @@ pg.connect('', (err, client, done) => { console.log(data); }); }); +pool.end(); diff --git a/types/pg/index.d.ts b/types/pg/index.d.ts index da6f4db575..f98f952884 100644 --- a/types/pg/index.d.ts +++ b/types/pg/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for pg 6.1 +// Type definitions for pg 7.1 // Project: https://github.com/brianc/node-postgres -// Definitions by: Phips Peter +// Definitions by: Phips Peter // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -9,16 +9,13 @@ import events = require("events"); import stream = require("stream"); import pgTypes = require("pg-types"); -export declare function connect(connection: string, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; -export declare function connect(config: ClientConfig, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; -export declare function end(): void; - export interface ConnectionConfig { user?: string; database?: string; password?: string; port?: number; host?: string; + connectionString?: string; } export interface Defaults extends ConnectionConfig { @@ -39,10 +36,9 @@ export interface PoolConfig extends ClientConfig { // properties from module 'node-pool' max?: number; min?: number; - refreshIdle?: boolean; + connectionTimeoutMillis?: number; idleTimeoutMillis?: number; - reapIntervalMillis?: number; - returnToHead?: boolean; + application_name?: string; Promise?: PromiseConstructorLike; } @@ -60,25 +56,35 @@ export interface QueryResult { rows: any[]; } +export interface Notification { + processId: number; + channel: string; + payload?: string; +} + export interface ResultBuilder extends QueryResult { addRow(row: any): void; } -export declare class Pool extends events.EventEmitter { +export class Pool extends events.EventEmitter { // `new Pool('pg://user@localhost/mydb')` is not allowed. // But it passes type check because of issue: // https://github.com/Microsoft/TypeScript/issues/7485 constructor(config?: PoolConfig); + readonly totalCount: number; + readonly idleCount: number; + readonly waitingCount: number; + connect(): Promise; connect(callback: (err: Error, client: Client, done: () => void) => void): void; - end(callback?: () => void): Promise; + end(): Promise; + end(callback: () => void): void; query(queryStream: QueryConfig & stream.Readable): stream.Readable; - query(queryTextOrConfig: string | QueryConfig): Promise; - query(queryText: string, values: any[]): Promise; - + query(queryConfig: QueryConfig): Promise; + query(queryText: string, values?: any[]): Promise; query(queryTextOrConfig: string | QueryConfig, callback: (err: Error, result: QueryResult) => void): Query; query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): Query; @@ -86,18 +92,20 @@ export declare class Pool extends events.EventEmitter { on(event: "connect" | "acquire", listener: (client: Client) => void): this; } -export declare class Client extends events.EventEmitter { - constructor(connection: string); +export class Client extends events.EventEmitter { constructor(config: ClientConfig); - connect(callback?: (err: Error) => void): void; - end(callback?: (err: Error) => void): void; + connect(): Promise; + connect(callback: (err: Error) => void): void; + + end(): Promise; + end(callback: (err: Error) => void): void; + release(err?: Error): void; query(queryStream: QueryConfig & stream.Readable): stream.Readable; - query(queryTextOrConfig: string | QueryConfig): Promise; - query(queryText: string, values: any[]): Promise; - + query(queryConfig: QueryConfig): Promise; + query(queryText: string, values?: any[]): Promise; query(queryTextOrConfig: string | QueryConfig, callback: (err: Error, result: QueryResult) => void): Query; query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): Query; @@ -109,20 +117,25 @@ export declare class Client extends events.EventEmitter { on(event: "drain", listener: () => void): this; on(event: "error", listener: (err: Error) => void): this; - on(event: "notification" | "notice", listener: (message: any) => void): this; + on(event: "notification" | "notice", listener: (message: Notification) => void): this; + // tslint:disable-next-line unified-signatures on(event: "end", listener: () => void): this; } -export declare class Query extends events.EventEmitter { +export class Query extends events.EventEmitter { on(event: "row", listener: (row: any, result?: ResultBuilder) => void): this; on(event: "error", listener: (err: Error) => void): this; on(event: "end", listener: (result: ResultBuilder) => void): this; } -export declare class Events extends events.EventEmitter { +export class Events extends events.EventEmitter { on(event: "error", listener: (err: Error, client: Client) => void): this; } export const types: typeof pgTypes; export const defaults: Defaults & ClientConfig; + +import * as Pg from 'pg'; + +export const native: typeof Pg | null; diff --git a/types/pg/pg-tests.ts b/types/pg/pg-tests.ts index 4b4cfba7ec..1f1e312544 100644 --- a/types/pg/pg-tests.ts +++ b/types/pg/pg-tests.ts @@ -1,39 +1,24 @@ import * as pg from "pg"; -var conString = "postgres://username:password@localhost/database"; - // https://github.com/brianc/node-pg-types +// tslint:disable-next-line no-unnecessary-callback-wrapper pg.types.setTypeParser(20, val => Number(val)); -// Client pooling -pg.defaults.ssl = true; -pg.connect(conString, (err, client, done) => { - if (err) { - return console.error("Error fetching client from pool", err); - } - client.query("SELECT $1::int AS number", ["1"], (err, result) => { - if (err) { - done(err); - return console.error("Error running query", err); - } - else { - done(); - } - console.log(result.rows[0]["number"]); - return null; - }); - return null; +const client = new pg.Client({ + host: 'my.database-server.com', + port: 5334, + user: 'database-user', + password: 'secretpassword!!', }); - -// Simple -var client = new pg.Client(conString); client.connect(err => { if (err) { - return console.error("Could not connect to postgres", err); + console.error("Could not connect to postgres", err); + return; } client.query("SELECT NOW() AS 'theTime'", (err, result) => { if (err) { - return console.error("Error running query", err); + console.error("Error running query", err); + return; } console.log(result.rowCount); console.log(result.rows[0]["theTime"]); @@ -44,38 +29,108 @@ client.connect(err => { }); client.on('end', () => console.log("Client was disconnected.")); -// client pooling +client.connect() + .then(() => console.log('connected')) + .catch(e => console.error('connection error', e.stack)); -var config = { - user: 'foo', //env var: PGUSER - database: 'my_db', //env var: PGDATABASE - password: 'secret', //env var: PGPASSWORD - port: 5432, //env var: PGPORT - max: 10, // max number of clients in the pool - idleTimeoutMillis: 30000, // how long a client is allowed to remain idle before being closed - Promise, +client.query('SELECT NOW()', (err, res) => { + if (err) throw err; + console.log(res); + client.end(); +}); + +client.query('SELECT $1::text as name', ['brianc'], (err, res) => { + if (err) throw err; + console.log(res); + client.end(); +}); + +const query = { + name: 'get-name', + text: 'SELECT $1::text', + values: ['brianc'], + rowMode: 'array' }; -var pool = new pg.Pool(config); +client.query(query, (err, res) => { + if (err) { + console.error(err.stack); + } else { + console.log(res.rows); + } +}); +client.query(query) + .then(res => { + console.log(res.rows); + }) + .catch(e => { + console.error(e.stack); + }); +client.end((err) => { + console.log('client has disconnected'); + if (err) { + console.log('error during disconnection', err.stack); + } +}); + +client.end() + .then(() => console.log('client has disconnected')) + .catch(err => console.error('error during disconnection', err.stack)); + +const poolOne = new pg.Pool({ + connectionString: 'postgresql://dbuser:secretpassword@database.server.com:3211/mydb' +}); + +const pool = new pg.Pool({ + host: 'localhost', + port: 5432, + user: 'database-user', + database: 'my_db', + max: 20, + idleTimeoutMillis: 30000, + connectionTimeoutMillis: 2000, +}); +console.log(pool.totalCount); pool.connect((err, client, done) => { - if(err) { - return console.error('error fetching client from pool', err); + if (err) { + console.error('error fetching client from pool', err); + return; } client.query('SELECT $1::int AS number', ['1'], (err, result) => { done(); - if(err) { - return console.error('error running query', err); + if (err) { + console.error('error running query', err); + return; } console.log(result.rows[0].number); }); }); pool.on('error', (err, client) => { - console.error('idle client error', err.message, err.stack) -}) - -pool.end(); -pool.end(() => { - console.log("pool is closed"); + console.error('idle client error', err.message, err.stack); }); + +pool.query('SELECT $1::text as name', ['brianc'], (err, result) => { + if (err) { + console.error('Error executing query', err.stack); + return; + } + console.log(result.rows[0].name); +}); + +pool.query('SELECT $1::text as name', ['brianc']) + .then((res) => console.log(res.rows[0].name)) + .catch(err => console.error('Error executing query', err.stack)); + +pool.end(() => { + console.log('pool has ended'); +}); + +pool.end().then(() => console.log('pool has ended')); + +(async () => { + const client = await pool.connect(); + await client.query('SELECT NOW()'); + client.release(); +})(); diff --git a/types/pg/tsconfig.json b/types/pg/tsconfig.json index 3535f4d43f..caa997a916 100644 --- a/types/pg/tsconfig.json +++ b/types/pg/tsconfig.json @@ -4,9 +4,10 @@ "lib": [ "es6" ], + "target": "es6", "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,4 +20,4 @@ "index.d.ts", "pg-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/pg/tslint.json b/types/pg/tslint.json new file mode 100644 index 0000000000..495d29983d --- /dev/null +++ b/types/pg/tslint.json @@ -0,0 +1,5 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + } +} diff --git a/types/pg/v6/index.d.ts b/types/pg/v6/index.d.ts new file mode 100644 index 0000000000..5624989ac7 --- /dev/null +++ b/types/pg/v6/index.d.ts @@ -0,0 +1,128 @@ +// Type definitions for pg 6.1 +// Project: https://github.com/brianc/node-postgres +// Definitions by: Phips Peter +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import events = require("events"); +import stream = require("stream"); +import pgTypes = require("pg-types"); + +export declare function connect(connection: string, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; +export declare function connect(config: ClientConfig, callback: (err: Error, client: Client, done: (err?: any) => void) => void): void; +export declare function end(): void; + +export interface ConnectionConfig { + user?: string; + database?: string; + password?: string; + port?: number; + host?: string; +} + +export interface Defaults extends ConnectionConfig { + poolSize?: number; + poolIdleTimeout?: number; + reapIntervalMillis?: number; + binary?: boolean; + parseInt8?: boolean; +} + +import { TlsOptions } from "tls"; + +export interface ClientConfig extends ConnectionConfig { + ssl?: boolean | TlsOptions; +} + +export interface PoolConfig extends ClientConfig { + // properties from module 'node-pool' + max?: number; + min?: number; + refreshIdle?: boolean; + idleTimeoutMillis?: number; + reapIntervalMillis?: number; + returnToHead?: boolean; + application_name?: string; + Promise?: PromiseConstructorLike; +} + +export interface QueryConfig { + name?: string; + text: string; + values?: any[]; +} + +export interface QueryResult { + command: string; + rowCount: number; + oid: number; + rows: any[]; +} + +export interface ResultBuilder extends QueryResult { + addRow(row: any): void; +} + +export declare class Pool extends events.EventEmitter { + // `new Pool('pg://user@localhost/mydb')` is not allowed. + // But it passes type check because of issue: + // https://github.com/Microsoft/TypeScript/issues/7485 + constructor(config?: PoolConfig); + + connect(): Promise; + connect(callback: (err: Error, client: Client, done: () => void) => void): void; + + end(callback?: () => void): Promise; + + query(queryStream: QueryConfig & stream.Readable): stream.Readable; + query(queryTextOrConfig: string | QueryConfig): Promise; + query(queryText: string, values: any[]): Promise; + + query(queryTextOrConfig: string | QueryConfig, callback: (err: Error, result: QueryResult) => void): Query; + query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): Query; + + on(event: "error", listener: (err: Error, client: Client) => void): this; + on(event: "connect" | "acquire", listener: (client: Client) => void): this; +} + +export declare class Client extends events.EventEmitter { + constructor(connection: string); + constructor(config: ClientConfig); + + connect(callback?: (err: Error) => void): void; + end(callback?: (err: Error) => void): void; + release(err?: Error): void; + + query(queryStream: QueryConfig & stream.Readable): stream.Readable; + query(queryTextOrConfig: string | QueryConfig): Promise; + query(queryText: string, values: any[]): Promise; + + query(queryTextOrConfig: string | QueryConfig, callback: (err: Error, result: QueryResult) => void): Query; + query(queryText: string, values: any[], callback: (err: Error, result: QueryResult) => void): Query; + + copyFrom(queryText: string): stream.Writable; + copyTo(queryText: string): stream.Readable; + + pauseDrain(): void; + resumeDrain(): void; + + on(event: "drain", listener: () => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "notification" | "notice", listener: (message: any) => void): this; + on(event: "end", listener: () => void): this; +} + +export declare class Query extends events.EventEmitter { + on(event: "row", listener: (row: any, result?: ResultBuilder) => void): this; + on(event: "error", listener: (err: Error) => void): this; + on(event: "end", listener: (result: ResultBuilder) => void): this; +} + +export declare class Events extends events.EventEmitter { + on(event: "error", listener: (err: Error, client: Client) => void): this; +} + +export const types: typeof pgTypes; + +export const defaults: Defaults & ClientConfig; diff --git a/types/pg/v6/pg-tests.ts b/types/pg/v6/pg-tests.ts new file mode 100644 index 0000000000..4b4cfba7ec --- /dev/null +++ b/types/pg/v6/pg-tests.ts @@ -0,0 +1,81 @@ +import * as pg from "pg"; + +var conString = "postgres://username:password@localhost/database"; + +// https://github.com/brianc/node-pg-types +pg.types.setTypeParser(20, val => Number(val)); + +// Client pooling +pg.defaults.ssl = true; +pg.connect(conString, (err, client, done) => { + if (err) { + return console.error("Error fetching client from pool", err); + } + client.query("SELECT $1::int AS number", ["1"], (err, result) => { + if (err) { + done(err); + return console.error("Error running query", err); + } + else { + done(); + } + console.log(result.rows[0]["number"]); + return null; + }); + return null; +}); + +// Simple +var client = new pg.Client(conString); +client.connect(err => { + if (err) { + return console.error("Could not connect to postgres", err); + } + client.query("SELECT NOW() AS 'theTime'", (err, result) => { + if (err) { + return console.error("Error running query", err); + } + console.log(result.rowCount); + console.log(result.rows[0]["theTime"]); + client.end(); + return null; + }); + return null; +}); +client.on('end', () => console.log("Client was disconnected.")); + +// client pooling + +var config = { + user: 'foo', //env var: PGUSER + database: 'my_db', //env var: PGDATABASE + password: 'secret', //env var: PGPASSWORD + port: 5432, //env var: PGPORT + max: 10, // max number of clients in the pool + idleTimeoutMillis: 30000, // how long a client is allowed to remain idle before being closed + Promise, +}; +var pool = new pg.Pool(config); + +pool.connect((err, client, done) => { + if(err) { + return console.error('error fetching client from pool', err); + } + client.query('SELECT $1::int AS number', ['1'], (err, result) => { + done(); + + if(err) { + return console.error('error running query', err); + } + console.log(result.rows[0].number); + }); +}); + +pool.on('error', (err, client) => { + console.error('idle client error', err.message, err.stack) +}) + +pool.end(); +pool.end(() => { + console.log("pool is closed"); +}); diff --git a/types/pg/v6/tsconfig.json b/types/pg/v6/tsconfig.json new file mode 100644 index 0000000000..2c44f5862b --- /dev/null +++ b/types/pg/v6/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "pg": [ "pg/v6" ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "pg-tests.ts" + ] +} diff --git a/types/postmark/tslint.json b/types/postmark/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/postmark/tslint.json +++ b/types/postmark/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/pouchdb-adapter-fruitdown/tslint.json b/types/pouchdb-adapter-fruitdown/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/pouchdb-adapter-fruitdown/tslint.json +++ b/types/pouchdb-adapter-fruitdown/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/pouchdb-adapter-http/tslint.json b/types/pouchdb-adapter-http/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/pouchdb-adapter-http/tslint.json +++ b/types/pouchdb-adapter-http/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/pouchdb-adapter-idb/tslint.json b/types/pouchdb-adapter-idb/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/pouchdb-adapter-idb/tslint.json +++ b/types/pouchdb-adapter-idb/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/pouchdb-adapter-leveldb/tslint.json b/types/pouchdb-adapter-leveldb/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/pouchdb-adapter-leveldb/tslint.json +++ b/types/pouchdb-adapter-leveldb/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/pouchdb-adapter-localstorage/tslint.json b/types/pouchdb-adapter-localstorage/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/pouchdb-adapter-localstorage/tslint.json +++ b/types/pouchdb-adapter-localstorage/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/pouchdb-adapter-memory/tslint.json b/types/pouchdb-adapter-memory/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/pouchdb-adapter-memory/tslint.json +++ b/types/pouchdb-adapter-memory/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/pouchdb-adapter-websql/tslint.json b/types/pouchdb-adapter-websql/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/pouchdb-adapter-websql/tslint.json +++ b/types/pouchdb-adapter-websql/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/pouchdb-core/tslint.json b/types/pouchdb-core/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/pouchdb-core/tslint.json +++ b/types/pouchdb-core/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/pouchdb-upsert/tslint.json b/types/pouchdb-upsert/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/pouchdb-upsert/tslint.json +++ b/types/pouchdb-upsert/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/prettier/index.d.ts b/types/prettier/index.d.ts index 48c89a5c57..317a514912 100644 --- a/types/prettier/index.d.ts +++ b/types/prettier/index.d.ts @@ -115,6 +115,9 @@ export interface ResolveConfigOptions { * The promise will be rejected if there was an error parsing the configuration file. */ export function resolveConfig(filePath?: string, options?: ResolveConfigOptions): Promise; +export namespace resolveConfig { + function sync(filePath?: string, options?: ResolveConfigOptions): null | Options; +} /** * As you repeatedly call `resolveConfig`, the file system structure will be cached for performance. This function will clear the cache. diff --git a/types/prettier/prettier-tests.ts b/types/prettier/prettier-tests.ts index a51e8902c4..8d95196101 100644 --- a/types/prettier/prettier-tests.ts +++ b/types/prettier/prettier-tests.ts @@ -24,4 +24,9 @@ prettier.resolveConfig('path/to/somewhere').then(options => { } }); +const options = prettier.resolveConfig.sync('path/to/somewhere'); +if (options !== null) { + const formatted = prettier.format('hello world', options); +} + prettier.clearConfigCache(); diff --git a/types/prosemirror-collab/tslint.json b/types/prosemirror-collab/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/prosemirror-collab/tslint.json +++ b/types/prosemirror-collab/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/prosemirror-history/tslint.json b/types/prosemirror-history/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/prosemirror-history/tslint.json +++ b/types/prosemirror-history/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/prosemirror-keymap/tslint.json b/types/prosemirror-keymap/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/prosemirror-keymap/tslint.json +++ b/types/prosemirror-keymap/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/prosemirror-state/tslint.json b/types/prosemirror-state/tslint.json index 6371e80ee3..0aca9484b9 100644 --- a/types/prosemirror-state/tslint.json +++ b/types/prosemirror-state/tslint.json @@ -3,6 +3,7 @@ "rules": { // TODO "no-object-literal-type-assertion": false, + "no-any-union": false, "no-unnecessary-generics": false } } diff --git a/types/rc-tooltip/index.d.ts b/types/rc-tooltip/index.d.ts index c24f0018fd..20f65e3059 100644 --- a/types/rc-tooltip/index.d.ts +++ b/types/rc-tooltip/index.d.ts @@ -5,9 +5,11 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -/// +import * as React from 'react'; -declare namespace Tooltip { +export as namespace RCTooltip; + +declare namespace RCTooltip { export type Trigger = "hover" | "click" | "focus"; export type Placement = "left" | "right" | "top" | "bottom" | @@ -34,8 +36,4 @@ declare namespace Tooltip { } } -declare class Tooltip extends React.Component {} - -declare module "rc-tooltip" { - export = Tooltip -} +export default class Tooltip extends React.Component {} diff --git a/types/rc-tooltip/rc-tooltip-tests.tsx b/types/rc-tooltip/rc-tooltip-tests.tsx index 832a292e97..06b230a55b 100644 --- a/types/rc-tooltip/rc-tooltip-tests.tsx +++ b/types/rc-tooltip/rc-tooltip-tests.tsx @@ -1,6 +1,6 @@ import * as React from 'react'; import * as ReactDOM from 'react-dom'; -import * as Tooltip from 'rc-tooltip'; +import Tooltip, {RCTooltip} from 'rc-tooltip'; ReactDOM.render( tooltip}> @@ -50,3 +50,9 @@ ReactDOM.render( , document.querySelector('.another-app') ); + +const props: RCTooltip.Props = { + placement: "bottomRight", + trigger: ['click', 'focus'], + overlay: () => tooltip, +}; diff --git a/types/react-bootstrap/index.d.ts b/types/react-bootstrap/index.d.ts index b59403cc39..5c55ce6910 100644 --- a/types/react-bootstrap/index.d.ts +++ b/types/react-bootstrap/index.d.ts @@ -119,6 +119,8 @@ export { TabPane, Tabs, Thumbnail, + ToggleButton, + ToggleButtonGroup, Tooltip, Well, utils, diff --git a/types/react-bootstrap/lib/ToggleButton.d.ts b/types/react-bootstrap/lib/ToggleButton.d.ts new file mode 100644 index 0000000000..2de57ca211 --- /dev/null +++ b/types/react-bootstrap/lib/ToggleButton.d.ts @@ -0,0 +1,11 @@ +import * as React from 'react'; + +declare class ToggleButton extends React.Component { } +declare namespace ToggleButton { } +export = ToggleButton + +interface ToggleButtonProps extends React.HTMLProps { + checked?: boolean; + name?: string; + value: number|string; +} diff --git a/types/react-bootstrap/lib/ToggleButtonGroup.d.ts b/types/react-bootstrap/lib/ToggleButtonGroup.d.ts new file mode 100644 index 0000000000..30849be038 --- /dev/null +++ b/types/react-bootstrap/lib/ToggleButtonGroup.d.ts @@ -0,0 +1,21 @@ +import * as React from 'react'; + +declare class ToggleButtonGroup extends React.Component { } +declare namespace ToggleButtonGroup { } +export = ToggleButtonGroup + +interface ToggleButtonGroupProps extends React.HTMLProps { + /** Required if `type` is set to "radio" */ + name?: string; + type: "radio" | "checkbox"; + /** + * You'll usually want to use string|number|string[]|number[] here, + * but you can technically use any|any[]. + */ + defaultValue?: any; + /** + * You'll usually want to use string|number|string[]|number[] here, + * but you can technically use any|any[]. + */ + value?: any; +} diff --git a/types/react-bootstrap/lib/index.d.ts b/types/react-bootstrap/lib/index.d.ts index 28078e1bcd..9cf3b61777 100644 --- a/types/react-bootstrap/lib/index.d.ts +++ b/types/react-bootstrap/lib/index.d.ts @@ -83,6 +83,8 @@ import * as TabPane from './TabPane'; import * as Tabs from './Tabs'; import * as Thumbnail from './Thumbnail'; import * as Tooltip from './Tooltip'; +import * as ToggleButton from './ToggleButton' +import * as ToggleButtonGroup from './ToggleButtonGroup' import * as Well from './Well'; import * as utils from './utils'; @@ -173,6 +175,8 @@ export { Tabs, Thumbnail, Tooltip, + ToggleButton, + ToggleButtonGroup, Well, utils, } diff --git a/types/react-bootstrap/test/react-bootstrap-tests.tsx b/types/react-bootstrap/test/react-bootstrap-tests.tsx index 873132e64b..445e65dc12 100644 --- a/types/react-bootstrap/test/react-bootstrap-tests.tsx +++ b/types/react-bootstrap/test/react-bootstrap-tests.tsx @@ -12,7 +12,8 @@ import { Label, Badge, Jumbotron, PageHeader, Glyphicon, Table, Form, FormGroup, ControlLabel, FormControl, HelpBlock, - Radio, Checkbox, Media, InputGroup + Radio, Checkbox, Media, InputGroup, ToggleButtonGroup, + ToggleButton } from 'react-bootstrap'; export class ReactBootstrapTest extends Component { @@ -1270,6 +1271,26 @@ export class ReactBootstrapTest extends Component { + +

+ + + Checkbox 1 (pre-checked) + Checkbox 2 + Checkbox 3 (pre-checked) + + + + + + + Radio 1 (pre-checked) + + Radio 2 + Radio 3 + + +
); } diff --git a/types/react-chartjs-2/test/mix.tsx b/types/react-chartjs-2/test/mix.tsx index 208023b62d..614e61723e 100755 --- a/types/react-chartjs-2/test/mix.tsx +++ b/types/react-chartjs-2/test/mix.tsx @@ -1,7 +1,8 @@ import * as React from 'react'; import { Bar } from 'react-chartjs-2'; +import { ChartData, ChartOptions } from 'chart.js'; -const data = { +const data: ChartData = { labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'], datasets: [{ label: 'Sales', @@ -22,13 +23,11 @@ const data = { fill: false, backgroundColor: '#71B37C', borderColor: '#71B37C', - hoverBackgroundColor: '#71B37C', - hoverBorderColor: '#71B37C', yAxisID: 'y-axis-1' }] }; -const options = { +const options: ChartOptions = { responsive: true, tooltips: { mode: 'label' @@ -44,9 +43,6 @@ const options = { display: true, gridLines: { display: false - }, - labels: { - show: true } } ], @@ -58,9 +54,6 @@ const options = { id: 'y-axis-1', gridLines: { display: false - }, - labels: { - show: true } }, { @@ -70,9 +63,6 @@ const options = { id: 'y-axis-2', gridLines: { display: false - }, - labels: { - show: true } } ] diff --git a/types/react-faux-dom/tslint.json b/types/react-faux-dom/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/react-faux-dom/tslint.json +++ b/types/react-faux-dom/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/react-loadable/tslint.json b/types/react-loadable/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/react-loadable/tslint.json +++ b/types/react-loadable/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/react-measure/tslint.json b/types/react-measure/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/react-measure/tslint.json +++ b/types/react-measure/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/react-native-google-analytics-bridge/tslint.json b/types/react-native-google-analytics-bridge/tslint.json index 3db14f85ea..71ee04c4e1 100644 --- a/types/react-native-google-analytics-bridge/tslint.json +++ b/types/react-native-google-analytics-bridge/tslint.json @@ -1 +1,6 @@ -{ "extends": "dtslint/dt.json" } +{ + "extends": "dtslint/dt.json", + "rules": { + "no-unnecessary-generics": false + } +} diff --git a/types/react-native-material-kit/index.d.ts b/types/react-native-material-kit/index.d.ts index 5556bd4282..d9564be179 100644 --- a/types/react-native-material-kit/index.d.ts +++ b/types/react-native-material-kit/index.d.ts @@ -305,6 +305,11 @@ export interface MKProgressProperties extends ViewProperties { bufferAniDuration?: number; } +export interface IndeterminateProgressProperties extends ViewProperties { + progressColor?: string; + progressAniDuration?: number; +} + export interface BaseSlider extends ViewProperties { min?: number; max?: number; @@ -382,6 +387,10 @@ export class MKRipple extends React.Component {} export class MKProgress extends React.Component {} +export namespace MKProgress { + class Indeterminate extends React.Component {} +} + export class MKSlider extends React.Component {} export class MKRangeSlider extends diff --git a/types/react-native-material-kit/react-native-material-kit-tests.tsx b/types/react-native-material-kit/react-native-material-kit-tests.tsx index 3a3efa11c0..4cb415d791 100644 --- a/types/react-native-material-kit/react-native-material-kit-tests.tsx +++ b/types/react-native-material-kit/react-native-material-kit-tests.tsx @@ -78,6 +78,7 @@ const MKIconToggleTest = () => //// PROGRESS const MKProgressTest = () => ; +const MKIndeterminateProgressTest = () => ; //// SLIDER interface MKSliderTestState { diff --git a/types/react-native-vector-icons/Icon.d.ts b/types/react-native-vector-icons/Icon.d.ts index bb56a01794..07fd38f91b 100644 --- a/types/react-native-vector-icons/Icon.d.ts +++ b/types/react-native-vector-icons/Icon.d.ts @@ -197,6 +197,7 @@ export class Icon extends React.Component { export namespace Icon { class ToolbarAndroid extends React.Component {} + class TabBarItem extends React.Component {} class TabBarItemIOS extends React.Component {} class Button extends React.Component {} } diff --git a/types/react-native-vector-icons/index.d.ts b/types/react-native-vector-icons/index.d.ts index 3e9af9e042..b9dfc622c3 100644 --- a/types/react-native-vector-icons/index.d.ts +++ b/types/react-native-vector-icons/index.d.ts @@ -24,7 +24,7 @@ export function createIconSet( glyphMap: {}, fontFamily: string, fontFile?: string -): Icon; +): typeof Icon; /** * Convenience method to create a custom font based on a fontello config file. @@ -41,7 +41,7 @@ export function createIconSet( * @param {{}} config * @returns {Icon} */ -export function createIconSetFromFontello(config: {}): Icon; +export function createIconSetFromFontello(config: {}): typeof Icon; /** * Convenience method to create a custom font from IcoMoon @@ -59,4 +59,4 @@ export function createIconSetFromFontello(config: {}): Icon; * @param {{}} config * @returns {Icon} */ -export function createIconSetFromIcoMoon(config: {}): Icon; +export function createIconSetFromIcoMoon(config: {}): typeof Icon; diff --git a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx index 99a2b3ac8b..b6adf8d8c6 100644 --- a/types/react-native-vector-icons/react-native-vector-icons-tests.tsx +++ b/types/react-native-vector-icons/react-native-vector-icons-tests.tsx @@ -1,9 +1,22 @@ import * as React from 'react'; import { View, Text, TabBarIOS } from 'react-native'; +import { createIconSet } from 'react-native-vector-icons'; import MaterialIcon from 'react-native-vector-icons/MaterialIcons'; import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome'; import Ionicon from 'react-native-vector-icons/Ionicons'; +const glyphMap = { + custom: 58918 +}; + +const CustomIcon = createIconSet(glyphMap, 'FontCustom', 'FontCustom.ttf'); + +const CustomIconButton = CustomIcon.Button; +const CustomIconTabBarItem = CustomIcon.TabBarItem; +const CustomIconTabBarItemIOS = CustomIcon.TabBarItemIOS; +const CustomIconToolbarAndroid = CustomIcon.ToolbarAndroid; +const CustomIcongetImageSource = CustomIcon.getImageSource; + class Example extends React.Component { handleButton() { console.log('You pressed me'); @@ -30,7 +43,7 @@ class Example extends React.Component { } } -class TabTest extends React.Component { +class TabTest extends React.Component { constructor() { super(); @@ -49,7 +62,7 @@ class TabTest extends React.Component { selectedIconColor="pink" renderAsOriginal selected={this.state.selectedTab === 'tab1'} - onPress={() => this.setState({selectedTab: 'tab1'})} + onPress={() => this.setState({ selectedTab: 'tab1' })} > @@ -61,7 +74,7 @@ class TabTest extends React.Component { selectedIconColor='pink' renderAsOriginal selected={this.state.selectedTab === 'tab2'} - onPress={() => this.setState({selectedTab: 'tab2'})} + onPress={() => this.setState({ selectedTab: 'tab2' })} > @@ -69,3 +82,33 @@ class TabTest extends React.Component { ); } } + +class TestCustomIcon extends React.Component { + constructor() { + super(); + } + + handleButton() { + console.log('You pressed me'); + } + + render() { + return ( + + {/* Custom Icon */} + + + {/* Custom Icon button */} + this.handleButton()} + > + + Hello CustomIcon! + + + + ); + } +} diff --git a/types/react-native-video/index.d.ts b/types/react-native-video/index.d.ts index 8b31bfed0d..b264df6d64 100644 --- a/types/react-native-video/index.d.ts +++ b/types/react-native-video/index.d.ts @@ -1,6 +1,7 @@ -// Type definitions for react-native-video 1.0 +// Type definitions for react-native-video 2.0 // Project: https://github.com/react-native-community/react-native-video // Definitions by: HuHuanming +// abrahambotros // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -48,7 +49,10 @@ export interface VideoProperties extends ViewProperties { onLoad?(): void; onBuffer?(): void; onError?(): void; - onProgress?(): void; + onProgress?(data: { + currentTime: number, + playableDuration: number, + }): void; onSeek?(): void; onEnd?(): void; onFullscreenPlayerWillPresent?(): void; diff --git a/types/react-native-video/react-native-video-tests.tsx b/types/react-native-video/react-native-video-tests.tsx index e0ec0bad73..5b61336e80 100644 --- a/types/react-native-video/react-native-video-tests.tsx +++ b/types/react-native-video/react-native-video-tests.tsx @@ -7,16 +7,26 @@ import { } from 'react-native'; import Video from 'react-native-video'; -class SwiperTest extends React.Component { +class VideoTest extends React.Component { constructor(props: {}) { super(props); } render(): React.ReactElement { return ( -