diff --git a/notNeededPackages.json b/notNeededPackages.json index c64738aa8d..251442309d 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -1512,6 +1512,12 @@ "sourceRepoURL": "https://github.com/mozilla/source-map", "asOfVersion": "0.5.7" }, + { + "libraryName": "Spectacle", + "typingsPackageName": "spectacle", + "sourceRepoURL": "http://github.com/FormidableLabs/spectacle/", + "asOfVersion": "5.2.3" + }, { "libraryName": "Spin.js", "typingsPackageName": "spin.js", diff --git a/package.json b/package.json index caf101cbc6..7fc0358f27 100644 --- a/package.json +++ b/package.json @@ -23,5 +23,6 @@ "devDependencies": { "dtslint": "github:Microsoft/dtslint#production", "types-publisher": "github:Microsoft/types-publisher#production" - } + }, + "dependencies": {} } diff --git a/types/ansi-colors/ansi-colors-tests.ts b/types/ansi-colors/ansi-colors-tests.ts index 9a9afc43f4..c267e879eb 100644 --- a/types/ansi-colors/ansi-colors-tests.ts +++ b/types/ansi-colors/ansi-colors-tests.ts @@ -1,30 +1,35 @@ -import * as colors from 'ansi-colors'; +import colors = require('ansi-colors'); -let s: string; +colors.red('This is a red string!'); // $ExpectType string +colors.green('This is a red string!'); // $ExpectType string +colors.cyan('This is a cyan string!'); // $ExpectType string +colors.yellow('This is a yellow string!'); // $ExpectType string -s = colors.bgblack("hello"); -s = colors.bgblue("hello"); -s = colors.bgcyan("hello"); -s = colors.bggreen("hello"); -s = colors.bgmagenta("hello"); -s = colors.bgred("hello"); -s = colors.bgwhite("hello"); -s = colors.bgyellow("hello"); -s = colors.black("hello"); -s = colors.blue("hello"); -s = colors.bold("hello"); -s = colors.cyan("hello"); -s = colors.dim("hello"); -s = colors.gray("hello"); -s = colors.green("hello"); -s = colors.grey("hello"); -s = colors.hidden("hello"); -s = colors.inverse("hello"); -s = colors.italic("hello"); -s = colors.magenta("hello"); -s = colors.red("hello"); -s = colors.reset("hello"); -s = colors.strikethrough("hello"); -s = colors.underline("hello"); -s = colors.white("hello"); -s = colors.yellow("hello"); +colors.bold.red('this is a bold red message'); // $ExpectType string +colors.bold.yellow.italic('this is a bold yellow italicized message'); // $ExpectType string +colors.green.bold.underline('this is a bold green underlined message'); // $ExpectType string + +colors.yellow(`foo ${colors.red.bold('red')} bar ${colors.cyan('cyan')} baz`); // $ExpectType string +colors.bold(`foo ${colors.red.dim('bar')} baz`); // $ExpectType string + +colors.enabled = false; +colors.visible = false; + +colors.hasAnsi(colors.blue('foo')); // $ExpectType boolean +colors.hasColor(colors.blue('foo')); // $ExpectType boolean + +colors.unstyle(colors.blue.bold('foo bar baz')); // $ExpectType string +colors.stripColor(colors.blue.bold('foo bar baz')); // $ExpectType string + +colors.none('foo'); // $ExpectType string +colors.clear('foo'); // $ExpectType string +colors.noop('foo'); // $ExpectType string + +colors.define('reset', [0, 0], 'modifier'); + +colors.symbols.ballotCross; // $ExpectType string | undefined +colors.symbols.windows.ballotCross; // $ExpectError +colors.symbols.other.ballotCross; // $ExpectType string +colors.symbols.cross; // $ExpectType string +colors.symbols.windows.cross; // $ExpectType string +colors.symbols.other.cross; // $ExpectType string diff --git a/types/ansi-colors/index.d.ts b/types/ansi-colors/index.d.ts index 092c4c1f2b..0cf9cd0d9f 100644 --- a/types/ansi-colors/index.d.ts +++ b/types/ansi-colors/index.d.ts @@ -1,31 +1,111 @@ -// Type definitions for ansi-colors 1.0 +// Type definitions for ansi-colors 3.2 // Project: https://github.com/doowb/ansi-colors // Definitions by: Rogier Schouten +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 -export function bgblack(s: string): string; -export function bgblue(s: string): string; -export function bgcyan(s: string): string; -export function bggreen(s: string): string; -export function bgmagenta(s: string): string; -export function bgred(s: string): string; -export function bgwhite(s: string): string; -export function bgyellow(s: string): string; -export function black(s: string): string; -export function blue(s: string): string; -export function bold(s: string): string; -export function cyan(s: string): string; -export function dim(s: string): string; -export function gray(s: string): string; -export function green(s: string): string; -export function grey(s: string): string; -export function hidden(s: string): string; -export function inverse(s: string): string; -export function italic(s: string): string; -export function magenta(s: string): string; -export function red(s: string): string; -export function reset(s: string): string; -export function strikethrough(s: string): string; -export function underline(s: string): string; -export function white(s: string): string; -export function yellow(s: string): string; +export = colors; + +declare const colors: colors.Colors; + +declare namespace colors { + type ColorFn = ((text: string) => string) & Colors; + + interface Colors { + enabled: boolean; + visible: boolean; + + reset: ColorFn; + bold: ColorFn; + dim: ColorFn; + italic: ColorFn; + underline: ColorFn; + inverse: ColorFn; + hidden: ColorFn; + strikethrough: ColorFn; + + black: ColorFn; + red: ColorFn; + green: ColorFn; + yellow: ColorFn; + blue: ColorFn; + magenta: ColorFn; + cyan: ColorFn; + white: ColorFn; + gray: ColorFn; + grey: ColorFn; + + bgBlack: ColorFn; + bgRed: ColorFn; + bgGreen: ColorFn; + bgYellow: ColorFn; + bgBlue: ColorFn; + bgMagenta: ColorFn; + bgCyan: ColorFn; + bgWhite: ColorFn; + + blackBright: ColorFn; + redBright: ColorFn; + greenBright: ColorFn; + yellowBright: ColorFn; + blueBright: ColorFn; + magentaBright: ColorFn; + cyanBright: ColorFn; + whiteBright: ColorFn; + + bgBlackBright: ColorFn; + bgRedBright: ColorFn; + bgGreenBright: ColorFn; + bgYellowBright: ColorFn; + bgBlueBright: ColorFn; + bgMagentaBright: ColorFn; + bgCyanBright: ColorFn; + bgWhiteBright: ColorFn; + + hasColor(text: string): boolean; + hasAnsi(text: string): boolean; + unstyle(text: string): string; + stripColor(text: string): string; + none(text: string): string; + clear(text: string): string; + noop(text: string): string; + + symbols: Symbols & { + windows: WindowsSymbols; + other: OtherPlatformsSymbols; + }; + + define( + name: string, + codes: [number, number], + type: 'modifier' | 'color' | 'bg' | 'bright' | 'bgBright' + ): void; + } + + interface WindowsSymbols { + bullet: string; + check: string; + cross: string; + ellipsis: string; + heart: string; + info: string; + line: string; + middot: string; + minus: string; + plus: string; + question: string; + questionSmall: string; + pointer: string; + pointerSmall: string; + warning: string; + } + + interface ExtendedSymbols { + ballotCross: string; + questionFull: string; + } + + type Symbols = WindowsSymbols & Partial; + type OtherPlatformsSymbols = WindowsSymbols & ExtendedSymbols; +} diff --git a/types/ansi-colors/tsconfig.json b/types/ansi-colors/tsconfig.json index ebd56021f9..8a0f980cbc 100644 --- a/types/ansi-colors/tsconfig.json +++ b/types/ansi-colors/tsconfig.json @@ -20,4 +20,4 @@ "index.d.ts", "ansi-colors-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/ansi-colors/v1/ansi-colors-tests.ts b/types/ansi-colors/v1/ansi-colors-tests.ts new file mode 100644 index 0000000000..9a9afc43f4 --- /dev/null +++ b/types/ansi-colors/v1/ansi-colors-tests.ts @@ -0,0 +1,30 @@ +import * as colors from 'ansi-colors'; + +let s: string; + +s = colors.bgblack("hello"); +s = colors.bgblue("hello"); +s = colors.bgcyan("hello"); +s = colors.bggreen("hello"); +s = colors.bgmagenta("hello"); +s = colors.bgred("hello"); +s = colors.bgwhite("hello"); +s = colors.bgyellow("hello"); +s = colors.black("hello"); +s = colors.blue("hello"); +s = colors.bold("hello"); +s = colors.cyan("hello"); +s = colors.dim("hello"); +s = colors.gray("hello"); +s = colors.green("hello"); +s = colors.grey("hello"); +s = colors.hidden("hello"); +s = colors.inverse("hello"); +s = colors.italic("hello"); +s = colors.magenta("hello"); +s = colors.red("hello"); +s = colors.reset("hello"); +s = colors.strikethrough("hello"); +s = colors.underline("hello"); +s = colors.white("hello"); +s = colors.yellow("hello"); diff --git a/types/ansi-colors/v1/index.d.ts b/types/ansi-colors/v1/index.d.ts new file mode 100644 index 0000000000..092c4c1f2b --- /dev/null +++ b/types/ansi-colors/v1/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for ansi-colors 1.0 +// Project: https://github.com/doowb/ansi-colors +// Definitions by: Rogier Schouten +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function bgblack(s: string): string; +export function bgblue(s: string): string; +export function bgcyan(s: string): string; +export function bggreen(s: string): string; +export function bgmagenta(s: string): string; +export function bgred(s: string): string; +export function bgwhite(s: string): string; +export function bgyellow(s: string): string; +export function black(s: string): string; +export function blue(s: string): string; +export function bold(s: string): string; +export function cyan(s: string): string; +export function dim(s: string): string; +export function gray(s: string): string; +export function green(s: string): string; +export function grey(s: string): string; +export function hidden(s: string): string; +export function inverse(s: string): string; +export function italic(s: string): string; +export function magenta(s: string): string; +export function red(s: string): string; +export function reset(s: string): string; +export function strikethrough(s: string): string; +export function underline(s: string): string; +export function white(s: string): string; +export function yellow(s: string): string; diff --git a/types/ansi-colors/v1/tsconfig.json b/types/ansi-colors/v1/tsconfig.json new file mode 100644 index 0000000000..8321162c90 --- /dev/null +++ b/types/ansi-colors/v1/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "ansi-colors": [ + "ansi-colors/v1" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ansi-colors-tests.ts" + ] +} diff --git a/types/ansi-colors/v1/tslint.json b/types/ansi-colors/v1/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/ansi-colors/v1/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/arr-diff/arr-diff-tests.ts b/types/arr-diff/arr-diff-tests.ts new file mode 100644 index 0000000000..509b2f43cc --- /dev/null +++ b/types/arr-diff/arr-diff-tests.ts @@ -0,0 +1,8 @@ +import diff = require('arr-diff'); + +const a = ['a', 'b', 'c', 'd']; +const b = [1, 2]; + +diff(['a']); // $ExpectType string[] +diff(['a'], [1]); // $ExpectType string[] +diff([1], ['a']); // $ExpectType number[] diff --git a/types/arr-diff/index.d.ts b/types/arr-diff/index.d.ts new file mode 100644 index 0000000000..3c9c5037cc --- /dev/null +++ b/types/arr-diff/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for arr-diff 4.0 +// Project: https://github.com/jonschlinkert/arr-diff +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = arrDiff; + +declare function arrDiff(first: T[], ...args: any[][]): T[]; diff --git a/types/arr-diff/tsconfig.json b/types/arr-diff/tsconfig.json new file mode 100644 index 0000000000..6ea302e0ba --- /dev/null +++ b/types/arr-diff/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "arr-diff-tests.ts" + ] +} diff --git a/types/arr-diff/tslint.json b/types/arr-diff/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/arr-diff/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/binaryextensions/binaryextensions-tests.ts b/types/binaryextensions/binaryextensions-tests.ts new file mode 100644 index 0000000000..c07a6b8b8a --- /dev/null +++ b/types/binaryextensions/binaryextensions-tests.ts @@ -0,0 +1,3 @@ +import extensions = require('binaryextensions'); + +extensions; // $ExpectType string[] diff --git a/types/binaryextensions/index.d.ts b/types/binaryextensions/index.d.ts new file mode 100644 index 0000000000..704e577f31 --- /dev/null +++ b/types/binaryextensions/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for binaryextensions 2.1 +// Project: https://github.com/bevry/binaryextensions +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = extensions; + +declare const extensions: string[]; diff --git a/types/binaryextensions/tsconfig.json b/types/binaryextensions/tsconfig.json new file mode 100644 index 0000000000..e666a0507c --- /dev/null +++ b/types/binaryextensions/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "binaryextensions-tests.ts" + ] +} diff --git a/types/binaryextensions/tslint.json b/types/binaryextensions/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/binaryextensions/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/bootstrap/bootstrap-tests.ts b/types/bootstrap/bootstrap-tests.ts index 94de3fcd79..9344423cfb 100755 --- a/types/bootstrap/bootstrap-tests.ts +++ b/types/bootstrap/bootstrap-tests.ts @@ -52,6 +52,7 @@ $("#carousel").carousel({ slide: false, pause: "hover", wrap: true, + touch: false, }); $("#carousel").carousel({ @@ -245,6 +246,26 @@ $("a[data-toggle=\"list\"]").on("shown.bs.tab", (e) => { const previousActiveTab: HTMLElement = e.relatedTarget; }); +// -------------------------------------------------------------------------------------- +// Toast +// -------------------------------------------------------------------------------------- + +// $ExpectType JQuery +$("#toast").toast(); + +// $ExpectType JQuery +$("#toast").toast("show"); + +$("#toast").on("shown.bs.toast", () => {}); + +$("#toast").toast({ + animation: false, + autohide: false, + delay: 100, +}); + +$("#toast").toast({}); + // -------------------------------------------------------------------------------------- // Tooltip // -------------------------------------------------------------------------------------- diff --git a/types/bootstrap/index.d.ts b/types/bootstrap/index.d.ts index cb425f17e2..e8cea54f58 100755 --- a/types/bootstrap/index.d.ts +++ b/types/bootstrap/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Bootstrap 4.1 +// Type definitions for Bootstrap 4.2 // Project: https://github.com/twbs/bootstrap/ // Definitions by: denisname // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -64,9 +64,10 @@ export interface CarouselOption { slide?: "next" | "prev" | false; /** - * If set to "hover", pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. + * If set to "hover", pauses the cycling of the carousel on `mouseenter` and resumes the cycling of the carousel on `mouseleave`. * If set to false, hovering over the carousel won't pause it. - * On touch-enabled devices, when set to "hover", cycling will pause on touchend (once the user finished interacting with the carousel) + * + * On touch-enabled devices, when set to "hover", cycling will pause on `touchend` (once the user finished interacting with the carousel) * for two intervals, before automatically resuming. Note that this is in addition to the above mouse behavior. * * @default "hover" @@ -79,6 +80,13 @@ export interface CarouselOption { * @default true */ wrap?: boolean; + + /** + * Whether the carousel should support left/right swipe interactions on touchscreen devices. + * + * @default true + */ + touch?: boolean; } export interface CollapseOption { @@ -210,6 +218,29 @@ export interface ScrollspyOption { target?: string | Element; } +export interface ToastOption { + /** + * Apply a CSS fade transition to the toast. + * + * @default true + */ + animation?: boolean; + + /** + * Auto hide the toast. + * + * @default true + */ + autohide?: boolean; + + /** + * Delay hiding the toast in millisecond. + * + * @default 500 + */ + delay?: number; +} + export interface TooltipOption { /** * Apply a CSS fade transition to the tooltip or popover. @@ -401,6 +432,7 @@ export type ModalEvent = "show.bs.modal" | "shown.bs.modal" | "hide.bs.modal" | export type PopoverEvent = "show.bs.popover" | "shown.bs.popover" | "hide.bs.popover" | "hidden.bs.popover" | "inserted.bs.popover"; export type ScrollspyEvent = "activate.bs.scrollspy"; export type TapEvent = "show.bs.tab" | "shown.bs.tab" | "hide.bs.tab" | "hidden.bs.tab"; +export type ToastEvent = "show.bs.toast" | "shown.bs.toast" | "hide.bs.toast" | "hidden.bs.toast"; export type TooltipEvent = "show.bs.tooltip" | "shown.bs.tooltip" | "hide.bs.tooltip" | "hidden.bs.tooltip" | "inserted.bs.tooltip"; // -------------------------------------------------------------------------------------- @@ -538,6 +570,20 @@ $('[data-spy="scroll"]').each(function () { */ tab(action: "show" | "dispose"): this; + /** + * Call a method on the toast element: + * * `show` – Reveals an element's toast. You have to manually call this method, instead your toast won't show. + * * `hide` – Hides an element's toast. You have to manually call this method if you made `autohide` to false. + * * `dispose` – Hides an element's toast. Your toast will remain on the DOM but won't show anymore. + * + * Returns to the caller before the toast has actually been shown or hidden (i.e. before the `shown.bs.toast` or `hidden.bs.toast` event occurs). + */ + toast(action: "show" | "hide" | "dispose"): this; + /** + * Attaches a toast handler to an element collection. + */ + toast(options?: ToastOption): this; + /** * Call a method on the tooltip element: * * `show` – Reveals an element's tooltip. @@ -564,7 +610,7 @@ $('[data-spy="scroll"]').each(function () { on(events: ModalEvent, handler: JQuery.EventHandlerBase>): this; on(events: TapEvent, handler: JQuery.EventHandlerBase>): this; on( - events: AlertEvent | CollapseEvent | PopoverEvent | ScrollspyEvent | TooltipEvent, + events: AlertEvent | CollapseEvent | PopoverEvent | ScrollspyEvent | ToastEvent | TooltipEvent, handler: JQuery.EventHandler ): this; } diff --git a/types/buffer-crc32/buffer-crc32-tests.ts b/types/buffer-crc32/buffer-crc32-tests.ts new file mode 100644 index 0000000000..979d70215c --- /dev/null +++ b/types/buffer-crc32/buffer-crc32-tests.ts @@ -0,0 +1,11 @@ +import crc32 = require('buffer-crc32'); + +const buf = new Buffer([0x00, 0x73, 0x75, 0x70, 0x20, 0x62, 0x72, 0x6f, 0x00]); +crc32(buf); // $ExpectType Buffer +crc32('自動販売機'); // $ExpectType Buffer + +crc32.signed(buf); // $ExpectType number +crc32.unsigned(buf); // $ExpectType number + +const partialCrc = crc32('hey'); +crc32(' ', partialCrc); // $ExpectType Buffer diff --git a/types/buffer-crc32/index.d.ts b/types/buffer-crc32/index.d.ts new file mode 100644 index 0000000000..f2857e36a8 --- /dev/null +++ b/types/buffer-crc32/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for buffer-crc32 0.2 +// Project: https://github.com/brianloveswords/buffer-crc32 +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export = crc32; + +declare function crc32(input: string | Buffer, partialCrc?: Buffer): Buffer; + +declare namespace crc32 { + function signed(buffer: Buffer): number; + function unsigned(buffer: Buffer): number; +} diff --git a/types/buffer-crc32/tsconfig.json b/types/buffer-crc32/tsconfig.json new file mode 100644 index 0000000000..cbcb036b91 --- /dev/null +++ b/types/buffer-crc32/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "buffer-crc32-tests.ts" + ] +} diff --git a/types/buffer-crc32/tslint.json b/types/buffer-crc32/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/buffer-crc32/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/chrome/index.d.ts b/types/chrome/index.d.ts index 060282a6ab..06daa9b62d 100644 --- a/types/chrome/index.d.ts +++ b/types/chrome/index.d.ts @@ -4576,7 +4576,10 @@ declare namespace chrome.omnibox { description: string; } - export interface OmniboxInputEnteredEvent extends chrome.events.Event<(text: string) => void> { } + /** The window disposition for the omnibox query. This is the recommended context to display results. */ + export type OnInputEnteredDisposition = 'currentTab' | 'newForegroundTab' | 'newBackgroundTab'; + + export interface OmniboxInputEnteredEvent extends chrome.events.Event<(text: string, disposition: OnInputEnteredDisposition) => void> { } export interface OmniboxInputChangedEvent extends chrome.events.Event<(text: string, suggest: (suggestResults: SuggestResult[]) => void) => void> { } @@ -4584,6 +4587,8 @@ declare namespace chrome.omnibox { export interface OmniboxInputCancelledEvent extends chrome.events.Event<() => void> { } + export interface OmniboxSuggestionDeletedEvent extends chrome.events.Event<(text: string) => void> { } + /** * Sets the description and styling for the default suggestion. The default suggestion is the text that is displayed in the first suggestion row underneath the URL bar. * @param suggestion A partial SuggestResult object, without the 'content' parameter. @@ -4598,6 +4603,11 @@ declare namespace chrome.omnibox { export var onInputStarted: OmniboxInputStartedEvent; /** User has ended the keyword input session without accepting the input. */ export var onInputCancelled: OmniboxInputCancelledEvent; + /** + * User has deleted a suggested result + * @since Chrome 63. + */ + export var onDeleteSuggestion: OmniboxSuggestionDeletedEvent; } //////////////////// diff --git a/types/cli-boxes/cli-boxes-tests.ts b/types/cli-boxes/cli-boxes-tests.ts new file mode 100644 index 0000000000..9885f28777 --- /dev/null +++ b/types/cli-boxes/cli-boxes-tests.ts @@ -0,0 +1,17 @@ +import cliBoxes = require('cli-boxes'); + +cliBoxes.single; // $ExpectType BoxDefinition +cliBoxes.double; // $ExpectType BoxDefinition +cliBoxes.round; // $ExpectType BoxDefinition +cliBoxes['single-double']; // $ExpectType BoxDefinition +cliBoxes['double-single']; // $ExpectType BoxDefinition +cliBoxes.classic; // $ExpectType BoxDefinition + +const single = cliBoxes.single; + +single.bottomLeft; // $ExpectType string +single.bottomRight; // $ExpectType string +single.horizontal; // $ExpectType string +single.topLeft; // $ExpectType string +single.topRight; // $ExpectType string +single.vertical; // $ExpectType string diff --git a/types/cli-boxes/index.d.ts b/types/cli-boxes/index.d.ts new file mode 100644 index 0000000000..e3b4c7be79 --- /dev/null +++ b/types/cli-boxes/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for cli-boxes 1.0 +// Project: https://github.com/sindresorhus/cli-boxes +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export = boxes; +declare const boxes: boxes.Boxes; + +declare namespace boxes { + type BoxNames = 'single' | 'double' | 'round' | 'single-double' | 'double-single' | 'classic'; + + type Boxes = Record; + + interface BoxDefinition { + topLeft: string; + topRight: string; + bottomRight: string; + bottomLeft: string; + vertical: string; + horizontal: string; + } +} diff --git a/types/cli-boxes/tsconfig.json b/types/cli-boxes/tsconfig.json new file mode 100644 index 0000000000..f8a8653c69 --- /dev/null +++ b/types/cli-boxes/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "cli-boxes-tests.ts" + ] +} diff --git a/types/cli-boxes/tslint.json b/types/cli-boxes/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/cli-boxes/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/cypress-axe/cypress-axe-tests.ts b/types/cypress-axe/cypress-axe-tests.ts new file mode 100644 index 0000000000..46bfe99c37 --- /dev/null +++ b/types/cypress-axe/cypress-axe-tests.ts @@ -0,0 +1 @@ +import 'cypress-axe'; diff --git a/types/cypress-axe/index.d.ts b/types/cypress-axe/index.d.ts new file mode 100644 index 0000000000..507a5f773d --- /dev/null +++ b/types/cypress-axe/index.d.ts @@ -0,0 +1,12 @@ +// Type definitions for cypress-axe 0.3 +// Project: https://github.com/avanslaars/cypress-axe#readme +// Definitions by: Justin Hall +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +declare namespace Cypress { + interface Chainable { + injectAxe(): void; + checkA11y(): void; + } +} diff --git a/types/cypress-axe/tsconfig.json b/types/cypress-axe/tsconfig.json new file mode 100644 index 0000000000..e71d30fe7d --- /dev/null +++ b/types/cypress-axe/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "cypress-axe-tests.ts" + ] +} diff --git a/types/cypress-axe/tslint.json b/types/cypress-axe/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/cypress-axe/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/download/index.d.ts b/types/download/index.d.ts index 5d19321fb0..3dd8e4dea8 100644 --- a/types/download/index.d.ts +++ b/types/download/index.d.ts @@ -24,6 +24,12 @@ declare namespace download { * Proxy endpoint */ proxy?: string; + /** + * Request Headers + */ + headers?: { + [name: string]: string; + }; } } diff --git a/types/expo/index.d.ts b/types/expo/index.d.ts index 602b9a3463..2cb20ae065 100644 --- a/types/expo/index.d.ts +++ b/types/expo/index.d.ts @@ -2126,7 +2126,7 @@ export namespace Location { function getProviderStatusAsync(): Promise; function getHeadingAsync(): Promise; function watchHeadingAsync(callback: (status: HeadingStatus) => void): EventSubscription; - function geocodeAsync(address: string): Promise; + function geocodeAsync(address: string): Promise; function reverseGeocodeAsync(location: LocationProps): Promise; function setApiKey(key: string): void; } diff --git a/types/fetch-mock/fetch-mock-tests.ts b/types/fetch-mock/fetch-mock-tests.ts index 594d78c127..a5dc13c348 100644 --- a/types/fetch-mock/fetch-mock-tests.ts +++ b/types/fetch-mock/fetch-mock-tests.ts @@ -120,6 +120,7 @@ const myMatcher: fetchMock.MockMatcherFunction = ( fetchMock.flush().then(resolved => resolved.forEach(console.log)); fetchMock.flush().catch(r => r); +fetchMock.flush(true).catch(r => r); fetchMock.get("http://test.com", { body: 'abc', diff --git a/types/fetch-mock/index.d.ts b/types/fetch-mock/index.d.ts index 4b2915756e..a872a824d9 100644 --- a/types/fetch-mock/index.d.ts +++ b/types/fetch-mock/index.d.ts @@ -8,6 +8,7 @@ // Quentin Bouygues // Fumiaki Matsushima // Colin Doig +// Felix Chen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -441,8 +442,10 @@ declare namespace fetchMock { /** * Returns a promise that resolves once all fetches handled by fetch-mock * have resolved. + * @param [waitForBody] Wait for all body parsing methods(res.json(), + * res.text(), etc.) to resolve too. */ - flush(): Promise; + flush(waitForBody?: boolean): Promise; /** * Returns an array of all calls to fetch matching the given filters. diff --git a/types/find-cache-dir/find-cache-dir-tests.ts b/types/find-cache-dir/find-cache-dir-tests.ts new file mode 100644 index 0000000000..5836be99b6 --- /dev/null +++ b/types/find-cache-dir/find-cache-dir-tests.ts @@ -0,0 +1,19 @@ +import findCacheDir = require('find-cache-dir'); + +findCacheDir({ name: 'unicorns' }); // $ExpectType string | null +findCacheDir({ name: 'unicorns', files: 'foo' }); // $ExpectType string | null +findCacheDir({ name: 'unicorns', files: ['foo', 'bar'] }); // $ExpectType string | null +findCacheDir({ name: 'unicorns', cwd: 'foo' }); // $ExpectType string | null +findCacheDir({ name: 'unicorns', create: true }); // $ExpectType string | null +findCacheDir({ name: 'unicorns', thunk: false }); // $ExpectType string | null +findCacheDir({}); // $ExpectError +findCacheDir(); // $ExpectError + +const thunk = findCacheDir({ name: 'unicorns', thunk: true }); +thunk; // $ExpectType ((...pathParts: string[]) => string) | null + +if (thunk) { + thunk(); // $ExpectType string + thunk('bar.js'); // $ExpectType string + thunk('baz', 'quz.js'); // $ExpectType string +} diff --git a/types/find-cache-dir/index.d.ts b/types/find-cache-dir/index.d.ts new file mode 100644 index 0000000000..4b69518e21 --- /dev/null +++ b/types/find-cache-dir/index.d.ts @@ -0,0 +1,57 @@ +// Type definitions for find-cache-dir 2.0 +// Project: https://github.com/avajs/find-cache-dir#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = findCacheDir; + +/** + * Finds the cache directory using the supplied options. The algorithm tries to find a `package.json` file, + * searching every parent directory of the `cwd` specified (or implied from other options). + * @param options + * @returns A string containing the absolute path to the cache directory, or null if package.json was never found. + */ +declare function findCacheDir( + options: findCacheDir.OptionsWithThunk +): ((...pathParts: string[]) => string) | null; +declare function findCacheDir(options: findCacheDir.Options): string | null; + +declare namespace findCacheDir { + interface Options { + /** + * Should be the same as your project name in `package.json`. + */ + name: string; + + /** + * An array of files that will be searched for a common parent directory. + * This common parent directory will be used in lieu of the `cwd` option below. + */ + files?: string | string[]; + + /** + * Directory to start searching for a `package.json` from. + */ + cwd?: string; + + /** + * If `true`, the directory will be created synchronously before returning. + * @default false + */ + create?: boolean; + + /** + * If `true`, this modifies the return type to be a function that is a thunk for `path.join(theFoundCacheDirectory)`. + * @default false + */ + thunk?: boolean; + } + + interface OptionsWithThunk extends Options { + /** + * If `true`, this modifies the return type to be a function that is a thunk for `path.join(theFoundCacheDirectory)`. + * @default false + */ + thunk: true; + } +} diff --git a/types/find-cache-dir/tsconfig.json b/types/find-cache-dir/tsconfig.json new file mode 100644 index 0000000000..68068b9343 --- /dev/null +++ b/types/find-cache-dir/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "find-cache-dir-tests.ts" + ] +} diff --git a/types/find-cache-dir/tslint.json b/types/find-cache-dir/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/find-cache-dir/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/flickity/index.d.ts b/types/flickity/index.d.ts index ae5dc46cb7..07a9e03d9e 100644 --- a/types/flickity/index.d.ts +++ b/types/flickity/index.d.ts @@ -457,7 +457,7 @@ interface FlickityOptions { * * default: disabled */ - asNavFor?: string; + asNavFor?: string | HTMLElement; /** * The number of pixels a mouse or touch has to move before dragging begins. Increase dragThreshold to allow for more wiggle room for vertical page scrolling on touch devices. diff --git a/types/get-func-name/get-func-name-tests.ts b/types/get-func-name/get-func-name-tests.ts new file mode 100644 index 0000000000..3199af25d7 --- /dev/null +++ b/types/get-func-name/get-func-name-tests.ts @@ -0,0 +1,12 @@ +import getFuncName = require('get-func-name'); + +const unknownFunction = function myCoolFunction(word: string) { + return word + 'is cool'; +}; + +const anonymousFunction = (() => { + return () => {}; +})(); + +getFuncName(unknownFunction); // $ExpectType string +getFuncName(anonymousFunction); // $ExpectType string diff --git a/types/get-func-name/index.d.ts b/types/get-func-name/index.d.ts new file mode 100644 index 0000000000..f43bf3dd2a --- /dev/null +++ b/types/get-func-name/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for get-func-name 2.0 +// Project: https://github.com/chaijs/get-func-name#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = getFuncName; + +declare function getFuncName(fn: Function): string; // tslint:disable-line:ban-types diff --git a/types/get-func-name/tsconfig.json b/types/get-func-name/tsconfig.json new file mode 100644 index 0000000000..acb6f50f0e --- /dev/null +++ b/types/get-func-name/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "get-func-name-tests.ts" + ] +} diff --git a/types/get-func-name/tslint.json b/types/get-func-name/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/get-func-name/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/git-branch/git-branch-tests.ts b/types/git-branch/git-branch-tests.ts index 4b02cb5da3..79676c58ff 100644 --- a/types/git-branch/git-branch-tests.ts +++ b/types/git-branch/git-branch-tests.ts @@ -1,14 +1,18 @@ import gitBranch = require('git-branch'); gitBranch() - .then((name) => {}); + .then((name) => { + name; // $ExpectType string + }); gitBranch('cwd') - .then((name) => {}); + .then((name) => { + name; // $ExpectType string + }); -gitBranch.sync(); -gitBranch.sync('cwd'); +gitBranch.sync(); // $ExpectType string +gitBranch.sync('cwd'); // $ExpectType string -gitBranch((err, name) => {}); +gitBranch((err, name) => {}); // $ExpectType void -gitBranch('cwd', (err, name) => {}); +gitBranch('cwd', (err, name) => {}); // $ExpectType void diff --git a/types/git-branch/index.d.ts b/types/git-branch/index.d.ts index a1cecc9691..9f893ca5cd 100644 --- a/types/git-branch/index.d.ts +++ b/types/git-branch/index.d.ts @@ -8,7 +8,7 @@ export = GitBranch; declare function GitBranch(cwd?: string): Promise; declare function GitBranch(cwd?: string, callback?: (err: null | string, name: string) => void): void; -declare function GitBranch(callback?: (err: null | string, name: string) => void): void; +declare function GitBranch(callback: (err: null | string, name: string) => void): void; declare namespace GitBranch { function sync(cwd?: string): string; diff --git a/types/google-maps-react/index.d.ts b/types/google-maps-react/index.d.ts index 1389982890..3d8d177d8b 100644 --- a/types/google-maps-react/index.d.ts +++ b/types/google-maps-react/index.d.ts @@ -89,6 +89,9 @@ export class Polyline extends React.Component { export class Circle extends React.Component { } +export class HeatMap extends React.Component { +} + export interface InfoWindowProps extends Partial { google: typeof google; map: google.maps.Map; diff --git a/types/graphql/index.d.ts b/types/graphql/index.d.ts index 0b87d35222..abaa81294b 100644 --- a/types/graphql/index.d.ts +++ b/types/graphql/index.d.ts @@ -16,6 +16,7 @@ // Brad Zacher // Curtis Layne // Jonathan Cardoso +// Pavel Lang // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.6 diff --git a/types/graphql/language/predicates.d.ts b/types/graphql/language/predicates.d.ts index 81d2e02c41..c31a87f2a5 100644 --- a/types/graphql/language/predicates.d.ts +++ b/types/graphql/language/predicates.d.ts @@ -1,19 +1,30 @@ -import { ASTNode } from "./ast"; +import { + ASTNode, + DefinitionNode, + ExecutableDefinitionNode, + SelectionNode, + ValueNode, + TypeNode, + TypeSystemDefinitionNode, + TypeDefinitionNode, + TypeSystemExtensionNode, + TypeExtensionNode, +} from "./ast"; -export function isDefinitionNode(node: ASTNode): boolean; +export function isDefinitionNode(node: ASTNode): node is DefinitionNode; -export function isExecutableDefinitionNode(node: ASTNode): boolean; +export function isExecutableDefinitionNode(node: ASTNode): node is ExecutableDefinitionNode; -export function isSelectionNode(node: ASTNode): boolean; +export function isSelectionNode(node: ASTNode): node is SelectionNode; -export function isValueNode(node: ASTNode): boolean; +export function isValueNode(node: ASTNode): node is ValueNode; -export function isTypeNode(node: ASTNode): boolean; +export function isTypeNode(node: ASTNode): node is TypeNode; -export function isTypeSystemDefinitionNode(node: ASTNode): boolean; +export function isTypeSystemDefinitionNode(node: ASTNode): node is TypeSystemDefinitionNode; -export function isTypeDefinitionNode(node: ASTNode): boolean; +export function isTypeDefinitionNode(node: ASTNode): node is TypeDefinitionNode; -export function isTypeSystemExtensionNode(node: ASTNode): boolean; +export function isTypeSystemExtensionNode(node: ASTNode): node is TypeSystemExtensionNode; -export function isTypeExtensionNode(node: ASTNode): boolean; +export function isTypeExtensionNode(node: ASTNode): node is TypeExtensionNode; diff --git a/types/iobroker/index.d.ts b/types/iobroker/index.d.ts index cee6ce75a6..314d8c8e30 100644 --- a/types/iobroker/index.d.ts +++ b/types/iobroker/index.d.ts @@ -968,6 +968,11 @@ declare global { * @param callback - gets called when a free port is found */ getPort(port: number, callback: (port: number) => void): void; + /** + * Helper function that looks for first free TCP port starting with the given one. + * @param port - The port to start with + */ + getPortAsync(port: number): Promise; /** Stops the adapter. Note: Is not always defined. */ stop?: () => void; @@ -978,16 +983,52 @@ declare global { /** Validates username and password */ checkPassword(user: string, password: string, callback: (result: boolean) => void): void; checkPassword(user: string, password: string, options: unknown, callback: (result: boolean) => void): void; + /** Validates username and password */ + checkPasswordAsync(user: string, password: string, options?: unknown): Promise; /** Sets a new password for the given user */ - setPassword(user: string, password: string, options?: unknown, callback?: (err?: any) => void): void; + setPassword(user: string, password: string, callback?: (err?: any) => void): void; + setPassword(user: string, password: string, options: unknown, callback?: (err?: any) => void): void; + /** Sets a new password for the given user */ + setPasswordAsync(user: string, password: string, options?: unknown): Promise; /** Checks if a user exists and is in the given group. */ checkGroup(user: string, group: string, callback: (result: boolean) => void): void; checkGroup(user: string, group: string, options: unknown, callback: (result: boolean) => void): void; + /** Checks if a user exists and is in the given group. */ + checkGroupAsync(user: string, group: string, options?: unknown): Promise; /** Determines the users permissions */ calculatePermissions(user: string, commandsPermissions: CommandsPermissions, callback: (result: PermissionSet) => void): void; calculatePermissions(user: string, commandsPermissions: CommandsPermissions, options: unknown, callback: (result: PermissionSet) => void): void; + /** Determines the users permissions */ + calculatePermissionsAsync(user: string, commandsPermissions: CommandsPermissions, options?: unknown): Promise; /** Returns SSL certificates by name (private key, public cert and chained certificate) for creation of HTTPS servers */ getCertificates(publicName: string, privateName: string, chainedName: string, callback: (err: string | null, certs?: Certificates, useLetsEncryptCert?: boolean) => void): void; + // TODO: getCertificates cannot be represented with promises right now + + /** + * Terminates the adapter execution but does not disable the adapter + * @param reason (optional) A message to print into the log prior to termination + */ + terminate(reason?: string): never; + + /** Restarts the adapter */ + restart(): never; + + /** + * Disables and stops the adapter instance. + * It is recommended that you leave the current method (e.g. by using `return`) after calling this. + */ + disable(): void; + + /** + * Updates the adapter config with new values. Only a subset of the configuration has to be provided, + * since merging with the existing config is done automatically. + * + * After updating the configuration, the adapter is automatically restarted. It is recommended that you + * leave the current method (e.g. by using `return`) after calling this. + * + * @param newConfig The new config values to be stored + */ + updateConfig(newConfig: Partial): void; /** * Sends a message to a specific instance or all instances of some specific adapter. @@ -999,12 +1040,26 @@ declare global { */ sendTo(instanceName: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; sendTo(instanceName: string, command: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; - + /** + * Sends a message to a specific instance or all instances of some specific adapter. + * @param instanceName The instance to send this message to. + * If the ID of an instance is given (e.g. "admin.0"), only this instance will receive the message. + * If the name of an adapter is given (e.g. "admin"), all instances of this adapter will receive it. + * @param command (optional) Command name of the target instance. Default: "send" + * @param message The message (e.g. params) to send. + */ + sendToAsync(instanceName: string, message: string | object): Promise; + sendToAsync(instanceName: string, command: string, message: string | object): Promise; /** * Sends a message to a specific host or all hosts. */ sendToHost(hostName: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; sendToHost(hostName: string, command: string, message: string | object, callback?: MessageCallback | MessageCallbackInfo): void; + /** + * Sends a message to a specific host or all hosts. + */ + sendToHostAsync(hostName: string, message: string | object): Promise; + sendToHostAsync(hostName: string, command: string, message: string | object): Promise; /** Convert ID to {device: D, channel: C, state: S} */ idToDCS(id: string): { @@ -1019,109 +1074,175 @@ declare global { /** Reads an object from the object db */ getObject(id: string, callback: GetObjectCallback): void; getObject(id: string, options: unknown, callback: GetObjectCallback): void; + /** Reads an object from the object db */ + getObjectAsync(id: string, options?: unknown): Promise>; /** Creates or overwrites an object in the object db */ setObject(id: string, obj: ioBroker.SettableObject, callback?: SetObjectCallback): void; setObject(id: string, obj: ioBroker.SettableObject, options: unknown, callback?: SetObjectCallback): void; + /** Creates or overwrites an object in the object db */ + setObjectAsync(id: string, obj: ioBroker.SettableObject, options?: unknown): Promise>; /** Creates an object in the object db. Existing objects are not overwritten. */ setObjectNotExists(id: string, obj: ioBroker.SettableObject, callback?: SetObjectCallback): void; setObjectNotExists(id: string, obj: ioBroker.SettableObject, options: unknown, callback?: SetObjectCallback): void; + /** Creates an object in the object db. Existing objects are not overwritten. */ + setObjectNotExistsAsync(id: string, obj: ioBroker.SettableObject, options?: unknown): Promise>; /** Get all states, channels and devices of this adapter */ getAdapterObjects(callback: (objects: Record) => void): void; + /** Get all states, channels and devices of this adapter */ + getAdapterObjectsAsync(): Promise>; /** Extend an object and create it if it might not exist */ extendObject(id: string, objPart: PartialObject, callback?: SetObjectCallback): void; extendObject(id: string, objPart: PartialObject, options: unknown, callback?: SetObjectCallback): void; + /** Extend an object and create it if it might not exist */ + extendObjectAsync(id: string, objPart: PartialObject, options?: unknown): Promise>; /** * Deletes an object from the object db * @param id - The id of the object without namespace */ delObject(id: string, callback?: ErrorCallback): void; delObject(id: string, options: unknown, callback?: ErrorCallback): void; + /** + * Deletes an object from the object db + * @param id - The id of the object without namespace + */ + delObjectAsync(id: string, options?: unknown): Promise; // ============================== // foreign objects - // tslint:disable:unified-signatures /** Reads an object (which might not belong to this adapter) from the object db */ getForeignObject(id: string, callback: GetObjectCallback): void; getForeignObject(id: string, options: unknown, callback: GetObjectCallback): void; + /** Reads an object (which might not belong to this adapter) from the object db */ + getForeignObjectAsync(id: string, options?: unknown): Promise>; /** Get foreign objects by pattern, by specific type and resolve their enums. */ + // tslint:disable:unified-signatures getForeignObjects(pattern: string, callback: GetObjectsCallback): void; getForeignObjects(pattern: string, options: unknown, callback: GetObjectsCallback): void; getForeignObjects(pattern: string, type: ObjectType, callback: GetObjectsCallback): void; getForeignObjects(pattern: string, type: ObjectType, enums: EnumList, callback: GetObjectsCallback): void; getForeignObjects(pattern: string, type: ObjectType, options: unknown, callback: GetObjectsCallback): void; getForeignObjects(pattern: string, type: ObjectType, enums: EnumList, options: unknown, callback: GetObjectsCallback): void; + // tslint:enable:unified-signatures + /** Get foreign objects by pattern, by specific type and resolve their enums. */ + getForeignObjectsAsync(pattern: string, options?: unknown): Promise>; + getForeignObjectsAsync(pattern: string, type: ObjectType, options?: unknown): Promise>; + getForeignObjectsAsync(pattern: string, type: ObjectType, enums: EnumList, options?: unknown): Promise>; /** Creates or overwrites an object (which might not belong to this adapter) in the object db */ setForeignObject(id: string, obj: ioBroker.SettableObject, callback?: SetObjectCallback): void; setForeignObject(id: string, obj: ioBroker.SettableObject, options: unknown, callback?: SetObjectCallback): void; + /** Creates or overwrites an object (which might not belong to this adapter) in the object db */ + setForeignObjectAsync(id: string, obj: ioBroker.SettableObject, options?: unknown): Promise>; /** Creates an object (which might not belong to this adapter) in the object db. Existing objects are not overwritten. */ setForeignObjectNotExists(id: string, obj: ioBroker.SettableObject, callback?: SetObjectCallback): void; setForeignObjectNotExists(id: string, obj: ioBroker.SettableObject, options: unknown, callback?: SetObjectCallback): void; + /** Creates an object (which might not belong to this adapter) in the object db. Existing objects are not overwritten. */ + setForeignObjectNotExistsAsync(id: string, obj: ioBroker.SettableObject, options?: unknown): Promise>; /** Extend an object (which might not belong to this adapter) and create it if it might not exist */ extendForeignObject(id: string, objPart: PartialObject, callback?: SetObjectCallback): void; extendForeignObject(id: string, objPart: PartialObject, options: unknown, callback?: SetObjectCallback): void; - // tslint:enable:unified-signatures + /** Extend an object (which might not belong to this adapter) and create it if it might not exist */ + extendForeignObjectAsync(id: string, objPart: PartialObject, options?: unknown): Promise>; /** * Finds an object by its ID or name * @param type - common.type of the state */ findForeignObject(idOrName: string, type: string, callback: FindObjectCallback): void; findForeignObject(idOrName: string, type: string, options: unknown, callback: FindObjectCallback): void; + /** + * Finds an object by its ID or name + * @param type - common.type of the state + */ + findForeignObjectAsync(idOrName: string, type: string): Promise<{ id: string, name: string }>; /** * Deletes an object (which might not belong to this adapter) from the object db * @param id - The id of the object including namespace */ delForeignObject(id: string, callback?: ErrorCallback): void; delForeignObject(id: string, options: unknown, callback?: ErrorCallback): void; + /** + * Deletes an object (which might not belong to this adapter) from the object db + * @param id - The id of the object including namespace + */ + delForeignObjectAsync(id: string, options?: unknown): Promise; // ============================== // states // Multiple signatures help understanding what the parameters are about - // tslint:disable:unified-signatures /** Writes a value into the states DB. */ + // tslint:disable:unified-signatures setState(id: string, state: string | number | boolean | State | Partial, callback?: SetStateCallback): void; setState(id: string, state: string | number | boolean | State | Partial, ack: boolean, callback?: SetStateCallback): void; setState(id: string, state: string | number | boolean | State | Partial, options: unknown, callback?: SetStateCallback): void; setState(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown, callback?: SetStateCallback): void; + /** Writes a value into the states DB. */ + setStateAsync(id: string, state: string | number | boolean | State | Partial, ack?: boolean): Promise>; + setStateAsync(id: string, state: string | number | boolean | State | Partial, options?: unknown): Promise>; + setStateAsync(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown): Promise>; /** Writes a value into the states DB only if it has changed. */ setStateChanged(id: string, state: string | number | boolean | State | Partial, callback?: SetStateChangedCallback): void; setStateChanged(id: string, state: string | number | boolean | State | Partial, ack: boolean, callback?: SetStateChangedCallback): void; setStateChanged(id: string, state: string | number | boolean | State | Partial, options: unknown, callback?: SetStateChangedCallback): void; setStateChanged(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown, callback?: SetStateChangedCallback): void; + /** Writes a value into the states DB only if it has changed. */ + setStateChangedAsync(id: string, state: string | number | boolean | State | Partial, ack?: boolean): Promise>; + setStateChangedAsync(id: string, state: string | number | boolean | State | Partial, options?: unknown): Promise>; + setStateChangedAsync(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown): Promise>; /** Writes a value (which might not belong to this adapter) into the states DB. */ setForeignState(id: string, state: string | number | boolean | State | Partial, callback?: SetStateCallback): void; setForeignState(id: string, state: string | number | boolean | State | Partial, ack: boolean, callback?: SetStateCallback): void; setForeignState(id: string, state: string | number | boolean | State | Partial, options: unknown, callback?: SetStateCallback): void; setForeignState(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown, callback?: SetStateCallback): void; + /** Writes a value (which might not belong to this adapter) into the states DB. */ + setForeignStateAsync(id: string, state: string | number | boolean | State | Partial, ack?: boolean): Promise>; + setForeignStateAsync(id: string, state: string | number | boolean | State | Partial, options?: unknown): Promise>; + setForeignStateAsync(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown): Promise>; /** Writes a value (which might not belong to this adapter) into the states DB only if it has changed. */ setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, callback?: SetStateChangedCallback): void; setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, ack: boolean, callback?: SetStateChangedCallback): void; setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, options: unknown, callback?: SetStateChangedCallback): void; setForeignStateChanged(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown, callback?: SetStateChangedCallback): void; + /** Writes a value (which might not belong to this adapter) into the states DB only if it has changed. */ + setForeignStateChangedAsync(id: string, state: string | number | boolean | State | Partial, ack?: boolean): Promise>; + setForeignStateChangedAsync(id: string, state: string | number | boolean | State | Partial, options?: unknown): Promise>; + setForeignStateChangedAsync(id: string, state: string | number | boolean | State | Partial, ack: boolean, options: unknown): Promise>; // tslint:enable:unified-signatures /** Read a value from the states DB. */ getState(id: string, callback: GetStateCallback): void; getState(id: string, options: unknown, callback: GetStateCallback): void; + /** Read a value from the states DB. */ + getStateAsync(id: string, options?: unknown): Promise>; /** Read a value (which might not belong to this adapter) from the states DB. */ getForeignState(id: string, callback: GetStateCallback): void; getForeignState(id: string, options: unknown, callback: GetStateCallback): void; + /** Read a value (which might not belong to this adapter) from the states DB. */ + getForeignStateAsync(id: string, options?: unknown): Promise>; /** Read all states of this adapter which match the given pattern */ getStates(pattern: string, callback: GetStatesCallback): void; getStates(pattern: string, options: unknown, callback: GetStatesCallback): void; + /** Read all states of this adapter which match the given pattern */ + getStatesAsync(pattern: string, options?: unknown): Promise>; /** Read all states (which might not belong to this adapter) which match the given pattern */ getForeignStates(pattern: string, callback: GetStatesCallback): void; getForeignStates(pattern: string, options: unknown, callback: GetStatesCallback): void; + /** Read all states (which might not belong to this adapter) which match the given pattern */ + getForeignStatesAsync(pattern: string, options?: unknown): Promise>; /** Deletes a state from the states DB, but not the associated object. Consider using @link{deleteState} instead */ delState(id: string, callback?: ErrorCallback): void; delState(id: string, options: unknown, callback?: ErrorCallback): void; + /** Deletes a state from the states DB, but not the associated object. Consider using @link{deleteState} instead */ + delStateAsync(id: string, options?: unknown): Promise; /** Deletes a state from the states DB, but not the associated object */ delForeignState(id: string, callback?: ErrorCallback): void; delForeignState(id: string, options: unknown, callback?: ErrorCallback): void; + /** Deletes a state from the states DB, but not the associated object */ + delForeignStateAsync(id: string, options?: unknown): Promise; getHistory(id: string, options: GetHistoryOptions, callback: GetHistoryCallback): void; + // TODO: getHistoryAsync // MISSING: // pushFifo and similar https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/adapter.js#L4105 @@ -1138,6 +1259,13 @@ declare global { */ setBinaryState(id: string, binary: Buffer, callback: SetStateCallback): void; setBinaryState(id: string, binary: Buffer, options: unknown, callback: SetStateCallback): void; + /** + * Writes a binary state into Redis + * @param id The id of the state + * @param binary The data to be written + * @param options (optional) Some internal options. + */ + setBinaryStateAsync(id: string, binary: Buffer, options?: unknown): Promise>; /** * Reads a binary state from Redis * @param id The id of the state @@ -1146,6 +1274,12 @@ declare global { */ getBinaryState(id: string, callback: GetBinaryStateCallback): void; getBinaryState(id: string, options: unknown, callback: GetBinaryStateCallback): void; + /** + * Reads a binary state from Redis + * @param id The id of the state + * @param options (optional) Some internal options. + */ + getBinaryStateAsync(id: string, options?: unknown): Promise>; // ============================== // enums @@ -1154,27 +1288,42 @@ declare global { getEnum(callback: GetEnumCallback): void; getEnum(name: string, callback: GetEnumCallback): void; getEnum(name: string, options: unknown, callback: GetEnumCallback): void; + /** Returns the enum tree, filtered by the optional enum name */ + getEnumAsync(name: string, options?: unknown): Promise<{ result: Record, requestEnum: string }>; + /** Returns the enum tree, filtered by the optional enum name */ getEnums(callback: GetEnumsCallback): void; getEnums(enumList: EnumList, callback: GetEnumsCallback): void; getEnums(enumList: EnumList, options: unknown, callback: GetEnumsCallback): void; + /** Returns the enum tree, filtered by the optional enum name */ + getEnumsAsync(enumList: EnumList, options?: unknown): Promise>; - addChannelToEnum(enumName: string, addTo: string, parentDevice: string, channelName: string, options?: unknown, callback?: ErrorCallback): void; - deleteChannelFromEnum(enumName: string, parentDevice: string, channelName: string, options?: unknown, callback?: ErrorCallback): void; + addChannelToEnum(enumName: string, addTo: string, parentDevice: string, channelName: string, callback?: ErrorCallback): void; + addChannelToEnum(enumName: string, addTo: string, parentDevice: string, channelName: string, options: unknown, callback?: ErrorCallback): void; + addChannelToEnumAsync(enumName: string, addTo: string, parentDevice: string, channelName: string, options?: unknown): Promise; - addStateToEnum(enumName: string, addTo: string, parentDevice: string, parentChannel: string, stateName: string, options?: unknown, callback?: ErrorCallback): void; - deleteStateFromEnum(enumName: string, parentDevice: string, parentChannel: string, stateName: string, options?: unknown, callback?: ErrorCallback): void; + deleteChannelFromEnum(enumName: string, parentDevice: string, channelName: string, callback?: ErrorCallback): void; + deleteChannelFromEnum(enumName: string, parentDevice: string, channelName: string, options: unknown, callback?: ErrorCallback): void; + deleteChannelFromEnumAsync(enumName: string, parentDevice: string, channelName: string, options?: unknown): Promise; + + addStateToEnum(enumName: string, addTo: string, parentDevice: string, parentChannel: string, stateName: string, callback?: ErrorCallback): void; + addStateToEnum(enumName: string, addTo: string, parentDevice: string, parentChannel: string, stateName: string, options: unknown, callback?: ErrorCallback): void; + addStateToEnumAsync(enumName: string, addTo: string, parentDevice: string, parentChannel: string, stateName: string, options?: unknown): Promise; + + deleteStateFromEnum(enumName: string, parentDevice: string, parentChannel: string, stateName: string, callback?: ErrorCallback): void; + deleteStateFromEnum(enumName: string, parentDevice: string, parentChannel: string, stateName: string, options: unknown, callback?: ErrorCallback): void; + deleteStateFromEnumAsync(enumName: string, parentDevice: string, parentChannel: string, stateName: string, options?: unknown): Promise; // ============================== // subscriptions /** Subscribe to changes of objects in this instance */ - subscribeObjects(pattern: string, options?: unknown): void; + subscribeObjects(pattern: string, options?: unknown, callback?: ErrorCallback): void; /** Subscribe to changes of objects (which might not belong to this adapter) */ - subscribeForeignObjects(pattern: string, options?: unknown): void; + subscribeForeignObjects(pattern: string, options?: unknown, callback?: ErrorCallback): void; /** Unsubscribe from changes of objects in this instance */ - unsubscribeObjects(pattern: string, options?: unknown): void; + unsubscribeObjects(pattern: string, options?: unknown, callback?: ErrorCallback): void; /** Unsubscribe from changes of objects (which might not belong to this adapter) */ - unsubscribeForeignObjects(pattern: string, options?: unknown): void; + unsubscribeForeignObjects(pattern: string, options?: unknown, callback?: ErrorCallback): void; /** Subscribe to changes of states in this instance */ subscribeStates(pattern: string, options?: unknown, callback?: ErrorCallback): void; @@ -1194,24 +1343,80 @@ declare global { // ============================== // devices and channels + // tslint:disable:unified-signatures /** creates an object with type device */ - createDevice(deviceName: string, common?: any, native?: any, options?: unknown, callback?: SetObjectCallback): void; + createDevice(deviceName: string, callback?: SetObjectCallback): void; + createDevice(deviceName: string, common: Partial, callback?: SetObjectCallback): void; + createDevice(deviceName: string, common: Partial, native: Record, callback?: SetObjectCallback): void; + createDevice(deviceName: string, common: Partial, native: Record, options: unknown, callback?: SetObjectCallback): void; + /** creates an object with type device */ + createDeviceAsync(deviceName: string, common?: Partial): Promise>; + createDeviceAsync(deviceName: string, common: Partial, native?: Record): Promise>; + createDeviceAsync(deviceName: string, common: Partial, native: Record, options?: unknown): Promise>; /** deletes a device, its channels and states */ - deleteDevice(deviceName: string, options?: unknown, callback?: ErrorCallback): void; - /** gets the devices of this instance */ + deleteDevice(deviceName: string, callback?: ErrorCallback): void; + deleteDevice(deviceName: string, options: unknown, callback?: ErrorCallback): void; + /** deletes a device, its channels and states */ + deleteDeviceAsync(deviceName: string, options?: unknown): Promise; - /** creates an object with type channel */ - createChannel(parentDevice: string, channelName: string, roleOrCommon?: string | object, native?: any, options?: unknown, callback?: SetObjectCallback): void; - /** deletes a channel and its states */ + /** Creates an object with type channel. It must be located under a device */ + createChannel(parentDevice: string, channelName: string, callback?: SetObjectCallback): void; + createChannel(parentDevice: string, channelName: string, roleOrCommon: string | Partial, callback?: SetObjectCallback): void; + createChannel(parentDevice: string, channelName: string, roleOrCommon: string | Partial, native: Record, callback?: SetObjectCallback): void; + createChannel( + parentDevice: string, channelName: string, roleOrCommon: string | Partial, + native: Record, options: unknown, callback?: SetObjectCallback + ): void; + /** Creates an object with type channel. It must be located under a device */ + createChannelAsync(parentDevice: string, channelName: string, roleOrCommon?: string | Partial): Promise>; + createChannelAsync( + parentDevice: string, channelName: string, roleOrCommon: string | Partial, native?: Record + ): Promise>; + createChannelAsync( + parentDevice: string, channelName: string, roleOrCommon: string | Partial, native: Record, + options?: unknown + ): Promise>; + /** Deletes a channel and its states. It must have been created with `createChannel` */ deleteChannel(channelName: string, options?: unknown, callback?: ErrorCallback): void; deleteChannel(parentDevice: string, channelName: string, options?: unknown, callback?: ErrorCallback): void; + /** Deletes a channel and its states. It must have been created with `createChannel` */ + deleteChannelAsync(channelName: string, options?: unknown): Promise; + deleteChannelAsync(parentDevice: string, channelName: string, options?: unknown): Promise; - /** creates a state and the corresponding object */ - createState(parentDevice: string, parentChannel: string, stateName: string, roleOrCommon?: string | object, native?: any, options?: unknown, callback?: SetObjectCallback): void; - /** deletes a state */ + /** + * Creates a state and the corresponding object. It must be located in a channel under a device + */ + createState(parentDevice: string, parentChannel: string, stateName: string, callback?: SetObjectCallback): void; + createState(parentDevice: string, parentChannel: string, stateName: string, roleOrCommon: string | Partial, callback?: SetObjectCallback): void; + createState( + parentDevice: string, parentChannel: string, stateName: string, roleOrCommon: string | Partial, + native: Record, callback?: SetObjectCallback + ): void; + createState( + parentDevice: string, parentChannel: string, stateName: string, roleOrCommon: string | Partial, + native: Record, options: unknown, callback?: SetObjectCallback + ): void; + /** + * Creates a state and the corresponding object. It must be located in a channel under a device + */ + createStateAsync(parentDevice: string, parentChannel: string, stateName: string, roleOrCommon?: string | Partial): Promise>; + createStateAsync( + parentDevice: string, parentChannel: string, stateName: string, roleOrCommon: string | Partial, + native?: Record + ): Promise>; + createStateAsync( + parentDevice: string, parentChannel: string, stateName: string, roleOrCommon: string | Partial, + native: Record, options?: unknown + ): Promise>; + /** Deletes a state. It must have been created with `createState` */ deleteState(stateName: string, options?: unknown, callback?: ErrorCallback): void; deleteState(parentChannel: string, stateName: string, options?: unknown, callback?: ErrorCallback): void; deleteState(parentDevice: string, parentChannel: string, stateName: string, options?: unknown, callback?: ErrorCallback): void; + /** Deletes a state. It must have been created with `createState` */ + deleteStateAsync(stateName: string, options?: unknown): Promise; + deleteStateAsync(parentChannel: string, stateName: string, options?: unknown): Promise; + deleteStateAsync(parentDevice: string, parentChannel: string, stateName: string, options?: unknown): Promise; + // tslint:enable:unified-signatures /** * Returns a list of all devices in this adapter instance @@ -1220,6 +1425,12 @@ declare global { */ getDevices(callback: GetObjectsCallback3): void; getDevices(options: unknown, callback: GetObjectsCallback3): void; + /** + * Returns a list of all devices in this adapter instance + * @param options (optional) Some internal options. + * @param callback Is called when the operation has finished (successfully or not) + */ + getDevicesAsync(options?: unknown): Promise>>; /** * Returns a list of all channels in this adapter instance @@ -1228,8 +1439,8 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ getChannels(callback: GetObjectsCallback3): void; - getChannels(parentDevice: string | null, callback: GetObjectsCallback3): void; - getChannels(parentDevice: string | null, options: unknown, callback: GetObjectsCallback3): void; + getChannels(parentDevice: string, callback: GetObjectsCallback3): void; + getChannels(parentDevice: string, options: unknown, callback: GetObjectsCallback3): void; /** * Returns a list of all channels in this adapter instance * @param parentDevice (optional) Name of the parent device to filter the channels by @@ -1237,8 +1448,16 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ getChannelsOf(callback: GetObjectsCallback3): void; - getChannelsOf(parentDevice: string | null, callback: GetObjectsCallback3): void; - getChannelsOf(parentDevice: string | null, options: unknown, callback: GetObjectsCallback3): void; + getChannelsOf(parentDevice: string, callback: GetObjectsCallback3): void; + getChannelsOf(parentDevice: string, options: unknown, callback: GetObjectsCallback3): void; + /** + * Returns a list of all channels in this adapter instance + * @param parentDevice (optional) Name of the parent device to filter the channels by + * @param options (optional) Some internal options. + */ + getChannelsOfAsync(): Promise>>; + // tslint:disable-next-line:unified-signatures + getChannelsOfAsync(parentDevice: string, options?: unknown): Promise>>; /** * Returns a list of all states in this adapter instance @@ -1248,36 +1467,82 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ getStatesOf(callback: GetObjectsCallback3): void; - getStatesOf(parentDevice: string | null, callback: GetObjectsCallback3): void; - getStatesOf(parentDevice: string | null, parentChannel: string | null, callback: GetObjectsCallback3): void; - getStatesOf(parentDevice: string | null, parentChannel: string | null, options: unknown, callback: GetObjectsCallback3): void; + getStatesOf(parentDevice: string, callback: GetObjectsCallback3): void; + getStatesOf(parentDevice: string, parentChannel: string, callback: GetObjectsCallback3): void; + getStatesOf(parentDevice: string, parentChannel: string, options: unknown, callback: GetObjectsCallback3): void; + /** + * Returns a list of all states in this adapter instance + * @param parentDevice (optional) Name of the parent device to filter the channels by + * @param parentChannel (optional) Name of the parent channel to filter the channels by + * @param options (optional) Some internal options. + */ + // tslint:disable:unified-signatures + getStatesOfAsync(): Promise>>; + getStatesOfAsync(parentDevice: string, parentChannel?: string): Promise>>; + getStatesOfAsync(parentDevice: string, parentChannel: string, options?: unknown): Promise>>; + // tslint:enable:unified-signatures // ============================== // filesystem /** * reads the content of directory from DB for given adapter and path - * @param adapter - adapter name. If adapter name is null, default will be the name of the current adapter. - * @param path - path to direcory without adapter name. E.g. If you want to read "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". + * @param adapterName - adapter name. If adapter name is null, default will be the name of the current adapter. + * @param path - path to directory without adapter name. E.g. If you want to read "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". */ - readDir(adapterName: string, path: string, callback: ReadDirCallback): void; - readDir(adapterName: string, path: string, options: unknown, callback: ReadDirCallback): void; - mkDir(adapterName: string, path: string, callback: ErrorCallback): void; - mkDir(adapterName: string, path: string, options: unknown, callback: ErrorCallback): void; + readDir(adapterName: string | null, path: string, callback: ReadDirCallback): void; + readDir(adapterName: string | null, path: string, options: unknown, callback: ReadDirCallback): void; + /** + * reads the content of directory from DB for given adapter and path + * @param adapterName - adapter name. If adapter name is null, default will be the name of the current adapter. + * @param path - path to directory without adapter name. E.g. If you want to read "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". + */ + readDirAsync(adapterName: string | null, path: string, options?: unknown): Promise>; - readFile(adapterName: string, path: string, callback: ReadFileCallback): void; - readFile(adapterName: string, path: string, options: unknown, callback: ReadFileCallback): void; - writeFile(adapterName: string, path: string, data: Buffer | string, callback: ErrorCallback): void; + mkDir(adapterName: string | null, path: string, callback: ErrorCallback): void; + mkDir(adapterName: string | null, path: string, options: unknown, callback: ErrorCallback): void; + mkDirAsync(adapterName: string | null, path: string, options?: unknown): Promise; + + readFile(adapterName: string | null, path: string, callback: ReadFileCallback): void; + readFile(adapterName: string | null, path: string, options: unknown, callback: ReadFileCallback): void; + readFileAsync(adapterName: string | null, path: string, options?: unknown): Promise<{ file: string | Buffer, mimeType: string }>; + + writeFile(adapterName: string | null, path: string, data: Buffer | string, callback: ErrorCallback): void; // options see https://github.com/ioBroker/ioBroker.js-controller/blob/master/lib/objects/objectsInMemServer.js#L599 - writeFile(adapterName: string, path: string, data: Buffer | string, options: unknown, callback: ErrorCallback): void; + writeFile(adapterName: string | null, path: string, data: Buffer | string, options: unknown, callback: ErrorCallback): void; + writeFileAsync(adapterName: string | null, path: string, data: Buffer | string, options?: unknown): Promise; - delFile(adapterName: string, path: string, callback: ErrorCallback): void; - delFile(adapterName: string, path: string, options: unknown, callback: ErrorCallback): void; - unlink(adapterName: string, path: string, callback: ErrorCallback): void; - unlink(adapterName: string, path: string, options: unknown, callback: ErrorCallback): void; + /** + * Deletes a given file + * @param adapterName - adapter name. If adapter name is null, default will be the name of the current adapter. + * @param path - path to directory without adapter name. E.g. If you want to delete "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". + */ + delFile(adapterName: string | null, path: string, callback: ErrorCallback): void; + delFile(adapterName: string | null, path: string, options: unknown, callback: ErrorCallback): void; + /** + * Deletes a given file + * @param adapterName - adapter name. If adapter name is null, default will be the name of the current adapter. + * @param path - path to directory without adapter name. E.g. If you want to delete "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". + */ + delFileAsync(adapterName: string | null, path: string, options?: unknown): Promise; - rename(adapterName: string, oldName: string, newName: string, callback: ErrorCallback): void; - rename(adapterName: string, oldName: string, newName: string, options: unknown, callback: ErrorCallback): void; + /** + * Deletes a given file + * @param adapterName - adapter name. If adapter name is null, default will be the name of the current adapter. + * @param path - path to directory without adapter name. E.g. If you want to delete "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". + */ + unlink(adapterName: string | null, path: string, callback: ErrorCallback): void; + unlink(adapterName: string | null, path: string, options: unknown, callback: ErrorCallback): void; + /** + * Deletes a given file + * @param adapterName - adapter name. If adapter name is null, default will be the name of the current adapter. + * @param path - path to directory without adapter name. E.g. If you want to delete "/vis.0/main/views.json", here must be "/main/views.json" and _adapter must be equal to "vis.0". + */ + unlinkAsync(adapterName: string | null, path: string, options?: unknown): Promise; + + rename(adapterName: string | null, oldName: string, newName: string, callback: ErrorCallback): void; + rename(adapterName: string | null, oldName: string, newName: string, options: unknown, callback: ErrorCallback): void; + renameAsync(adapterName: string | null, oldName: string, newName: string, options?: unknown): Promise; /** * Changes access rights of all files in the adapter directory @@ -1287,6 +1552,7 @@ declare global { * @param callback Is called when the operation has finished (successfully or not) */ chmodFile(adapter: string | null, path: string, options: { mode: number | string } | Record, callback: ChownFileCallback): void; + chmodFileAsync(adapter: string | null, path: string, options: { mode: number | string } | Record): Promise<{ entries: ChownFileResult[], id: string }>; // ============================== // formatting @@ -1354,6 +1620,8 @@ declare global { // This is a version used by GetDevices/GetChannelsOf/GetStatesOf type GetObjectsCallback3 = (err: string | null, result?: Array>) => void; + type SecondParameterOf any> = T extends (arg0: any, arg1: infer R, ...args: any[]) => any ? R : never; + type CallbackReturnTypeOf any> = Exclude, null | undefined>; type GetStateCallback = (err: string | null, state: State | null | undefined) => void; type GetStatesCallback = (err: string | null, states: Record) => void; /** Version of the callback used by States.getStates */ diff --git a/types/iobroker/iobroker-tests.ts b/types/iobroker/iobroker-tests.ts index 997775c76f..fcdc4d5c9e 100644 --- a/types/iobroker/iobroker-tests.ts +++ b/types/iobroker/iobroker-tests.ts @@ -1,34 +1,7 @@ -// For now, this "utils" module is necessary, as it is included in every adapter -// Once this PR is merged and @types/iobroker is available, it will become part of -// `iobroker.adapter-core`, which brings typings for it -declare const utils: { - readonly controllerDir: string; - getConfig(): string; - - // tslint:disable:unified-signatures - adapter(adapterName: string): ioBroker.Adapter; - adapter(adapterOptions: ioBroker.AdapterOptions): ioBroker.Adapter; - // tslint:enable:unified-signatures -}; - declare function assertNever(val: never): never; // Let the tests begin -let adapter: ioBroker.Adapter; - -// Test constructors -adapter = utils.adapter("my-adapter-name"); -adapter = utils.adapter({ - name: "my-adapter-name" -}); -adapter = utils.adapter({ - name: "my-adapter-name", - ready: readyHandler, - stateChange: stateChangeHandler, - objectChange: objectChangeHandler, - message: messageHandler, - unload: unloadHandler, -}); +declare let adapter: ioBroker.Adapter; // Test EventEmitter definitions adapter @@ -141,37 +114,62 @@ adapter.setState("state.name", "value", (err, id) => { }); adapter.setState("state.name", { val: "value", ack: true }); adapter.setState("state.name", { val: "value", ack: true }, (err, id) => { }); +adapter.setStateAsync("state.name", "value").then(id => id.toLowerCase()); +adapter.setStateAsync("state.name", "value", true).then(id => id.toLowerCase()); +adapter.setStateAsync("state.name", { val: "value", ack: true }).then(id => id.toLowerCase()); + adapter.setStateChanged("state.name", "value"); adapter.setStateChanged("state.name", "value", true); adapter.setStateChanged("state.name", "value", (err, id) => { }); adapter.setStateChanged("state.name", { val: "value", ack: true }); adapter.setStateChanged("state.name", { val: "value", ack: true }, (err, id) => { }); +adapter.setStateChangedAsync("state.name", "value").then(id => id.toLowerCase()); +adapter.setStateChangedAsync("state.name", "value", true).then(id => id.toLowerCase()); +adapter.setStateChangedAsync("state.name", { val: "value", ack: true }).then(id => id.toLowerCase()); + adapter.setForeignState("state.name", "value"); adapter.setForeignState("state.name", "value", true); adapter.setForeignState("state.name", "value", (err, id) => { }); adapter.setForeignState("state.name", { val: "value", ack: true }); adapter.setForeignState("state.name", { val: "value", ack: true }, (err, id) => { }); +adapter.setForeignStateAsync("state.name", "value").then(id => id.toLowerCase()); +adapter.setForeignStateAsync("state.name", "value", true).then(id => id.toLowerCase()); +adapter.setForeignStateAsync("state.name", { val: "value", ack: true }).then(id => id.toLowerCase()); + adapter.setForeignStateChanged("state.name", "value"); adapter.setForeignStateChanged("state.name", "value", true); adapter.setForeignStateChanged("state.name", "value", (err, id) => { }); adapter.setForeignStateChanged("state.name", { val: "value", ack: true }); adapter.setForeignStateChanged("state.name", { val: "value", ack: true }, (err, id) => { }); +adapter.setForeignStateChangedAsync("state.name", "value").then(id => id.toLowerCase()); +adapter.setForeignStateChangedAsync("state.name", "value", true).then(id => id.toLowerCase()); +adapter.setForeignStateChangedAsync("state.name", { val: "value", ack: true }).then(id => id.toLowerCase()); + adapter.setObject("obj.id", { type: "state", common: { name: "foo" }, native: {} }); adapter.setObject("obj.id", { type: "state", common: { name: "foo" }, native: {} }, (err, id) => { }); adapter.setForeignObject("obj.id", { type: "state", common: { name: "foo" }, native: {} }); adapter.setForeignObject("obj.id", { type: "state", common: { name: "foo" }, native: {} }, (err, id) => { }); +adapter.setObjectAsync("obj.id", { type: "state", common: { name: "foo" }, native: {} }).then(({ id }) => id.toLowerCase()); +adapter.setForeignObjectAsync("obj.id", { type: "state", common: { name: "foo" }, native: {} }).then(({ id }) => id.toLowerCase()); + adapter.setObjectNotExists("obj.id", { type: "state", common: { name: "foo" }, native: {} }); adapter.setObjectNotExists("obj.id", { type: "state", common: { name: "foo" }, native: {} }, (err, id) => { }); adapter.setForeignObjectNotExists("obj.id", { type: "state", common: { name: "foo" }, native: {} }); adapter.setForeignObjectNotExists("obj.id", { type: "state", common: { name: "foo" }, native: {} }, (err, id) => { }); +adapter.setObjectNotExistsAsync("obj.id", { type: "state", common: { name: "foo" }, native: {} }).then(({ id }) => id.toLowerCase()); +adapter.setForeignObjectNotExistsAsync("obj.id", { type: "state", common: { name: "foo" }, native: {} }).then(({ id }) => id.toLowerCase()); + adapter.getObject("obj.id", (err, obj) => { }); adapter.getForeignObject("obj.id", (err, obj) => { }); +adapter.getObjectAsync("obj.id").then(obj => obj._id.toLowerCase()); +adapter.getForeignObjectAsync("obj.id").then(obj => obj._id.toLowerCase()); + adapter.subscribeObjects("*"); adapter.subscribeStates("*"); adapter.subscribeForeignObjects("*"); diff --git a/types/ip/index.d.ts b/types/ip/index.d.ts index ed9ba584bc..edcf3ba669 100644 --- a/types/ip/index.d.ts +++ b/types/ip/index.d.ts @@ -1,11 +1,12 @@ -// Type definitions for node-ip +// Type definitions for ip 1.1 // Project: https://github.com/indutny/node-ip // Definitions by: Peter Harris +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -interface SubnetInfo { +export interface SubnetInfo { networkAddress: string; firstAddress: string; lastAddress: string; @@ -17,110 +18,108 @@ interface SubnetInfo { contains(ip: string): boolean; } -declare module "ip" { - /** - * Check two IP address are the same. - **/ - export function isEqual(ip1: string, ip2: string): boolean; +/** + * Check two IP address are the same. + */ +export function isEqual(ip1: string, ip2: string): boolean; - /** - * Convert an IP string into a buffer. - **/ - export function toBuffer(ip: string, buffer?: Buffer, offset?: number): Buffer; +/** + * Convert an IP string into a buffer. + */ +export function toBuffer(ip: string, buffer?: Buffer, offset?: number): Buffer; - /** - * Convert an IP buffer into a string. - **/ - export function toString(ip: Buffer, offset?: number, length?: number): string; +/** + * Convert an IP buffer into a string. + */ +export function toString(ip: Buffer, offset?: number, length?: number): string; - /** - * Get the subnet mask from a CIDR prefix length. - * - * @param family The IP family is infered from the prefixLength, but can be explicity specified as either "ipv4" or "ipv6". - **/ - export function fromPrefixLen(prefixLength: number, family?:string): string; +/** + * Get the subnet mask from a CIDR prefix length. + * + * @param family The IP family is infered from the prefixLength, but can be explicity specified as either "ipv4" or "ipv6". + */ +export function fromPrefixLen(prefixLength: number, family?: 'ipv4' | 'ipv6'): string; - /** - * Get the network ID IP address from an IP address and its subnet mask. - **/ - export function mask(ip: string, mask: string): string; +/** + * Get the network ID IP address from an IP address and its subnet mask. + */ +export function mask(ip: string, mask: string): string; - /** - * Get the network ID IP address from an IP address in CIDR notation. - **/ - export function cidr(cidr: string): string; +/** + * Get the network ID IP address from an IP address in CIDR notation. + */ +export function cidr(cidr: string): string; - /** - * Get the bitwise inverse (NOT every octet) of an IP address or subnet mask. - **/ - export function not(ip: string): string; +/** + * Get the bitwise inverse (NOT every octet) of an IP address or subnet mask. + */ +export function not(ip: string): string; - /** - * Get the bitwise OR of two IP addresses (usually an IP address and a subnet mask). - **/ - export function or(ip: string, mask:string): string; +/** + * Get the bitwise OR of two IP addresses (usually an IP address and a subnet mask). + */ +export function or(ip: string, mask: string): string; - /** - * Check whether an IP is within a private IP address range. - **/ - export function isPrivate(ip: string): boolean; +/** + * Check whether an IP is within a private IP address range. + */ +export function isPrivate(ip: string): boolean; - /** - * Check whether an IP is within a public IP address range. - **/ - export function isPublic(ip: string): boolean; +/** + * Check whether an IP is within a public IP address range. + */ +export function isPublic(ip: string): boolean; - /** - * Check whether an IP is a loopback address. - **/ - export function isLoopback(ip: string): boolean; +/** + * Check whether an IP is a loopback address. + */ +export function isLoopback(ip: string): boolean; - /** - * Check whether an IP is a IPv4 address. - **/ - export function isV4Format(ip: string): boolean; +/** + * Check whether an IP is a IPv4 address. + */ +export function isV4Format(ip: string): boolean; - /** - * Check whether an IP is a IPv6 address. - **/ - export function isV6Format(ip: string): boolean; +/** + * Check whether an IP is a IPv6 address. + */ +export function isV6Format(ip: string): boolean; - /** - * Get the loopback address for an IP family. - * - * @param family The family can be either "ipv4" or "ipv6". Default: "ipv4". - **/ - export function loopback(family?: string): string; +/** + * Get the loopback address for an IP family. + * + * @param family The family can be either "ipv4" or "ipv6". Default: "ipv4". + */ +export function loopback(family?: 'ipv4' | 'ipv6'): string; - /** - * Get the address for the network interface on the current system with the specified 'name'. - * If no interface name is specified, the first IPv4 address or loopback address is returned. - * - * @param name The name can be any named interface, or 'public' or 'private'. - * @param family The family can be either "ipv4" or "ipv6". Default: "ipv4". - **/ - export function address(name?: string, family?: string):string; +/** + * Get the address for the network interface on the current system with the specified 'name'. + * If no interface name is specified, the first IPv4 address or loopback address is returned. + * + * @param name The name can be any named interface, or 'public' or 'private'. + * @param family The family can be either "ipv4" or "ipv6". Default: "ipv4". + */ +export function address(name?: 'public' | 'private' | string, family?: 'ipv4' | 'ipv6'): string; - /** - * Convert a string IPv4 IP address to the equivalent long numeric value. - **/ - export function toLong(ip: string): number; +/** + * Convert a string IPv4 IP address to the equivalent long numeric value. + */ +export function toLong(ip: string): number; - /** - * Convert an IPv4 IP address from its the long numeric value to a string. - **/ - export function fromLong(ip: number): string; +/** + * Convert an IPv4 IP address from its the long numeric value to a string. + */ +export function fromLong(ip: number): string; - /** - * Get the subnet information. - * @param ip IP address. - * @param subnet Subnet address. - */ - export function subnet(ip: string, subnet: string): SubnetInfo; +/** + * Get the subnet information. + * @param ip IP address. + * @param subnet Subnet address. + */ +export function subnet(ip: string, subnet: string): SubnetInfo; - /** - * Get the subnet information. - * @param cidr CIDR address. - */ - export function cidrSubnet(cidr: string): SubnetInfo; -} +/** + * Get the subnet information. + * @param cidr CIDR address. + */ +export function cidrSubnet(cidr: string): SubnetInfo; diff --git a/types/ip/ip-tests.ts b/types/ip/ip-tests.ts index f1fbf4726d..efbf1a574c 100644 --- a/types/ip/ip-tests.ts +++ b/types/ip/ip-tests.ts @@ -1,26 +1,24 @@ - - import ip = require('ip'); -var myIP = ip.address(); +const myIP = ip.address(); -ip.cidr("192.168.0.1/24"); +ip.cidr('192.168.0.1/24'); ip.fromLong(ip.toLong(myIP)); ip.fromPrefixLen(24); -ip.isEqual("192.168.0.1", myIP); -ip.isLoopback("127.0.0.1"); +ip.isEqual('192.168.0.1', myIP); +ip.isLoopback('127.0.0.1'); ip.isPrivate(myIP); ip.isPublic(myIP); -ip.loopback("ipv6"); -ip.mask("192.168.0.1", "255.255.255.0"); -ip.not("255.255.255.0"); -ip.or("192.168.0.1", "255.255.255.0"); -var buff:any = ip.toBuffer(myIP); +ip.loopback('ipv6'); +ip.mask('192.168.0.1', '255.255.255.0'); +ip.not('255.255.255.0'); +ip.or('192.168.0.1', '255.255.255.0'); +const buff: any = ip.toBuffer(myIP); ip.toString(buff); ip.subnet('192.168.1.134', '255.255.255.192'); ip.cidrSubnet('192.168.1.134/26'); ip.cidrSubnet('192.168.1.134/26').contains('192.168.1.134'); -var buf = new Buffer(128); -var offset = 64; +const buf = new Buffer(128); +const offset = 64; ip.toBuffer('127.0.0.1', buf, offset); ip.toString(buf, offset, 4); diff --git a/types/ip/tsconfig.json b/types/ip/tsconfig.json index a445ebefe8..ee6d3f766e 100644 --- a/types/ip/tsconfig.json +++ b/types/ip/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -20,4 +20,4 @@ "index.d.ts", "ip-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/ip/tslint.json b/types/ip/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/ip/tslint.json +++ b/types/ip/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" } diff --git a/types/is-plain-obj/index.d.ts b/types/is-plain-obj/index.d.ts new file mode 100644 index 0000000000..89b5b5aae5 --- /dev/null +++ b/types/is-plain-obj/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for is-plain-obj 1.1 +// Project: https://github.com/sindresorhus/is-plain-obj +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = isPlainObj; + +declare function isPlainObj(input: any): boolean; diff --git a/types/is-plain-obj/is-plain-obj-tests.ts b/types/is-plain-obj/is-plain-obj-tests.ts new file mode 100644 index 0000000000..15b402b8f5 --- /dev/null +++ b/types/is-plain-obj/is-plain-obj-tests.ts @@ -0,0 +1,3 @@ +import isPlainObj = require('is-plain-obj'); + +isPlainObj({ foo: 'bar' }); // $ExpectType boolean diff --git a/types/is-plain-obj/tsconfig.json b/types/is-plain-obj/tsconfig.json new file mode 100644 index 0000000000..43671920dd --- /dev/null +++ b/types/is-plain-obj/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-plain-obj-tests.ts" + ] +} diff --git a/types/is-plain-obj/tslint.json b/types/is-plain-obj/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/is-plain-obj/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/istextorbinary/index.d.ts b/types/istextorbinary/index.d.ts new file mode 100644 index 0000000000..d41400f89b --- /dev/null +++ b/types/istextorbinary/index.d.ts @@ -0,0 +1,93 @@ +// Type definitions for istextorbinary 2.3 +// Project: https://github.com/bevry/istextorbinary +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +/** + * Is Text (Synchronous) + * Determine whether or not a file is a text or binary file. + * Determined by extension checks first, then if unknown extension, will fallback on encoding detection. + * We do that as encoding detection cannot guarantee everything, especially for chars between utf8 and utf16. + * We use the extensions from https://github.com/bevry/textextensions and https://github.com/bevry/binaryextensions + * @param filename the filename for the file/buffer if available + * @param buffer the buffer for the file if available + */ +export function isTextSync(filename: string, buffer?: Buffer): boolean; +export function isTextSync(filename: undefined, buffer: Buffer): boolean; + +/** + * Is Text + * Uses `isTextSync` behind the scenes. + * @param filename forwarded to `isTextSync` + * @param buffer forwarded to `isTextSync` + * @param next accepts arguments: (error: Error, result: Boolean) + */ +export function isText( + filename: string, + buffer: Buffer | undefined, + next: (err: null, result: boolean) => void +): void; +export function isText( + filename: undefined, + buffer: Buffer, + next: (err: null, result: boolean) => void +): void; + +/** + * Is Binary (Synchronous) + * Uses `isTextSync` behind the scenes. + * @param filename forwarded to `isTextSync` + * @param buffer forwarded to `isTextSync` + */ +export function isBinarySync(filename: string, buffer?: Buffer): boolean; +export function isBinarySync(filename: undefined, buffer: Buffer): boolean; + +/** + * Is Binary + * Uses `isText` behind the scenes. + * @param filename forwarded to `isText` + * @param buffer forwarded to `isText` + * @param next accepts arguments: (error: Error, result: Boolean) + */ +export function isBinary( + filename: string, + buffer: Buffer | undefined, + next: (err: null, result: boolean) => void +): void; +export function isBinary( + filename: undefined, + buffer: Buffer, + next: (err: null, result: boolean) => void +): void; + +/** + * Get the encoding of a buffer. + * We fetch a bunch chars from the start, middle and end of the buffer. + * We check all three, as doing only start was not enough, and doing only middle was not enough, so better safe than sorry. + * @param buffer + * @param [opts] + * @param [opts.chunkLength = 24] + * @param [opts.chunkBegin = 0] + * @returns either an Error instance if something went wrong, or if successful "utf8" or "binary" + */ +export function getEncodingSync(buffer: Buffer, opts?: Options): 'utf8' | 'binary'; + +/** + * Get the encoding of a buffer + * Uses `getEncodingSync` behind the scenes. + * @param buffer forwarded to `getEncodingSync` + * @param opts forwarded to `getEncodingSync` + * @param next accepts arguments: (error: Error, result: Boolean) + */ +export function getEncoding( + buffer: Buffer, + opts: Options | undefined, + next: (err: null, result: 'utf8' | 'binary') => void +): void; + +export interface Options { + chunkLength?: number; + chunkBegin?: number; +} diff --git a/types/istextorbinary/istextorbinary-tests.ts b/types/istextorbinary/istextorbinary-tests.ts new file mode 100644 index 0000000000..cf9c953711 --- /dev/null +++ b/types/istextorbinary/istextorbinary-tests.ts @@ -0,0 +1,67 @@ +import { + isTextSync, + isText, + isBinarySync, + isBinary, + getEncodingSync, + getEncoding, +} from 'istextorbinary'; + +isTextSync('foo.txt'); // $ExpectType boolean +isTextSync('foo.txt', new Buffer(1)); // $ExpectType boolean +isTextSync(undefined, new Buffer(1)); // $ExpectType boolean +isTextSync(); // $ExpectError +isTextSync(undefined); // $ExpectError +isTextSync(undefined, undefined); // $ExpectError + +isText('foo.txt', undefined, (err, result) => { + err; // $ExpectType null + result; // $ExpectType boolean +}); +isText('foo.txt', new Buffer(1), (err, result) => { + err; // $ExpectType null + result; // $ExpectType boolean +}); +isText(undefined, new Buffer(1), (err, result) => { + err; // $ExpectType null + result; // $ExpectType boolean +}); +isText(undefined, undefined, (err, result) => {}); // $ExpectError + +isBinarySync('foo.txt'); // $ExpectType boolean +isBinarySync('foo.txt', new Buffer(1)); // $ExpectType boolean +isBinarySync(undefined, new Buffer(1)); // $ExpectType boolean +isBinarySync(); // $ExpectError +isBinarySync(undefined); // $ExpectError +isBinarySync(undefined, undefined); // $ExpectError + +isBinary('foo.txt', undefined, (err, result) => { + err; // $ExpectType null + result; // $ExpectType boolean +}); +isBinary('foo.txt', new Buffer(1), (err, result) => { + err; // $ExpectType null + result; // $ExpectType boolean +}); +isBinary(undefined, new Buffer(1), (err, result) => { + err; // $ExpectType null + result; // $ExpectType boolean +}); +isBinary(undefined, undefined, (err, result) => {}); // $ExpectError + +getEncodingSync(new Buffer(1)); // $ExpectType "utf8" | "binary" +getEncodingSync(new Buffer(1), { chunkBegin: 0 }); // $ExpectType "utf8" | "binary" +getEncodingSync(new Buffer(1), { chunkLength: 10 }); // $ExpectType "utf8" | "binary" + +getEncoding(new Buffer(1), undefined, (err, result) => { + err; // $ExpectType null + result; // $ExpectType "utf8" | "binary" +}); +getEncoding(new Buffer(1), { chunkBegin: 0 }, (err, result) => { + err; // $ExpectType null + result; // $ExpectType "utf8" | "binary" +}); +getEncoding(new Buffer(1), { chunkLength: 10 }, (err, result) => { + err; // $ExpectType null + result; // $ExpectType "utf8" | "binary" +}); diff --git a/types/istextorbinary/tsconfig.json b/types/istextorbinary/tsconfig.json new file mode 100644 index 0000000000..7e5e7e256c --- /dev/null +++ b/types/istextorbinary/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "istextorbinary-tests.ts" + ] +} diff --git a/types/istextorbinary/tslint.json b/types/istextorbinary/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/istextorbinary/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/jest-when/index.d.ts b/types/jest-when/index.d.ts index f484502f4d..0579419425 100644 --- a/types/jest-when/index.d.ts +++ b/types/jest-when/index.d.ts @@ -6,22 +6,22 @@ /// -export interface PartialMockInstance { - mockReturnValue: jest.MockInstance['mockReturnValue']; - mockReturnValueOnce: jest.MockInstance['mockReturnValueOnce']; - mockResolvedValue: jest.MockInstance['mockResolvedValue']; - mockResolvedValueOnce: jest.MockInstance['mockResolvedValueOnce']; - mockRejectedValue: jest.MockInstance['mockRejectedValue']; - mockRejectedValueOnce: jest.MockInstance['mockRejectedValueOnce']; -} - export interface When { (fn: jest.Mocked | jest.Mock): When; + // due to no-unnecessary-generics lint rule, the generics have been replaced with 'any' // calledWith(...matchers: any[]): PartialMockInstance; // expectCalledWith(...matchers: any[]): PartialMockInstance; - calledWith(...matchers: any[]): PartialMockInstance; - expectCalledWith(...matchers: any[]): PartialMockInstance; + calledWith(...matchers: any[]): When; + + expectCalledWith(...matchers: any[]): When; + + mockReturnValue: (value: any) => jest.MockInstance['mockReturnValue'] & When; + mockReturnValueOnce: (value: any) => jest.MockInstance['mockReturnValue'] & When; + mockResolvedValue: (value: any) => jest.MockInstance['mockReturnValue'] & When; + mockResolvedValueOnce: (value: any) => jest.MockInstance['mockReturnValue'] & When; + mockRejectedValue: (value: any) => jest.MockInstance['mockReturnValue'] & When; + mockRejectedValueOnce: (value: any) => jest.MockInstance['mockReturnValue'] & When; } export const when: When; diff --git a/types/jest-when/jest-when-tests.ts b/types/jest-when/jest-when-tests.ts index 13da65928d..179ea2fae1 100644 --- a/types/jest-when/jest-when-tests.ts +++ b/types/jest-when/jest-when-tests.ts @@ -43,6 +43,37 @@ describe('mock-when test', () => { expect(fn(5)).toEqual(undefined); }); + it('Supports chained calls:', () => { + const fn = jest.fn(); + when(fn) + .calledWith(1).mockReturnValue('no') + .calledWith(2).mockReturnValue('way?') + .calledWith(3).mockReturnValue('yes') + .calledWith(4).mockReturnValue('way!'); + + expect(fn(1)).toEqual('no'); + expect(fn(2)).toEqual('way?'); + expect(fn(3)).toEqual('yes'); + expect(fn(4)).toEqual('way!'); + expect(fn(5)).toEqual(undefined); + }); + + it('Supports chained calls with defaults:', () => { + const fn = jest.fn(); + when(fn) + .mockReturnValue('nice') + .calledWith(1).mockReturnValue('no') + .calledWith(2).mockReturnValue('way?') + .calledWith(3).mockReturnValue('yes') + .calledWith(4).mockReturnValue('way!'); + + expect(fn(1)).toEqual('no'); + expect(fn(2)).toEqual('way?'); + expect(fn(3)).toEqual('yes'); + expect(fn(4)).toEqual('way!'); + expect(fn(5)).toEqual('nice'); + }); + it('Assert the args:', () => { const fn = jest.fn(); when(fn).expectCalledWith(1).mockReturnValue('x'); diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index d434b5e198..6fb82e76b2 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -981,7 +981,7 @@ declare function pending(reason?: string): void; /** * Fails a test when called within one. */ -declare function fail(error?: any): void; +declare function fail(error?: any): never; declare namespace jasmine { let DEFAULT_TIMEOUT_INTERVAL: number; function clock(): Clock; diff --git a/types/jwplayer/index.d.ts b/types/jwplayer/index.d.ts index 6481b59faf..1d65bca261 100644 --- a/types/jwplayer/index.d.ts +++ b/types/jwplayer/index.d.ts @@ -5,6 +5,7 @@ // Philipp Gürtler // Daniel McGraw // Benjamin Dobson +// Be Birchall // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -241,6 +242,31 @@ interface Region { height: number; } +interface CaptionOptions { + color: string; + fontSize: number; + fontFamily: string; + fontOpacity: number; + backgroundColor: string; + backgroundOpacity: number; + edgeStyle: string; + windowColor: string; + windowOpacity: number; +} + +interface Level { + bitrate: number; + height: number; + width: number; + label: string; +} + +interface QualityLevel { + mode: 'auto' | 'manual'; + level: Level; + reason: 'auto' | 'api' | 'initial choice'; +} + interface JWPlayer { addButton(icon: string, label: string, handler: () => void, id: string): void; getAudioTracks(): any[]; @@ -266,6 +292,7 @@ interface JWPlayer { getContainer(): HTMLElement; getEnvironment(): Environment; getWidth(): number; + getVisualQuality(): QualityLevel | undefined; load(playlist: any[]): void; load(playlist: string): void; on(event: 'adClick', callback: EventCallback): void; @@ -469,6 +496,7 @@ interface JWPlayer { setMute(state?: boolean): void; setup(options: any): JWPlayer; setVolume(volume: number): void; + setCaptions(options: CaptionOptions): void; stop(): void; } diff --git a/types/keyv/index.d.ts b/types/keyv/index.d.ts index 69e644c2d9..d3ef77a9a3 100644 --- a/types/keyv/index.d.ts +++ b/types/keyv/index.d.ts @@ -1,49 +1,33 @@ -// Type definitions for keyv 3.0 +// Type definitions for keyv 3.1 // Project: https://github.com/lukechilds/keyv // Definitions by: AryloYeung +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 -/// -interface KeyvOptions { - /** Namespace for the current instance. */ - namespace?: string; - /** A custom serialization function. */ - serialize?: (data: any) => string; - /** A custom deserialization function. */ - deserialize?: (data: string) => any; - /** The connection string URI. */ - uri?: string; - /** The storage adapter instance to be used by Keyv. */ - store?: any; - /** Default TTL. Can be overridden by specififying a TTL on `.set()`. */ - ttl?: number; - /** Specify an adapter to use. e.g `'redis'` or `'mongodb'`. */ - adapter?: string; -} +// TypeScript Version: 2.3 -declare class Keyv extends NodeJS.EventEmitter { +/// + +declare class Keyv extends NodeJS.EventEmitter { /** * @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options. */ - constructor(opts?: KeyvOptions); + constructor(opts?: Keyv.Options); /** * @param uri The connection string URI. * * Merged into the options object as options.uri. * @param opts The options object is also passed through to the storage adapter. Check your storage adapter docs for any extra options. */ - constructor(uri?: string, opts?: KeyvOptions); - /** Returns the namespace of a key */ - _getKeyPrefix(key: string): string; + constructor(uri?: string, opts?: Keyv.Options); /** Returns the value. */ - get(key: string): Promise; + get(key: string): Promise; /** * Set a value. * * By default keys are persistent. You can set an expiry TTL in milliseconds. */ - set(key: string, value: any, ttl?: number): (Promise | undefined); + set(key: string, value: TValue, ttl?: number): Promise; /** * Deletes an entry. * @@ -54,4 +38,32 @@ declare class Keyv extends NodeJS.EventEmitter { clear(): Promise; } +declare namespace Keyv { + interface Options { + /** Namespace for the current instance. */ + namespace?: string; + /** A custom serialization function. */ + serialize?: (data: TValue) => string; + /** A custom deserialization function. */ + deserialize?: (data: string) => TValue; + /** The connection string URI. */ + uri?: string; + /** The storage adapter instance to be used by Keyv. */ + store?: Store; + /** Default TTL. Can be overridden by specififying a TTL on `.set()`. */ + ttl?: number; + /** Specify an adapter to use. e.g `'redis'` or `'mongodb'`. */ + adapter?: 'redis' | 'mongodb' | 'mongo' | 'sqlite' | 'postgresql' | 'postgres' | 'mysql'; + + [key: string]: any; + } + + interface Store { + get(key: string): TValue | Promise | undefined; + set(key: string, value: TValue, ttl?: number): any; + delete(key: string): boolean | Promise; + clear(): void | Promise; + } +} + export = Keyv; diff --git a/types/keyv/keyv-tests.ts b/types/keyv/keyv-tests.ts index 7ee4cac90e..d8b0ccd910 100644 --- a/types/keyv/keyv-tests.ts +++ b/types/keyv/keyv-tests.ts @@ -1,11 +1,31 @@ -import Keyv = require("keyv"); +import Keyv = require('keyv'); +import QuickLRU = require('quick-lru'); new Keyv({ uri: 'redis://user:pass@localhost:6379', - namespace: "redis" + namespace: 'redis', }); +new Keyv({ uri: 'redis://user:pass@localhost:6379' }); +new Keyv({ namespace: 'redis' }); +new Keyv({ ttl: 123 }); +new Keyv({ adapter: 'redis' }); +new Keyv({ adapter: 'mongo' }); +new Keyv({ adapter: 'mongodb' }); +new Keyv({ adapter: 'sqlite' }); +new Keyv({ adapter: 'postgres' }); +new Keyv({ adapter: 'postgresql' }); +new Keyv({ adapter: 'mysql' }); +new Keyv({ adapter: 'foo' }); // $ExpectError +new Keyv({ serialize: JSON.stringify }); +new Keyv({ deserialize: JSON.parse }); -new Keyv('mongodb://user:pass@localhost:27017/dbname'); +new Keyv({ store: new Map() }); + +const lru = new QuickLRU({ maxSize: 1000 }); +const opts: Keyv.Options = { store: lru }; +new Keyv(opts); + +new Keyv('mongodb://user:pass@localhost:27017/dbname', { namespace: 'mongodb' }); new Keyv('redis://user:pass@localhost:6379'); new Keyv('sqlite://path/to/database.sqlite'); new Keyv('postgresql://user:pass@localhost:5432/dbname'); @@ -13,13 +33,13 @@ new Keyv('mysql://user:pass@localhost:3306/dbname'); new Keyv(); (async () => { - const keyv = new Keyv(); + const keyv = new Keyv(); keyv.on('error', err => console.log('Connection Error', err)); - await keyv.set('foo', 'expires in 1 second', 1000); // true - await keyv.set('foo', 'never expires'); // true - await keyv.get('foo'); // 'never expires' - await keyv.delete('foo'); // true - await keyv.clear(); // undefined + await keyv.set('foo', 'expires in 1 second', 1000); // $ExpectType true + await keyv.set('foo', 'never expires'); // $ExpectType true + await keyv.get('foo'); // $ExpectType string | undefined + await keyv.delete('foo'); // $ExpectType boolean + await keyv.clear(); // $ExpectType void })(); diff --git a/types/klaw-sync/index.d.ts b/types/klaw-sync/index.d.ts index 78ca30b2ff..707bdf094f 100644 --- a/types/klaw-sync/index.d.ts +++ b/types/klaw-sync/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for klaw-sync 5.0 +// Type definitions for klaw-sync 6.0 // Project: https://github.com/manidlou/node-klaw-sync // Definitions by: Brendan Forster // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -53,6 +53,17 @@ declare namespace klawSync { * @since v2.0.0 */ filter?: Filter + + /** + * @description traverse all subdirectories, regardless of `filter` option. + * + * When set to true, traverseAll produces similar behavior to the default + * behavior prior to `v4.0.0`. The current default of `traverseAll: false` + * is equivalent to the old `noRecurseOnFailedFilter: true`). + * + * @since v6.0.0 + */ + traverseAll?: boolean } } diff --git a/types/klaw-sync/klaw-sync-tests.ts b/types/klaw-sync/klaw-sync-tests.ts index 41719734bf..1a5729ed7e 100644 --- a/types/klaw-sync/klaw-sync-tests.ts +++ b/types/klaw-sync/klaw-sync-tests.ts @@ -18,7 +18,8 @@ const options: klawSync.Options = { return item.path.indexOf('node_modules') < 0 }, depthLimit: 5, - fs + fs, + traverseAll: true } klawSync('/some/dir', options).forEach(outputMessage) diff --git a/types/memory-pager/index.d.ts b/types/memory-pager/index.d.ts new file mode 100644 index 0000000000..7df3c3cf7b --- /dev/null +++ b/types/memory-pager/index.d.ts @@ -0,0 +1,60 @@ +// Type definitions for memory-pager 1.4 +// Project: https://github.com/mafintosh/memory-pager +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export = Pager; + +declare const Pager: Pager; + +interface Pager { + /** + * Create a new pager. + * @param pageSize defaults to 1024. + */ + (pageSize?: number): Pager.PagerInstance; + /** + * Create a new pager. + * @param pageSize defaults to 1024. + */ + new (pageSize?: number): Pager.PagerInstance; +} + +declare namespace Pager { + interface PagerInstance { + /** + * Get a page. The page will be allocated at first access. + * @param pageNumber + * @param noAllocate will make the method return `undefined` if no page has been allocated already + */ + get(pageNumber: number, noAllocate?: false): Page; + get(pageNumber: number, noAllocate: true): Page | undefined; + + /** + * Explicitly set the buffer for a page. + */ + set(pageNumber: number, buffer: Buffer): void; + + /** + * Mark a page as updated. + */ + updated(page: Page): void; + + /** + * Get the last page that was updated. + */ + lastUpdate(): Page | null; + + /** + * Concat all pages allocated pages into a single buffer. + */ + toBuffer(): Buffer; + } + + interface Page { + offset: number; + buffer: Buffer; + } +} diff --git a/types/memory-pager/memory-pager-tests.ts b/types/memory-pager/memory-pager-tests.ts new file mode 100644 index 0000000000..fb327097d0 --- /dev/null +++ b/types/memory-pager/memory-pager-tests.ts @@ -0,0 +1,17 @@ +import Pager = require('memory-pager'); + +const pages = new Pager(1024); +new Pager(); +Pager(1024); +Pager(); + +const page = pages.get(10); +page; // $ExpectType Page +page.offset; // $ExpectType number +page.buffer; // $ExpectType Buffer +pages.get(10, false); // $ExpectType Page +pages.get(10, true); // $ExpectType Page | undefined +pages.set(10, new Buffer(10)); +pages.updated(page); +pages.lastUpdate(); // $ExpectType Page | null +pages.toBuffer(); // $ExpectType Buffer diff --git a/types/memory-pager/tsconfig.json b/types/memory-pager/tsconfig.json new file mode 100644 index 0000000000..c8923c0d5e --- /dev/null +++ b/types/memory-pager/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "memory-pager-tests.ts" + ] +} diff --git a/types/memory-pager/tslint.json b/types/memory-pager/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/memory-pager/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/micro-events/index.d.ts b/types/micro-events/index.d.ts new file mode 100644 index 0000000000..a9c046cb6f --- /dev/null +++ b/types/micro-events/index.d.ts @@ -0,0 +1,22 @@ +// Type definitions for micro-events 1.0 +// Project: https://github.com/alexanderGugel/micro-events +// Definitions by: Alexander Sychev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/** Event emitter class */ +declare class MicroEventEmitter { + /** Max listeners count */ + maxListeners: number; + /** Attach listener */ + on(type: string, handler: MicroEventEmitter.EventHandler): MicroEventEmitter; + /** Detach listener */ + off(type: string, handler?: MicroEventEmitter.EventHandler): MicroEventEmitter; + /** Trigger event */ + emit(type: string, ...arguments: any[]): MicroEventEmitter; +} +declare namespace MicroEventEmitter { + /** Event handler function signature */ + type EventHandler = (...args: any[]) => any; +} +export = MicroEventEmitter; diff --git a/types/micro-events/micro-events-tests.ts b/types/micro-events/micro-events-tests.ts new file mode 100644 index 0000000000..3d8ac6f4d0 --- /dev/null +++ b/types/micro-events/micro-events-tests.ts @@ -0,0 +1,13 @@ +import * as EventEmitter from "micro-events"; + +const myEventEmitter = new EventEmitter(); + +myEventEmitter.maxListeners; // $ExpectType number + +const listener = (first: string) => {}; + +myEventEmitter.on('foo', listener); // $ExpectType MicroEventEmitter + +myEventEmitter.emit('foo', 'bar'); // $ExpectType MicroEventEmitter + +myEventEmitter.off('foo', listener); // $ExpectType MicroEventEmitter diff --git a/types/micro-events/tsconfig.json b/types/micro-events/tsconfig.json new file mode 100644 index 0000000000..a42efbcba0 --- /dev/null +++ b/types/micro-events/tsconfig.json @@ -0,0 +1,24 @@ + +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "micro-events-tests.ts" + ] +} diff --git a/types/micro-events/tslint.json b/types/micro-events/tslint.json new file mode 100644 index 0000000000..e60c15844f --- /dev/null +++ b/types/micro-events/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} \ No newline at end of file diff --git a/types/moment-timezone/index.d.ts b/types/moment-timezone/index.d.ts index 0f2d68cb57..95a8621fdd 100644 --- a/types/moment-timezone/index.d.ts +++ b/types/moment-timezone/index.d.ts @@ -1,6 +1,8 @@ // Type definitions for moment-timezone.js 0.5 // Project: http://momentjs.com/timezone/ -// Definitions by: Michel Salib , Alan Brazil Lins +// Definitions by: Michel Salib +// Alan Brazil Lins +// Agustin Carrasco // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import moment = require('moment'); @@ -53,7 +55,7 @@ declare module "moment" { names(): string[]; guess(ignoreCache?: boolean): string; - setDefault(timezone: string): MomentTimezone; + setDefault(timezone?: string): MomentTimezone; } interface Moment { diff --git a/types/moment-timezone/moment-timezone-tests.ts b/types/moment-timezone/moment-timezone-tests.ts index 9daffd1ba2..e3ca243d8a 100644 --- a/types/moment-timezone/moment-timezone-tests.ts +++ b/types/moment-timezone/moment-timezone-tests.ts @@ -77,6 +77,8 @@ moment.tz.names(); moment.tz.setDefault('America/Los_Angeles'); +moment.tz.setDefault(); + moment.tz.guess(); moment.tz.guess(true); diff --git a/types/murmurhash3js/index.d.ts b/types/murmurhash3js/index.d.ts index 2193085d5b..0bddd535de 100644 --- a/types/murmurhash3js/index.d.ts +++ b/types/murmurhash3js/index.d.ts @@ -5,7 +5,7 @@ declare module 'murmurhash3js' { export module x86 { - function hash32(val: string, seed?: number): string; + function hash32(val: string, seed?: number): number; function hash128(val: string, seed?: number): string; } diff --git a/types/nedb/index.d.ts b/types/nedb/index.d.ts index dd3035dd72..e336aa8ab4 100644 --- a/types/nedb/index.d.ts +++ b/types/nedb/index.d.ts @@ -5,10 +5,14 @@ // Alejandro Fernandez Haro // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + +import { EventEmitter } from 'events'; + export = Nedb; export as namespace Nedb; -declare class Nedb { +declare class Nedb extends EventEmitter { constructor(pathOrOptions?: string | Nedb.DataStoreOptions); persistence: Nedb.Persistence; @@ -153,6 +157,17 @@ declare class Nedb { */ remove(query: any, options: Nedb.RemoveOptions, cb?: (err: Error, n: number) => void): void; remove(query: any, cb?: (err: Error, n: number) => void): void; + + addListener(event: 'compaction.done', listener: () => void): this; + on(event: 'compaction.done', listener: () => void): this; + once(event: 'compaction.done', listener: () => void): this; + prependListener(event: 'compaction.done', listener: () => void): this; + prependOnceListener(event: 'compaction.done', listener: () => void): this; + removeListener(event: 'compaction.done', listener: () => void): this; + off(event: 'compaction.done', listener: () => void): this; + listeners(event: 'compaction.done'): Array<() => void>; + rawListeners(event: 'compaction.done'): Array<() => void>; + listenerCount(type: 'compaction.done'): number; } declare namespace Nedb { diff --git a/types/nedb/nedb-tests.ts b/types/nedb/nedb-tests.ts index 0df7168cf1..bbf0e4e43c 100644 --- a/types/nedb/nedb-tests.ts +++ b/types/nedb/nedb-tests.ts @@ -514,3 +514,14 @@ db.insert({ somefield: 'nedb' }, (err: Error) => { // Remove index on field somefield db.removeIndex('somefield', (err: Error) => { }); + +db.addListener("compaction.done", () => {}); +db.on("compaction.done", () => {}); +db.once("compaction.done", () => {}); +db.prependListener("compaction.done", () => {}); +db.prependOnceListener("compaction.done", () => {}); +db.removeListener("compaction.done", () => {}); +db.off("compaction.done", () => {}); +db.listeners("compaction.done"); // $ExpectType (() => void)[] +db.rawListeners("compaction.done"); // $ExpectType (() => void)[] +db.listenerCount("compaction.done"); // $ExpectType number diff --git a/types/node-rsa/index.d.ts b/types/node-rsa/index.d.ts index e0730eef74..882511cc3b 100644 --- a/types/node-rsa/index.d.ts +++ b/types/node-rsa/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for node-rsa 0.4 +// Type definitions for node-rsa 1.0 // Project: https://github.com/rzcoder/node-rsa // Definitions by: Ali Taheri // Christian Moniz +// Florian Keller // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -27,12 +28,12 @@ declare class NodeRSA { * @param bits Key size in bits. 2048 by default. * @param exponent public exponent. 65537 by default. */ - generateKeyPair(bits?: number, exponent?: number): void; + generateKeyPair(bits?: number, exponent?: number): NodeRSA; /** * Import key from PEM string, PEM/DER Buffer or components. */ - importKey(key: NodeRSA.Key, format?: NodeRSA.Format): void; + importKey(key: NodeRSA.Key, format?: NodeRSA.Format): NodeRSA; /** * Export key to PEM string, PEM/DER Buffer or components. @@ -120,8 +121,7 @@ declare namespace NodeRSA { type HashingAlgorithm = | 'ripemd160' | 'md4' | 'md5' - | 'sha' | 'sha1' - | 'sha224' | 'sha256' | 'sha384' | 'sha512'; + | 'sha1' | 'sha224' | 'sha256' | 'sha384' | 'sha512'; type SigningScheme = 'pkcs1' | 'pss'; diff --git a/types/object-path/index.d.ts b/types/object-path/index.d.ts index 535fbe2878..9c3055ab5d 100644 --- a/types/object-path/index.d.ts +++ b/types/object-path/index.d.ts @@ -1,249 +1,141 @@ -// Type definitions for objectPath v0.9.x +// Type definitions for objectPath 0.11 // Project: https://github.com/mariocasciaro/object-path // Definitions by: Paulo Cesar +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -declare var objectPath: ObjectPathGlobal.IObjectPathStatic; +declare const objectPath: objectPath.ObjectPathStatic & { + withInheritedProps: objectPath.ObjectPathStatic; + create(options?: objectPath.Options): objectPath.ObjectPathStatic; +}; -declare namespace ObjectPathGlobal { +declare namespace objectPath { + interface Options { + includeInheritedProps?: boolean; + } - type IPath = Array|number|string; - type IMultiArray = Array; + type Path = Array | number | string; - interface IObjectPathStatic { + interface ObjectPathStatic { /** * Binds an object */ - (object: T): IObjectPathBound; - - /*======== Del =========*/ + (object: T): ObjectPathBound; /** * Deletes a member from object or array - * @param {object} object - * @param {string[]|string} path - * @return object */ - del(object: T, path: IPath): T; - /** - * @see objectPath.del - */ - del(object: T):T; - /** - * @see objectPath.del - */ - del():void; + del(object: object, path: Path): { [key: string]: any }; - /*======== Has =========*/ /** * Tests path existence - * @param {object} object - * @param {string[]|string} path - * @return object */ - has(object: T, path: IPath): boolean; - /** - * @see objectPath.has - */ - has(object: T): boolean; - /** - * @see objectPath.has - */ - has(): boolean; + has(object: object, path: Path): boolean; - /*======== Get =========*/ /** * Get a path from an object - * @param {object} object - * @param {string|string[]|number|number[]} path - * @param {*} [defaultValue=undefined] */ - get(object: T, path: IPath, defaultValue?: TResult): TResult; - /** - * @see objectPath.get - */ - get(object: T): T; - /** - * @see objectPath.get - */ - get():void; + get(object: object, path: Path): any; + get(object: object, path: Path, defaultValue: TResult): TResult; - /*======== Set =========*/ /** * Set a path to a value - * @param {object} object - * @param {string|string[]|number|number[]} path - * @param {*} value - * @param {boolean} [doNotReplace=false] * @return Any existing value on the path if any */ - set(object: T, path: IPath, value: any, doNotReplace?:boolean): TExisting; - /** - * @see objectPath.set - */ - set(object: T): T; - /** - * @see objectPath.set - */ - set():void; + set( + object: object, + path: Path, + value: TResult, + doNotReplace?: boolean + ): TResult | undefined; - /*======== Push =========*/ /** * Create (if path isn't an array) and push the value to it. Can push unlimited number of values - * @param {object} object */ - push(object: T, path: IPath, ...args:any[]):void; - /** - * @see objectPath.push - */ - push():void; + push(object: object, path: Path, ...items: any[]): void; - /*======== Coalesce =========*/ /** * Get the first non undefined property - * @param {object} object - * @param {string[]|string[][]|number[]|number[][]} paths - * @param {*} defaultValue - * @return {*} */ - coalesce(object: T, paths: IMultiArray, defaultValue?: TResult):TResult; + coalesce(object: object, paths: Path | Path[], defaultValue: TResult): TResult; + coalesce( + object: object, + paths: Path | Path[], + defaultValue?: TResult + ): TResult | undefined; - /*======== Empty =========*/ /** * Empty a path. Arrays are set to length 0, objects have all elements deleted, strings * are set to empty, numbers to 0, everything else is set to null - * @param {object} object - * @param {string|string[]|number[]} path */ - empty(object: T, path: IPath):TResult; - /** - * @see objectPath.empty - */ - empty(object: T):T; - /** - * @see objectPath.empty - */ - empty():void; + empty(object: object, path: Path): any; - /*======== EnsureExists =========*/ /** * Set a value if it doesn't exist, do nothing if it does - * @param {object} object - * @param {string|string[]|number|number[]} path */ - ensureExists(object: T, path: IPath, value: any):TExisting; - /** - * @see objectPath.ensureExists - */ - ensureExists(object: T): T; - /** - * @see objectPath.ensureExists - */ - ensureExists():void; + ensureExists(object: object, path: Path, defaultValue: TResult): TResult; + ensureExists( + object: object, + path: Path, + defaultValue?: TResult + ): TResult | undefined; - /*======== Insert =========*/ /** * Insert an item in an array path - * @param {object} object - * @param {string|string[]|number|number[]} path - * @param {*} value - * @param {number} [at=0] */ - insert(object: T, path: IPath, value: any, at?: number):void; + insert(object: object, path: Path, value: any, at?: number): void; } - interface IObjectPathBound { - /*======== Del =========*/ - - /** - * @see objectPath.ensureExists - */ - del(path: IPath): T; + interface ObjectPathBound { /** * @see objectPath.del */ - del(): T; + del(path: Path): { [key: string]: any }; - /*======== Has =========*/ - /** - * @see objectPath.ensureExists - */ - has(path: IPath): boolean; /** * @see objectPath.has */ - has(): boolean; + has(path: Path): boolean; - /*======== Get =========*/ - /** - * @see objectPath.ensureExists - */ - get(path: IPath, defaultValue?: TResult): TResult; /** * @see objectPath.get */ - get(): T; + get(path: Path): any; + get(path: Path, defaultValue: TResult): TResult; - /*======== Set =========*/ - /** - * @see objectPath.ensureExists - */ - set(path: IPath, value: any, doNotReplace?:boolean): TExisting; /** * @see objectPath.set */ - set(): T; + set(path: Path, value: TResult, doNotReplace?: boolean): TResult | undefined; - /*======== Push =========*/ - /** - * @see objectPath.ensureExists - */ - push(path: IPath, ...args:any[]):void; /** * @see objectPath.push */ - push():void; + push(path: Path, ...items: any[]): void; - /*======== Coalesce =========*/ /** - * @see objectPath.ensureExists + * @see objectPath.coalesce */ - coalesce(paths: IMultiArray, defaultValue?: TResult):TResult; + coalesce(paths: Path | Path[], defaultValue: TResult): TResult; + coalesce(paths: Path | Path[], defaultValue?: TResult): TResult | undefined; - /*======== Empty =========*/ - /** - * @see objectPath.ensureExists - */ - empty(path: IPath):T; /** * @see objectPath.empty */ - empty():T; + empty(path: Path): any; - /*======== EnsureExists =========*/ /** * @see objectPath.ensureExists */ - ensureExists(path: IPath, value: any):TExisting; - /** - * @see objectPath.ensureExists - */ - ensureExists(): T; + ensureExists(path: Path, defaultValue: TResult): TResult; + ensureExists(path: Path, defaultValue?: TResult): TResult | undefined; - /*======== Insert =========*/ /** * @see objectPath.insert */ - insert(path: IPath, value: any, at?: number):void; + insert(path: Path, value: any, at?: number): void; } } -// browser version -declare module 'objectPath' { - export = objectPath; -} - -// node version -declare module 'object-path' { - export = objectPath; -} +export = objectPath; diff --git a/types/object-path/object-path-tests.ts b/types/object-path/object-path-tests.ts index 4516b336a8..0515af157a 100644 --- a/types/object-path/object-path-tests.ts +++ b/types/object-path/object-path-tests.ts @@ -1,111 +1,57 @@ +import objectPath = require('object-path'); - -import ObjectPath = require('object-path'); - -var - object = { +const object = { one: 1, two: { - three: 3, - four: ['4'] - } - }, - array: any[] = [], - Null:any = null; + three: 3, + four: ['4'], + }, +}; -var obj = ObjectPath(object); +objectPath.get(object, []); +objectPath.get(object, [1, 2]); +objectPath.get(object, [1, '2']); +objectPath.get(object, 1); +objectPath.get(object, '1'); -obj.del(array); -obj.coalesce([1,2]); -obj.ensureExists('1.2', 1); -obj.push(1, 'value'); -obj.get(array); -obj.set(array, 'value'); -obj.insert(1, 10); +objectPath.del(object, 'a'); // $ExpectType { [key: string]: any; } +objectPath.has(object, 'a'); // $ExpectType boolean +objectPath.get(object, 'a'); // $ExpectType any +objectPath.get(object, 'a', 1); // $ExpectType 1 +objectPath.set(object, 'a', 1); // $ExpectType 1 | undefined +objectPath.set(object, 'a', 1, true); // $ExpectType 1 | undefined +objectPath.push(object, 'a', 1, 2); // $ExpectType void +objectPath.coalesce(object, 'a', 1); // $ExpectType 1 +objectPath.coalesce(object, 'a'); // $ExpectType any +objectPath.coalesce(object, [['a']]); // $ExpectType any +objectPath.coalesce(object, 'a'); // $ExpectType number | undefined +objectPath.empty(object, 'a'); // $ExpectType any +objectPath.ensureExists(object, 'a', 1); // $ExpectType 1 +objectPath.ensureExists(object, 'a'); // $ExpectType any +objectPath.ensureExists(object, 'a'); // $ExpectType number | undefined +objectPath.insert(object, 'a', 1); // $ExpectType void +objectPath.insert(object, 'a', 1, 2); // $ExpectType void -objectPath.del(object, array) === object; -objectPath.del(object, [1,2]) === object; -objectPath.del(object, [1,'2']) === object; -objectPath.del(object, 1) === object; -objectPath.del(object, '1') === object; -objectPath.del(object) === object; -obj.del() === object; +const obj = objectPath(object); -objectPath.has(object, ['1','2','3']) === true; -objectPath.has(object, ['1.2.3']) === false; -objectPath.has(object, [1,2,3]) === true; -objectPath.has(object, [1,'2',3]) === true; -objectPath.has(object, 1) === false; -objectPath.has(object, '1') === false; -objectPath.has() === false; +obj.del('a'); // $ExpectType { [key: string]: any; } +obj.has('a'); // $ExpectType boolean +obj.get('a'); // $ExpectType any +obj.get('a', 1); // $ExpectType 1 +obj.set('a', 1); // $ExpectType 1 | undefined +obj.set('a', 1, true); // $ExpectType 1 | undefined +obj.push('a', 1, 2); // $ExpectType void +obj.coalesce('a', 1); // $ExpectType 1 +obj.coalesce('a'); // $ExpectType any +obj.coalesce([['a']]); // $ExpectType any +obj.coalesce('a'); // $ExpectType number | undefined +obj.empty('a'); // $ExpectType any +obj.ensureExists('a', 1); // $ExpectType 1 +obj.ensureExists('a'); // $ExpectType any +obj.ensureExists('a'); // $ExpectType number | undefined +obj.insert('a', 1); // $ExpectType void +obj.insert('a', 1, 2); // $ExpectType void -objectPath.del() === void 0; -objectPath.del(object, ['1','2','3']); -objectPath.del(object, [1,2,3]); -objectPath.del(object, [1,'2',3]); -objectPath.del(object, 1); -objectPath.del(object, 'one').one === 1; -obj.del('one').one === 1; - -objectPath.coalesce(object, ['1','2']) === void 0; -objectPath.coalesce(object, ['1',['2','1']]) === void 0; -objectPath.coalesce(object, ['1',['2','1']], 1) === 1; -objectPath.coalesce(object, [1,1], 1) === 1; -objectPath.coalesce(object, [1,'1'], 1) === 1; -objectPath.coalesce(object, [1,[1,1],'1',[1,'1']], 1) === 1; -obj.coalesce([1,[1,1],'1',['1',1]], 1) === 1; - -objectPath.ensureExists(object, '1.2', 2); -objectPath.ensureExists(object, 1, 2); -objectPath.ensureExists(object, [1,2], 2); -objectPath.ensureExists(object, ['1','2'], 2); -objectPath.ensureExists(object, ['1',2], 2); -objectPath.ensureExists(object, ['1','2'], 2) === 3; -objectPath.ensureExists(object, ['1','2'], 2) === [[]]; -obj.ensureExists(['1','2'], 2) === [[]]; - -objectPath.push(object, 1, 1,2,3,4); -objectPath.push(object, 1, 1,'2', 3, false); -objectPath.push(object, 'one.four', 1,'2', 3, false); -objectPath.push(object, ['one','two'], [1,'2', 3, false]); -objectPath.push(object, [1, 'two'], [1,'2', 3, false]); -obj.push(['one','two'], [1,'2', 3, false]); -obj.push(['one', 2], [1,'2', 3, false]); - -objectPath.get(array) === array; -objectPath.get(Null) === Null; -objectPath.get() === void 0; -objectPath.get(object, 'one') === 1; -objectPath.get(object, ['two','three']) === 3; -objectPath.get(object, ['three'], 3) === 3; -objectPath.get(object, 'three', 3) === 3; -objectPath.get(object, 0, 3) === 3; -objectPath.get(object, 0, '3') === '3'; -objectPath.get(object, 0, ['1','2']) === ['1','2']; -objectPath.get(object, 0) === 10; -objectPath.get(object, 0) === 10; -obj.get(0, 10) === 10; - -objectPath.set(object, '1.2', true); -objectPath.set(object, ['1','2'], true); -objectPath.set(object, [1, 2], true); -objectPath.set(object, [1, '2'], true); -objectPath.set(object, '1.2', true, true); -objectPath.set(object, '1.2', true, false); -objectPath.set(object, '1.2', true, false) === ['string']; -objectPath.set(object, '1.2', true, false) === object; -obj.set('1.2', true, false) === object; -obj.set(['1','2'], true, false) === object; -obj.set(['1', 2], true, false) === object; - -objectPath.insert(object, '1.2', 1); -objectPath.insert(object, ['1','2'], 1); -objectPath.insert(object, 1, 1); -objectPath.insert(object, [1,2], 1); -objectPath.insert(object, '1.2', 1, 2); -objectPath.insert(object, ['1.2'], 1, 6); -objectPath.insert(object, ['1',2], 1, 6); -obj.insert(['1.2'], 1, 6); -obj.insert(1, 1, 6); -obj.insert(['1',1], 1, 6); -obj.insert('1', 1, 6); \ No newline at end of file +objectPath.withInheritedProps; // $ExpectType ObjectPathStatic +objectPath.create(); // $ExpectType ObjectPathStatic +objectPath.create({ includeInheritedProps: true }); // $ExpectType ObjectPathStatic diff --git a/types/object-path/tsconfig.json b/types/object-path/tsconfig.json index 14192cc5b0..14d40fa370 100644 --- a/types/object-path/tsconfig.json +++ b/types/object-path/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -20,4 +20,4 @@ "index.d.ts", "object-path-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/object-path/tslint.json b/types/object-path/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/object-path/tslint.json +++ b/types/object-path/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" } diff --git a/types/one-time/index.d.ts b/types/one-time/index.d.ts new file mode 100644 index 0000000000..755cf03f3e --- /dev/null +++ b/types/one-time/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for one-time 0.0 +// Project: https://github.com/unshiftio/one-time +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = oneTime; + +declare function oneTime(fn: TFn): TFn; // tslint:disable-line:ban-types diff --git a/types/one-time/one-time-tests.ts b/types/one-time/one-time-tests.ts new file mode 100644 index 0000000000..e95e0918c8 --- /dev/null +++ b/types/one-time/one-time-tests.ts @@ -0,0 +1,7 @@ +import one = require('one-time'); + +const fn = (foo: boolean) => { + return 'bar'; +}; + +one(fn); // $ExpectType (foo: boolean) => string diff --git a/types/one-time/tsconfig.json b/types/one-time/tsconfig.json new file mode 100644 index 0000000000..e81fac558c --- /dev/null +++ b/types/one-time/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "one-time-tests.ts" + ] +} diff --git a/types/one-time/tslint.json b/types/one-time/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/one-time/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/openpgp/index.d.ts b/types/openpgp/index.d.ts index edbe0eb77c..d564c6df6d 100644 --- a/types/openpgp/index.d.ts +++ b/types/openpgp/index.d.ts @@ -4,6 +4,7 @@ // Errietta Kostala // Daniel Montesinos // Carlos Villavicencio +// Eric Camellini // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.2 @@ -27,6 +28,7 @@ export interface EncryptOptions { sessionKey?: SessionKey, compression?: enums.compression, armor?: boolean, + streaming?: 'web' | 'node' | false detached?: boolean, signature?: Signature, returnSessionKey?: boolean, @@ -39,6 +41,8 @@ export interface EncryptOptions { export interface EncryptedMessage { data?: string, message?: message.Message, + signature?: string | ReadableStream | Signature // TODO add NodeStream + sessionKey?: SessionKey } export interface DecryptOptions { @@ -48,17 +52,35 @@ export interface DecryptOptions { sessionKeys?: SessionKey | SessionKey[], publicKeys?: key.Key | key.Key[], format?: string, + streaming?: 'web' | 'node' | false, signature?: Signature, date?: Date, } +export interface SignOptions { + message: message.Message, + privateKeys?: key.Key | key.Key[], + armor?: boolean, + streaming?: 'web' | 'node' | false, + detached?: boolean + date?: Date, + fromUserIds?: UserId[] +} + +export interface SignedMessage { + signature?: string | ReadableStream | Signature, // TODO add NodeStream + data?: string | ReadableStream, // TODO add NodeStream + message?: message.Message +} + export interface KeyContainer { key: key.Key, } export interface KeyPair extends KeyContainer { privateKeyArmored: string, - publicKeyArmored: string + publicKeyArmored: string, + revocationCertificate: string } export interface KeyOptions { @@ -77,13 +99,27 @@ export interface Keyid { export interface Signature { keyid: Keyid, - valid: boolean + valid: boolean, + verified?: boolean +} + +export interface VerifyOptions { + message: message.Message, + publicKeys: key.Key | key.Key[], + streaming?: 'web' | 'node' | false, + signature?: Signature, + date?: Date } export interface VerifiedMessage { - data: Uint8Array | string, + data: Uint8Array | string | ReadableStream, // TODO add NodeStream signatures: Array, - filename: string, +} + +export interface DecryptedMessage { + data: Uint8Array | string | ReadableStream, // TODO add NodeStream + signatures: Array, + filename: string } export interface OpenPGPWorker { @@ -98,7 +134,7 @@ export interface WorkerOptions { path?: string, n?: number, workers?: OpenPGPWorker[], - config?: any, + config?: any } export class AsyncProxy { @@ -140,16 +176,23 @@ export function destroyWorker(): void; * @param {Object} sessionKey (optional) session key in the form: { data:Uint8Array, algorithm:String } * @param {module:enums.compression} compression (optional) which compression algorithm to compress the message with, defaults to what is specified in config * @param {Boolean} armor (optional) if the return values should be ascii armored or the message/signature objects + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. * @param {Boolean} detached (optional) if the signature should be detached (if true, signature will be added to returned object) * @param {Signature} signature (optional) a detached signature to add to the encrypted message * @param {Boolean} returnSessionKey (optional) if the unencrypted session key should be added to returned object * @param {Boolean} wildcard (optional) use a key ID of 0 instead of the public key IDs - * @param {Date} date (optional) override the creation date of the message and the message signature + * @param {Date} date (optional) override the creation date of the message signature * @param {Object} fromUserId (optional) user ID to sign with, e.g. { name:'Steve Sender', email:'steve@openpgp.org' } * @param {Object} toUserId (optional) user ID to encrypt for, e.g. { name:'Robert Receiver', email:'robert@openpgp.org' } - * @returns {Promise} encrypted (and optionally signed message) in the form: - * {data: ASCII armored message if 'armor' is true, - * message: full Message object if 'armor' is false, signature: detached signature if 'detached' is true} + * @returns {Promise} Object containing encrypted (and optionally signed) message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if `armor` was true, the default) + * message: Message, (if `armor` was false) + * signature: String|ReadableStream|NodeStream, (if `detached` was true and `armor` was true) + * signature: Signature (if `detached` was true and `armor` was false) + * sessionKey: { data, algorithm, aeadAlgorithm } (if `returnSessionKey` was true) + * } * @async * @static */ @@ -164,14 +207,79 @@ export function encrypt(options: EncryptOptions): Promise; * @param {Object|Array} sessionKeys (optional) session keys in the form: { data:Uint8Array, algorithm:String } * @param {Key|Array} publicKeys (optional) array of public keys or single key, to verify signatures * @param {String} format (optional) return data format either as 'utf8' or 'binary' + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. * @param {Signature} signature (optional) detached signature for verification * @param {Date} date (optional) use the given date for verification instead of the current time - * @returns {Promise} decrypted and verified message in the form: - * { data:Uint8Array|String, filename:String, signatures:[{ keyid:String, valid:Boolean }] } + * @returns {Promise} Object containing decrypted and verified message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if format was 'utf8', the default) + * data: Uint8Array|ReadableStream|NodeStream, (if format was 'binary') + * filename: String, + * signatures: [ + * { + * keyid: module:type/keyid, + * verified: Promise, + * valid: Boolean (if streaming was false) + * }, ... + * ] + * } * @async * @static */ -export function decrypt(options: DecryptOptions): Promise; +export function decrypt(options: DecryptOptions): Promise; + +/** + * Signs a cleartext message. + * @param {CleartextMessage|Message} message (cleartext) message to be signed + * @param {Key|Array} privateKeys array of keys or single key with decrypted secret key data to sign cleartext + * @param {Boolean} armor (optional) if the return value should be ascii armored or the message object + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. + * @param {Boolean} detached (optional) if the return value should contain a detached signature + * @param {Date} date (optional) override the creation date of the signature + * @param {Array} fromUserIds (optional) array of user IDs to sign with, one per key in `privateKeys`, e.g. [{ name:'Steve Sender', email:'steve@openpgp.org' }] + * @returns {Promise} Object containing signed message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if `armor` was true, the default) + * message: Message (if `armor` was false) + * } + * + * Or, if `detached` was true: + * + * { + * signature: String|ReadableStream|NodeStream, (if `armor` was true, the default) + * signature: Signature (if `armor` was false) + * } + * @async + * @static + */ +export function sign(options: SignOptions): Promise; + +/** + * Verifies signatures of cleartext signed message + * @param {Key|Array} publicKeys array of publicKeys or single key, to verify signatures + * @param {CleartextMessage|Message} message (cleartext) message object with signatures + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. + * @param {Signature} signature (optional) detached signature for verification + * @param {Date} date (optional) use the given date for verification instead of the current time + * @returns {Promise} Object containing verified message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if `message` was a CleartextMessage) + * data: Uint8Array|ReadableStream|NodeStream, (if `message` was a Message) + * signatures: [ + * { + * keyid: module:type/keyid, + * verified: Promise, + * valid: Boolean (if `streaming` was false) + * }, ... + * ] + * } + * @async + * @static + */ +export function verify(options: VerifyOptions): Promise; /** * Generates a new OpenPGP key pair. Supports RSA and ECC keys. Primary and subkey will be of same type. @@ -186,7 +294,7 @@ export function decrypt(options: DecryptOptions): Promise; * @param {Array} subkeys (optional) options for each subkey, default to main key options. e.g. [{sign: true, passphrase: '123'}] * sign parameter defaults to false, and indicates whether the subkey should sign rather than encrypt * @returns {Promise} The generated key object in the form: - * { key:Key, privateKeyArmored:String, publicKeyArmored:String } + * { key:Key, privateKeyArmored:String, publicKeyArmored:String, revocationCertificate:String } * @async * @static */ @@ -198,8 +306,9 @@ export function generateKey(options: KeyOptions): Promise; * @param {Array} userIds array of user IDs e.g. [{ name:'Phil Zimmermann', email:'phil@openpgp.org' }] * @param {String} passphrase (optional) The passphrase used to encrypt the resulting private key * @param {Number} keyExpirationTime (optional) The number of seconds after the key creation time that the key expires + * @param {Boolean} revocationCertificate (optional) Whether the returned object should include a revocation certificate to revoke the public key * @returns {Promise} The generated key object in the form: - * { key:Key, privateKeyArmored:String, publicKeyArmored:String } + * { key:Key, privateKeyArmored:String, publicKeyArmored:String, revocationCertificate:String } * @async * @static */ @@ -208,6 +317,29 @@ export function reformatKey(options: { userIds?: UserId[], passphrase?: string, keyExpirationTime?: number, + revocationCertificate?: boolean +}): Promise; + +/** + * Revokes a key. Requires either a private key or a revocation certificate. + * If a revocation certificate is passed, the reasonForRevocation parameters will be ignored. + * @param {Key} key (optional) public or private key to revoke + * @param {String} revocationCertificate (optional) revocation certificate to revoke the key with + * @param {Object} reasonForRevocation (optional) object indicating the reason for revocation + * @param {module:enums.reasonForRevocation} reasonForRevocation.flag (optional) flag indicating the reason for revocation + * @param {String} reasonForRevocation.string (optional) string explaining the reason for revocation + * @returns {Promise} The revoked key object in the form: + * { privateKey:Key, privateKeyArmored:String, publicKey:Key, publicKeyArmored:String } + * (if private key is passed) or { publicKey:Key, publicKeyArmored:String } (otherwise) + * @static + */ +export function revokeKey(options: { + key?: key.Key, + revocationCertificate?: string + reasonForRevocation?: { + flag: enums.reasonForRevocation, + 'string': string + }, }): Promise; /** @@ -222,11 +354,20 @@ export function decryptKey(options: { passphrase?: string | string[], }): Promise; +/** + * Lock a private key with your passphrase. + * @param {Key} privateKey the private key that is to be decrypted + * @param {String|Array} passphrase the user's passphrase(s) chosen during key generation + * @returns {Promise} the locked key object in the form: { key:Key } + * @async + */ export function encryptKey(options: { privateKey: key.Key, - passphrase?: string + passphrase?: string | string[], }): Promise; +// TODO add typings for encryptSessionKey and decryptSessionKeys + export namespace armor { /** Armor an OpenPGP binary packet block @@ -485,6 +626,14 @@ export namespace enums { valid, no_self_cert } + + enum reasonForRevocation { + no_reason, + key_superseded, + key_compromised, + key_retired, + userid_invalid + } } export namespace key { diff --git a/types/openpgp/openpgp-tests.ts b/types/openpgp/openpgp-tests.ts index 30f9adbc8b..19e305cb26 100644 --- a/types/openpgp/openpgp-tests.ts +++ b/types/openpgp/openpgp-tests.ts @@ -110,6 +110,31 @@ openpgp.initWorker({ path:'openpgp.worker.js' }); })(); +(async () => { + const publicKey = (await openpgp.key.readArmored(spubkey)) + const privateKey = (await openpgp.key.readArmored(sprivkey)) + const signOptions: openpgp.SignOptions = { + message: openpgp.message.fromText('hello world'), + privateKeys: privateKey.keys, + detached: true + }; + + const signed = await openpgp.sign(signOptions); + + const signature = signed.signature as openpgp.Signature; + const message = signed.message; + + const verifyOptions: openpgp.VerifyOptions = { + message, + signature, + publicKeys: publicKey.keys + }; + + let verified = await openpgp.verify(verifyOptions); + + return verified.signatures[0].valid; +})(); + // Open PGP Tests diff --git a/types/openpgp/ts3.2/index.d.ts b/types/openpgp/ts3.2/index.d.ts index 0bf040bc17..428f785dbe 100644 --- a/types/openpgp/ts3.2/index.d.ts +++ b/types/openpgp/ts3.2/index.d.ts @@ -4,6 +4,7 @@ // Errietta Kostala // Daniel Montesinos // Carlos Villavicencio +// Eric Camellini // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export as namespace openpgp; @@ -26,6 +27,7 @@ export interface EncryptOptions { sessionKey?: SessionKey, compression?: enums.compression, armor?: boolean, + streaming?: 'web' | 'node' | false detached?: boolean, signature?: Signature, returnSessionKey?: boolean, @@ -38,6 +40,8 @@ export interface EncryptOptions { export interface EncryptedMessage { data?: string, message?: message.Message, + signature?: string | ReadableStream | Signature // TODO add NodeStream + sessionKey?: SessionKey } export interface DecryptOptions { @@ -47,17 +51,35 @@ export interface DecryptOptions { sessionKeys?: SessionKey | SessionKey[], publicKeys?: key.Key | key.Key[], format?: string, + streaming?: 'web' | 'node' | false, signature?: Signature, date?: Date, } +export interface SignOptions { + message: message.Message, + privateKeys?: key.Key | key.Key[], + armor?: boolean, + streaming?: 'web' | 'node' | false, + detached?: boolean + date?: Date, + fromUserIds?: UserId[] +} + +export interface SignedMessage { + signature?: string | ReadableStream | Signature, // TODO add NodeStream + data?: string | ReadableStream, // TODO add NodeStream + message?: message.Message +} + export interface KeyContainer { key: key.Key, } export interface KeyPair extends KeyContainer { privateKeyArmored: string, - publicKeyArmored: string + publicKeyArmored: string, + revocationCertificate: string } export interface KeyOptions { @@ -76,13 +98,27 @@ export interface Keyid { export interface Signature { keyid: Keyid, - valid: boolean + valid: boolean, + verified?: boolean +} + +export interface VerifyOptions { + message: message.Message, + publicKeys: key.Key | key.Key[], + streaming?: 'web' | 'node' | false, + signature?: Signature, + date?: Date } export interface VerifiedMessage { - data: Uint8Array | string, + data: Uint8Array | string | ReadableStream | ReadableStream, // TODO add NodeStream signatures: Array, - filename: string, +} + +export interface DecryptedMessage { + data: Uint8Array | string | ReadableStream | ReadableStream, // TODO add NodeStream + signatures: Array, + filename: string } export interface OpenPGPWorker { @@ -97,7 +133,7 @@ export interface WorkerOptions { path?: string, n?: number, workers?: OpenPGPWorker[], - config?: any, + config?: any } export class AsyncProxy { @@ -139,16 +175,23 @@ export function destroyWorker(): void; * @param {Object} sessionKey (optional) session key in the form: { data:Uint8Array, algorithm:String } * @param {module:enums.compression} compression (optional) which compression algorithm to compress the message with, defaults to what is specified in config * @param {Boolean} armor (optional) if the return values should be ascii armored or the message/signature objects + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. * @param {Boolean} detached (optional) if the signature should be detached (if true, signature will be added to returned object) * @param {Signature} signature (optional) a detached signature to add to the encrypted message * @param {Boolean} returnSessionKey (optional) if the unencrypted session key should be added to returned object * @param {Boolean} wildcard (optional) use a key ID of 0 instead of the public key IDs - * @param {Date} date (optional) override the creation date of the message and the message signature + * @param {Date} date (optional) override the creation date of the message signature * @param {Object} fromUserId (optional) user ID to sign with, e.g. { name:'Steve Sender', email:'steve@openpgp.org' } * @param {Object} toUserId (optional) user ID to encrypt for, e.g. { name:'Robert Receiver', email:'robert@openpgp.org' } - * @returns {Promise} encrypted (and optionally signed message) in the form: - * {data: ASCII armored message if 'armor' is true, - * message: full Message object if 'armor' is false, signature: detached signature if 'detached' is true} + * @returns {Promise} Object containing encrypted (and optionally signed) message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if `armor` was true, the default) + * message: Message, (if `armor` was false) + * signature: String|ReadableStream|NodeStream, (if `detached` was true and `armor` was true) + * signature: Signature (if `detached` was true and `armor` was false) + * sessionKey: { data, algorithm, aeadAlgorithm } (if `returnSessionKey` was true) + * } * @async * @static */ @@ -163,14 +206,79 @@ export function encrypt(options: EncryptOptions): Promise; * @param {Object|Array} sessionKeys (optional) session keys in the form: { data:Uint8Array, algorithm:String } * @param {Key|Array} publicKeys (optional) array of public keys or single key, to verify signatures * @param {String} format (optional) return data format either as 'utf8' or 'binary' + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. * @param {Signature} signature (optional) detached signature for verification * @param {Date} date (optional) use the given date for verification instead of the current time - * @returns {Promise} decrypted and verified message in the form: - * { data:Uint8Array|String, filename:String, signatures:[{ keyid:String, valid:Boolean }] } + * @returns {Promise} Object containing decrypted and verified message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if format was 'utf8', the default) + * data: Uint8Array|ReadableStream|NodeStream, (if format was 'binary') + * filename: String, + * signatures: [ + * { + * keyid: module:type/keyid, + * verified: Promise, + * valid: Boolean (if streaming was false) + * }, ... + * ] + * } * @async * @static */ -export function decrypt(options: DecryptOptions): Promise; +export function decrypt(options: DecryptOptions): Promise; + +/** + * Signs a cleartext message. + * @param {CleartextMessage|Message} message (cleartext) message to be signed + * @param {Key|Array} privateKeys array of keys or single key with decrypted secret key data to sign cleartext + * @param {Boolean} armor (optional) if the return value should be ascii armored or the message object + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. + * @param {Boolean} detached (optional) if the return value should contain a detached signature + * @param {Date} date (optional) override the creation date of the signature + * @param {Array} fromUserIds (optional) array of user IDs to sign with, one per key in `privateKeys`, e.g. [{ name:'Steve Sender', email:'steve@openpgp.org' }] + * @returns {Promise} Object containing signed message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if `armor` was true, the default) + * message: Message (if `armor` was false) + * } + * + * Or, if `detached` was true: + * + * { + * signature: String|ReadableStream|NodeStream, (if `armor` was true, the default) + * signature: Signature (if `armor` was false) + * } + * @async + * @static + */ +export function sign(options: SignOptions): Promise; + +/** + * Verifies signatures of cleartext signed message + * @param {Key|Array} publicKeys array of publicKeys or single key, to verify signatures + * @param {CleartextMessage|Message} message (cleartext) message object with signatures + * @param {'web'|'node'|false} streaming (optional) whether to return data as a stream. Defaults to the type of stream `message` was created from, if any. + * @param {Signature} signature (optional) detached signature for verification + * @param {Date} date (optional) use the given date for verification instead of the current time + * @returns {Promise} Object containing verified message in the form: + * + * { + * data: String|ReadableStream|NodeStream, (if `message` was a CleartextMessage) + * data: Uint8Array|ReadableStream|NodeStream, (if `message` was a Message) + * signatures: [ + * { + * keyid: module:type/keyid, + * verified: Promise, + * valid: Boolean (if `streaming` was false) + * }, ... + * ] + * } + * @async + * @static + */ +export function verify(options: VerifyOptions): Promise; /** * Generates a new OpenPGP key pair. Supports RSA and ECC keys. Primary and subkey will be of same type. @@ -185,7 +293,7 @@ export function decrypt(options: DecryptOptions): Promise; * @param {Array} subkeys (optional) options for each subkey, default to main key options. e.g. [{sign: true, passphrase: '123'}] * sign parameter defaults to false, and indicates whether the subkey should sign rather than encrypt * @returns {Promise} The generated key object in the form: - * { key:Key, privateKeyArmored:String, publicKeyArmored:String } + * { key:Key, privateKeyArmored:String, publicKeyArmored:String, revocationCertificate:String } * @async * @static */ @@ -197,8 +305,9 @@ export function generateKey(options: KeyOptions): Promise; * @param {Array} userIds array of user IDs e.g. [{ name:'Phil Zimmermann', email:'phil@openpgp.org' }] * @param {String} passphrase (optional) The passphrase used to encrypt the resulting private key * @param {Number} keyExpirationTime (optional) The number of seconds after the key creation time that the key expires + * @param {Boolean} revocationCertificate (optional) Whether the returned object should include a revocation certificate to revoke the public key * @returns {Promise} The generated key object in the form: - * { key:Key, privateKeyArmored:String, publicKeyArmored:String } + * { key:Key, privateKeyArmored:String, publicKeyArmored:String, revocationCertificate:String } * @async * @static */ @@ -207,6 +316,29 @@ export function reformatKey(options: { userIds?: UserId[], passphrase?: string, keyExpirationTime?: number, + revocationCertificate?: boolean +}): Promise; + +/** + * Revokes a key. Requires either a private key or a revocation certificate. + * If a revocation certificate is passed, the reasonForRevocation parameters will be ignored. + * @param {Key} key (optional) public or private key to revoke + * @param {String} revocationCertificate (optional) revocation certificate to revoke the key with + * @param {Object} reasonForRevocation (optional) object indicating the reason for revocation + * @param {module:enums.reasonForRevocation} reasonForRevocation.flag (optional) flag indicating the reason for revocation + * @param {String} reasonForRevocation.string (optional) string explaining the reason for revocation + * @returns {Promise} The revoked key object in the form: + * { privateKey:Key, privateKeyArmored:String, publicKey:Key, publicKeyArmored:String } + * (if private key is passed) or { publicKey:Key, publicKeyArmored:String } (otherwise) + * @static + */ +export function revokeKey(options: { + key?: key.Key, + revocationCertificate?: string + reasonForRevocation?: { + flag: enums.reasonForRevocation, + 'string': string + }, }): Promise; /** @@ -221,11 +353,20 @@ export function decryptKey(options: { passphrase?: string | string[], }): Promise; +/** + * Lock a private key with your passphrase. + * @param {Key} privateKey the private key that is to be decrypted + * @param {String|Array} passphrase the user's passphrase(s) chosen during key generation + * @returns {Promise} the locked key object in the form: { key:Key } + * @async + */ export function encryptKey(options: { privateKey: key.Key, - passphrase?: string + passphrase?: string | string[], }): Promise; +// TODO add typings for encryptSessionKey and decryptSessionKeys + export namespace armor { /** Armor an OpenPGP binary packet block @@ -484,6 +625,14 @@ export namespace enums { valid, no_self_cert } + + enum reasonForRevocation { + no_reason, + key_superseded, + key_compromised, + key_retired, + userid_invalid + } } export namespace key { diff --git a/types/openpgp/ts3.2/openpgp-tests.ts b/types/openpgp/ts3.2/openpgp-tests.ts index 30f9adbc8b..7dffc0109b 100644 --- a/types/openpgp/ts3.2/openpgp-tests.ts +++ b/types/openpgp/ts3.2/openpgp-tests.ts @@ -109,6 +109,30 @@ openpgp.initWorker({ path:'openpgp.worker.js' }); return plain.data; })(); +(async () => { + const publicKey = (await openpgp.key.readArmored(spubkey)) + const privateKey = (await openpgp.key.readArmored(sprivkey)) + const signOptions: openpgp.SignOptions = { + message: openpgp.message.fromText('hello world'), + privateKeys: privateKey.keys, + detached: true + }; + + const signed = await openpgp.sign(signOptions); + + const signature = signed.signature as openpgp.Signature; + const message = signed.message; + + const verifyOptions: openpgp.VerifyOptions = { + message, + signature, + publicKeys: publicKey.keys + }; + + let verified = await openpgp.verify(verifyOptions); + + return verified.signatures[0].valid; +})(); // Open PGP Tests diff --git a/types/parse-passwd/index.d.ts b/types/parse-passwd/index.d.ts new file mode 100644 index 0000000000..9f74d078ce --- /dev/null +++ b/types/parse-passwd/index.d.ts @@ -0,0 +1,20 @@ +// Type definitions for parse-passwd 1.0 +// Project: https://github.com/doowb/parse-passwd +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = parsePasswd; + +declare function parsePasswd(passwdText: string): parsePasswd.PasswdEntry[]; + +declare namespace parsePasswd { + interface PasswdEntry { + username: string; + password: string; + uid: string; + gid: string; + gecos: string; + homedir: string; + shell: string; + } +} diff --git a/types/parse-passwd/parse-passwd-tests.ts b/types/parse-passwd/parse-passwd-tests.ts new file mode 100644 index 0000000000..6eb6eeb32e --- /dev/null +++ b/types/parse-passwd/parse-passwd-tests.ts @@ -0,0 +1,14 @@ +import parse = require('parse-passwd'); + +const entries = parse('doowb:*:123:123:Brian Woodward:/Users/doowb:/bin/bash'); +entries; // $ExpectType PasswdEntry[] + +const entry = entries[0]; + +entry.username; // $ExpectType string +entry.password; // $ExpectType string +entry.uid; // $ExpectType string +entry.gid; // $ExpectType string +entry.gecos; // $ExpectType string +entry.homedir; // $ExpectType string +entry.shell; // $ExpectType string diff --git a/types/parse-passwd/tsconfig.json b/types/parse-passwd/tsconfig.json new file mode 100644 index 0000000000..2ed7a0a913 --- /dev/null +++ b/types/parse-passwd/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "parse-passwd-tests.ts" + ] +} diff --git a/types/parse-passwd/tslint.json b/types/parse-passwd/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/parse-passwd/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/pem/index.d.ts b/types/pem/index.d.ts index c6689a273f..bdfa3e1196 100644 --- a/types/pem/index.d.ts +++ b/types/pem/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/andris9/pem // Definitions by: Anthony Trinh , Ruslan Arkhipau // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// export interface ModuleConfiguration { /** @@ -135,6 +136,12 @@ export interface CertificateSubjectReadResult { emailAddress: string; } +export interface Pkcs12ReadResult { + key: string; + cert: string; + ca: string[]; +} + export type Callback = (error: any, result: T) => any; /** @@ -244,8 +251,8 @@ export function createPkcs12(key: string, certificate: string, password: string, * @param callback Callback function with an error object and {pkcs12} * @returns the result of the callback */ -export function readPkcs12(bufferOrPath: string, options: Pkcs12ReadOptions, callback: Callback<{ pkcs12: any }>): any; -export function readPkcs12(bufferOrPath: string, callback: Callback<{ pkcs12: any }>): any; +export function readPkcs12(bufferOrPath: Buffer | string, options: Pkcs12ReadOptions, callback: Callback): any; +export function readPkcs12(bufferOrPath: Buffer | string, callback: Callback): any; /** * Verifies the signing chain of the passed certificate diff --git a/types/pem/pem-tests.ts b/types/pem/pem-tests.ts index fe409b6560..6841b568d7 100644 --- a/types/pem/pem-tests.ts +++ b/types/pem/pem-tests.ts @@ -1,4 +1,5 @@ import * as pem from 'pem'; +import * as fs from 'fs'; const tests = { 'Create default sized dhparam key': (test: any) => { @@ -557,8 +558,21 @@ const tests = { test.ok(pkcs12.pkcs12); // test.ok(fs.readdirSync('./tmp').length === 0); + const pkcs12Buffer = new Buffer(pkcs12.pkcs12); - pem.readPkcs12(pkcs12.pkcs12, (error: any, keystore: any) => { + pem.readPkcs12(pkcs12Buffer, (error: any, keystore: pem.Pkcs12ReadResult) => { + test.ifError(error); + test.ok(keystore); + + test.equal(ca.certificate, keystore.ca[0]); + test.equal(cert.certificate, keystore.cert); + test.equal(cert.clientKey, keystore.key); + }); + + const pkcs12File: string = __dirname + '/test.pkcs12'; + fs.writeFileSync(pkcs12File, pkcs12Buffer); + + pem.readPkcs12(pkcs12File, (error: any, keystore: pem.Pkcs12ReadResult) => { test.ifError(error); test.ok(keystore); diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index ad10e12bbf..4832a13fdd 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -565,6 +565,8 @@ declare namespace R { /** * Makes a shallow clone of an object, setting or overriding the specified property with the given value. */ + assoc(__: Placeholder, val: T, obj: U): (prop: K) => Record & U; + assoc(prop: K, __: Placeholder, obj: U): (val: T) => Record & U; assoc(prop: K, val: T, obj: U): Record & U; assoc(prop: K, val: T): (obj: U) => Record & U; assoc(prop: K): (val: T, obj: U) => Record & U; @@ -573,6 +575,8 @@ declare namespace R { * Makes a shallow clone of an object, setting or overriding the nodes required to create the given path, and * placing the specific value at the tail end of that path. */ + assocPath(__: Placeholder, val: T, obj: U): (path: Path) => U; + assocPath(path: Path, __: Placeholder, obj: U): (val: T) => U; assocPath(path: Path, val: T, obj: U): U; assocPath(path: Path, val: T): (obj: U) => U; assocPath(path: Path): CurriedFunction2; @@ -2069,7 +2073,7 @@ declare namespace R { /** * Returns a new list by plucking the same named property off all objects in the list supplied. */ - pluck

(p: P, list: ReadonlyArray>): T[]; + pluck(p: K, list: ReadonlyArray): Array; pluck(p: number, list: ReadonlyArray<{ [k: number]: T }>): T[]; pluck

(p: P): (list: ReadonlyArray>) => T[]; pluck(p: number): (list: ReadonlyArray<{ [k: number]: T }>) => T[]; @@ -2095,6 +2099,7 @@ declare namespace R { /** * Returns a function that when supplied an object returns the indicated property of that object, if it exists. */ + prop(__: Placeholder, obj: T):

(p: P) => T[P]; prop

(p: P, obj: T): T[P]; prop

(p: P): (obj: Record) => T; prop

(p: P): (obj: Record) => T; diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 2c4c4fbfaa..362948adda 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -637,7 +637,7 @@ R.times(i, 5); /********************* * List category - ********************/ + */ () => { const lessThan2 = R.flip(R.lt)(2); const lessThan3 = R.flip(R.lt)(3); @@ -1502,6 +1502,8 @@ type Pair = KeyValuePair; const a: ABC = R.assoc("c", 3, {a: 1, b: 2}); // => {a: 1, b: 2, c: 3} const b: ABC = R.assoc("c")(3, {a: 1, b: 2}); // => {a: 1, b: 2, c: 3} const c: ABC = R.assoc("c", 3)({a: 1, b: 2}); // => {a: 1, b: 2, c: 3} + const d: ABC = R.assoc(R.__, 3, {a: 1, b: 2})("c"); // => {a: 1, b: 2, c: 3} + const e: ABC = R.assoc("c", R.__, {a: 1, b: 2})(3); // => {a: 1, b: 2, c: 3} }; () => { @@ -1519,6 +1521,8 @@ type Pair = KeyValuePair; const testPath = ["x", 0, "y"]; const testObj = {x: [{y: 2, z: 3}, {y: 4, z: 5}]}; + R.assocPath(R.__, 42, testObj)(testPath); // => {x: [{y: 42, z: 3}, {y: 4, z: 5}]} + R.assocPath(testPath, R.__, testObj)(42); // => {x: [{y: 42, z: 3}, {y: 4, z: 5}]} R.assocPath(testPath, 42, testObj); // => {x: [{y: 42, z: 3}, {y: 4, z: 5}]} R.assocPath(testPath, 42)(testObj); // => {x: [{y: 42, z: 3}, {y: 4, z: 5}]} R.assocPath(testPath)(42)(testObj); // => {x: [{y: 42, z: 3}, {y: 4, z: 5}]} @@ -1923,6 +1927,8 @@ class Rectangle { const strVal: string = R.prop('str', obj); // => 'string' const numVal: number = R.prop('num', obj); // => 5 + const strValPl: string = R.prop(R.__, obj)('str'); // => 'string' + const strValCur: string = R.prop('str')(obj); // => 'string' const numValCur: number = R.prop('num')(obj); // => 5 }; diff --git a/types/rc/index.d.ts b/types/rc/index.d.ts index 3ab9cc3a26..07bc827079 100644 --- a/types/rc/index.d.ts +++ b/types/rc/index.d.ts @@ -1,22 +1,24 @@ -// Type definitions for rc +// Type definitions for rc 1.1 // Project: https://github.com/dominictarr/rc // Definitions by: Daniel Rosenwasser +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 declare function rc( - name: string, - defaults?: any, + name: string, + defaults?: { [key: string]: any }, /** * Parsed argv object. For example, if args is `--foo bar`, then this value should be `{foo: 'bar'}` * If `argv` is `null` or `undefined`, then `rc`'s default parser will parse `process.argv`. */ - argv?: {} | null, + argv?: { [key: string]: any } | null, /** * Custom config file parser. * This function will be passed the string contents of each * discovered configuration file should return a parsed object dictionary. */ - parse?: ((content: string) => any) | null -): any; + parse?: ((content: string) => { [key: string]: any }) | null +): { [key: string]: any }; export = rc; diff --git a/types/rc/rc-tests.ts b/types/rc/rc-tests.ts index 9574bec339..81522ccd59 100644 --- a/types/rc/rc-tests.ts +++ b/types/rc/rc-tests.ts @@ -1,15 +1,15 @@ -import rc = require("rc") +import rc = require('rc'); -let confA = rc("appname1", { +const confA = rc('appname1', { port: 2468, views: { - engine: "jade" - } + engine: 'jade', + }, }); //////////////////// -let appCfg = rc("appname2", {}, null, function parse(s) { +const appCfg = rc('appname2', {}, null, function parse(s) { return JSON.parse(s.toLowerCase()); }); @@ -19,15 +19,18 @@ appCfg.config; //////////////////// -let customArgv = rc("appname3", { - option: true -}, -{ - option: false, - envOption: 24, - argv: { - remain: [], - cooked: ['--no-option', '--envOption', '24'], - original: ['--no-option', '--envOption=24'] +const customArgv = rc( + 'appname3', + { + option: true, + }, + { + option: false, + envOption: 24, + argv: { + remain: [], + cooked: ['--no-option', '--envOption', '24'], + original: ['--no-option', '--envOption=24'], + }, } -}); +); diff --git a/types/rc/tslint.json b/types/rc/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/rc/tslint.json +++ b/types/rc/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" } diff --git a/types/react-headroom/index.d.ts b/types/react-headroom/index.d.ts new file mode 100644 index 0000000000..a69b16211d --- /dev/null +++ b/types/react-headroom/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for react-headroom 2.2 +// Project: https://kyleamathews.github.io/react-headroom/ +// Definitions by: Zero Cho +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { CSSProperties, ReactNode, Component } from 'react'; + +declare class Headroom extends Component { + constructor(props: ReactHeadroomProps); +} + +export interface ReactHeadroomProps { + style?: CSSProperties; + onPin?: () => void; + onUnpin?: () => void; + onUnfix?: () => void; + upTolerance?: number; + downTolerance?: number; + disable?: boolean; + wrapperStyle?: CSSProperties; + parent?: () => any; + pinStart?: number; + calcHeightOnResize?: boolean; + disableInlineStyles?: boolean; + className?: string; + children: ReactNode; +} + +export default Headroom; diff --git a/types/react-headroom/react-headroom-tests.tsx b/types/react-headroom/react-headroom-tests.tsx new file mode 100644 index 0000000000..85afcbbbfd --- /dev/null +++ b/types/react-headroom/react-headroom-tests.tsx @@ -0,0 +1,12 @@ +import * as React from 'react'; +import Headroom from 'react-headroom'; + +class HeadroomWrapper extends React.Component { + render() { + return ( + +

This is a header

+ + ); + } +} diff --git a/types/react-headroom/tsconfig.json b/types/react-headroom/tsconfig.json new file mode 100644 index 0000000000..a7432e6c4f --- /dev/null +++ b/types/react-headroom/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "jsx": "react", + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "react-headroom-tests.tsx"] +} diff --git a/types/react-headroom/tslint.json b/types/react-headroom/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-headroom/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 3090285ecc..865a46eefa 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -7687,11 +7687,21 @@ export interface PushNotification { */ getSound(): string; + /** + * Gets the category string from the `aps` object + */ + getCategory(): string; + /** * Gets the notification's main message from the `aps` object */ getAlert(): string | Object; + /** + * Gets the content-available number from the `aps` object + */ + getContentAvailable(): number; + /** * Gets the badge count number from the `aps` object */ diff --git a/types/react-places-autocomplete/index.d.ts b/types/react-places-autocomplete/index.d.ts index e24e479be8..f4609e9ca0 100644 --- a/types/react-places-autocomplete/index.d.ts +++ b/types/react-places-autocomplete/index.d.ts @@ -1,8 +1,9 @@ // Type definitions for react-places-autocomplete 7.2 -// Project: https://github.com/kenny-hibino/react-places-autocomplete/ +// Project: https://github.com/hibiken/react-places-autocomplete/ // Definitions by: Guilherme Hübner // Andrew Makarov // Nokky Goren +// Aziz Khambati // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 // @@ -10,35 +11,26 @@ import * as React from "react"; -export interface formattedSuggestionType { - mainText: string; - secundaryText: string; +export type AutocompletePrediction = google.maps.places.AutocompletePrediction; + +export interface Suggestion { + id: string; + active: boolean; + index: number; + description: AutocompletePrediction["description"]; + placeId: AutocompletePrediction["place_id"]; + formattedSuggestion: { + mainText: AutocompletePrediction["structured_formatting"]["main_text"]; + secondaryText: AutocompletePrediction["structured_formatting"]["secondary_text"]; + }; + matchedSubstrings: AutocompletePrediction["matched_substrings"]; + terms: AutocompletePrediction["terms"]; + types: AutocompletePrediction["types"]; } export interface PropTypes { - inputProps?: { - type?: string; - name?: string; - placeholder?: string; - disabled?: boolean; - }; onError?: (status: string, clearSuggestion: () => void) => void; onSelect?: (address: string, placeID: string) => void; - renderSuggestion?: (suggestion: string, formattedSuggestion: formattedSuggestionType) => React.ReactNode; - classNames?: { - root?: string; - input?: string; - autocompleteContainer?: string; - autocompleteItem?: string; - autocompleteItemActive?: string; - }; - styles?: { - root?: React.CSSProperties; - input?: React.CSSProperties; - autocompleteContainer?: React.CSSProperties; - autocompleteItem?: React.CSSProperties; - autocompleteItemActive?: React.CSSProperties; - }; searchOptions?: { bounds?: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral; componentRestrictions?: google.maps.GeocoderComponentRestrictions; @@ -49,18 +41,44 @@ export interface PropTypes { }; value?: string; onChange?: (value: string) => void; - onBlur?: (event: React.FocusEvent) => void; debounce?: number; highlightFirstSuggestion?: boolean; - renderFooter?: () => React.ReactNode; - shouldFetchSuggestions?: (value: string) => boolean; + shouldFetchSuggestions?: boolean; + + children: (opts: Readonly<{ + loading: boolean; + suggestions: ReadonlyArray; + getInputProps: (options?: InputProps) => { + type: 'text'; + autoComplete: 'off'; + role: 'combobox'; + 'aria-autocomplete': 'list'; + 'aria-expanded': boolean; + 'aria-activedescendant': string | null; + disabled: boolean; + onKeyDown: React.KeyboardEventHandler; + onBlur: () => void; + value: string | undefined; + onChange: (ev: { target: { value: string }}) => void; + } & InputProps; + getSuggestionItemProps: (suggestion: Suggestion, options?: SuggestionProps) => { + key: number; + id: string | null; + role: 'option'; + onMouseEnter: () => void; + onMouseLeave: () => void; + onMouseDown: React.MouseEventHandler; + onMouseUp: () => void; + onTouchStart: () => void; + onTouchEnd: () => void; + onClick: (event?: Event) => void; + } & SuggestionProps; + }>) => React.ReactNode; } -export function geocodeByAddress(address: string, callback: (results: google.maps.GeocoderResult[], status: google.maps.GeocoderStatus) => void): void; export function geocodeByAddress(address: string): Promise; -export function geocodeByPlaceId(placeId: string, callback: (results: google.maps.GeocoderResult[], status: google.maps.GeocoderStatus) => void): void; export function geocodeByPlaceId(placeId: string): Promise; export function getLatLng(results: google.maps.GeocoderResult): Promise; diff --git a/types/react-places-autocomplete/react-places-autocomplete-tests.tsx b/types/react-places-autocomplete/react-places-autocomplete-tests.tsx index a7a7816d99..d2420edb6b 100644 --- a/types/react-places-autocomplete/react-places-autocomplete-tests.tsx +++ b/types/react-places-autocomplete/react-places-autocomplete-tests.tsx @@ -12,18 +12,6 @@ class Test extends React.Component { const { address, placeId } = this.state; - // Old API - geocodeByAddress(address, (results, status) => { - const latLng = getLatLng(results[0]); - console.info(latLng, status); - }); - - geocodeByPlaceId(placeId, (results, status) => { - const latLng = getLatLng(results[0]); - console.info(latLng, status); - }); - - // New API geocodeByAddress(address) .then((results) => getLatLng(results[0])) .then((latLng) => console.log('Success', latLng)) @@ -38,14 +26,22 @@ class Test extends React.Component { onChange = (address: string) => this.setState({ address }); render() { - const inputProps = { - value: this.state.address, - onChange: this.onChange, - }; - return (
- + + {({getInputProps, getSuggestionItemProps, suggestions}) => ( + <> + +
+ {suggestions.map(suggestion => ( +
+ {suggestion.description} +
+ ))} +
+ + )} +
); } diff --git a/types/react-places-autocomplete/v6/index.d.ts b/types/react-places-autocomplete/v6/index.d.ts new file mode 100644 index 0000000000..25f1907f0c --- /dev/null +++ b/types/react-places-autocomplete/v6/index.d.ts @@ -0,0 +1,71 @@ +// Type definitions for react-places-autocomplete 6.1 +// Project: https://github.com/hibiken/react-places-autocomplete/ +// Definitions by: Guilherme Hübner +// Andrew Makarov +// Nokky Goren +// Aziz Khambati +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 +// +/// + +import * as React from "react"; + +export interface formattedSuggestionType { + mainText: string; + secondaryText: string; +} + +export interface InputProps extends Pick< + React.InputHTMLAttributes, + Exclude< + keyof React.InputHTMLAttributes, + "onChange" + > +> { + value: string; + onChange: (value: string) => void; +} + +export interface PropTypes { + inputProps: InputProps; + onError?: (status: string, clearSuggestion: () => void) => void; + onSelect?: (address: string, placeID: string) => void; + renderSuggestion?: (obj: { + suggestion: string; + formattedSuggestion: formattedSuggestionType; + }) => React.ReactNode; + classNames?: { + root?: string; + input?: string; + autocompleteContainer?: string; + autocompleteItem?: string; + autocompleteItemActive?: string; + }; + styles?: { + root?: React.CSSProperties; + input?: React.CSSProperties; + autocompleteContainer?: React.CSSProperties; + autocompleteItem?: React.CSSProperties; + autocompleteItemActive?: React.CSSProperties; + }; + options?: { + bounds?: google.maps.LatLngBounds | google.maps.LatLngBoundsLiteral; + componentRestrictions?: google.maps.GeocoderComponentRestrictions; + location?: google.maps.LatLng | google.maps.LatLngLiteral; + offset?: number | string; + radius?: number | string; + types?: string[]; + }; + + debounce?: number; + highlightFirstSuggestion?: boolean; + renderFooter?: () => React.ReactNode; + shouldFetchSuggestions?: (value: string) => boolean; +} + +export function geocodeByAddress(address: string, callback: (results: google.maps.GeocoderResult[], status: google.maps.GeocoderStatus) => void): void; +export function geocodeByPlaceId(placeId: string, callback: (results: google.maps.GeocoderResult[], status: google.maps.GeocoderStatus) => void): void; +export function getLatLng(results: google.maps.GeocoderResult): Promise; + +export default class PlacesAutocomplete extends React.Component {} diff --git a/types/react-places-autocomplete/v6/react-places-autocomplete-tests.tsx b/types/react-places-autocomplete/v6/react-places-autocomplete-tests.tsx new file mode 100644 index 0000000000..9afea47154 --- /dev/null +++ b/types/react-places-autocomplete/v6/react-places-autocomplete-tests.tsx @@ -0,0 +1,44 @@ +import * as React from 'react'; +import PlacesAutocomplete, { geocodeByAddress, geocodeByPlaceId, getLatLng } from 'react-places-autocomplete'; + +class Test extends React.Component { + state = { + address: 'San Francisco, CA', + placeId: '12345', + }; + + handleFormSubmit = (event: any) => { + event.preventDefault(); + + const { address, placeId } = this.state; + + geocodeByAddress(address, (results, status) => { + getLatLng(results[0]).then((latLng) => { + console.info(latLng, status); + }); + }); + + geocodeByPlaceId(placeId, (results, status) => { + getLatLng(results[0]).then((latLng) => { + console.info(latLng, status); + }); + }); + } + + onChange = (address: string) => this.setState({ address }); + + render() { + const inputProps: PlacesAutocomplete["props"]["inputProps"] = { + value: this.state.address, + onChange: this.onChange, + }; + + return ( +
+ + + ); + } +} diff --git a/types/react-places-autocomplete/v6/tsconfig.json b/types/react-places-autocomplete/v6/tsconfig.json new file mode 100644 index 0000000000..f330afea6b --- /dev/null +++ b/types/react-places-autocomplete/v6/tsconfig.json @@ -0,0 +1,25 @@ +{ + "files": [ + "index.d.ts", + "react-places-autocomplete-tests.tsx" + ], + "compilerOptions": { + "baseUrl": "../../", + "forceConsistentCasingInFileNames": true, + "jsx": "react", + "lib": ["es6", "dom"], + "module": "commonjs", + "noEmit": true, + "noImplicitAny": true, + "noImplicitThis": true, + "paths": { + "react-places-autocomplete": [ + "react-places-autocomplete/v6" + ] + }, + "strictFunctionTypes": true, + "strictNullChecks": true, + "typeRoots": ["../../"], + "types": [] + } +} diff --git a/types/react-places-autocomplete/v6/tslint.json b/types/react-places-autocomplete/v6/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/react-places-autocomplete/v6/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/react-rangeslider/index.d.ts b/types/react-rangeslider/index.d.ts new file mode 100644 index 0000000000..8c7a34c15b --- /dev/null +++ b/types/react-rangeslider/index.d.ts @@ -0,0 +1,26 @@ +// Type definitions for react-rangeslider 2.2 +// Project: https://github.com/whoisandy/react-rangeslider +// Definitions by: Riku Kallio +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import * as React from 'react'; + +export interface SliderProps { + disabled?: boolean; + format?: (value: number) => string | number | undefined; + handleLabel?: boolean; + labels?: { [value: number]: string }; + max?: number; + min?: number; + onChange?(value: number): void; + onChangeComplete?(value: number): void; + onChangeStart?(value: number): void; + orientation?: string; + reverse?: boolean; + step?: number; + tooltip?: boolean; + value: number; +} + +export default class Slider extends React.Component { } diff --git a/types/react-rangeslider/react-rangeslider-tests.tsx b/types/react-rangeslider/react-rangeslider-tests.tsx new file mode 100644 index 0000000000..f73132a9f6 --- /dev/null +++ b/types/react-rangeslider/react-rangeslider-tests.tsx @@ -0,0 +1,22 @@ +import Slider from 'react-rangeslider'; +import * as React from 'react'; + +const value = 80; + +const handleChange = (value: number) => { + console.log('changed to', value); +}; + +const slider = ; diff --git a/types/react-rangeslider/tsconfig.json b/types/react-rangeslider/tsconfig.json new file mode 100644 index 0000000000..41d76949dd --- /dev/null +++ b/types/react-rangeslider/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom", + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "jsx": "react", + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-rangeslider-tests.tsx" + ] +} diff --git a/types/react-rangeslider/tslint.json b/types/react-rangeslider/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-rangeslider/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/react-stripe-elements/index.d.ts b/types/react-stripe-elements/index.d.ts index 0697e4b869..7fb4c934db 100644 --- a/types/react-stripe-elements/index.d.ts +++ b/types/react-stripe-elements/index.d.ts @@ -6,6 +6,7 @@ // Andrew Goh Yisheng // Thomas Chia // Piotr Dabrowski +// Victor Irzak // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 @@ -19,6 +20,7 @@ export namespace ReactStripeElements { type TokenResponse = stripe.TokenResponse; type SourceResponse = stripe.SourceResponse; type SourceOptions = stripe.SourceOptions; + type HTMLStripeElement = stripe.elements.Element; /** * There's a bug in @types/stripe which defines the property as @@ -60,7 +62,7 @@ export namespace ReactStripeElements { onFocus?(event: ElementChangeResponse): void; - onReady?(el: HTMLElement): void; + onReady?(el: HTMLStripeElement): void; } } @@ -91,3 +93,9 @@ export class PostalCodeElement extends React.Component { } + +export class IbanElement extends React.Component { +} + +export class IdealBankElement extends React.Component { +} diff --git a/types/react-stripe-elements/react-stripe-elements-tests.tsx b/types/react-stripe-elements/react-stripe-elements-tests.tsx index ac801e60f7..20bb920723 100644 --- a/types/react-stripe-elements/react-stripe-elements-tests.tsx +++ b/types/react-stripe-elements/react-stripe-elements-tests.tsx @@ -16,6 +16,7 @@ import ElementChangeResponse = stripe.elements.ElementChangeResponse; import ElementsOptions = stripe.elements.ElementsOptions; import ElementsCreateOptions = stripe.elements.ElementsCreateOptions; import PatchedTokenResponse = ReactStripeElements.PatchedTokenResponse; +import HTMLStripeElement = ReactStripeElements.HTMLStripeElement; const cardElementProps: ElementsOptions = { iconStyle: 'solid', @@ -63,41 +64,46 @@ const fontElementsProps: ElementsCreateOptions = { locale: "es" }; + el.clear()} +/>; + const ElementsWithPropsTest: React.SFC = () => (
void 0} onBlur={(event: ElementChangeResponse) => void 0} - onReady={(el: HTMLElement) => void 0} + onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} - onReady={(el: HTMLElement) => void 0} + onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} - onReady={(el: HTMLElement) => void 0} + onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} - onReady={(el: HTMLElement) => void 0} + onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} /> void 0} onBlur={(event: ElementChangeResponse) => void 0} - onReady={(el: HTMLElement) => void 0} + onReady={(el: HTMLStripeElement) => void 0} onFocus={(event: ElementChangeResponse) => void 0} />
diff --git a/types/react-youtube/index.d.ts b/types/react-youtube/index.d.ts index fe9baf2e42..f24c43b22c 100644 --- a/types/react-youtube/index.d.ts +++ b/types/react-youtube/index.d.ts @@ -5,36 +5,41 @@ // TypeScript Version: 2.8 import * as React from "react"; + +export interface PlayerVars { + autoplay?: 0 | 1; + cc_load_policy?: 1; + color?: 'red' | 'white'; + controls?: 0 | 1 | 2; + disablekb?: 0 | 1; + enablejsapi?: 0 | 1; + end?: number; + fs?: 0 | 1; + hl?: string; + iv_load_policy?: 1 | 3; + list?: string; + listType?: 'playlist' | 'search' | 'user_uploads'; + loop?: 0 | 1; + modestbranding?: 1; + origin?: string; + playlist?: string; + playsinline?: 0 | 1; + rel?: 0 | 1; + showinfo?: 0 | 1; + start?: number; +} + +export interface Options { + height?: string; + width?: string; + playerVars?: PlayerVars; +} + export default class YouTube extends React.Component<{ videoId?: string, id?: string, className?: string, - opts?: { - height?: string, - width?: string, - playerVars?: { - autoplay?: 0 | 1, - cc_load_policy?: 1, - color?: 'red' | 'white', - controls?: 0 | 1 | 2, - disablekb?: 0 | 1, - enablejsapi?: 0 | 1, - end?: number, - fs?: 0 | 1, - hl?: string, - iv_load_policy?: 1 | 3, - list?: string, - listType?: 'playlist' | 'search' | 'user_uploads', - loop?: 0 | 1, - modestbranding?: 1, - origin?: string, - playlist?: string, - playsinline?: 0 | 1, - rel?: 0 | 1, - showinfo?: 0 | 1, - start?: number - } - }, + opts?: Options, onReady?(event: { target: any }): void, onError?(event: { target: any, data: number }): void, onPlay?(event: { target: any, data: number }): void, diff --git a/types/regression/index.d.ts b/types/regression/index.d.ts new file mode 100644 index 0000000000..a2959be3d2 --- /dev/null +++ b/types/regression/index.d.ts @@ -0,0 +1,95 @@ +// Type definitions for regression 2.0 +// Project: https://github.com/Tom-Alexander/regression-js +// Definitions by: Mattias B. Martens +// Definitions: https://github.com/MattiasMartens/DefinitelyTyped + +/** + * [x, y] + */ +export type DataPoint = [number, number]; + +export interface Options { + /** + * The number of decimal places to round to. + * This is used to round the calculated fitting coefficients, + * the output predictions, and the value of r^2. + */ + precision?: number; + /** + * The number of terms to solve for (and therefore + * the number of coefficients to calculate). Only + * relevant for polynomial fitting. + */ + order?: number; +} + +export interface Result { + /** + * A human-readable string representation of the derived + * formula in the form y = f(x) where f depends on the + * fitting method used and the coefficients that were + * calculated. + */ + string: string; + /** + * For each point (x, y) in the input data, a point + * corresponding to the regression prediction for that + * value of x. + * One could use this to directly evaluate the quality + * of the fit. + */ + points: ReadonlyArray; + /** + * Function that takes an arbitrary value of x and + * produces a coordinate representing the y-value of + * the regression curve at that point. + * Both the resulting x- and y-values are rounded to + * a number of decimal places defined in the options + * (default is 2). + */ + predict: (x: number) => DataPoint; + /** + * The generated coefficients describing the equation + * of best fit. + * + * For a linear fit, the coefficients are `[a, b]` in `y = a * x + b`. + * For an exponential fit, the coefficients are `[a, b]` in `y = a * e ^ (b * x)`. + * For a logarithmic fit, the coefficients are `[a, b]` in `y = a + b * ln(x)`. + * For a power fit, the coefficients are `[a, b]` in `y = a * x^b`. + * For a polynomial fit, the coefficients are `[a0, a1, a2, ...aN]` in: + * ```y = a0 * x ^ N + a1 * x ^ (N - 1) + ... + aN``` + * where N is the order (default 2). + */ + equation: number[]; + /** + * The value of R squared, a statistical measure of the conformance of the + * fitted curve to the input data where 1 is an exact fit and 0 is no fit + * at all. + * + * This value is rounded to the number of decimal places defined by + * the precision option (default 2). + */ + r2: number; +} + +export function _round(number: number, precision: number): number; +export function linear( + data: ReadonlyArray, + options?: Options +): Result; +export function exponential( + data: ReadonlyArray, + options?: Options +): Result; +export function logarithmic( + data: ReadonlyArray, + options?: Options +): Result; +export function power( + data: ReadonlyArray, + options?: Options +): Result; +export function polynomial( + data: ReadonlyArray, + options?: Options +): Result; diff --git a/types/regression/regression-tests.ts b/types/regression/regression-tests.ts new file mode 100644 index 0000000000..0d9532aacf --- /dev/null +++ b/types/regression/regression-tests.ts @@ -0,0 +1,12 @@ +import * as Regression from "regression"; + +const data: ReadonlyArray<[number, number]> = [[0, 0], [1, 1], [2, 2]]; +const result1 = Regression.linear(data); +const result2 = Regression.exponential(data); +const result3 = Regression.logarithmic(data); +const result4 = Regression.power(data); +const result5 = Regression.polynomial(data); +const result6 = Regression._round(10.312, 3); +const result7 = Regression.polynomial(data, { order: 4 }); +const result8 = Regression.polynomial(data, { precision: 4 }); +const result9 = Regression.polynomial(data, { order: 4, precision: 4 }); diff --git a/types/regression/tsconfig.json b/types/regression/tsconfig.json new file mode 100644 index 0000000000..e57fee7c91 --- /dev/null +++ b/types/regression/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "regression-tests.ts"] +} diff --git a/types/regression/tslint.json b/types/regression/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/regression/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/saslprep/index.d.ts b/types/saslprep/index.d.ts new file mode 100644 index 0000000000..4a5f931433 --- /dev/null +++ b/types/saslprep/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for saslprep 1.0 +// Project: https://github.com/reklatsmasters/saslprep#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = saslPrep; + +declare function saslPrep(input: string, options?: saslPrep.Options): string; + +declare namespace saslPrep { + interface Options { + allowUnassigned?: boolean; + } +} diff --git a/types/saslprep/saslprep-tests.ts b/types/saslprep/saslprep-tests.ts new file mode 100644 index 0000000000..b3dad713ca --- /dev/null +++ b/types/saslprep/saslprep-tests.ts @@ -0,0 +1,4 @@ +import saslprep = require('saslprep'); + +saslprep('password\u00AD'); // $ExpectType string +saslprep('password\u00AD', { allowUnassigned: true }); // $ExpectType string diff --git a/types/saslprep/tsconfig.json b/types/saslprep/tsconfig.json new file mode 100644 index 0000000000..19cbde2f08 --- /dev/null +++ b/types/saslprep/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "saslprep-tests.ts" + ] +} diff --git a/types/saslprep/tslint.json b/types/saslprep/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/saslprep/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/screeps/index.d.ts b/types/screeps/index.d.ts index 27ca10960d..3ae5315443 100644 --- a/types/screeps/index.d.ts +++ b/types/screeps/index.d.ts @@ -1439,6 +1439,16 @@ interface FindPathOpts { * Path to within (range) tiles of target tile. The default is to path to the tile that the target is on (0). */ range?: number; + + /** + * Cost for walking on plain positions. The default is 1. + */ + plainCost?: number; + + /** + * Cost for walking on swamp positions. The default is 5. + */ + swampCost?: number; } interface MoveToOpts extends FindPathOpts { @@ -1499,7 +1509,7 @@ interface _Constructor { } interface _ConstructorById extends _Constructor { - new (id: string): T; + new(id: string): T; (id: string): T; } /* @@ -1949,87 +1959,66 @@ type EVENT_HEAL_TYPE_RANGED = 2; type EventDestroyType = "creep" | StructureConstant; -type EventItem = - | { - type: EVENT_ATTACK; - objectId: string; - data: { - targetId: string; - damage: number; - attackType: EventAttackType; - }; - } - | { - type: EVENT_OBJECT_DESTROYED; - objectId: string; - data: { - type: EventDestroyType; - }; - } - | { - type: EVENT_ATTACK_CONTROLLER; - objectId: string; - } - | { - type: EVENT_BUILD; - objectId: string; - data: { - targetId: string; - amount: number; - energySpent: number; - }; - } - | { - type: EVENT_HARVEST; - objectId: string; - data: { - targetId: string; - amount: number; - }; - } - | { - type: EVENT_HEAL; - objectId: string; - data: { - targetId: string; - amount: number; - healType: EventHealType; - }; - } - | { - type: EVENT_REPAIR; - objectId: string; - data: { - targetId: string; - amount: number; - energySpent: number; - }; - } - | { - type: EVENT_RESERVE_CONTROLLER; - objectId: string; - data: { - amount: number; - }; - } - | { - type: EVENT_UPGRADE_CONTROLLER; - objectId: string; - data: - | { - amount: number; - energySpent: number; - } - | { - type: EVENT_EXIT; - objectId: string; - data: { - room: string; - x: number; - y: number; - }; - }; - }; +interface EventItem { + event: T; + objectId: string; + data: EventData[T]; +} + +interface EventData { + [key: number]: null | { + targetId?: string; + damage?: number; + attackType?: EventAttackType; + amount?: number; + energySpent?: number; + type?: EventDestroyType; + healType?: EventHealType; + room?: string; + x?: number; + y?: number; + }; + 1: { // EVENT_ATTACK + targetId: string; + damage: number; + attackType: EventAttackType; + }; + 2: { // EVENT_OBJECT_DESTORYED + type: EventDestroyType; + }; + 3: null; // EVENT_ATTACK_CONTROLLER + 4: { // EVENT_BUILD + targetId: string; + amount: number; + energySpent: number; + }; + 5: { // EVENT_HARVEST + targetId: string; + amount: number; + }; + 6: { // EVENT_HEAL + targetId: string; + amount: number; + healType: EventHealType; + }; + 7: { // EVENT_REPAIR + targetId: string; + amount: number; + energySpent: number; + }; + 8: { // EVENT_RESERVE_CONTROLLER + amount: number; + }; + 9: { // EVENT_UPGRADE_CONTROLLER + amount: number; + energySpent: number; + }; + 10: { // EVENT_EXIT + room: string; + x: number; + y: number; + }; +} /** * The options that can be accepted by `findRoute()` and friends. */ diff --git a/types/screeps/screeps-tests.ts b/types/screeps/screeps-tests.ts index d7befaf3bd..6a47cb3e0a 100644 --- a/types/screeps/screeps-tests.ts +++ b/types/screeps/screeps-tests.ts @@ -655,6 +655,12 @@ function keys(o: T): Array { { room.getEventLog(); room.getEventLog(true); + + const events = room.getEventLog(); + + const event = events[0] as EventItem; + + event.data.attackType; } // Room.Terrain diff --git a/types/shallowequal/index.d.ts b/types/shallowequal/index.d.ts index af13b55eb4..95b91d6de5 100644 --- a/types/shallowequal/index.d.ts +++ b/types/shallowequal/index.d.ts @@ -1,10 +1,15 @@ -// Type definitions for shallowequal v0.2.2 +// Type definitions for shallowequal 1.1 // Project: https://github.com/dashed/shallowequal // Definitions by: Sean Kelley +// BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 -declare function shallowEqual(objA: any, objB: any, compare?: (objA: any, objB: any, indexOrKey?: number | string) => (boolean | undefined), compareContext?: any): boolean; - -declare namespace shallowEqual { } +declare function shallowEqual( + objA: any, + objB: any, + compare?: (this: TCtx, objA: any, objB: any, indexOrKey?: number | string) => boolean | void, + compareContext?: TCtx +): boolean; export = shallowEqual; diff --git a/types/shallowequal/shallowequal-tests.ts b/types/shallowequal/shallowequal-tests.ts index 2a8589fc32..efa5b546a5 100644 --- a/types/shallowequal/shallowequal-tests.ts +++ b/types/shallowequal/shallowequal-tests.ts @@ -1,15 +1,24 @@ -import shallowEqual_require = require('shallowequal'); -import * as shallowEqual_splat from 'shallowequal'; +import shallowEqual = require('shallowequal'); -const a = {}, b = {}; -function compare(a: any, b: any, indexOrKey?: number | string) { - return false; -} +const a = {}; +const b = {}; -shallowEqual_require(a, b); -shallowEqual_require(a, b, compare); -shallowEqual_require(a, b, compare, {}); +shallowEqual(a, b); // $ExpectType boolean +// $ExpectType boolean +shallowEqual(a, b, (a, b, indexOrKey) => { + a; // $ExpectType any + b; // $ExpectType any + indexOrKey; // $ExpectType string | number | undefined -shallowEqual_splat(a, b); -shallowEqual_splat(a, b, compare); -shallowEqual_splat(a, b, compare, {}); + return false; +}); +shallowEqual(a, b, () => {}); // $ExpectType boolean +// $ExpectType boolean +shallowEqual( + a, + b, + function() { + this; // $ExpectType { foo: string; } + }, + { foo: 'bar' } +); diff --git a/types/shallowequal/tsconfig.json b/types/shallowequal/tsconfig.json index de32c6c47b..acae2da6d5 100644 --- a/types/shallowequal/tsconfig.json +++ b/types/shallowequal/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ @@ -20,4 +20,4 @@ "index.d.ts", "shallowequal-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/shallowequal/tslint.json b/types/shallowequal/tslint.json index a41bf5d19a..f93cf8562a 100644 --- a/types/shallowequal/tslint.json +++ b/types/shallowequal/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } + "extends": "dtslint/dt.json" } diff --git a/types/shallowequal/v0/index.d.ts b/types/shallowequal/v0/index.d.ts new file mode 100644 index 0000000000..f9eb1c460c --- /dev/null +++ b/types/shallowequal/v0/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for shallowequal 0.2 +// Project: https://github.com/dashed/shallowequal +// Definitions by: Sean Kelley +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function shallowEqual(objA: any, objB: any, compare?: (objA: any, objB: any, indexOrKey?: number | string) => (boolean | undefined), compareContext?: any): boolean; + +declare namespace shallowEqual { } + +export = shallowEqual; diff --git a/types/shallowequal/v0/shallowequal-tests.ts b/types/shallowequal/v0/shallowequal-tests.ts new file mode 100644 index 0000000000..d7192971da --- /dev/null +++ b/types/shallowequal/v0/shallowequal-tests.ts @@ -0,0 +1,16 @@ +import shallowEqual_require = require('shallowequal'); +import * as shallowEqual_splat from 'shallowequal'; + +const a = {}; +const b = {}; +function compare(a: any, b: any, indexOrKey?: number | string) { + return false; +} + +shallowEqual_require(a, b); +shallowEqual_require(a, b, compare); +shallowEqual_require(a, b, compare, {}); + +shallowEqual_splat(a, b); +shallowEqual_splat(a, b, compare); +shallowEqual_splat(a, b, compare, {}); diff --git a/types/shallowequal/v0/tsconfig.json b/types/shallowequal/v0/tsconfig.json new file mode 100644 index 0000000000..adc93ac644 --- /dev/null +++ b/types/shallowequal/v0/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "shallowequal": [ + "shallowequal/v0" + ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shallowequal-tests.ts" + ] +} diff --git a/types/shallowequal/v0/tslint.json b/types/shallowequal/v0/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/shallowequal/v0/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} diff --git a/types/shebang-command/index.d.ts b/types/shebang-command/index.d.ts new file mode 100644 index 0000000000..3dfe023617 --- /dev/null +++ b/types/shebang-command/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for shebang-command 1.2 +// Project: https://github.com/kevva/shebang-command#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = shebangCommand; + +declare function shebangCommand(str: string): string | null; diff --git a/types/shebang-command/shebang-command-tests.ts b/types/shebang-command/shebang-command-tests.ts new file mode 100644 index 0000000000..0cdf85b022 --- /dev/null +++ b/types/shebang-command/shebang-command-tests.ts @@ -0,0 +1,3 @@ +import shebangCommand = require('shebang-command'); + +shebangCommand('#!/usr/bin/env node'); // $ExpectType string | null diff --git a/types/shebang-command/tsconfig.json b/types/shebang-command/tsconfig.json new file mode 100644 index 0000000000..9ae22f761b --- /dev/null +++ b/types/shebang-command/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shebang-command-tests.ts" + ] +} diff --git a/types/shebang-command/tslint.json b/types/shebang-command/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/shebang-command/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/shebang-regex/index.d.ts b/types/shebang-regex/index.d.ts new file mode 100644 index 0000000000..2bba6ec84d --- /dev/null +++ b/types/shebang-regex/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for shebang-regex 2.0 +// Project: https://github.com/sindresorhus/shebang-regex +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = shebangRegex; + +declare const shebangRegex: RegExp; diff --git a/types/shebang-regex/shebang-regex-tests.ts b/types/shebang-regex/shebang-regex-tests.ts new file mode 100644 index 0000000000..eec7893e93 --- /dev/null +++ b/types/shebang-regex/shebang-regex-tests.ts @@ -0,0 +1,5 @@ +import shebangRegex = require('shebang-regex'); + +const str = '#!/usr/bin/env node\nconsole.log("unicorns");'; + +shebangRegex.test(str); diff --git a/types/shebang-regex/tsconfig.json b/types/shebang-regex/tsconfig.json new file mode 100644 index 0000000000..0842063948 --- /dev/null +++ b/types/shebang-regex/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "shebang-regex-tests.ts" + ] +} diff --git a/types/shebang-regex/tslint.json b/types/shebang-regex/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/shebang-regex/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/sinon/ts3.1/index.d.ts b/types/sinon/ts3.1/index.d.ts index 920b109281..119ff98137 100644 --- a/types/sinon/ts3.1/index.d.ts +++ b/types/sinon/ts3.1/index.d.ts @@ -626,10 +626,13 @@ declare namespace Sinon { } interface SinonStubStatic { + // Disable rule so assignment to typed stub works (see examples in tests). /** * Creates an anonymous stub function */ - (): SinonStub; + // tslint:disable-next-line no-unnecessary-generics + (): SinonStub; + /** * Stubs all the object’s methods. * Note that it’s usually better practice to stub individual methods, particularly on objects that you don’t understand or control all the methods for (e.g. library dependencies). diff --git a/types/sinon/ts3.1/sinon-tests.ts b/types/sinon/ts3.1/sinon-tests.ts index a420d9851d..2aae56dfdc 100644 --- a/types/sinon/ts3.1/sinon-tests.ts +++ b/types/sinon/ts3.1/sinon-tests.ts @@ -483,6 +483,23 @@ function testStub() { stub.withArgs('a', 2).returns(true); } +function testTypedStub() { + class Foo { + bar(baz: number, qux: string): boolean { + return true; + } + } + let stub: sinon.SinonStub<[number, string], boolean> = sinon.stub(); + let stub2 = sinon.stub<[number, string], boolean>(); + const foo = new Foo(); + stub = sinon.stub(foo, 'bar'); + stub2 = sinon.stub(foo, 'bar'); + const result: boolean = stub(42, 'qux'); + const fooStub: sinon.SinonStubbedInstance = { + bar: sinon.stub() + }; +} + function testMock() { const obj = {}; const mock = sinon.mock(obj); diff --git a/types/slate/index.d.ts b/types/slate/index.d.ts index 1f17afe93f..22cf22f8ef 100644 --- a/types/slate/index.d.ts +++ b/types/slate/index.d.ts @@ -68,7 +68,7 @@ export interface ValueJSON { object?: "value"; } -export type Path = Immutable.List | string; +export type Path = Immutable.List | string | number; export class Value extends Immutable.Record({}) { document: Document; diff --git a/types/smart-truncate/index.d.ts b/types/smart-truncate/index.d.ts new file mode 100644 index 0000000000..a1250c9f54 --- /dev/null +++ b/types/smart-truncate/index.d.ts @@ -0,0 +1,6 @@ +// Type definitions for smart-truncate 1.0 +// Project: https://github.com/millerized/smart-truncate +// Definitions by: Omer Yalhi +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function smartTruncate(text: string, length: number, options?: { position?: number; mark?: string }): string; diff --git a/types/smart-truncate/smart-truncate-tests.ts b/types/smart-truncate/smart-truncate-tests.ts new file mode 100644 index 0000000000..0e0caefc50 --- /dev/null +++ b/types/smart-truncate/smart-truncate-tests.ts @@ -0,0 +1,7 @@ +import { smartTruncate } from 'smart-truncate'; + +const length = 9; +let result = ''; +result = smartTruncate('Steve Miller', length); +result = smartTruncate('Steve Miller', length, {position: 4}); +result = smartTruncate('abcdefghijklmnopqrstuvwxyz', 7, {position: 3, mark: '—'}); diff --git a/types/smart-truncate/tsconfig.json b/types/smart-truncate/tsconfig.json new file mode 100644 index 0000000000..708868434f --- /dev/null +++ b/types/smart-truncate/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "smart-truncate-tests.ts" + ] +} \ No newline at end of file diff --git a/types/smart-truncate/tslint.json b/types/smart-truncate/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/smart-truncate/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/spectacle/index.d.ts b/types/spectacle/index.d.ts deleted file mode 100644 index 621f08f67e..0000000000 --- a/types/spectacle/index.d.ts +++ /dev/null @@ -1,321 +0,0 @@ -// Type definitions for Spectacle 5.2.2 -// Project: https://github.com/FormidableLabs/spectacle -// Definitions by: Zachary Maybury -// Kylie Stewart -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.8 - -/// - -declare module "spectacle" { - import * as React from "react"; - import * as CSS from "csstype"; - /** - * Alignment Types for Spectacle - */ - type alignType = - | "flex-start flex-start" - | "flex-start center" - | "flex-start flex-end" - | "center flex-start" - | "center center" - | "center flex-end" - | "flex-end flex-start" - | "flex-end center" - | "flex-end flex-end"; - - /** - * Animation Types for Spectacle - */ - type easeType = - | "back" - | "backIn" - | "backOut" - | "backInOut" - | "bounce" - | "bounceIn" - | "bounceOut" - | "bounceInOut" - | "circle" - | "circleIn" - | "circleOut" - | "circleInOut" - | "linear" - | "linearIn" - | "linearOut" - | "linearInOut" - | "cubic" - | "cubicIn" - | "cubicOut" - | "cubicInOut" - | "elastic" - | "elasticIn" - | "elasticOut" - | "elasticInOut" - | "exp" - | "expIn" - | "expOut" - | "expInOut" - | "poly" - | "polyIn" - | "polyOut" - | "polyInOut" - | "quad" - | "quadIn" - | "quadOut" - | "quadInOut" - | "sin" - | "sinIn" - | "sinOut" - | "sinInOut"; - - /** - * Progress Types for Spectacle - */ - type progressType = "pacman" | "bar" | "number" | "none"; - - /** - * S Types for StyledS in Spectacle - */ - type sType = "italic" | "bold" | "line-through" | "underline"; - - /** - * Target Types for links - */ - type targetType = "_blank" | "_self" | "_parent" | "_top"; - - /** - * Theme Types for CodePane in Spectacle - */ - type themeType = "dark" | "light" | "external"; - - /** - * Transition Types for Spectacle - */ - type transitionType = "slide" | "zoom" | "fade" | "spin"; - - /** - * All available DOM style properties and their types - * https://www.npmjs.com/package/csstype - */ - export interface CSSProperties extends CSS.Properties {} - - export interface AnimProps { - easing: easeType; - fromStyle: CSSProperties | CSSProperties[]; - onAnim?: (forwards?: boolean, animIndex?: number) => void; - order?: number; - route?: object; - style?: CSSProperties; - toStyle: CSSProperties | CSSProperties[]; - transitionDuration: number; - } - - export interface AppearProps { - easing?: easeType; - endValue?: object; - fid?: string; - order?: number; - startValue?: object; - style?: BaseProps["style"]; - transitionDuration?: number; - } - - /** - * Base props for many Spectacle components - */ - export interface BaseProps { - bgColor?: string; - bgDarken?: number; - bgImage?: string; - bold?: boolean; - caps?: boolean; - className?: string; - italic?: boolean; - margin?: number | string; - padding?: number | string; - style?: CSSProperties; - textAlign?: string; - textColor?: string; - textFont?: string; - textSize?: string; - } - export interface CodePaneProps { - className?: BaseProps["className"]; - contentEditable?: boolean; - lang?: string; - source?: string; - style?: BaseProps["style"]; - theme?: themeType; - } - - export interface ComponentPlaygroundProps { - code?: string; - previewBackgroundColor?: string; - scope?: object; - theme?: themeType; - transformCode?: (code: string) => string; - } - - export interface DeckProps { - autoplay?: boolean; - autoplayDuration?: number; - autoplayLoop?: boolean; - controls?: boolean; - globalStyles?: boolean; - history?: any; // Needs a type, see https://github.com/ReactTraining/history - progress?: progressType; - theme?: Theme; - transition?: transitionType[]; - transitionDuration?: number; - } - - export interface FillProps { - className?: string; - style?: CSSProperties; - } - - export interface FitProps extends FillProps {} - - export interface GoToActionProps { - margin?: BaseProps["margin"]; - padding?: BaseProps["padding"]; - render?: (goToSlide?: (slide: number | string) => void) => void; - slide?: number | string; - style?: BaseProps["style"]; - } - - export interface HeadingProps extends BaseProps { - fit?: boolean; - lineHeight?: number; - size?: number; - } - - export interface ImageProps { - alt?: string; - className?: BaseProps["className"]; - display?: string; - height?: number | string; - margin?: BaseProps["margin"]; - padding?: BaseProps["padding"]; - src?: string; - width?: number | string; - } - - export interface LayoutProps { - style?: CSSProperties; - } - - export interface LinkProps extends BaseProps { - href?: string; - target?: targetType; - } - - export interface MarkdownProps { - mdastConfig?: { [key: string]: number | string }; - source?: string; - } - - export interface SlideProps extends BaseProps { - align?: alignType; - contentStyles?: CSSProperties; - controlColor?: string; - dispatch?: () => void; - hash?: number | string; - progressColor?: string; - history?: any; // Needs a type, see https://github.com/ReactTraining/history - id?: string; - lastSlideIndex?: number; - notes?: string; - onActive?: (slideIndex: string | number) => void; - slideIndex?: number; - transition?: transitionType[]; - transitionDuration?: number; - transitionIn?: transitionType[]; - transitionOut?: transitionType[]; - } - - export interface SProps extends BaseProps { - type?: sType | sType[]; - } - - export interface TextProps extends BaseProps { - fit?: boolean; - lineHeight?: number; - } - - export type Theme = { [key: string]: number | string }; - - export class Anim extends React.Component {} - - export class Appear extends React.Component {} - - export class BlockQuote extends React.Component {} - - export class Cite extends React.Component {} - - export class Code extends React.Component {} - - export class CodePane extends React.Component {} - - export class ComponentPlayground extends React.Component< - ComponentPlaygroundProps - > {} - - export class Deck extends React.Component {} - - export class Fill extends React.Component {} - - export class Fit extends React.Component {} - - export class GoToAction extends React.Component {} - - export class Heading extends React.Component {} - - export class Image extends React.Component {} - - export class Layout extends React.Component {} - - export class Link extends React.Component {} - - export class List extends React.Component {} - - export class ListItem extends React.Component {} - - export class Markdown extends React.Component {} - - export class Notes extends React.Component {} - - export class Quote extends React.Component {} - - export class S extends React.Component {} - - export class Slide extends React.Component {} - - export class SlideSet extends React.Component {} - - export class Table extends React.Component {} - - export class TableBody extends React.Component {} - - export class TableHeader extends React.Component {} - - export class TableHeaderItem extends React.Component {} - - export class TableItem extends React.Component {} - - export class TableRow extends React.Component {} - - export class Text extends React.Component {} -} - -declare module "spectacle/lib/utils/preloader" { - const preloader: (obj: object) => void; - export default preloader; -} - -declare module "spectacle/lib/themes/default" { - import { Theme } from "spectacle"; - const createTheme: (...args: object[]) => Theme; - export default createTheme; -} diff --git a/types/spectacle/package.json b/types/spectacle/package.json deleted file mode 100644 index 9de3dd17fa..0000000000 --- a/types/spectacle/package.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "private": true, - "dependencies": { - "csstype": "^2.2.0" - } - } diff --git a/types/spectacle/spectacle-tests.tsx b/types/spectacle/spectacle-tests.tsx deleted file mode 100644 index 04c3403f41..0000000000 --- a/types/spectacle/spectacle-tests.tsx +++ /dev/null @@ -1,377 +0,0 @@ -import * as React from "react"; -import { - Anim, - Appear, - BlockQuote, - Cite, - CodePane, - ComponentPlayground, - Deck, - Fill, - GoToAction, - Heading, - Image, - Layout, - Link, - List, - ListItem, - Markdown, - Notes, - Quote, - Slide, - SlideSet, - Table, - TableBody, - TableHeader, - TableHeaderItem, - TableItem, - TableRow, - Text -} from "spectacle"; - -// Import image preloader util -import preloader from "spectacle/lib/utils/preloader"; - -// Import theme -import createTheme from "spectacle/lib/themes/default"; - -const images = { - city: "a-url", - logo: "another-url" -}; - -preloader(images); - -const theme = createTheme( - { - primary: "white", - secondary: "#1F2022", - tertiary: "#03A9FC", - quartenary: "#CECECE" - }, - { - primary: "Montserrat", - secondary: "Helvetica" - } -); - -export class SpectacleTest extends React.Component { - public render() { - return ( - - - - Spectacle - - - A ReactJS Presentation Library - - - Where You Can Write Your Decks In JSX - - - - View on Github - - - - Hit Your Right Arrow To Begin! - - - - - Wait what? - - - - - - Full Width - - - - - Adjustable Darkness - - - - - Background Imagery - - - - - - - - - This is a component playground - - - - Flexible Layouts - - - - - Left - - - - - Right - - - - - - - Inline Markdown - - - {` - You can write inline images, [Markdown Links](http://commonmark.org), paragraph text and most other markdown syntax - * Lists too! - * With ~~strikethrough~~ and _italic_ - * And let's not forget **bold** - * Add some \`inline code\` to your sldes! - `} - - - - { - /* eslint-disable */ - console.log("forwards ", forwards); - console.log("animIndex ", animIndex); - /* eslint-enable */ - }} - fromStyle={{ - opacity: 0, - transform: - "translate3d(0px, -100px, 0px) scale(1) rotate(0deg)" - }} - toStyle={[ - { - opacity: 1, - transform: - "translate3d(0px, 0px, 0px) scale(1) rotate(0deg)" - }, - { - opacity: 1, - transform: - "translate3d(0px, 0px, 0px) scale(1.6) rotate(-15deg)" - }, - { - opacity: 1, - transform: - "translate3d(0px, 0px, 0px) scale(0.8) rotate(0deg)" - } - ]} - easing={"bounceOut"} - transitionDuration={500} - > - - - Flexible -
- animations -
-
-
-
- - - Mix it up! - - - You can even jump to different slides with a standard - button or custom component! - - - Jump to Slide 8 - - ( - - )} - /> - - -
- Wonderfully formatted quotes - Ken Wheeler -
-
- -
- Wonderfully formatted quotes - Ken Wheeler -
-
- - - - - - Inline style based theme system - - - - Autofit text - - - Flexbox layout system - - - PDF export - - - And... - - - - - - You can even share styles with SlideSet - - - - - - Pizza Toppings - - - - - - - 2011 - 2013 - 2015 - - - - - None - 61.8% - 39.6% - 35.0% - - - Pineapple - 28.3% - 54.5% - 61.5% - - - Pepperoni - - 50.2% - 77.2% - - - Olives - - 24.9% - 55.9% - - -
-
-
- - - Made with love in Seattle by - - - - - -
- ); - } -} diff --git a/types/spectacle/tslint.json b/types/spectacle/tslint.json deleted file mode 100644 index a41bf5d19a..0000000000 --- a/types/spectacle/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} diff --git a/types/strip-color/index.d.ts b/types/strip-color/index.d.ts new file mode 100644 index 0000000000..3a3a126995 --- /dev/null +++ b/types/strip-color/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for strip-color 0.1 +// Project: https://github.com/jonschlinkert/strip-color +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = stripColor; + +declare function stripColor(text: string): string; diff --git a/types/strip-color/strip-color-tests.ts b/types/strip-color/strip-color-tests.ts new file mode 100644 index 0000000000..952c1d630c --- /dev/null +++ b/types/strip-color/strip-color-tests.ts @@ -0,0 +1,3 @@ +import strip = require('strip-color'); + +strip('abc'); // $ExpectType string diff --git a/types/strip-color/tsconfig.json b/types/strip-color/tsconfig.json new file mode 100644 index 0000000000..e5f91623bc --- /dev/null +++ b/types/strip-color/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "strip-color-tests.ts" + ] +} diff --git a/types/strip-color/tslint.json b/types/strip-color/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/strip-color/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/stripe/index.d.ts b/types/stripe/index.d.ts index dcac6a2e19..7017070d59 100644 --- a/types/stripe/index.d.ts +++ b/types/stripe/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for stripe 6.18 +// Type definitions for stripe 6.19 // Project: https://github.com/stripe/stripe-node/ // Definitions by: William Johnston // Peter Harris @@ -3683,25 +3683,6 @@ declare namespace Stripe { interface ISkuAttributes {} } - namespace webhooks { - interface StripeWebhookEvent { - id: string; - object: string; - api_version: string; - created: number; - data: { - object: T; - }; - livemode: boolean; - pending_webhooks: number; - /** - * One of https://stripe.com/docs/api#event_types - * E.g. account.updated - */ - type: string; - } - } - namespace ephemeralKeys { interface IStripeVersion { /** @@ -7345,7 +7326,7 @@ declare namespace Stripe { } class WebHooks { - constructEvent(requestBody: any, signature: string | string[], endpointSecret: string, tolerance?: number): webhooks.StripeWebhookEvent; + constructEvent(requestBody: any, signature: string | string[], endpointSecret: string, tolerance?: number): events.IEvent; } class EphemeralKeys { diff --git a/types/stripe/stripe-tests.ts b/types/stripe/stripe-tests.ts index 685f29cd77..a7d0e5c45c 100644 --- a/types/stripe/stripe-tests.ts +++ b/types/stripe/stripe-tests.ts @@ -829,11 +829,11 @@ const webhookRequest = { }; const webhookSecret = ''; -const event = stripe.webhooks.constructEvent( +const event: Stripe.events.IEvent = stripe.webhooks.constructEvent( webhookRequest.rawBody, webhookRequest.headers['stripe-signature'], webhookSecret -) as Stripe.webhooks.StripeWebhookEvent; +); //#endregion diff --git a/types/styled-system/dist/mixed.d.ts b/types/styled-system/dist/mixed.d.ts deleted file mode 100644 index 25f115aa55..0000000000 --- a/types/styled-system/dist/mixed.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface MixedProps { - key?: any; - // Defaults to "variant" - prop?: string; -} - -export function mixed(...args: any[]): any; diff --git a/types/styled-system/dist/space.d.ts b/types/styled-system/dist/space.d.ts deleted file mode 100644 index 9632ed7e45..0000000000 --- a/types/styled-system/dist/space.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -import * as CSS from 'csstype'; -export type TLengthStyledSystem = string | 0 | number; -export type ResponsiveValue = T | Array; - -/** - * Converts shorthand margin and padding props to margin and padding CSS declarations - * - * - Numbers from 0-4 (or the length of theme.space) are converted to values on the spacing scale. - * - Negative values can be used for negative margins. - * - Numbers greater than the length of the theme.space array are converted to raw pixel values. - * - String values are passed as raw CSS values. - * - Array values are converted into responsive values. - */ - -export interface SpaceProps { - /** Margin on top, left, bottom and right */ - m?: ResponsiveValue>; - /** Margin for the top */ - mt?: ResponsiveValue>; - /** Margin for the right */ - mr?: ResponsiveValue>; - /** Margin for the bottom */ - mb?: ResponsiveValue>; - /** Margin for the left */ - ml?: ResponsiveValue>; - /** Margin for the left and right */ - mx?: ResponsiveValue>; - /** Margin for the top and bottom */ - my?: ResponsiveValue>; - /** Padding on top, left, bottom and right */ - p?: ResponsiveValue>; - /** Padding for the top */ - pt?: ResponsiveValue>; - /** Padding for the right */ - pr?: ResponsiveValue>; - /** Padding for the bottom */ - pb?: ResponsiveValue>; - /** Padding for the left */ - pl?: ResponsiveValue>; - /** Padding for the left and right */ - px?: ResponsiveValue>; - /** Padding for the top and bottom */ - py?: ResponsiveValue>; -} - -export function space(...args: any[]): any; diff --git a/types/styled-system/dist/styles.d.ts b/types/styled-system/dist/styles.d.ts deleted file mode 100644 index 59f8077ec9..0000000000 --- a/types/styled-system/dist/styles.d.ts +++ /dev/null @@ -1,836 +0,0 @@ -import * as CSS from 'csstype'; -import { ResponsiveValue, TLengthStyledSystem } from './space'; - -export * from './space'; - -export interface BaseTheme { - breakpoints?: number[]; - space?: number[]; - fontSizes?: number[]; - colors?: { - [name: string]: string; - }; -} - -/** - * Font Size - */ - -export interface FontSizeProps { - /** - * The fontSize utility parses a component's `fontSize` prop and converts it into a CSS font-size declaration. - * - * - Numbers from 0-8 (or `theme.fontSizes.length`) are converted to values on the [font size scale](#default-theme). - * - Numbers greater than `theme.fontSizes.length` are converted to raw pixel values. - * - String values are passed as raw CSS values. - * - And array values are converted into responsive values. - * - */ - fontSize?: ResponsiveValue>; -} - -export function fontSize(...args: any[]): any; - -/** - * Color - */ - -export interface TextColorProps { - /** - * The color utility parses a component's `color` and `bg` props and converts them into CSS declarations. - * By default the raw value of the prop is returned. - * - * Color palettes can be configured with the ThemeProvider to use keys as prop values, with support for dot notation. - * Array values are converted into responsive values. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/color) - */ - color?: ResponsiveValue; -} - -export function textColor(...args: any[]): any; - -export interface BgColorProps { - /** - * The color utility parses a component's `color` and `bg` props and converts them into CSS declarations. - * By default the raw value of the prop is returned. - * - * Color palettes can be configured with the ThemeProvider to use keys as prop values, with support for dot notation. - * Array values are converted into responsive values. - * - * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-color) - */ - bg?: ResponsiveValue>; -} - -export function bgColor(...args: any[]): any; - -export interface ColorProps extends TextColorProps, BgColorProps {} - -export function color(...args: any[]): any; - -/** - * Typography - */ -export interface FontFamilyProps { - fontFamily?: ResponsiveValue; -} -export function fontFamily(...args: any[]): any; - -export interface TextAlignProps { - /** - * The text-align CSS property specifies the horizontal alignment of an inline or table-cell box. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/text-align) - */ - textAlign?: ResponsiveValue; -} - -export function textAlign(...args: any[]): any; - -export interface LineHeightProps { - /** - * The line-height CSS property sets the amount of space used for lines, such as in text. On block-level elements, - * it specifies the minimum height of line boxes within the element. - * - * On non-replaced inline elements, it specifies the height that is used to calculate line box height. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height) - */ - lineHeight?: ResponsiveValue>; -} -export function lineHeight(...args: any[]): any; - -export interface FontWeightProps { - /** - * The font-weight CSS property specifies the weight (or boldness) of the font. - * - * The font weights available to you will depend on the font-family you are using. Some fonts are only available in normal and bold. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight) - */ - fontWeight?: ResponsiveValue; -} - -export function fontWeight(...args: any[]): any; - -export interface FontStyleProps { - /** - * The font-style CSS property specifies whether a font should be styled with a normal, italic, - * or oblique face from its font-family. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/font-style) - */ - fontStyle?: ResponsiveValue; -} -export function fontStyle(...args: any[]): any; - -export interface LetterSpacingProps { - /** - * The letter-spacing CSS property sets the spacing behavior between text characters. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/letter-spacing) - */ - letterSpacing?: ResponsiveValue>; -} -export function letterSpacing(...args: any[]): any; - -/** - * Layout - */ - -export interface DisplayProps { - /** - * The display CSS property defines the display type of an element, which consists of the two basic qualities - * of how an element generates boxes — the outer display type defining how the box participates in flow layout, - * and the inner display type defining how the children of the box are laid out. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/display) - */ - display?: ResponsiveValue; -} - -export function display(...args: any[]): any; - -export interface MaxWidthProps { - /** - * The max-width CSS property sets the maximum width of an element. - * It prevents the used value of the width property from becoming larger than the value specified by max-width. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/max-width) - */ - maxWidth?: ResponsiveValue>; -} - -export function maxWidth(...args: any[]): any; - -export interface MinWidthProps { - /** - * The min-width CSS property sets the minimum width of an element. - * It prevents the used value of the width property from becoming smaller than the value specified for min-width. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/min-width) - */ - minWidth?: ResponsiveValue>; -} - -export function minWidth(...args: any[]): any; - -export interface WidthProps { - /** - * The width utility parses a component's `width` prop and converts it into a CSS width declaration. - * - * - Numbers from 0-1 are converted to percentage widths. - * - Numbers greater than 1 are converted to pixel values. - * - String values are passed as raw CSS values. - * - And arrays are converted to responsive width styles. - */ - width?: ResponsiveValue>; -} - -export function width(...args: any[]): any; - -export interface MaxHeightProps { - /** - * The max-height CSS property sets the maximum height of an element. It prevents the used value of the height - * property from becoming larger than the value specified for max-height. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/max-height) - */ - maxHeight?: ResponsiveValue>; -} - -export function maxHeight(...args: any[]): any; - -export interface MinHeightProps { - /** - * The min-height CSS property sets the minimum height of an element. It prevents the used value of the height - * property from becoming smaller than the value specified for min-height. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/display) - */ - minHeight?: ResponsiveValue>; -} - -export function minHeight(...args: any[]): any; - -export interface HeightProps { - /** - * The height CSS property specifies the height of an element. By default, the property defines the height of the - * content area. If box-sizing is set to border-box, however, it instead determines the height of the border area. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/height) - */ - height?: ResponsiveValue>; -} - -export function height(...args: any[]): any; - -// TODO: Document, I couldn't find any info on these two properties... - -export interface SizeWidthProps { - size?: ResponsiveValue>; -} - -export function sizeWidth(...args: any[]): any; - -export interface SizeHeightProps { - size?: ResponsiveValue>; -} - -export function sizeHeight(...args: any[]): any; - -export interface SizeProps extends SizeHeightProps, SizeWidthProps {} - -export function size(...args: any[]): any; - -export interface RatioProps { - /** - * The ration is height: 0 & paddingBottom - */ - ratio?: ResponsiveValue; -} - -export function ratio(...args: any[]): any; - -export interface VerticalAlignProps { - /** - * The vertical-align CSS property specifies sets vertical alignment of an inline or table-cell box. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align) - */ - verticalAlign?: ResponsiveValue>; -} - -export function verticalAlign(...args: any[]): any; - -/** - * Flexbox - */ - -export interface AlignItemsProps { - /** - * The CSS align-items property sets the align-self value on all direct children as a group. The align-self - * property sets the alignment of an item within its containing block. - * - * In Flexbox it controls the alignment of items on the Cross Axis, in Grid Layout it controls the alignment - * of items on the Block Axis within their grid area. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) - */ - alignItems?: ResponsiveValue; -} - -export function alignItems(...args: any[]): any; - -export interface AlignContentProps { - /** - * The CSS align-content property sets how the browser distributes space between and around content items - * along the cross-axis of a flexbox container, and the main-axis of a grid container. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) - */ - alignContent?: ResponsiveValue; -} - -export function alignContent(...args: any[]): any; - -export interface JustifyItemsProps { - /** - * The CSS justify-items property defines the default justify-self for all items of the box, giving them all - * a default way of justifying each box along the appropriate axis. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items) - */ - justifyItems?: ResponsiveValue; -} - -export interface JustifyContentProps { - /** - * The CSS justify-content property defines how the browser distributes space between and around content items - * along the main-axis of a flex container, and the inline axis of a grid container. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content) - */ - justifyContent?: ResponsiveValue; -} - -export function justifyContent(...args: any[]): any; - -export interface FlexWrapProps { - /** - * The flex-wrap CSS property sets whether flex items are forced onto one line or can wrap onto multiple lines. - * If wrapping is allowed, it sets the direction that lines are stacked. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap) - */ - flexWrap?: ResponsiveValue; -} - -export function flexWrap(...args: any[]): any; - -export interface FlexBasisProps { - // TODO: The FlexBasisValue currently really only exists for documentation - // purposes, because flex-basis also accepts `Nem` and `Npx` strings. - // Not sure there’s a way to still have the union values show up as - // auto-completion results. - flexBasis?: ResponsiveValue>; -} - -export function flexBasis(...args: any[]): any; - -export interface FlexDirectionProps { - /** - * The flex-direction CSS property specifies how flex items are placed in the flex container defining the main - * axis and the direction (normal or reversed). - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction) - */ - flexDirection?: ResponsiveValue; -} - -export function flexDirection(...args: any[]): any; - -export interface FlexProps { - /** - * The flex CSS property specifies how a flex item will grow or shrink so as to fit the space available in - * its flex container. This is a shorthand property that sets flex-grow, flex-shrink, and flex-basis. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex) - */ - flex?: ResponsiveValue>; -} - -export function flex(...args: any[]): any; - -export interface JustifySelfProps { - /** - * The CSS justify-self property set the way a box is justified inside its alignment container along - * the appropriate axis. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self) - */ - justifySelf?: ResponsiveValue; -} - -export function justifySelf(...args: any[]): any; - -export interface AlignSelfProps { - /** - * The align-self CSS property aligns flex items of the current flex line overriding the align-items value. - * - * If any of the item's cross-axis margin is set to auto, then align-self is ignored. In Grid layout align-self - * aligns the item inside the grid area. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-self) - */ - alignSelf?: ResponsiveValue; -} - -export function alignSelf(...args: any[]): any; - -export interface OrderProps { - /** - * The order CSS property sets the order to lay out an item in a flex or grid container. Items in a container - * are sorted by ascending order value and then by their source code order. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/order) - */ - order?: ResponsiveValue; -} - -export function order(...args: any[]): any; - -/** - * Grid Layout - */ - -export interface GridGapProps { - /** - * The gap CSS property sets the gaps (gutters) between rows and columns. It is a shorthand for row-gap - * and column-gap. - * - * @deprecated use gap - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/gap) - */ - gridGap?: ResponsiveValue>; -} - -export function gridGap(...args: any[]): any; - -export interface GridColumnGapProps { - /** - * The column-gap CSS property sets the size of the gap (gutter) between an element's columns. - * - * @deprecated use column-gap - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap) - */ - gridColumnGap?: ResponsiveValue>; -} - -export function gridColumnGap(...args: any[]): any; - -export interface GridRowGapProps { - /** - * The row-gap CSS property sets the size of the gap (gutter) between an element's rows. - * - * @deprecated use row-gap - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap) - */ - gridRowGap?: ResponsiveValue>; -} - -export function gridRowGap(...args: any[]): any; - -export interface GridColumnProps { - /** - * The grid-column CSS property is a shorthand property for grid-column-start and grid-column-end specifying - * a grid item's size and location within the grid column by contributing a line, a span, or nothing (automatic) - * to its grid placement, thereby specifying the inline-start and inline-end edge of its grid area. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column) - */ - gridColumn?: ResponsiveValue; -} - -export function gridColumn(...args: any[]): any; - -export interface GridRowProps { - /** - * The grid-row CSS property is a shorthand property for grid-row-start and grid-row-end specifying a grid item’s - * size and location within the grid row by contributing a line, a span, or nothing (automatic) to its grid - * placement, thereby specifying the inline-start and inline-end edge of its grid area. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row) - */ - gridRow?: ResponsiveValue; -} - -export function gridRow(...args: any[]): any; - -export interface GridAutoFlowProps { - /** - * The grid-auto-flow CSS property controls how the auto-placement algorithm works, specifying exactly - * how auto-placed items get flowed into the grid. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow) - */ - gridAutoFlow?: ResponsiveValue; -} - -export function gridAutoFlow(...args: any[]): any; - -export interface GridAutoColumnsProps { - /** - * The grid-auto-columns CSS property specifies the size of an implicitly-created grid column track. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns) - */ - gridAutoColumns?: ResponsiveValue>; -} - -export function gridAutoColumns(...args: any[]): any; - -export interface GridAutoRowsProps { - /** - * The grid-auto-rows CSS property specifies the size of an implicitly-created grid row track. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows) - */ - gridAutoRows?: ResponsiveValue>; -} - -export function gridAutoRows(...args: any[]): any; - -export interface GridTemplatesColumnsProps { - /** - * The grid-template-columns CSS property defines the line names and track sizing functions of the grid columns. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns) - */ - gridTemplateColumns?: ResponsiveValue>; -} - -export function gridTemplateColumns(...args: any[]): any; - -export interface GridTemplatesRowsProps { - /** - * The grid-template-rows CSS property defines the line names and track sizing functions of the grid rows. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/row-template-rows) - */ - gridTemplateRows?: ResponsiveValue>; -} - -export function gridTemplateRows(...args: any[]): any; - -export interface GridTemplatesAreasProps { - /** - * The grid-template-areas CSS property specifies named grid areas. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas) - */ - gridTemplateAreas?: ResponsiveValue; -} - -export function gridTemplateAreas(...args: any[]): any; - -export interface GridAreaProps { - /** - * The grid-area CSS property is a shorthand property for grid-row-start, grid-column-start, grid-row-end - * and grid-column-end, specifying a grid item’s size and location within the grid row by contributing a line, - * a span, or nothing (automatic) to its grid placement, thereby specifying the edges of its grid area. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area) - */ - gridArea?: ResponsiveValue; -} - -export function gridArea(...args: any[]): any; - -/** - * Borders - */ - -export interface BorderProps { - /** - * The border CSS property sets an element's border. It's a shorthand for border-width, border-style, - * and border-color. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border) - */ - border?: ResponsiveValue>; -} - -export function border(...args: any[]): any; - -export interface BorderTopProps { - /** - * The border-top CSS property is a shorthand that sets the values of border-top-width, border-top-style, - * and border-top-color. These properties describe an element's top border. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top) - */ - borderTop?: ResponsiveValue>; -} - -export function borderTop(...args: any[]): any; - -export interface BorderRightProps { - /** - * The border-right CSS property is a shorthand that sets border-right-width, border-right-style, - * and border-right-color. These properties set an element's right border. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-right) - */ - borderRight?: ResponsiveValue>; -} - -export function borderRight(...args: any[]): any; - -export interface BorderBottomProps { - /** - * The border-bottom CSS property sets an element's bottom border. It's a shorthand for - * border-bottom-width, border-bottom-style and border-bottom-color. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom) - */ - borderBottom?: ResponsiveValue>; -} - -export function borderBottom(...args: any[]): any; - -export interface BorderLeftProps { - /** - * The border-left CSS property is a shorthand that sets the values of border-left-width, - * border-left-style, and border-left-color. These properties describe an element's left border. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-left) - */ - borderLeft?: ResponsiveValue>; -} - -export function borderLeft(...args: any[]): any; - -export interface BordersProps extends BorderTopProps, BorderRightProps, BorderBottomProps, BorderLeftProps {} - -export function borders(...args: any[]): any; - -export interface BorderColorProps { - /** - * The border-color shorthand CSS property sets the color of all sides of an element's border. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-color) - */ - borderColor?: ResponsiveValue; -} - -export function borderColor(...args: any[]): any; - -export interface BorderRadiusProps { - /** - * The border-radius CSS property rounds the corners of an element's outer border edge. You can set a single - * radius to make circular corners, or two radii to make elliptical corners. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius) - */ - borderRadius?: ResponsiveValue>; -} - -export function borderRadius(...args: any[]): any; - -export interface BoxShadowProps { - /** - * The box-shadow CSS property adds shadow effects around an element's frame. You can set multiple effects - * separated by commas. A box shadow is described by X and Y offsets relative to the element, blur and spread - * radii, and color. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow) - */ - boxShadow?: ResponsiveValue; -} - -export function boxShadow(...arg: any[]): any; - -export interface OpacityProps { - /** - * The opacity CSS property sets the transparency of an element or the degree to which content - * behind an element is visible. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/opacity) - */ - opacity?: ResponsiveValue; -} - -export function opacity(...arg: any[]): any; - -export interface OverflowProps { - /** - * The overflow CSS property sets what to do when an element's content is too big to fit in its block - * formatting context. It is a shorthand for overflow-x and overflow-y. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow) - */ - overflow?: ResponsiveValue; -} - -export function overflow(...arg: any[]): any; -/** - * Background - */ - -export interface BackgroundProps { - /** - * The background shorthand CSS property sets all background style properties at once, - * such as color, image, origin and size, repeat method, and others. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background) - */ - background?: ResponsiveValue>; -} - -export function background(...args: any[]): any; - -export interface BackgroundImageProps { - /** - * The background-image CSS property sets one or more background images on an element. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-image) - */ - backgroundImage?: ResponsiveValue; -} - -export function backgroundImage(...args: any[]): any; - -export interface BackgroundSizeProps { - /** - * The background-size CSS property sets the size of the element's background image. The - * image can be left to its natural size, stretched, or constrained to fit the available space. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-size) - */ - backgroundSize?: ResponsiveValue>; -} - -export function backgroundSize(...args: any[]): any; - -export interface BackgroundPositionProps { - /** - * The background-position CSS property sets the initial position for each background image. The - * position is relative to the position layer set by background-origin. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-position) - */ - backgroundPosition?: ResponsiveValue>; -} - -export function backgroundPosition(...args: any[]): any; - -export interface BackgroundRepeatProps { - /** - * The background-repeat CSS property sets how background images are repeated. A background - * image can be repeated along the horizontal and vertical axes, or not repeated at all. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat) - */ - backgroundRepeat?: ResponsiveValue; -} - -export function backgroundRepeat(...args: any[]): any; - -/** - * Position - */ - -export interface PositionProps { - /** - * The position CSS property specifies how an element is positioned in a document. - * The top, right, bottom, and left properties determine the final location of positioned elements. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/position) - */ - position?: ResponsiveValue; -} - -export function position(...args: any[]): any; - -export interface ZIndexProps { - /** - * The z-index CSS property sets the z-order of a positioned element and its descendants or - * flex items. Overlapping elements with a larger z-index cover those with a smaller one. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/z-index) - */ - zIndex?: ResponsiveValue; -} - -export function zIndex(...args: any[]): any; - -export interface TopProps { - /** - * The top CSS property participates in specifying the vertical position of a - * positioned element. It has no effect on non-positioned elements. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/top) - */ - top?: ResponsiveValue>; -} - -export function top(...args: any[]): any; - -export interface RightProps { - /** - * The right CSS property participates in specifying the horizontal position of a - * positioned element. It has no effect on non-positioned elements. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/right) - */ - right?: ResponsiveValue>; -} - -export function right(...args: any[]): any; - -export interface BottomProps { - /** - * The bottom CSS property participates in specifying the vertical position of a - * positioned element. It has no effect on non-positioned elements. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/top) - */ - bottom?: ResponsiveValue>; -} - -export function bottom(...args: any[]): any; - -export interface LeftProps { - /** - * The left CSS property participates in specifying the horizontal position - * of a positioned element. It has no effect on non-positioned elements. - * - * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/left) - */ - left?: ResponsiveValue>; -} - -export function left(...args: any[]): any; - -export interface TextStyleProps { - textStyle?: ResponsiveValue; -} - -export function textStyle(...args: any[]): any; - -export interface ColorStyleProps { - colors?: ResponsiveValue; -} - -export function colorStyle(...args: any[]): any; - -export interface ButtonStyleProps { - variant?: ResponsiveValue; -} - -export function buttonStyle(...args: any[]): any; diff --git a/types/styled-system/dist/util.d.ts b/types/styled-system/dist/util.d.ts deleted file mode 100644 index 445bb81567..0000000000 --- a/types/styled-system/dist/util.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -export const defaultBreakpoints: string[]; -export function is(n: any): boolean; -export function num(n: any): boolean; -export function px(n: any): string; - -export function get(obj: any, ...paths: Array): any; - -export function themeGet(keys: string, fallback?: string): any; -export function cloneFunc(fn: (...args: any[]) => any): (...args: any[]) => any; - -export function merge(a: any, b: any): any; - -export function compose(...funcs: Array<(...args: any[]) => any>): (...args: any[]) => any; - -export function createMediaQuery(n: string): string; - -export interface LowLevelStylefunctionArguments { - prop: string; - cssProperty?: string; - key?: string; - getter?: () => any; - transformValue?: (n: string|number) => any; - scale?: Array; -} - -export function style(args: LowLevelStylefunctionArguments): any; diff --git a/types/styled-system/dist/variant.d.ts b/types/styled-system/dist/variant.d.ts deleted file mode 100644 index 8a3f8b15ec..0000000000 --- a/types/styled-system/dist/variant.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface VariantArgs { - key?: string; - // Defaults to "variant" - prop?: string; -} - -export function variant(props: VariantArgs): (...args: any[]) => any; diff --git a/types/styled-system/index.d.ts b/types/styled-system/index.d.ts index 2511fbb99c..495df8a6d3 100644 --- a/types/styled-system/index.d.ts +++ b/types/styled-system/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for styled-system 3.0 +// Type definitions for styled-system 3.1 // Project: https://github.com/jxnblk/styled-system#readme // Definitions by: Marshall Bowers // Ben McCormick @@ -11,16 +11,935 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 -import * as util from './dist/util'; +import * as CSS from "csstype"; -export { util }; -export { - style, - themeGet, - merge, - compose, -} from './dist/util'; +export const defaultBreakpoints: string[]; +export function is(n: any): boolean; +export function num(n: any): boolean; +export function px(n: any): string; -export * from './dist/styles'; -export * from './dist/variant'; -export * from './dist/mixed'; +export function get(obj: any, ...paths: Array): any; + +export function themeGet(keys: string, fallback?: string): any; +export function cloneFunc(fn: (...args: any[]) => any): (...args: any[]) => any; + +export function merge(a: any, b: any): any; + +export function compose( + ...funcs: Array<(...args: any[]) => any> +): (...args: any[]) => any; + +export function createMediaQuery(n: number | string): string; + +export interface LowLevelStylefunctionArguments { + prop: string; + cssProperty?: string; + key?: string; + getter?: () => any; + transformValue?: (n: string | number) => any; + scale?: Array; +} + +export function style(args: LowLevelStylefunctionArguments): any; + +export type TLengthStyledSystem = string | 0 | number; +export type ResponsiveValue = T | Array; + +/** + * Converts shorthand margin and padding props to margin and padding CSS declarations + * + * - Numbers from 0-4 (or the length of theme.space) are converted to values on the spacing scale. + * - Negative values can be used for negative margins. + * - Numbers greater than the length of the theme.space array are converted to raw pixel values. + * - String values are passed as raw CSS values. + * - Array values are converted into responsive values. + */ + +export interface SpaceProps { + /** Margin on top, left, bottom and right */ + m?: ResponsiveValue>; + /** Margin for the top */ + mt?: ResponsiveValue>; + /** Margin for the right */ + mr?: ResponsiveValue>; + /** Margin for the bottom */ + mb?: ResponsiveValue>; + /** Margin for the left */ + ml?: ResponsiveValue>; + /** Margin for the left and right */ + mx?: ResponsiveValue>; + /** Margin for the top and bottom */ + my?: ResponsiveValue>; + /** Padding on top, left, bottom and right */ + p?: ResponsiveValue>; + /** Padding for the top */ + pt?: ResponsiveValue>; + /** Padding for the right */ + pr?: ResponsiveValue>; + /** Padding for the bottom */ + pb?: ResponsiveValue>; + /** Padding for the left */ + pl?: ResponsiveValue>; + /** Padding for the left and right */ + px?: ResponsiveValue>; + /** Padding for the top and bottom */ + py?: ResponsiveValue>; +} + +export function space(...args: any[]): any; + +export interface VariantArgs { + key?: string; + // Defaults to "variant" + prop?: string; +} + +export function variant(props: VariantArgs): (...args: any[]) => any; + +export interface BaseTheme { + breakpoints?: number[]; + space?: number[]; + fontSizes?: number[]; + colors?: { + [name: string]: string; + }; +} + +/** + * Font Size + */ + +export interface FontSizeProps { + /** + * The fontSize utility parses a component's `fontSize` prop and converts it into a CSS font-size declaration. + * + * - Numbers from 0-8 (or `theme.fontSizes.length`) are converted to values on the [font size scale](#default-theme). + * - Numbers greater than `theme.fontSizes.length` are converted to raw pixel values. + * - String values are passed as raw CSS values. + * - And array values are converted into responsive values. + * + */ + fontSize?: ResponsiveValue>; +} + +export function fontSize(...args: any[]): any; + +/** + * Color + */ + +export interface TextColorProps { + /** + * The color utility parses a component's `color` and `bg` props and converts them into CSS declarations. + * By default the raw value of the prop is returned. + * + * Color palettes can be configured with the ThemeProvider to use keys as prop values, with support for dot notation. + * Array values are converted into responsive values. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/color) + */ + color?: ResponsiveValue; +} + +export function textColor(...args: any[]): any; + +export interface BgColorProps { + /** + * The color utility parses a component's `color` and `bg` props and converts them into CSS declarations. + * By default the raw value of the prop is returned. + * + * Color palettes can be configured with the ThemeProvider to use keys as prop values, with support for dot notation. + * Array values are converted into responsive values. + * + * [MDN Reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-color) + */ + bg?: ResponsiveValue>; +} + +export function bgColor(...args: any[]): any; + +export interface ColorProps extends TextColorProps, BgColorProps {} + +export function color(...args: any[]): any; + +/** + * Typography + */ +export interface FontFamilyProps { + fontFamily?: ResponsiveValue; +} +export function fontFamily(...args: any[]): any; + +export interface TextAlignProps { + /** + * The text-align CSS property specifies the horizontal alignment of an inline or table-cell box. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/text-align) + */ + textAlign?: ResponsiveValue; +} + +export function textAlign(...args: any[]): any; + +export interface LineHeightProps { + /** + * The line-height CSS property sets the amount of space used for lines, such as in text. On block-level elements, + * it specifies the minimum height of line boxes within the element. + * + * On non-replaced inline elements, it specifies the height that is used to calculate line box height. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height) + */ + lineHeight?: ResponsiveValue>; +} +export function lineHeight(...args: any[]): any; + +export interface FontWeightProps { + /** + * The font-weight CSS property specifies the weight (or boldness) of the font. + * + * The font weights available to you will depend on the font-family you are using. Some fonts are only available in normal and bold. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight) + */ + fontWeight?: ResponsiveValue; +} + +export function fontWeight(...args: any[]): any; + +export interface FontStyleProps { + /** + * The font-style CSS property specifies whether a font should be styled with a normal, italic, + * or oblique face from its font-family. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/font-style) + */ + fontStyle?: ResponsiveValue; +} +export function fontStyle(...args: any[]): any; + +export interface LetterSpacingProps { + /** + * The letter-spacing CSS property sets the spacing behavior between text characters. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/letter-spacing) + */ + letterSpacing?: ResponsiveValue>; +} +export function letterSpacing(...args: any[]): any; + +/** + * Layout + */ + +export interface DisplayProps { + /** + * The display CSS property defines the display type of an element, which consists of the two basic qualities + * of how an element generates boxes — the outer display type defining how the box participates in flow layout, + * and the inner display type defining how the children of the box are laid out. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/display) + */ + display?: ResponsiveValue; +} + +export function display(...args: any[]): any; + +export interface MaxWidthProps { + /** + * The max-width CSS property sets the maximum width of an element. + * It prevents the used value of the width property from becoming larger than the value specified by max-width. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/max-width) + */ + maxWidth?: ResponsiveValue>; +} + +export function maxWidth(...args: any[]): any; + +export interface MinWidthProps { + /** + * The min-width CSS property sets the minimum width of an element. + * It prevents the used value of the width property from becoming smaller than the value specified for min-width. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/min-width) + */ + minWidth?: ResponsiveValue>; +} + +export function minWidth(...args: any[]): any; + +export interface WidthProps { + /** + * The width utility parses a component's `width` prop and converts it into a CSS width declaration. + * + * - Numbers from 0-1 are converted to percentage widths. + * - Numbers greater than 1 are converted to pixel values. + * - String values are passed as raw CSS values. + * - And arrays are converted to responsive width styles. + */ + width?: ResponsiveValue>; +} + +export function width(...args: any[]): any; + +export interface MaxHeightProps { + /** + * The max-height CSS property sets the maximum height of an element. It prevents the used value of the height + * property from becoming larger than the value specified for max-height. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/max-height) + */ + maxHeight?: ResponsiveValue>; +} + +export function maxHeight(...args: any[]): any; + +export interface MinHeightProps { + /** + * The min-height CSS property sets the minimum height of an element. It prevents the used value of the height + * property from becoming smaller than the value specified for min-height. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/display) + */ + minHeight?: ResponsiveValue>; +} + +export function minHeight(...args: any[]): any; + +export interface HeightProps { + /** + * The height CSS property specifies the height of an element. By default, the property defines the height of the + * content area. If box-sizing is set to border-box, however, it instead determines the height of the border area. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/height) + */ + height?: ResponsiveValue>; +} + +export function height(...args: any[]): any; + +// TODO: Document, I couldn't find any info on these two properties... + +export interface SizeWidthProps { + size?: ResponsiveValue>; +} + +export function sizeWidth(...args: any[]): any; + +export interface SizeHeightProps { + size?: ResponsiveValue>; +} + +export function sizeHeight(...args: any[]): any; + +export interface SizeProps extends SizeHeightProps, SizeWidthProps {} + +export function size(...args: any[]): any; + +export interface RatioProps { + /** + * The ration is height: 0 & paddingBottom + */ + ratio?: ResponsiveValue; +} + +export function ratio(...args: any[]): any; + +export interface VerticalAlignProps { + /** + * The vertical-align CSS property specifies sets vertical alignment of an inline or table-cell box. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/vertical-align) + */ + verticalAlign?: ResponsiveValue>; +} + +export function verticalAlign(...args: any[]): any; + +/** + * Flexbox + */ + +export interface AlignItemsProps { + /** + * The CSS align-items property sets the align-self value on all direct children as a group. The align-self + * property sets the alignment of an item within its containing block. + * + * In Flexbox it controls the alignment of items on the Cross Axis, in Grid Layout it controls the alignment + * of items on the Block Axis within their grid area. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-items) + */ + alignItems?: ResponsiveValue; +} + +export function alignItems(...args: any[]): any; + +export interface AlignContentProps { + /** + * The CSS align-content property sets how the browser distributes space between and around content items + * along the cross-axis of a flexbox container, and the main-axis of a grid container. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-content) + */ + alignContent?: ResponsiveValue; +} + +export function alignContent(...args: any[]): any; + +export interface JustifyItemsProps { + /** + * The CSS justify-items property defines the default justify-self for all items of the box, giving them all + * a default way of justifying each box along the appropriate axis. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items) + */ + justifyItems?: ResponsiveValue; +} + +export interface JustifyContentProps { + /** + * The CSS justify-content property defines how the browser distributes space between and around content items + * along the main-axis of a flex container, and the inline axis of a grid container. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content) + */ + justifyContent?: ResponsiveValue; +} + +export function justifyContent(...args: any[]): any; + +export interface FlexWrapProps { + /** + * The flex-wrap CSS property sets whether flex items are forced onto one line or can wrap onto multiple lines. + * If wrapping is allowed, it sets the direction that lines are stacked. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap) + */ + flexWrap?: ResponsiveValue; +} + +export function flexWrap(...args: any[]): any; + +export interface FlexBasisProps { + // TODO: The FlexBasisValue currently really only exists for documentation + // purposes, because flex-basis also accepts `Nem` and `Npx` strings. + // Not sure there’s a way to still have the union values show up as + // auto-completion results. + flexBasis?: ResponsiveValue>; +} + +export function flexBasis(...args: any[]): any; + +export interface FlexDirectionProps { + /** + * The flex-direction CSS property specifies how flex items are placed in the flex container defining the main + * axis and the direction (normal or reversed). + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction) + */ + flexDirection?: ResponsiveValue; +} + +export function flexDirection(...args: any[]): any; + +export interface FlexProps { + /** + * The flex CSS property specifies how a flex item will grow or shrink so as to fit the space available in + * its flex container. This is a shorthand property that sets flex-grow, flex-shrink, and flex-basis. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/flex) + */ + flex?: ResponsiveValue>; +} + +export function flex(...args: any[]): any; + +export interface JustifySelfProps { + /** + * The CSS justify-self property set the way a box is justified inside its alignment container along + * the appropriate axis. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self) + */ + justifySelf?: ResponsiveValue; +} + +export function justifySelf(...args: any[]): any; + +export interface AlignSelfProps { + /** + * The align-self CSS property aligns flex items of the current flex line overriding the align-items value. + * + * If any of the item's cross-axis margin is set to auto, then align-self is ignored. In Grid layout align-self + * aligns the item inside the grid area. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/align-self) + */ + alignSelf?: ResponsiveValue; +} + +export function alignSelf(...args: any[]): any; + +export interface OrderProps { + /** + * The order CSS property sets the order to lay out an item in a flex or grid container. Items in a container + * are sorted by ascending order value and then by their source code order. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/order) + */ + order?: ResponsiveValue; +} + +export function order(...args: any[]): any; + +/** + * Grid Layout + */ + +export interface GridGapProps { + /** + * The gap CSS property sets the gaps (gutters) between rows and columns. It is a shorthand for row-gap + * and column-gap. + * + * @deprecated use gap + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/gap) + */ + gridGap?: ResponsiveValue>; +} + +export function gridGap(...args: any[]): any; + +export interface GridColumnGapProps { + /** + * The column-gap CSS property sets the size of the gap (gutter) between an element's columns. + * + * @deprecated use column-gap + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/column-gap) + */ + gridColumnGap?: ResponsiveValue>; +} + +export function gridColumnGap(...args: any[]): any; + +export interface GridRowGapProps { + /** + * The row-gap CSS property sets the size of the gap (gutter) between an element's rows. + * + * @deprecated use row-gap + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/row-gap) + */ + gridRowGap?: ResponsiveValue>; +} + +export function gridRowGap(...args: any[]): any; + +export interface GridColumnProps { + /** + * The grid-column CSS property is a shorthand property for grid-column-start and grid-column-end specifying + * a grid item's size and location within the grid column by contributing a line, a span, or nothing (automatic) + * to its grid placement, thereby specifying the inline-start and inline-end edge of its grid area. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-column) + */ + gridColumn?: ResponsiveValue; +} + +export function gridColumn(...args: any[]): any; + +export interface GridRowProps { + /** + * The grid-row CSS property is a shorthand property for grid-row-start and grid-row-end specifying a grid item’s + * size and location within the grid row by contributing a line, a span, or nothing (automatic) to its grid + * placement, thereby specifying the inline-start and inline-end edge of its grid area. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-row) + */ + gridRow?: ResponsiveValue; +} + +export function gridRow(...args: any[]): any; + +export interface GridAutoFlowProps { + /** + * The grid-auto-flow CSS property controls how the auto-placement algorithm works, specifying exactly + * how auto-placed items get flowed into the grid. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow) + */ + gridAutoFlow?: ResponsiveValue; +} + +export function gridAutoFlow(...args: any[]): any; + +export interface GridAutoColumnsProps { + /** + * The grid-auto-columns CSS property specifies the size of an implicitly-created grid column track. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-columns) + */ + gridAutoColumns?: ResponsiveValue>; +} + +export function gridAutoColumns(...args: any[]): any; + +export interface GridAutoRowsProps { + /** + * The grid-auto-rows CSS property specifies the size of an implicitly-created grid row track. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-rows) + */ + gridAutoRows?: ResponsiveValue>; +} + +export function gridAutoRows(...args: any[]): any; + +export interface GridTemplatesColumnsProps { + /** + * The grid-template-columns CSS property defines the line names and track sizing functions of the grid columns. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns) + */ + gridTemplateColumns?: ResponsiveValue< + CSS.GridTemplateColumnsProperty + >; +} + +export function gridTemplateColumns(...args: any[]): any; + +export interface GridTemplatesRowsProps { + /** + * The grid-template-rows CSS property defines the line names and track sizing functions of the grid rows. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/row-template-rows) + */ + gridTemplateRows?: ResponsiveValue>; +} + +export function gridTemplateRows(...args: any[]): any; + +export interface GridTemplatesAreasProps { + /** + * The grid-template-areas CSS property specifies named grid areas. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-areas) + */ + gridTemplateAreas?: ResponsiveValue; +} + +export function gridTemplateAreas(...args: any[]): any; + +export interface GridAreaProps { + /** + * The grid-area CSS property is a shorthand property for grid-row-start, grid-column-start, grid-row-end + * and grid-column-end, specifying a grid item’s size and location within the grid row by contributing a line, + * a span, or nothing (automatic) to its grid placement, thereby specifying the edges of its grid area. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/grid-area) + */ + gridArea?: ResponsiveValue; +} + +export function gridArea(...args: any[]): any; + +/** + * Borders + */ + +export interface BorderProps { + /** + * The border CSS property sets an element's border. It's a shorthand for border-width, border-style, + * and border-color. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border) + */ + border?: ResponsiveValue>; +} + +export function border(...args: any[]): any; + +export interface BorderTopProps { + /** + * The border-top CSS property is a shorthand that sets the values of border-top-width, border-top-style, + * and border-top-color. These properties describe an element's top border. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-top) + */ + borderTop?: ResponsiveValue>; +} + +export function borderTop(...args: any[]): any; + +export interface BorderRightProps { + /** + * The border-right CSS property is a shorthand that sets border-right-width, border-right-style, + * and border-right-color. These properties set an element's right border. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-right) + */ + borderRight?: ResponsiveValue>; +} + +export function borderRight(...args: any[]): any; + +export interface BorderBottomProps { + /** + * The border-bottom CSS property sets an element's bottom border. It's a shorthand for + * border-bottom-width, border-bottom-style and border-bottom-color. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-bottom) + */ + borderBottom?: ResponsiveValue>; +} + +export function borderBottom(...args: any[]): any; + +export interface BorderLeftProps { + /** + * The border-left CSS property is a shorthand that sets the values of border-left-width, + * border-left-style, and border-left-color. These properties describe an element's left border. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-left) + */ + borderLeft?: ResponsiveValue>; +} + +export function borderLeft(...args: any[]): any; + +export interface BordersProps + extends BorderTopProps, + BorderRightProps, + BorderBottomProps, + BorderLeftProps {} + +export function borders(...args: any[]): any; + +export interface BorderColorProps { + /** + * The border-color shorthand CSS property sets the color of all sides of an element's border. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-color) + */ + borderColor?: ResponsiveValue; +} + +export function borderColor(...args: any[]): any; + +export interface BorderRadiusProps { + /** + * The border-radius CSS property rounds the corners of an element's outer border edge. You can set a single + * radius to make circular corners, or two radii to make elliptical corners. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius) + */ + borderRadius?: ResponsiveValue>; +} + +export function borderRadius(...args: any[]): any; + +export interface BoxShadowProps { + /** + * The box-shadow CSS property adds shadow effects around an element's frame. You can set multiple effects + * separated by commas. A box shadow is described by X and Y offsets relative to the element, blur and spread + * radii, and color. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow) + */ + boxShadow?: ResponsiveValue; +} + +export function boxShadow(...arg: any[]): any; + +export interface OpacityProps { + /** + * The opacity CSS property sets the transparency of an element or the degree to which content + * behind an element is visible. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/opacity) + */ + opacity?: ResponsiveValue; +} + +export function opacity(...arg: any[]): any; + +export interface OverflowProps { + /** + * The overflow CSS property sets what to do when an element's content is too big to fit in its block + * formatting context. It is a shorthand for overflow-x and overflow-y. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow) + */ + overflow?: ResponsiveValue; +} + +export function overflow(...arg: any[]): any; +/** + * Background + */ + +export interface BackgroundProps { + /** + * The background shorthand CSS property sets all background style properties at once, + * such as color, image, origin and size, repeat method, and others. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background) + */ + background?: ResponsiveValue>; +} + +export function background(...args: any[]): any; + +export interface BackgroundImageProps { + /** + * The background-image CSS property sets one or more background images on an element. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-image) + */ + backgroundImage?: ResponsiveValue; +} + +export function backgroundImage(...args: any[]): any; + +export interface BackgroundSizeProps { + /** + * The background-size CSS property sets the size of the element's background image. The + * image can be left to its natural size, stretched, or constrained to fit the available space. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-size) + */ + backgroundSize?: ResponsiveValue>; +} + +export function backgroundSize(...args: any[]): any; + +export interface BackgroundPositionProps { + /** + * The background-position CSS property sets the initial position for each background image. The + * position is relative to the position layer set by background-origin. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-position) + */ + backgroundPosition?: ResponsiveValue< + CSS.BackgroundPositionProperty + >; +} + +export function backgroundPosition(...args: any[]): any; + +export interface BackgroundRepeatProps { + /** + * The background-repeat CSS property sets how background images are repeated. A background + * image can be repeated along the horizontal and vertical axes, or not repeated at all. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/background-repeat) + */ + backgroundRepeat?: ResponsiveValue; +} + +export function backgroundRepeat(...args: any[]): any; + +/** + * Position + */ + +export interface PositionProps { + /** + * The position CSS property specifies how an element is positioned in a document. + * The top, right, bottom, and left properties determine the final location of positioned elements. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/position) + */ + position?: ResponsiveValue; +} + +export function position(...args: any[]): any; + +export interface ZIndexProps { + /** + * The z-index CSS property sets the z-order of a positioned element and its descendants or + * flex items. Overlapping elements with a larger z-index cover those with a smaller one. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/z-index) + */ + zIndex?: ResponsiveValue; +} + +export function zIndex(...args: any[]): any; + +export interface TopProps { + /** + * The top CSS property participates in specifying the vertical position of a + * positioned element. It has no effect on non-positioned elements. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/top) + */ + top?: ResponsiveValue>; +} + +export function top(...args: any[]): any; + +export interface RightProps { + /** + * The right CSS property participates in specifying the horizontal position of a + * positioned element. It has no effect on non-positioned elements. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/right) + */ + right?: ResponsiveValue>; +} + +export function right(...args: any[]): any; + +export interface BottomProps { + /** + * The bottom CSS property participates in specifying the vertical position of a + * positioned element. It has no effect on non-positioned elements. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/top) + */ + bottom?: ResponsiveValue>; +} + +export function bottom(...args: any[]): any; + +export interface LeftProps { + /** + * The left CSS property participates in specifying the horizontal position + * of a positioned element. It has no effect on non-positioned elements. + * + * [MDN reference](https://developer.mozilla.org/en-US/docs/Web/CSS/left) + */ + left?: ResponsiveValue>; +} + +export function left(...args: any[]): any; + +export interface TextStyleProps { + textStyle?: ResponsiveValue; +} + +export function textStyle(...args: any[]): any; + +export interface ColorStyleProps { + colors?: ResponsiveValue; +} + +export function colorStyle(...args: any[]): any; + +export interface ButtonStyleProps { + variant?: ResponsiveValue; +} + +export function buttonStyle(...args: any[]): any; + +export interface MixedProps { + key?: any; + // Defaults to "variant" + prop?: string; +} + +export function mixed(...args: any[]): any; diff --git a/types/styled-system/styled-system-tests.tsx b/types/styled-system/styled-system-tests.tsx index 756dd0c039..4608aeebec 100644 --- a/types/styled-system/styled-system-tests.tsx +++ b/types/styled-system/styled-system-tests.tsx @@ -122,12 +122,20 @@ import { ButtonStyleProps, MixedProps, VerticalAlignProps, - verticalAlign + verticalAlign, + px, + createMediaQuery } from "styled-system"; // tslint:disable-next-line:strict-export-declare-modifiers declare const styled: (...props: any[]) => React.ComponentType; +const breakpoints = [480, 960]; + +const breakpointsPx = breakpoints.map(px); + +const mediaQueries = breakpoints.map(createMediaQuery); + const boxStyle = variant({ prop: 'boxStyle', key: 'box', diff --git a/types/symlink-or-copy/index.d.ts b/types/symlink-or-copy/index.d.ts new file mode 100644 index 0000000000..d80ad54bc6 --- /dev/null +++ b/types/symlink-or-copy/index.d.ts @@ -0,0 +1,10 @@ +// Type definitions for symlink-or-copy 1.2 +// Project: https://github.com/broccolijs/node-symlink-or-copy#readme +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function sync(srcPath: string, destPath: string): void; + +export const canSymlink: boolean; +export const canSymlinkFile: boolean; +export const canSymlinkDirectory: boolean; diff --git a/types/symlink-or-copy/symlink-or-copy-tests.ts b/types/symlink-or-copy/symlink-or-copy-tests.ts new file mode 100644 index 0000000000..314b2f2bc9 --- /dev/null +++ b/types/symlink-or-copy/symlink-or-copy-tests.ts @@ -0,0 +1,7 @@ +import * as symlinkOrCopy from 'symlink-or-copy'; + +symlinkOrCopy.sync('src_dir/some_file.txt', 'dest_dir/some_file.txt'); + +symlinkOrCopy.canSymlink; // $ExpectType boolean +symlinkOrCopy.canSymlinkDirectory; // $ExpectType boolean +symlinkOrCopy.canSymlinkFile; // $ExpectType boolean diff --git a/types/symlink-or-copy/tsconfig.json b/types/symlink-or-copy/tsconfig.json new file mode 100644 index 0000000000..cba75531dc --- /dev/null +++ b/types/symlink-or-copy/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "symlink-or-copy-tests.ts" + ] +} diff --git a/types/symlink-or-copy/tslint.json b/types/symlink-or-copy/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/symlink-or-copy/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/textextensions/index.d.ts b/types/textextensions/index.d.ts new file mode 100644 index 0000000000..bbb37873bd --- /dev/null +++ b/types/textextensions/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for textextensions 2.4 +// Project: https://github.com/bevry/textextensions +// Definitions by: BendingBender +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = extensions; + +declare const extensions: string[]; diff --git a/types/textextensions/textextensions-tests.ts b/types/textextensions/textextensions-tests.ts new file mode 100644 index 0000000000..19e4b8f82a --- /dev/null +++ b/types/textextensions/textextensions-tests.ts @@ -0,0 +1,3 @@ +import extensions = require('textextensions'); + +extensions; // $ExpectType string[] diff --git a/types/textextensions/tsconfig.json b/types/textextensions/tsconfig.json new file mode 100644 index 0000000000..2ecfa340a3 --- /dev/null +++ b/types/textextensions/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "textextensions-tests.ts" + ] +} diff --git a/types/textextensions/tslint.json b/types/textextensions/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/textextensions/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/three/three-core.d.ts b/types/three/three-core.d.ts index 5bc604232c..25a0f2c07a 100755 --- a/types/three/three-core.d.ts +++ b/types/three/three-core.d.ts @@ -707,7 +707,7 @@ export class BufferAttribute { setArray(array?: ArrayBufferView): void; setDynamic(dynamic: boolean): BufferAttribute; clone(): this; - copy(source: this): this; + copy(source: BufferAttribute): this; copyAt(index1: number, attribute: BufferAttribute, index2: number): BufferAttribute; copyArray(array: ArrayLike): BufferAttribute; copyColorsArray(colors: {r: number, g: number, b: number}[]): BufferAttribute; @@ -927,7 +927,7 @@ export class BufferGeometry extends EventDispatcher { toJSON(): any; clone(): this; - copy(source: this): this; + copy(source: BufferGeometry): this; /** * Disposes the object from memory. @@ -1196,7 +1196,7 @@ export class Face3 { materialIndex: number; clone(): this; - copy(source: this): this; + copy(source: Face3): this; } /** @@ -1427,7 +1427,7 @@ export class Geometry extends EventDispatcher { */ clone(): this; - copy(source: this): this; + copy(source: Geometry): this; /** * Removes The object from memory. @@ -1510,10 +1510,9 @@ export class InterleavedBuffer { setArray(array?: ArrayBufferView): void; setDynamic(dynamic: boolean): InterleavedBuffer; clone(): this; - copy(source: this): this; + copy(source: InterleavedBuffer): this; copyAt(index1: number, attribute: InterleavedBufferAttribute, index2: number): InterleavedBuffer; set(value: ArrayLike, index: number): InterleavedBuffer; - clone(): this; } /** @@ -1847,7 +1846,7 @@ export class Object3D extends EventDispatcher { * @param object * @param recursive */ - copy(source: this, recursive?: boolean): this; + copy(source: Object3D, recursive?: boolean): this; } export interface Intersection { @@ -2016,7 +2015,7 @@ export class LightShadow { map: RenderTarget; matrix: Matrix4; - copy(source: this): this; + copy(source: LightShadow): this; clone(recursive?: boolean): this; toJSON(): any; } @@ -2698,7 +2697,7 @@ export class Material extends EventDispatcher { * Copy the parameters from the passed material into this material. * @param material */ - copy(material: this): this; + copy(material: Material): this; /** * This disposes the material. Textures of a material don't get disposed. These needs to be disposed by {@link Texture}. @@ -3166,8 +3165,10 @@ export class SpriteMaterial extends Material { color: Color; map: Texture | null; rotation: number; + isSpriteMaterial: true; setValues(parameters: SpriteMaterialParameters): void; + copy(source: SpriteMaterial): this; } export class ShadowMaterial extends ShaderMaterial { @@ -3186,7 +3187,7 @@ export class Box2 { setFromPoints(points: Vector2[]): Box2; setFromCenterAndSize(center: Vector2, size: Vector2): Box2; clone(): this; - copy(box: this): this; + copy(box: Box2): this; makeEmpty(): Box2; isEmpty(): boolean; getCenter(target: Vector2): Vector2; @@ -3226,7 +3227,7 @@ export class Box3 { setFromCenterAndSize(center: Vector3, size: Vector3): this; setFromObject(object: Object3D): this; clone(): this; - copy(box: this): this; + copy(box: Box3): this; makeEmpty(): this; isEmpty(): boolean; getCenter(target: Vector3): Vector3; @@ -3335,7 +3336,7 @@ export class Color { * Copies given color. * @param color Color to copy. */ - copy(color: this): this; + copy(color: Color): this; /** * Copies given color making conversion from gamma to linear space. @@ -3553,7 +3554,7 @@ export class Euler { set(x: number, y: number, z: number, order?: string): Euler; clone(): this; - copy(euler: this): this; + copy(euler: Euler): this; setFromRotationMatrix(m: Matrix4, order?: string, update?: boolean): Euler; setFromQuaternion(q: Quaternion, order?: string, update?: boolean): Euler; setFromVector3( v: Vector3, order?: string ): Euler; @@ -3581,7 +3582,7 @@ export class Frustum { set(p0?: number, p1?: number, p2?: number, p3?: number, p4?: number, p5?: number): Frustum; clone(): this; - copy(frustum: this): this; + copy(frustum: Frustum): this; setFromMatrix(m: Matrix4): Frustum; intersectsObject(object: Object3D): boolean; intersectsObject(sprite: Sprite): boolean; @@ -3598,7 +3599,7 @@ export class Line3 { set(start?: Vector3, end?: Vector3): Line3; clone(): this; - copy(line: this): this; + copy(line: Line3): this; getCenter(target: Vector3): Vector3; delta(target: Vector3): Vector3; distanceSq(): number; @@ -3760,7 +3761,7 @@ export class Matrix3 implements Matrix { set(n11: number, n12: number, n13: number, n21: number, n22: number, n23: number, n31: number, n32: number, n33: number): Matrix3; identity(): Matrix3; clone(): this; - copy(m: this): this; + copy(m: Matrix3): this; setFromMatrix4(m: Matrix4): Matrix3; /** @@ -3852,7 +3853,7 @@ export class Matrix4 implements Matrix { */ identity(): Matrix4; clone(): this; - copy(m: this): this; + copy(m: Matrix4): this; copyPosition(m: Matrix4): Matrix4; extractBasis( xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): Matrix4; makeBasis( xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): Matrix4; @@ -4049,7 +4050,7 @@ export class Plane { setFromNormalAndCoplanarPoint(normal: Vector3, point: Vector3): Plane; setFromCoplanarPoints(a: Vector3, b: Vector3, c: Vector3): Plane; clone(): this; - copy(plane: this): this; + copy(plane: Plane): this; normalize(): Plane; negate(): Plane; distanceToPoint(point: Vector3): number; @@ -4079,7 +4080,7 @@ export class Spherical { set(radius: number, phi: number, theta: number): Spherical; clone(): this; - copy(other: this): this; + copy(other: Spherical): this; makeSafe(): void; setFromVector3(vec3: Vector3): Spherical; } @@ -4092,7 +4093,7 @@ export class Cylindrical { y: number; clone(): this; - copy(other: this): this; + copy(other: Cylindrical): this; set(radius: number, theta: number, y: number): this; setFromVector3(vec3: Vector3): this; } @@ -4133,7 +4134,7 @@ export class Quaternion { /** * Copies values of q to this quaternion. */ - copy(q: this): this; + copy(q: Quaternion): this; /** * Sets this quaternion from rotation specified by Euler angles. @@ -4216,7 +4217,7 @@ export class Ray { set(origin: Vector3, direction: Vector3): Ray; clone(): this; - copy(ray: this): this; + copy(ray: Ray): this; at(t: number, target: Vector3): Vector3; lookAt(v: Vector3): Vector3; recast(t: number): Ray; @@ -4260,7 +4261,7 @@ export class Sphere { set(center: Vector3, radius: number): Sphere; setFromPoints(points: Vector3[], optionalCenter?: Vector3): Sphere; clone(): this; - copy(sphere: this): this; + copy(sphere: Sphere): this; empty(): boolean; containsPoint(point: Vector3): boolean; distanceToPoint(point: Vector3): number; @@ -4290,7 +4291,7 @@ export class Triangle { set(a: Vector3, b: Vector3, c: Vector3): Triangle; setFromPointsAndIndices(points: Vector3[], i0: number, i1: number, i2: number): Triangle; clone(): this; - copy(triangle: this): this; + copy(triangle: Triangle): this; getArea(): number; getMidpoint(target: Vector3): Vector3; getNormal(target: Vector3): Vector3; @@ -4426,7 +4427,7 @@ export interface Vector { /** * clone():T; */ - clone(): Vector; + clone(): this; } /** @@ -4476,12 +4477,12 @@ export class Vector2 implements Vector { /** * Returns a new Vector2 instance with the same `x` and `y` values. */ - clone(): Vector2; + clone(): this; /** * Copies value of v to this vector. */ - copy(v: this): this; + copy(v: Vector2): this; /** * Adds v to this vector. @@ -4795,7 +4796,7 @@ export class Vector3 implements Vector { /** * Clones this vector. */ - clone(): Vector3; + clone(): this; /** * Copies value of v to this vector. @@ -5042,12 +5043,12 @@ export class Vector4 implements Vector { /** * Clones this vector. */ - clone(): Vector4; + clone(): this; /** * Copies value of v to this vector. */ - copy(v: this): this; + copy(v: Vector4): this; /** * Adds v to this vector. @@ -5841,7 +5842,7 @@ export class WebGLRenderTarget extends EventDispatcher { setSize(width: number, height: number): void; clone(): this; - copy(source: this): this; + copy(source: WebGLRenderTarget): this; dispose(): void; } @@ -6554,7 +6555,7 @@ export class Texture extends EventDispatcher { static DEFAULT_MAPPING: any; clone(): this; - copy(source: this): this; + copy(source: Texture): this; toJSON(meta: any): any; dispose(): void; transformUv(uv: Vector): void; diff --git a/types/trie-prefix-tree/index.d.ts b/types/trie-prefix-tree/index.d.ts new file mode 100644 index 0000000000..7dcd7ec53c --- /dev/null +++ b/types/trie-prefix-tree/index.d.ts @@ -0,0 +1,66 @@ +// Type definitions for trie-prefix-tree 1.5 +// Project: https://github.com/lyndseybrowning/trie-prefix#readme +// Definitions by: James Lismore +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +export default function Trie( + strings: string[] +): { + /** + * Get a string representation of the trie + */ + dump(spacer?: number): string; + /** + * Get the generated raw trie object + */ + tree(): any; + /** + * Add a new word to the trie + */ + addWord(word: string): ReturnType; + /** + * Remove an existing word from the trie + */ + removeWord(word: string): ReturnType; + /** + * Check a prefix is valid + * @returns Boolean + */ + isPrefix(word: string): boolean; + /** + * Count the number of words with the given prefixSearch + * @returns Number + */ + countPrefix(word: string): number; + /** + * Get a list of all words in the trie with the given prefix + * @returns Array + */ + getPrefix(word: string, sort?: boolean): string[]; + /** + * Get a random word in the trie with the given prefix + * @returns Array + */ + getRandomWordWithPrefix(prefix: string): string; + /** + * Get all words in the trie + * @returns Array + */ + getWords(sorted?: boolean): string[]; + /** + * Check the existence of a word in the trie + * @returns Boolean + */ + hasWord(word: string): boolean; + /** + * Get a list of valid anagrams that can be made from the given letters + * @returns Array + */ + getAnagrams(word: string): string[]; + /** + * Get a list of all sub-anagrams that can be made from the given letters + * @returns Array + */ + getSubAnagrams(word: string): string[]; +}; diff --git a/types/trie-prefix-tree/trie-prefix-tree-tests.ts b/types/trie-prefix-tree/trie-prefix-tree-tests.ts new file mode 100644 index 0000000000..debd86871b --- /dev/null +++ b/types/trie-prefix-tree/trie-prefix-tree-tests.ts @@ -0,0 +1,62 @@ +import trie from "trie-prefix-tree"; + +// Instantiate the Trie +const test = trie(["cat", "cats", "dogs", "elephant", "tiger"]); + +// retrieve a stringified dump of the Trie object +test.dump(); + +// optionally pass in spacer parameter to format the output string +test.dump(2); + +// retrieve the Trie object instance +test.tree(); + +// add a new word to the Trie +test.addWord("lion"); + +// remove an existing word from the Trie +test.removeWord("dogs"); + +// Adding and removing words can be chained: +test.addWord("hello").removeWord("hello"); +test.removeWord("hello").addWord("hello"); + +// check if a prefix exists: +test.isPrefix("do"); +test.isPrefix("z"); + +// count prefixes +test.countPrefix("c"); + +// get an array of words with the passed in prefix +test.getPrefix("c"); + +// Pass false as the second parameter to disable +// output being sorted alphabetically +// this is useful when your dictionary is already sorted +// and will therefore save performance +test.getPrefix("c", false); + +// get a random word at a prefix +test.getRandomWordWithPrefix("c"); +test.getRandomWordWithPrefix("c"); + +// retrieve a full list of words in the Trie +// the output array is automatically sorted +test.getWords(); + +// pass false to disable the output being sorted +// this is useful when your dictionary is already sorted +// and will therefore save performance +test.getWords(false); + +// check if a word exists in the Trie +test.hasWord("elephant"); +test.hasWord("zoo"); + +// generate a list of valid anagrams from the given letters +test.getAnagrams("act"); + +// generate a list of valid sub-anagrams from the given letters +test.getSubAnagrams("ctalion"); diff --git a/types/trie-prefix-tree/tsconfig.json b/types/trie-prefix-tree/tsconfig.json new file mode 100644 index 0000000000..72f38f1616 --- /dev/null +++ b/types/trie-prefix-tree/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": ["index.d.ts", "trie-prefix-tree-tests.ts"] +} diff --git a/types/trie-prefix-tree/tslint.json b/types/trie-prefix-tree/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/trie-prefix-tree/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/ui-box/index.d.ts b/types/ui-box/index.d.ts new file mode 100644 index 0000000000..ee91dc72ce --- /dev/null +++ b/types/ui-box/index.d.ts @@ -0,0 +1,92 @@ +// Type definitions for ui-box 1.4 +// Project: https://github.com/segmentio/ui-box +// Definitions by: Netto Farah +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.8 + +import { Component, ComponentClass, ReactNode } from "react"; +import * as CSS from "csstype"; + +/** Placeholder type for UI box props */ +type UIBoxProp = string | number | boolean | null | undefined; + +/** A prop defining which */ +type UIBoxIsProp = string | ReactNode; + +type CSSProps = CSS.StandardProperties; + +export interface BoxProps { + /** + * Callback that gets passed a ref to inner DOM node (or component if the is prop is set to a + * React component type). + */ + innerRef?(node: ReactNode): any; + + /** + * Lets you change the underlying element type. + * You can pass either a string to change the DOM element type, or a React component type to + * inherit another component. The component just needs to accept a className prop to work. + * A good example is inheriting the react-router Link component + */ + is?: UIBoxIsProp; + + /** + * The className prop you know and love. Internally it gets enhanced with additional class + * names for the CSS properties you specify. + */ + className?: string; + + /** Set to border - box by default. */ + boxSizing?: UIBoxProp; + + /** Sets marginLeft and marginRight to the same value */ + marginX?: UIBoxProp; + + /** Sets marginTop and marginBottom to the same value */ + marginY?: UIBoxProp; + + /** Sets paddingLeft and paddingRight to the same value */ + paddingX?: UIBoxProp; + + /** Sets paddingTop and paddingBottom to the same value */ + paddingY?: UIBoxProp; + + /** Utility property for easily adding clearfix styles to the element. */ + clearfix?: boolean; + + // accept any other arbitrary prop + [key: string]: any; +} + +export type Box = Component; +export const Box: ComponentClass; +export default Box; + +type CacheEntry = ReadonlyArray<[/** key */ string, /** value */ string]>; + +/** + * Returns a { cache, styles } object which contains the cache entries and rendered styles + * for server rendering. The styles can be output in a