This commit is contained in:
parent
7bec1706df
commit
cfb7799134
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/babel__core`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for @babel/core ( https://github.com/babel/babel/tree/master/packages/babel-core ).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babel__core
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Wed, 15 May 2019 16:25:45 GMT
|
||||||
|
* Dependencies: @types/babel__generator, @types/babel__traverse, @types/babel__template, @types/babel__types, @types/babel__parser
|
||||||
|
* Global values: babel
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by Troy Gerwien <https://github.com/yortus>, Marvin Hagemeister <https://github.com/marvinhagemeister>, Melvin Groenhoff <https://github.com/mgroenhoff>, Jessica Franco <https://github.com/Jessidhia>.
|
||||||
|
|
@ -0,0 +1,684 @@
|
||||||
|
// Type definitions for @babel/core 7.1
|
||||||
|
// Project: https://github.com/babel/babel/tree/master/packages/babel-core, https://babeljs.io
|
||||||
|
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||||
|
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||||
|
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||||
|
// Jessica Franco <https://github.com/Jessidhia>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
// TypeScript Version: 2.9
|
||||||
|
|
||||||
|
import { GeneratorOptions } from "@babel/generator";
|
||||||
|
import traverse, { Visitor, NodePath } from "@babel/traverse";
|
||||||
|
import template from "@babel/template";
|
||||||
|
import * as t from "@babel/types";
|
||||||
|
import { ParserOptions } from "@babel/parser";
|
||||||
|
|
||||||
|
export {
|
||||||
|
ParserOptions,
|
||||||
|
GeneratorOptions,
|
||||||
|
t as types,
|
||||||
|
template,
|
||||||
|
traverse,
|
||||||
|
NodePath,
|
||||||
|
Visitor
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Node = t.Node;
|
||||||
|
export type ParseResult = t.File | t.Program;
|
||||||
|
export const version: string;
|
||||||
|
export const DEFAULT_EXTENSIONS: ['.js', '.jsx', '.es6', '.es', '.mjs'];
|
||||||
|
|
||||||
|
export interface TransformOptions {
|
||||||
|
/**
|
||||||
|
* Include the AST in the returned object
|
||||||
|
*
|
||||||
|
* Default: `false`
|
||||||
|
*/
|
||||||
|
ast?: boolean | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attach a comment after all non-user injected code
|
||||||
|
*
|
||||||
|
* Default: `null`
|
||||||
|
*/
|
||||||
|
auxiliaryCommentAfter?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attach a comment before all non-user injected code
|
||||||
|
*
|
||||||
|
* Default: `null`
|
||||||
|
*/
|
||||||
|
auxiliaryCommentBefore?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify the "root" folder that defines the location to search for "babel.config.js", and the default folder to allow `.babelrc` files inside of.
|
||||||
|
*
|
||||||
|
* Default: `"."`
|
||||||
|
*/
|
||||||
|
root?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This option, combined with the "root" value, defines how Babel chooses its project root.
|
||||||
|
* The different modes define different ways that Babel can process the "root" value to get
|
||||||
|
* the final project root.
|
||||||
|
*
|
||||||
|
* @see https://babeljs.io/docs/en/next/options#rootmode
|
||||||
|
*/
|
||||||
|
rootMode?: 'root' | 'upward' | 'upward-optional';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The config file to load Babel's config from. Defaults to searching for "babel.config.js" inside the "root" folder. `false` will disable searching for config files.
|
||||||
|
*
|
||||||
|
* Default: `undefined`
|
||||||
|
*/
|
||||||
|
configFile?: string | false | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify whether or not to use .babelrc and
|
||||||
|
* .babelignore files.
|
||||||
|
*
|
||||||
|
* Default: `true`
|
||||||
|
*/
|
||||||
|
babelrc?: boolean | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify which packages should be search for .babelrc files when they are being compiled. `true` to always search, or a path string or an array of paths to packages to search
|
||||||
|
* inside of. Defaults to only searching the "root" package.
|
||||||
|
*
|
||||||
|
* Default: `(root)`
|
||||||
|
*/
|
||||||
|
babelrcRoots?: true | string | string[] | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defaults to environment variable `BABEL_ENV` if set, or else `NODE_ENV` if set, or else it defaults to `"development"`
|
||||||
|
*
|
||||||
|
* Default: env vars
|
||||||
|
*/
|
||||||
|
envName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable code generation
|
||||||
|
*
|
||||||
|
* Default: `true`
|
||||||
|
*/
|
||||||
|
code?: boolean | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output comments in generated output
|
||||||
|
*
|
||||||
|
* Default: `true`
|
||||||
|
*/
|
||||||
|
comments?: boolean | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not include superfluous whitespace characters and line terminators. When set to `"auto"` compact is set to `true` on input sizes of >500KB
|
||||||
|
*
|
||||||
|
* Default: `"auto"`
|
||||||
|
*/
|
||||||
|
compact?: boolean | "auto" | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The working directory that Babel's programmatic options are loaded relative to.
|
||||||
|
*
|
||||||
|
* Default: `"."`
|
||||||
|
*/
|
||||||
|
cwd?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utilities may pass a caller object to identify themselves to Babel and
|
||||||
|
* pass capability-related flags for use by configs, presets and plugins.
|
||||||
|
*
|
||||||
|
* @see https://babeljs.io/docs/en/next/options#caller
|
||||||
|
*/
|
||||||
|
caller?: TransformCaller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an object of keys that represent different environments. For example, you may have: `{ env: { production: { \/* specific options *\/ } } }`
|
||||||
|
* which will use those options when the `envName` is `production`
|
||||||
|
*
|
||||||
|
* Default: `{}`
|
||||||
|
*/
|
||||||
|
env?: { [index: string]: TransformOptions | null | undefined; } | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A path to a `.babelrc` file to extend
|
||||||
|
*
|
||||||
|
* Default: `null`
|
||||||
|
*/
|
||||||
|
extends?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filename for use in errors etc
|
||||||
|
*
|
||||||
|
* Default: `"unknown"`
|
||||||
|
*/
|
||||||
|
filename?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filename relative to `sourceRoot`
|
||||||
|
*
|
||||||
|
* Default: `(filename)`
|
||||||
|
*/
|
||||||
|
filenameRelative?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object containing the options to be passed down to the babel code generator, @babel/generator
|
||||||
|
*
|
||||||
|
* Default: `{}`
|
||||||
|
*/
|
||||||
|
generatorOpts?: GeneratorOptions | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify a custom callback to generate a module id with. Called as `getModuleId(moduleName)`. If falsy value is returned then the generated module id is used
|
||||||
|
*
|
||||||
|
* Default: `null`
|
||||||
|
*/
|
||||||
|
getModuleId?: ((moduleName: string) => string | null | undefined) | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ANSI highlight syntax error code frames
|
||||||
|
*
|
||||||
|
* Default: `true`
|
||||||
|
*/
|
||||||
|
highlightCode?: boolean | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opposite to the `only` option. `ignore` is disregarded if `only` is specified
|
||||||
|
*
|
||||||
|
* Default: `null`
|
||||||
|
*/
|
||||||
|
ignore?: string[] | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A source map object that the output source map will be based on
|
||||||
|
*
|
||||||
|
* Default: `null`
|
||||||
|
*/
|
||||||
|
inputSourceMap?: object | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should the output be minified (not printing last semicolons in blocks, printing literal string values instead of escaped ones, stripping `()` from `new` when safe)
|
||||||
|
*
|
||||||
|
* Default: `false`
|
||||||
|
*/
|
||||||
|
minified?: boolean | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify a custom name for module ids
|
||||||
|
*
|
||||||
|
* Default: `null`
|
||||||
|
*/
|
||||||
|
moduleId?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If truthy, insert an explicit id for modules. By default, all modules are anonymous. (Not available for `common` modules)
|
||||||
|
*
|
||||||
|
* Default: `false`
|
||||||
|
*/
|
||||||
|
moduleIds?: boolean | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions
|
||||||
|
*
|
||||||
|
* Default: `(sourceRoot)`
|
||||||
|
*/
|
||||||
|
moduleRoot?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A glob, regex, or mixed array of both, matching paths to **only** compile. Can also be an array of arrays containing paths to explicitly match. When attempting to compile
|
||||||
|
* a non-matching file it's returned verbatim
|
||||||
|
*
|
||||||
|
* Default: `null`
|
||||||
|
*/
|
||||||
|
only?: string | RegExp | Array<string | RegExp> | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object containing the options to be passed down to the babel parser, @babel/parser
|
||||||
|
*
|
||||||
|
* Default: `{}`
|
||||||
|
*/
|
||||||
|
parserOpts?: ParserOptions | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of plugins to load and use
|
||||||
|
*
|
||||||
|
* Default: `[]`
|
||||||
|
*/
|
||||||
|
plugins?: PluginItem[] | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of presets (a set of plugins) to load and use
|
||||||
|
*
|
||||||
|
* Default: `[]`
|
||||||
|
*/
|
||||||
|
presets?: PluginItem[] | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retain line numbers. This will lead to wacky code but is handy for scenarios where you can't use source maps. (**NOTE**: This will not retain the columns)
|
||||||
|
*
|
||||||
|
* Default: `false`
|
||||||
|
*/
|
||||||
|
retainLines?: boolean | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An optional callback that controls whether a comment should be output or not. Called as `shouldPrintComment(commentContents)`. **NOTE**: This overrides the `comment` option when used
|
||||||
|
*
|
||||||
|
* Default: `null`
|
||||||
|
*/
|
||||||
|
shouldPrintComment?: ((commentContents: string) => boolean) | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set `sources[0]` on returned source map
|
||||||
|
*
|
||||||
|
* Default: `(filenameRelative)`
|
||||||
|
*/
|
||||||
|
sourceFileName?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If truthy, adds a `map` property to returned output. If set to `"inline"`, a comment with a sourceMappingURL directive is added to the bottom of the returned code. If set to `"both"`
|
||||||
|
* then a `map` property is returned as well as a source map comment appended. **This does not emit sourcemap files by itself!**
|
||||||
|
*
|
||||||
|
* Default: `false`
|
||||||
|
*/
|
||||||
|
sourceMaps?: boolean | "inline" | "both" | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The root from which all sources are relative
|
||||||
|
*
|
||||||
|
* Default: `(moduleRoot)`
|
||||||
|
*/
|
||||||
|
sourceRoot?: string | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicate the mode the code should be parsed in. Can be one of "script", "module", or "unambiguous". `"unambiguous"` will make Babel attempt to guess, based on the presence of ES6
|
||||||
|
* `import` or `export` statements. Files with ES6 `import`s and `export`s are considered `"module"` and are otherwise `"script"`.
|
||||||
|
*
|
||||||
|
* Default: `("module")`
|
||||||
|
*/
|
||||||
|
sourceType?: "script" | "module" | "unambiguous" | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An optional callback that can be used to wrap visitor methods. **NOTE**: This is useful for things like introspection, and not really needed for implementing anything. Called as
|
||||||
|
* `wrapPluginVisitorMethod(pluginAlias, visitorType, callback)`.
|
||||||
|
*/
|
||||||
|
wrapPluginVisitorMethod?: ((pluginAlias: string, visitorType: "enter" | "exit", callback: (path: NodePath, state: any) => void) => (path: NodePath, state: any) => void) | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TransformCaller {
|
||||||
|
// the only required property
|
||||||
|
name: string;
|
||||||
|
// e.g. set to true by `babel-loader` and false by `babel-jest`
|
||||||
|
supportsStaticESM?: boolean;
|
||||||
|
// augment this with a "declare module '@babel/core' { ... }" if you need more keys
|
||||||
|
}
|
||||||
|
|
||||||
|
export type FileResultCallback = (err: Error | null, result: BabelFileResult | null) => any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transforms the passed in code. Calling a callback with an object with the generated code, source map, and AST.
|
||||||
|
*/
|
||||||
|
export function transform(code: string, callback: FileResultCallback): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transforms the passed in code. Calling a callback with an object with the generated code, source map, and AST.
|
||||||
|
*/
|
||||||
|
export function transform(code: string, opts: TransformOptions | undefined, callback: FileResultCallback): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Here for backward-compatibility. Ideally use `transformSync` if you want a synchronous API.
|
||||||
|
*/
|
||||||
|
export function transform(code: string, opts?: TransformOptions): BabelFileResult | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transforms the passed in code. Returning an object with the generated code, source map, and AST.
|
||||||
|
*/
|
||||||
|
export function transformSync(code: string, opts?: TransformOptions): BabelFileResult | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transforms the passed in code. Calling a callback with an object with the generated code, source map, and AST.
|
||||||
|
*/
|
||||||
|
export function transformAsync(code: string, opts?: TransformOptions): Promise<BabelFileResult | null>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asynchronously transforms the entire contents of a file.
|
||||||
|
*/
|
||||||
|
export function transformFile(filename: string, callback: FileResultCallback): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asynchronously transforms the entire contents of a file.
|
||||||
|
*/
|
||||||
|
export function transformFile(filename: string, opts: TransformOptions | undefined, callback: FileResultCallback): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Synchronous version of `babel.transformFile`. Returns the transformed contents of the `filename`.
|
||||||
|
*/
|
||||||
|
export function transformFileSync(filename: string, opts?: TransformOptions): BabelFileResult | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asynchronously transforms the entire contents of a file.
|
||||||
|
*/
|
||||||
|
export function transformFileAsync(filename: string, opts?: TransformOptions): Promise<BabelFileResult | null>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given an AST, transform it.
|
||||||
|
*/
|
||||||
|
export function transformFromAst(ast: Node, code: string | undefined, callback: FileResultCallback): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given an AST, transform it.
|
||||||
|
*/
|
||||||
|
export function transformFromAst(ast: Node, code: string | undefined, opts: TransformOptions | undefined, callback: FileResultCallback): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Here for backward-compatibility. Ideally use ".transformSync" if you want a synchronous API.
|
||||||
|
*/
|
||||||
|
export function transformFromAstSync(ast: Node, code?: string, opts?: TransformOptions): BabelFileResult | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given an AST, transform it.
|
||||||
|
*/
|
||||||
|
export function transformFromAstAsync(ast: Node, code?: string, opts?: TransformOptions): Promise<BabelFileResult | null>;
|
||||||
|
|
||||||
|
// A babel plugin is a simple function which must return an object matching
|
||||||
|
// the following interface. Babel will throw if it finds unknown properties.
|
||||||
|
// The list of allowed plugin keys is here:
|
||||||
|
// https://github.com/babel/babel/blob/4e50b2d9d9c376cee7a2cbf56553fe5b982ea53c/packages/babel-core/src/config/option-manager.js#L71
|
||||||
|
export interface PluginObj<S = {}> {
|
||||||
|
name?: string;
|
||||||
|
manipulateOptions?(opts: any, parserOpts: any): void;
|
||||||
|
pre?(this: S, state: any): void;
|
||||||
|
visitor: Visitor<S>;
|
||||||
|
post?(this: S, state: any): void;
|
||||||
|
inherits?: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BabelFileResult {
|
||||||
|
ast?: t.File | null;
|
||||||
|
code?: string | null;
|
||||||
|
ignored?: boolean;
|
||||||
|
map?: {
|
||||||
|
version: number;
|
||||||
|
sources: string[];
|
||||||
|
names: string[];
|
||||||
|
sourceRoot?: string;
|
||||||
|
sourcesContent?: string[];
|
||||||
|
mappings: string;
|
||||||
|
file: string;
|
||||||
|
} | null;
|
||||||
|
metadata?: BabelFileMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BabelFileMetadata {
|
||||||
|
usedHelpers: string[];
|
||||||
|
marked: Array<{
|
||||||
|
type: string;
|
||||||
|
message: string;
|
||||||
|
loc: object;
|
||||||
|
}>;
|
||||||
|
modules: BabelFileModulesMetadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BabelFileModulesMetadata {
|
||||||
|
imports: object[];
|
||||||
|
exports: {
|
||||||
|
exported: object[];
|
||||||
|
specifiers: object[];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export type FileParseCallback = (err: Error | null, result: ParseResult | null) => any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given some code, parse it using Babel's standard behavior.
|
||||||
|
* Referenced presets and plugins will be loaded such that optional syntax plugins are automatically enabled.
|
||||||
|
*/
|
||||||
|
export function parse(code: string, callback: FileParseCallback): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given some code, parse it using Babel's standard behavior.
|
||||||
|
* Referenced presets and plugins will be loaded such that optional syntax plugins are automatically enabled.
|
||||||
|
*/
|
||||||
|
export function parse(code: string, options: TransformOptions | undefined, callback: FileParseCallback): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given some code, parse it using Babel's standard behavior.
|
||||||
|
* Referenced presets and plugins will be loaded such that optional syntax plugins are automatically enabled.
|
||||||
|
*/
|
||||||
|
export function parse(code: string, options?: TransformOptions): ParseResult | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given some code, parse it using Babel's standard behavior.
|
||||||
|
* Referenced presets and plugins will be loaded such that optional syntax plugins are automatically enabled.
|
||||||
|
*/
|
||||||
|
export function parseSync(code: string, options?: TransformOptions): ParseResult | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given some code, parse it using Babel's standard behavior.
|
||||||
|
* Referenced presets and plugins will be loaded such that optional syntax plugins are automatically enabled.
|
||||||
|
*/
|
||||||
|
export function parseAsync(code: string, options?: TransformOptions): Promise<ParseResult | null>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resolve Babel's options fully, resulting in an options object where:
|
||||||
|
*
|
||||||
|
* * opts.plugins is a full list of Plugin instances.
|
||||||
|
* * opts.presets is empty and all presets are flattened into opts.
|
||||||
|
* * It can be safely passed back to Babel. Fields like babelrc have been set to false so that later calls to Babel
|
||||||
|
* will not make a second attempt to load config files.
|
||||||
|
*
|
||||||
|
* Plugin instances aren't meant to be manipulated directly, but often callers will serialize this opts to JSON to
|
||||||
|
* use it as a cache key representing the options Babel has received. Caching on this isn't 100% guaranteed to
|
||||||
|
* invalidate properly, but it is the best we have at the moment.
|
||||||
|
*/
|
||||||
|
export function loadOptions(options?: TransformOptions): object | null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To allow systems to easily manipulate and validate a user's config, this function resolves the plugins and
|
||||||
|
* presets and proceeds no further. The expectation is that callers will take the config's .options, manipulate it
|
||||||
|
* as then see fit and pass it back to Babel again.
|
||||||
|
*
|
||||||
|
* * `babelrc: string | void` - The path of the `.babelrc` file, if there was one.
|
||||||
|
* * `babelignore: string | void` - The path of the `.babelignore` file, if there was one.
|
||||||
|
* * `options: ValidatedOptions` - The partially resolved options, which can be manipulated and passed back
|
||||||
|
* to Babel again.
|
||||||
|
* * `plugins: Array<ConfigItem>` - See below.
|
||||||
|
* * `presets: Array<ConfigItem>` - See below.
|
||||||
|
* * It can be safely passed back to Babel. Fields like `babelrc` have been set to false so that later calls to
|
||||||
|
* Babel will not make a second attempt to load config files.
|
||||||
|
*
|
||||||
|
* `ConfigItem` instances expose properties to introspect the values, but each item should be treated as
|
||||||
|
* immutable. If changes are desired, the item should be removed from the list and replaced with either a normal
|
||||||
|
* Babel config value, or with a replacement item created by `babel.createConfigItem`. See that function for
|
||||||
|
* information about `ConfigItem` fields.
|
||||||
|
*/
|
||||||
|
export function loadPartialConfig(options?: TransformOptions): Readonly<PartialConfig> | null;
|
||||||
|
|
||||||
|
export interface PartialConfig {
|
||||||
|
options: TransformOptions;
|
||||||
|
babelrc?: string;
|
||||||
|
babelignore?: string;
|
||||||
|
config?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ConfigItem {
|
||||||
|
/**
|
||||||
|
* The name that the user gave the plugin instance, e.g. `plugins: [ ['env', {}, 'my-env'] ]`
|
||||||
|
*/
|
||||||
|
name?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The resolved value of the plugin.
|
||||||
|
*/
|
||||||
|
value: object | ((...args: any[]) => any);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The options object passed to the plugin.
|
||||||
|
*/
|
||||||
|
options?: object | false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The path that the options are relative to.
|
||||||
|
*/
|
||||||
|
dirname: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Information about the plugin's file, if Babel knows it.
|
||||||
|
* *
|
||||||
|
*/
|
||||||
|
file?: {
|
||||||
|
/**
|
||||||
|
* The file that the user requested, e.g. `"@babel/env"`
|
||||||
|
*/
|
||||||
|
request: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The full path of the resolved file, e.g. `"/tmp/node_modules/@babel/preset-env/lib/index.js"`
|
||||||
|
*/
|
||||||
|
resolved: string;
|
||||||
|
} | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PluginOptions = object | undefined | false;
|
||||||
|
|
||||||
|
export type PluginTarget = string | object | ((...args: any[]) => any);
|
||||||
|
|
||||||
|
export type PluginItem = ConfigItem | PluginObj<any> | PluginTarget | [PluginTarget, PluginOptions] | [PluginTarget, PluginOptions, string | undefined];
|
||||||
|
|
||||||
|
export interface CreateConfigItemOptions {
|
||||||
|
dirname?: string;
|
||||||
|
type?: "preset" | "plugin";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows build tooling to create and cache config items up front. If this function is called multiple times for a
|
||||||
|
* given plugin, Babel will call the plugin's function itself multiple times. If you have a clear set of expected
|
||||||
|
* plugins and presets to inject, pre-constructing the config items would be recommended.
|
||||||
|
*/
|
||||||
|
export function createConfigItem(value: PluginTarget | [PluginTarget, PluginOptions] | [PluginTarget, PluginOptions, string | undefined], options?: CreateConfigItemOptions): ConfigItem;
|
||||||
|
|
||||||
|
// NOTE: the documentation says the ConfigAPI also exposes @babel/core's exports, but it actually doesn't
|
||||||
|
/**
|
||||||
|
* @see https://babeljs.io/docs/en/next/config-files#config-function-api
|
||||||
|
*/
|
||||||
|
export interface ConfigAPI {
|
||||||
|
/**
|
||||||
|
* The version string for the Babel version that is loading the config file.
|
||||||
|
*
|
||||||
|
* @see https://babeljs.io/docs/en/next/config-files#apiversion
|
||||||
|
*/
|
||||||
|
version: string;
|
||||||
|
/**
|
||||||
|
* @see https://babeljs.io/docs/en/next/config-files#apicache
|
||||||
|
*/
|
||||||
|
cache: SimpleCacheConfigurator;
|
||||||
|
/**
|
||||||
|
* @see https://babeljs.io/docs/en/next/config-files#apienv
|
||||||
|
*/
|
||||||
|
env: EnvFunction;
|
||||||
|
// undocumented; currently hardcoded to return 'false'
|
||||||
|
// async(): boolean
|
||||||
|
/**
|
||||||
|
* This API is used as a way to access the `caller` data that has been passed to Babel.
|
||||||
|
* Since many instances of Babel may be running in the same process with different `caller` values,
|
||||||
|
* this API is designed to automatically configure `api.cache`, the same way `api.env()` does.
|
||||||
|
*
|
||||||
|
* The `caller` value is available as the first parameter of the callback function.
|
||||||
|
* It is best used with something like this to toggle configuration behavior
|
||||||
|
* based on a specific environment:
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* function isBabelRegister(caller?: { name: string }) {
|
||||||
|
* return !!(caller && caller.name === "@babel/register")
|
||||||
|
* }
|
||||||
|
* api.caller(isBabelRegister)
|
||||||
|
*
|
||||||
|
* @see https://babeljs.io/docs/en/next/config-files#apicallercb
|
||||||
|
*/
|
||||||
|
caller<T extends SimpleCacheKey>(callerCallback: (caller: TransformOptions['caller']) => T): T;
|
||||||
|
/**
|
||||||
|
* While `api.version` can be useful in general, it's sometimes nice to just declare your version.
|
||||||
|
* This API exposes a simple way to do that with:
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* api.assertVersion(7) // major version only
|
||||||
|
* api.assertVersion("^7.2")
|
||||||
|
*
|
||||||
|
* @see https://babeljs.io/docs/en/next/config-files#apiassertversionrange
|
||||||
|
*/
|
||||||
|
assertVersion(versionRange: number | string): boolean;
|
||||||
|
// NOTE: this is an undocumented reexport from "@babel/parser" but it's missing from its types
|
||||||
|
// tokTypes: typeof tokTypes
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JS configs are great because they can compute a config on the fly,
|
||||||
|
* but the downside there is that it makes caching harder.
|
||||||
|
* Babel wants to avoid re-executing the config function every time a file is compiled,
|
||||||
|
* because then it would also need to re-execute any plugin and preset functions
|
||||||
|
* referenced in that config.
|
||||||
|
*
|
||||||
|
* To avoid this, Babel expects users of config functions to tell it how to manage caching
|
||||||
|
* within a config file.
|
||||||
|
*
|
||||||
|
* @see https://babeljs.io/docs/en/next/config-files#apicache
|
||||||
|
*/
|
||||||
|
export interface SimpleCacheConfigurator {
|
||||||
|
// there is an undocumented call signature that is a shorthand for forever()/never()/using().
|
||||||
|
// (ever: boolean): void
|
||||||
|
// <T extends SimpleCacheKey>(callback: CacheCallback<T>): T
|
||||||
|
/**
|
||||||
|
* Permacache the computed config and never call the function again.
|
||||||
|
*/
|
||||||
|
forever(): void;
|
||||||
|
/**
|
||||||
|
* Do not cache this config, and re-execute the function every time.
|
||||||
|
*/
|
||||||
|
never(): void;
|
||||||
|
/**
|
||||||
|
* Any time the using callback returns a value other than the one that was expected,
|
||||||
|
* the overall config function will be called again and a new entry will be added to the cache.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* api.cache.using(() => process.env.NODE_ENV)
|
||||||
|
*/
|
||||||
|
using<T extends SimpleCacheKey>(callback: SimpleCacheCallback<T>): T;
|
||||||
|
/**
|
||||||
|
* Any time the using callback returns a value other than the one that was expected,
|
||||||
|
* the overall config function will be called again and all entries in the cache will
|
||||||
|
* be replaced with the result.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* api.cache.invalidate(() => process.env.NODE_ENV)
|
||||||
|
*/
|
||||||
|
invalidate<T extends SimpleCacheKey>(callback: SimpleCacheCallback<T>): T;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/babel/babel/blob/v7.3.3/packages/babel-core/src/config/caching.js#L231
|
||||||
|
export type SimpleCacheKey = string | boolean | number | null | undefined;
|
||||||
|
export type SimpleCacheCallback<T extends SimpleCacheKey> = () => T;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Since `NODE_ENV` is a fairly common way to toggle behavior, Babel also includes an API function
|
||||||
|
* meant specifically for that. This API is used as a quick way to check the `"envName"` that Babel
|
||||||
|
* was loaded with, which takes `NODE_ENV` into account if no other overriding environment is set.
|
||||||
|
*
|
||||||
|
* @see https://babeljs.io/docs/en/next/config-files#apienv
|
||||||
|
*/
|
||||||
|
export interface EnvFunction {
|
||||||
|
/**
|
||||||
|
* @returns the current `envName` string
|
||||||
|
*/
|
||||||
|
(): string;
|
||||||
|
/**
|
||||||
|
* @returns `true` if the `envName` is `===` any of the given strings
|
||||||
|
*/
|
||||||
|
(envName: string | ReadonlyArray<string>): boolean;
|
||||||
|
// the official documentation is misleading for this one...
|
||||||
|
// this just passes the callback to `cache.using` but with an additional argument.
|
||||||
|
// it returns its result instead of necessarily returning a boolean.
|
||||||
|
<T extends SimpleCacheKey>(envCallback: (envName: NonNullable<TransformOptions['envName']>) => T): T;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ConfigFunction = (api: ConfigAPI) => TransformOptions;
|
||||||
|
|
||||||
|
export as namespace babel;
|
||||||
|
|
@ -0,0 +1,49 @@
|
||||||
|
{
|
||||||
|
"name": "@types/babel__core",
|
||||||
|
"version": "7.1.2",
|
||||||
|
"description": "TypeScript definitions for @babel/core",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Troy Gerwien",
|
||||||
|
"url": "https://github.com/yortus",
|
||||||
|
"githubUsername": "yortus"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Marvin Hagemeister",
|
||||||
|
"url": "https://github.com/marvinhagemeister",
|
||||||
|
"githubUsername": "marvinhagemeister"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Melvin Groenhoff",
|
||||||
|
"url": "https://github.com/mgroenhoff",
|
||||||
|
"githubUsername": "mgroenhoff"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jessica Franco",
|
||||||
|
"url": "https://github.com/Jessidhia",
|
||||||
|
"githubUsername": "Jessidhia"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
|
"directory": "types/babel__core"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/parser": "^7.1.0",
|
||||||
|
"@babel/types": "^7.0.0",
|
||||||
|
"@types/babel__generator": "*",
|
||||||
|
"@types/babel__template": "*",
|
||||||
|
"@types/babel__traverse": "*"
|
||||||
|
},
|
||||||
|
"typesPublisherContentHash": "8ddbc9ecfefbb1a61ece46d6e48876a63d101c6c5291bb173a929cead248d6a2",
|
||||||
|
"typeScriptVersion": "2.9"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.2.tgz"
|
||||||
|
,"_integrity": "sha512-cfCCrFmiGY/yq0NuKNxIQvZFy9kY/1immpSpTngOnyIbD4+eJOG5mxphhHDv3CHL9GltO4GcKr54kGBg3RNdbg=="
|
||||||
|
,"_from": "@types/babel__core@7.1.2"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/babel__generator`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for @babel/generator ( https://github.com/babel/babel/tree/master/packages/babel-generator ).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babel__generator
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Wed, 13 Feb 2019 21:04:23 GMT
|
||||||
|
* Dependencies: @types/babel__types
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by Troy Gerwien <https://github.com/yortus>, Johnny Estilles <https://github.com/johnnyestilles>, Melvin Groenhoff <https://github.com/mgroenhoff>.
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
// Type definitions for @babel/generator 7.0
|
||||||
|
// Project: https://github.com/babel/babel/tree/master/packages/babel-generator, https://babeljs.io
|
||||||
|
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||||
|
// Johnny Estilles <https://github.com/johnnyestilles>
|
||||||
|
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
// TypeScript Version: 2.9
|
||||||
|
|
||||||
|
import * as t from "@babel/types";
|
||||||
|
|
||||||
|
export interface GeneratorOptions {
|
||||||
|
/**
|
||||||
|
* Optional string to add as a block comment at the start of the output file.
|
||||||
|
*/
|
||||||
|
auxiliaryCommentBefore?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optional string to add as a block comment at the end of the output file.
|
||||||
|
*/
|
||||||
|
auxiliaryCommentAfter?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that takes a comment (as a string) and returns true if the comment should be included in the output.
|
||||||
|
* By default, comments are included if `opts.comments` is `true` or if `opts.minifed` is `false` and the comment
|
||||||
|
* contains `@preserve` or `@license`.
|
||||||
|
*/
|
||||||
|
shouldPrintComment?(comment: string): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempt to use the same line numbers in the output code as in the source code (helps preserve stack traces).
|
||||||
|
* Defaults to `false`.
|
||||||
|
*/
|
||||||
|
retainLines?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should comments be included in output? Defaults to `true`.
|
||||||
|
*/
|
||||||
|
comments?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to true to avoid adding whitespace for formatting. Defaults to the value of `opts.minified`.
|
||||||
|
*/
|
||||||
|
compact?: boolean | "auto";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should the output be minified. Defaults to `false`.
|
||||||
|
*/
|
||||||
|
minified?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to true to reduce whitespace (but not as much as opts.compact). Defaults to `false`.
|
||||||
|
*/
|
||||||
|
concise?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type of quote to use in the output. If omitted, autodetects based on `ast.tokens`.
|
||||||
|
*/
|
||||||
|
quotes?: "single" | "double";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used in warning messages
|
||||||
|
*/
|
||||||
|
filename?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable generating source maps. Defaults to `false`.
|
||||||
|
*/
|
||||||
|
sourceMaps?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The filename of the generated code that the source map will be associated with.
|
||||||
|
*/
|
||||||
|
sourceMapTarget?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A root for all relative URLs in the source map.
|
||||||
|
*/
|
||||||
|
sourceRoot?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The filename for the source code (i.e. the code in the `code` argument).
|
||||||
|
* This will only be used if `code` is a string.
|
||||||
|
*/
|
||||||
|
sourceFileName?: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set to true to run jsesc with "json": true to print "\u00A9" vs. "©";
|
||||||
|
*/
|
||||||
|
jsonCompatibleStrings?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CodeGenerator {
|
||||||
|
constructor(ast: t.Node, opts?: GeneratorOptions, code?: string);
|
||||||
|
generate(): GeneratorResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Turns an AST into code, maintaining sourcemaps, user preferences, and valid output.
|
||||||
|
* @param ast - the abstract syntax tree from which to generate output code.
|
||||||
|
* @param opts - used for specifying options for code generation.
|
||||||
|
* @param code - the original source code, used for source maps.
|
||||||
|
* @returns - an object containing the output code and source map.
|
||||||
|
*/
|
||||||
|
export default function generate(ast: t.Node, opts?: GeneratorOptions, code?: string | { [filename: string]: string; }): GeneratorResult;
|
||||||
|
|
||||||
|
export interface GeneratorResult {
|
||||||
|
code: string;
|
||||||
|
map: {
|
||||||
|
version: number;
|
||||||
|
sources: string[];
|
||||||
|
names: string[];
|
||||||
|
sourceRoot?: string;
|
||||||
|
sourcesContent?: string[];
|
||||||
|
mappings: string;
|
||||||
|
file: string;
|
||||||
|
} | null;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
{
|
||||||
|
"name": "@types/babel__generator",
|
||||||
|
"version": "7.0.2",
|
||||||
|
"description": "TypeScript definitions for @babel/generator",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Troy Gerwien",
|
||||||
|
"url": "https://github.com/yortus",
|
||||||
|
"githubUsername": "yortus"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Johnny Estilles",
|
||||||
|
"url": "https://github.com/johnnyestilles",
|
||||||
|
"githubUsername": "johnnyestilles"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Melvin Groenhoff",
|
||||||
|
"url": "https://github.com/mgroenhoff",
|
||||||
|
"githubUsername": "mgroenhoff"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/types": "^7.0.0"
|
||||||
|
},
|
||||||
|
"typesPublisherContentHash": "12b47650c77333060b8da231a33c95326cb124929b12d19cd41d9c2dae936d80",
|
||||||
|
"typeScriptVersion": "2.9"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.0.2.tgz"
|
||||||
|
,"_integrity": "sha512-NHcOfab3Zw4q5sEE2COkpfXjoE7o+PmqD9DQW4koUT3roNxwziUdXGnRndMat/LJNUtePwn1TlP4do3uoe3KZQ=="
|
||||||
|
,"_from": "@types/babel__generator@7.0.2"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/babel__template`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for @babel/template ( https://github.com/babel/babel/tree/master/packages/babel-template ).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babel__template
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Wed, 13 Feb 2019 21:04:23 GMT
|
||||||
|
* Dependencies: @types/babel__parser, @types/babel__types
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by Troy Gerwien <https://github.com/yortus>, Marvin Hagemeister <https://github.com/marvinhagemeister>, Melvin Groenhoff <https://github.com/mgroenhoff>.
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
// Type definitions for @babel/template 7.0
|
||||||
|
// Project: https://github.com/babel/babel/tree/master/packages/babel-template, https://babeljs.io
|
||||||
|
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||||
|
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||||
|
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
// TypeScript Version: 2.9
|
||||||
|
|
||||||
|
import { ParserOptions } from "@babel/parser";
|
||||||
|
import { Expression, File, Program, Statement } from "@babel/types";
|
||||||
|
|
||||||
|
export interface TemplateBuilderOptions extends ParserOptions {
|
||||||
|
/**
|
||||||
|
* A set of placeholder names to automatically accept. Items in this list do not need to match the given placeholder pattern.
|
||||||
|
*/
|
||||||
|
placeholderWhitelist?: Set<string>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A pattern to search for when looking for Identifier and StringLiteral nodes that should be considered placeholders. `false` will
|
||||||
|
* disable placeholder searching entirely, leaving only the `placeholderWhitelist` value to find placeholders.
|
||||||
|
*/
|
||||||
|
placeholderPattern?: RegExp | false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set this to `true` to preserve any comments from the `code` parameter.
|
||||||
|
*/
|
||||||
|
preserveComments?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TemplateBuilder<T> {
|
||||||
|
/**
|
||||||
|
* Build a new builder, merging the given options with the previous ones.
|
||||||
|
*/
|
||||||
|
(opts: TemplateBuilderOptions): TemplateBuilder<T>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Building from a string produces an AST builder function by default.
|
||||||
|
*/
|
||||||
|
(code: string, opts?: TemplateBuilderOptions): (arg?: PublicReplacements) => T;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Building from a template literal produces an AST builder function by default.
|
||||||
|
*/
|
||||||
|
(tpl: TemplateStringsArray, ...args: any[]): (arg?: PublicReplacements) => T;
|
||||||
|
|
||||||
|
// Allow users to explicitly create templates that produce ASTs, skipping the need for an intermediate function.
|
||||||
|
ast: {
|
||||||
|
(tpl: string, opts?: TemplateBuilderOptions): T;
|
||||||
|
(tpl: TemplateStringsArray, ...args: any[]): T;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export type PublicReplacements = { [index: string]: any; } | any[];
|
||||||
|
|
||||||
|
export const smart: TemplateBuilder<Statement | Statement[]>;
|
||||||
|
export const statement: TemplateBuilder<Statement>;
|
||||||
|
export const statements: TemplateBuilder<Statement[]>;
|
||||||
|
export const expression: TemplateBuilder<Expression>;
|
||||||
|
export const program: TemplateBuilder<Program>;
|
||||||
|
|
||||||
|
type DefaultTemplateBuilder = typeof smart & {
|
||||||
|
smart: typeof smart;
|
||||||
|
statement: typeof statement;
|
||||||
|
statements: typeof statements;
|
||||||
|
expression: typeof expression;
|
||||||
|
program: typeof program;
|
||||||
|
ast: typeof smart.ast;
|
||||||
|
};
|
||||||
|
|
||||||
|
declare const templateBuilder: DefaultTemplateBuilder;
|
||||||
|
|
||||||
|
export default templateBuilder;
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
{
|
||||||
|
"name": "@types/babel__template",
|
||||||
|
"version": "7.0.2",
|
||||||
|
"description": "TypeScript definitions for @babel/template",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Troy Gerwien",
|
||||||
|
"url": "https://github.com/yortus",
|
||||||
|
"githubUsername": "yortus"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Marvin Hagemeister",
|
||||||
|
"url": "https://github.com/marvinhagemeister",
|
||||||
|
"githubUsername": "marvinhagemeister"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Melvin Groenhoff",
|
||||||
|
"url": "https://github.com/mgroenhoff",
|
||||||
|
"githubUsername": "mgroenhoff"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/parser": "^7.1.0",
|
||||||
|
"@babel/types": "^7.0.0"
|
||||||
|
},
|
||||||
|
"typesPublisherContentHash": "fd665ffdd94e184259796e85ff1a8e8626a23fb0eeefd6cfb9f77a316eda2624",
|
||||||
|
"typeScriptVersion": "2.9"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.0.2.tgz"
|
||||||
|
,"_integrity": "sha512-/K6zCpeW7Imzgab2bLkLEbz0+1JlFSrUMdw7KoIIu+IUdu51GWaBZpd3y1VXGVXzynvGa4DaIaxNZHiON3GXUg=="
|
||||||
|
,"_from": "@types/babel__template@7.0.2"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/babel__traverse`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for @babel/traverse ( https://github.com/babel/babel/tree/master/packages/babel-traverse ).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/babel__traverse
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Tue, 11 Jun 2019 02:00:21 GMT
|
||||||
|
* Dependencies: @types/babel__types
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by Troy Gerwien <https://github.com/yortus>, Marvin Hagemeister <https://github.com/marvinhagemeister>, Ryan Petrich <https://github.com/rpetrich>, Melvin Groenhoff <https://github.com/mgroenhoff>.
|
||||||
|
|
@ -0,0 +1,829 @@
|
||||||
|
// Type definitions for @babel/traverse 7.0
|
||||||
|
// Project: https://github.com/babel/babel/tree/master/packages/babel-traverse, https://babeljs.io
|
||||||
|
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||||
|
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||||
|
// Ryan Petrich <https://github.com/rpetrich>
|
||||||
|
// Melvin Groenhoff <https://github.com/mgroenhoff>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
// TypeScript Version: 2.9
|
||||||
|
|
||||||
|
import * as t from "@babel/types";
|
||||||
|
|
||||||
|
export type Node = t.Node;
|
||||||
|
|
||||||
|
export default function traverse<S>(
|
||||||
|
parent: Node | Node[],
|
||||||
|
opts: TraverseOptions<S>,
|
||||||
|
scope: Scope | undefined,
|
||||||
|
state: S,
|
||||||
|
parentPath?: NodePath,
|
||||||
|
): void;
|
||||||
|
export default function traverse(
|
||||||
|
parent: Node | Node[],
|
||||||
|
opts: TraverseOptions,
|
||||||
|
scope?: Scope,
|
||||||
|
state?: any,
|
||||||
|
parentPath?: NodePath,
|
||||||
|
): void;
|
||||||
|
|
||||||
|
export interface TraverseOptions<S = Node> extends Visitor<S> {
|
||||||
|
scope?: Scope;
|
||||||
|
noScope?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Scope {
|
||||||
|
constructor(path: NodePath, parentScope?: Scope);
|
||||||
|
path: NodePath;
|
||||||
|
block: Node;
|
||||||
|
parentBlock: Node;
|
||||||
|
parent: Scope;
|
||||||
|
hub: Hub;
|
||||||
|
bindings: { [name: string]: Binding; };
|
||||||
|
|
||||||
|
/** Traverse node with current scope and path. */
|
||||||
|
traverse<S>(node: Node | Node[], opts: TraverseOptions<S>, state: S): void;
|
||||||
|
traverse(node: Node | Node[], opts?: TraverseOptions, state?: any): void;
|
||||||
|
|
||||||
|
/** Generate a unique identifier and add it to the current scope. */
|
||||||
|
generateDeclaredUidIdentifier(name?: string): t.Identifier;
|
||||||
|
|
||||||
|
/** Generate a unique identifier. */
|
||||||
|
generateUidIdentifier(name?: string): t.Identifier;
|
||||||
|
|
||||||
|
/** Generate a unique `_id1` binding. */
|
||||||
|
generateUid(name?: string): string;
|
||||||
|
|
||||||
|
/** Generate a unique identifier based on a node. */
|
||||||
|
generateUidIdentifierBasedOnNode(parent: Node, defaultName?: string): t.Identifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether evaluating the specific input `node` is a consequenceless reference. ie.
|
||||||
|
* evaluating it wont result in potentially arbitrary code from being ran. The following are
|
||||||
|
* whitelisted and determined not to cause side effects:
|
||||||
|
*
|
||||||
|
* - `this` expressions
|
||||||
|
* - `super` expressions
|
||||||
|
* - Bound identifiers
|
||||||
|
*/
|
||||||
|
isStatic(node: Node): boolean;
|
||||||
|
|
||||||
|
/** Possibly generate a memoised identifier if it is not static and has consequences. */
|
||||||
|
maybeGenerateMemoised(node: Node, dontPush?: boolean): t.Identifier;
|
||||||
|
|
||||||
|
checkBlockScopedCollisions(local: Node, kind: string, name: string, id: object): void;
|
||||||
|
|
||||||
|
rename(oldName: string, newName?: string, block?: Node): void;
|
||||||
|
|
||||||
|
dump(): void;
|
||||||
|
|
||||||
|
toArray(node: Node, i?: number): Node;
|
||||||
|
|
||||||
|
registerDeclaration(path: NodePath): void;
|
||||||
|
|
||||||
|
buildUndefinedNode(): Node;
|
||||||
|
|
||||||
|
registerConstantViolation(path: NodePath): void;
|
||||||
|
|
||||||
|
registerBinding(kind: string, path: NodePath, bindingPath?: NodePath): void;
|
||||||
|
|
||||||
|
addGlobal(node: Node): void;
|
||||||
|
|
||||||
|
hasUid(name: string): boolean;
|
||||||
|
|
||||||
|
hasGlobal(name: string): boolean;
|
||||||
|
|
||||||
|
hasReference(name: string): boolean;
|
||||||
|
|
||||||
|
isPure(node: Node, constantsOnly?: boolean): boolean;
|
||||||
|
|
||||||
|
setData(key: string, val: any): any;
|
||||||
|
|
||||||
|
getData(key: string): any;
|
||||||
|
|
||||||
|
removeData(key: string): void;
|
||||||
|
|
||||||
|
push(opts: {
|
||||||
|
id: t.LVal,
|
||||||
|
init?: t.Expression,
|
||||||
|
unique?: boolean,
|
||||||
|
kind?: "var" | "let" | "const",
|
||||||
|
}): void;
|
||||||
|
|
||||||
|
getProgramParent(): Scope;
|
||||||
|
|
||||||
|
getFunctionParent(): Scope | null;
|
||||||
|
|
||||||
|
getBlockParent(): Scope;
|
||||||
|
|
||||||
|
/** Walks the scope tree and gathers **all** bindings. */
|
||||||
|
getAllBindings(...kinds: string[]): object;
|
||||||
|
|
||||||
|
bindingIdentifierEquals(name: string, node: Node): boolean;
|
||||||
|
|
||||||
|
getBinding(name: string): Binding | undefined;
|
||||||
|
|
||||||
|
getOwnBinding(name: string): Binding | undefined;
|
||||||
|
|
||||||
|
getBindingIdentifier(name: string): t.Identifier;
|
||||||
|
|
||||||
|
getOwnBindingIdentifier(name: string): t.Identifier;
|
||||||
|
|
||||||
|
hasOwnBinding(name: string): boolean;
|
||||||
|
|
||||||
|
hasBinding(name: string, noGlobals?: boolean): boolean;
|
||||||
|
|
||||||
|
parentHasBinding(name: string, noGlobals?: boolean): boolean;
|
||||||
|
|
||||||
|
/** Move a binding of `name` to another `scope`. */
|
||||||
|
moveBindingTo(name: string, scope: Scope): void;
|
||||||
|
|
||||||
|
removeOwnBinding(name: string): void;
|
||||||
|
|
||||||
|
removeBinding(name: string): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Binding {
|
||||||
|
constructor(opts: { existing: Binding; identifier: t.Identifier; scope: Scope; path: NodePath; kind: "var" | "let" | "const"; });
|
||||||
|
identifier: t.Identifier;
|
||||||
|
scope: Scope;
|
||||||
|
path: NodePath;
|
||||||
|
kind: "var" | "let" | "const" | "module";
|
||||||
|
referenced: boolean;
|
||||||
|
references: number;
|
||||||
|
referencePaths: NodePath[];
|
||||||
|
constant: boolean;
|
||||||
|
constantViolations: NodePath[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Visitor<S = {}> = VisitNodeObject<S, Node> & {
|
||||||
|
[Type in Node["type"]]?: VisitNode<S, Extract<Node, { type: Type; }>>;
|
||||||
|
} & {
|
||||||
|
[K in keyof t.Aliases]?: VisitNode<S, t.Aliases[K]>
|
||||||
|
};
|
||||||
|
|
||||||
|
export type VisitNode<S, P> = VisitNodeFunction<S, P> | VisitNodeObject<S, P>;
|
||||||
|
|
||||||
|
export type VisitNodeFunction<S, P> = (this: S, path: NodePath<P>, state: S) => void;
|
||||||
|
|
||||||
|
export interface VisitNodeObject<S, P> {
|
||||||
|
enter?: VisitNodeFunction<S, P>;
|
||||||
|
exit?: VisitNodeFunction<S, P>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class NodePath<T = Node> {
|
||||||
|
constructor(hub: Hub, parent: Node);
|
||||||
|
parent: Node;
|
||||||
|
hub: Hub;
|
||||||
|
contexts: TraversalContext[];
|
||||||
|
data: object;
|
||||||
|
shouldSkip: boolean;
|
||||||
|
shouldStop: boolean;
|
||||||
|
removed: boolean;
|
||||||
|
state: any;
|
||||||
|
opts: object;
|
||||||
|
skipKeys: object;
|
||||||
|
parentPath: NodePath;
|
||||||
|
context: TraversalContext;
|
||||||
|
container: object | object[];
|
||||||
|
listKey: string;
|
||||||
|
inList: boolean;
|
||||||
|
parentKey: string;
|
||||||
|
key: string | number;
|
||||||
|
node: T;
|
||||||
|
scope: Scope;
|
||||||
|
type: T extends undefined | null ? string | null : string;
|
||||||
|
typeAnnotation: object;
|
||||||
|
|
||||||
|
getScope(scope: Scope): Scope;
|
||||||
|
|
||||||
|
setData(key: string, val: any): any;
|
||||||
|
|
||||||
|
getData(key: string, def?: any): any;
|
||||||
|
|
||||||
|
buildCodeFrameError<TError extends Error>(msg: string, Error?: new (msg: string) => TError): TError;
|
||||||
|
|
||||||
|
traverse<T>(visitor: Visitor<T>, state: T): void;
|
||||||
|
traverse(visitor: Visitor): void;
|
||||||
|
|
||||||
|
set(key: string, node: Node): void;
|
||||||
|
|
||||||
|
getPathLocation(): string;
|
||||||
|
|
||||||
|
// Example: https://github.com/babel/babel/blob/63204ae51e020d84a5b246312f5eeb4d981ab952/packages/babel-traverse/src/path/modification.js#L83
|
||||||
|
debug(buildMessage: () => string): void;
|
||||||
|
|
||||||
|
// ------------------------- ancestry -------------------------
|
||||||
|
/**
|
||||||
|
* Call the provided `callback` with the `NodePath`s of all the parents.
|
||||||
|
* When the `callback` returns a truthy value, we return that node path.
|
||||||
|
*/
|
||||||
|
findParent(callback: (path: NodePath) => boolean): NodePath;
|
||||||
|
|
||||||
|
find(callback: (path: NodePath) => boolean): NodePath;
|
||||||
|
|
||||||
|
/** Get the parent function of the current path. */
|
||||||
|
getFunctionParent(): NodePath<t.Function>;
|
||||||
|
|
||||||
|
/** Walk up the tree until we hit a parent node path in a list. */
|
||||||
|
getStatementParent(): NodePath<t.Statement>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the deepest common ancestor and then from it, get the earliest relationship path
|
||||||
|
* to that ancestor.
|
||||||
|
*
|
||||||
|
* Earliest is defined as being "before" all the other nodes in terms of list container
|
||||||
|
* position and visiting key.
|
||||||
|
*/
|
||||||
|
getEarliestCommonAncestorFrom(paths: NodePath[]): NodePath[];
|
||||||
|
|
||||||
|
/** Get the earliest path in the tree where the provided `paths` intersect. */
|
||||||
|
getDeepestCommonAncestorFrom(
|
||||||
|
paths: NodePath[],
|
||||||
|
filter?: (deepest: Node, i: number, ancestries: NodePath[]) => NodePath
|
||||||
|
): NodePath;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build an array of node paths containing the entire ancestry of the current node path.
|
||||||
|
*
|
||||||
|
* NOTE: The current node path is included in this.
|
||||||
|
*/
|
||||||
|
getAncestry(): NodePath[];
|
||||||
|
|
||||||
|
inType(...candidateTypes: string[]): boolean;
|
||||||
|
|
||||||
|
// ------------------------- inference -------------------------
|
||||||
|
/** Infer the type of the current `NodePath`. */
|
||||||
|
getTypeAnnotation(): t.FlowType;
|
||||||
|
|
||||||
|
isBaseType(baseName: string, soft?: boolean): boolean;
|
||||||
|
|
||||||
|
couldBeBaseType(name: string): boolean;
|
||||||
|
|
||||||
|
baseTypeStrictlyMatches(right: NodePath): boolean;
|
||||||
|
|
||||||
|
isGenericType(genericName: string): boolean;
|
||||||
|
|
||||||
|
// ------------------------- replacement -------------------------
|
||||||
|
/**
|
||||||
|
* Replace a node with an array of multiple. This method performs the following steps:
|
||||||
|
*
|
||||||
|
* - Inherit the comments of first provided node with that of the current node.
|
||||||
|
* - Insert the provided nodes after the current node.
|
||||||
|
* - Remove the current node.
|
||||||
|
*/
|
||||||
|
replaceWithMultiple(nodes: Node[]): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse a string as an expression and replace the current node with the result.
|
||||||
|
*
|
||||||
|
* NOTE: This is typically not a good idea to use. Building source strings when
|
||||||
|
* transforming ASTs is an antipattern and SHOULD NOT be encouraged. Even if it's
|
||||||
|
* easier to use, your transforms will be extremely brittle.
|
||||||
|
*/
|
||||||
|
replaceWithSourceString(replacement: any): void;
|
||||||
|
|
||||||
|
/** Replace the current node with another. */
|
||||||
|
replaceWith(replacement: Node | NodePath): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method takes an array of statements nodes and then explodes it
|
||||||
|
* into expressions. This method retains completion records which is
|
||||||
|
* extremely important to retain original semantics.
|
||||||
|
*/
|
||||||
|
replaceExpressionWithStatements(nodes: Node[]): Node;
|
||||||
|
|
||||||
|
replaceInline(nodes: Node | Node[]): void;
|
||||||
|
|
||||||
|
// ------------------------- evaluation -------------------------
|
||||||
|
/**
|
||||||
|
* Walk the input `node` and statically evaluate if it's truthy.
|
||||||
|
*
|
||||||
|
* Returning `true` when we're sure that the expression will evaluate to a
|
||||||
|
* truthy value, `false` if we're sure that it will evaluate to a falsy
|
||||||
|
* value and `undefined` if we aren't sure. Because of this please do not
|
||||||
|
* rely on coercion when using this method and check with === if it's false.
|
||||||
|
*/
|
||||||
|
evaluateTruthy(): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Walk the input `node` and statically evaluate it.
|
||||||
|
*
|
||||||
|
* Returns an object in the form `{ confident, value }`. `confident` indicates
|
||||||
|
* whether or not we had to drop out of evaluating the expression because of
|
||||||
|
* hitting an unknown node that we couldn't confidently find the value of.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* t.evaluate(parse("5 + 5")) // { confident: true, value: 10 }
|
||||||
|
* t.evaluate(parse("!true")) // { confident: true, value: false }
|
||||||
|
* t.evaluate(parse("foo + foo")) // { confident: false, value: undefined }
|
||||||
|
*/
|
||||||
|
evaluate(): { confident: boolean; value: any };
|
||||||
|
|
||||||
|
// ------------------------- introspection -------------------------
|
||||||
|
/**
|
||||||
|
* Match the current node if it matches the provided `pattern`.
|
||||||
|
*
|
||||||
|
* For example, given the match `React.createClass` it would match the
|
||||||
|
* parsed nodes of `React.createClass` and `React["createClass"]`.
|
||||||
|
*/
|
||||||
|
matchesPattern(pattern: string, allowPartial?: boolean): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether we have the input `key`. If the `key` references an array then we check
|
||||||
|
* if the array has any items, otherwise we just check if it's falsy.
|
||||||
|
*/
|
||||||
|
has(key: string): boolean;
|
||||||
|
|
||||||
|
isStatic(): boolean;
|
||||||
|
|
||||||
|
/** Alias of `has`. */
|
||||||
|
is(key: string): boolean;
|
||||||
|
|
||||||
|
/** Opposite of `has`. */
|
||||||
|
isnt(key: string): boolean;
|
||||||
|
|
||||||
|
/** Check whether the path node `key` strict equals `value`. */
|
||||||
|
equals(key: string, value: any): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check the type against our stored internal type of the node. This is handy when a node has
|
||||||
|
* been removed yet we still internally know the type and need it to calculate node replacement.
|
||||||
|
*/
|
||||||
|
isNodeType(type: string): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This checks whether or not we're in one of the following positions:
|
||||||
|
*
|
||||||
|
* for (KEY in right);
|
||||||
|
* for (KEY;;);
|
||||||
|
*
|
||||||
|
* This is because these spots allow VariableDeclarations AND normal expressions so we need
|
||||||
|
* to tell the path replacement that it's ok to replace this with an expression.
|
||||||
|
*/
|
||||||
|
canHaveVariableDeclarationOrExpression(): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This checks whether we are swapping an arrow function's body between an
|
||||||
|
* expression and a block statement (or vice versa).
|
||||||
|
*
|
||||||
|
* This is because arrow functions may implicitly return an expression, which
|
||||||
|
* is the same as containing a block statement.
|
||||||
|
*/
|
||||||
|
canSwapBetweenExpressionAndStatement(replacement: Node): boolean;
|
||||||
|
|
||||||
|
/** Check whether the current path references a completion record */
|
||||||
|
isCompletionRecord(allowInsideFunction?: boolean): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether or not the current `key` allows either a single statement or block statement
|
||||||
|
* so we can explode it if necessary.
|
||||||
|
*/
|
||||||
|
isStatementOrBlock(): boolean;
|
||||||
|
|
||||||
|
/** Check if the currently assigned path references the `importName` of `moduleSource`. */
|
||||||
|
referencesImport(moduleSource: string, importName: string): boolean;
|
||||||
|
|
||||||
|
/** Get the source code associated with this node. */
|
||||||
|
getSource(): string;
|
||||||
|
|
||||||
|
/** Check if the current path will maybe execute before another path */
|
||||||
|
willIMaybeExecuteBefore(path: NodePath): boolean;
|
||||||
|
|
||||||
|
// ------------------------- context -------------------------
|
||||||
|
call(key: string): boolean;
|
||||||
|
|
||||||
|
isBlacklisted(): boolean;
|
||||||
|
|
||||||
|
visit(): boolean;
|
||||||
|
|
||||||
|
skip(): void;
|
||||||
|
|
||||||
|
skipKey(key: string): void;
|
||||||
|
|
||||||
|
stop(): void;
|
||||||
|
|
||||||
|
setScope(): void;
|
||||||
|
|
||||||
|
setContext(context: TraversalContext): NodePath<T>;
|
||||||
|
|
||||||
|
popContext(): void;
|
||||||
|
|
||||||
|
pushContext(context: TraversalContext): void;
|
||||||
|
|
||||||
|
// ------------------------- removal -------------------------
|
||||||
|
remove(): void;
|
||||||
|
|
||||||
|
// ------------------------- modification -------------------------
|
||||||
|
/** Insert the provided nodes before the current one. */
|
||||||
|
insertBefore(nodes: Node | Node[]): any;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Insert the provided nodes after the current one. When inserting nodes after an
|
||||||
|
* expression, ensure that the completion record is correct by pushing the current node.
|
||||||
|
*/
|
||||||
|
insertAfter(nodes: Node | Node[]): any;
|
||||||
|
|
||||||
|
/** Update all sibling node paths after `fromIndex` by `incrementBy`. */
|
||||||
|
updateSiblingKeys(fromIndex: number, incrementBy: number): void;
|
||||||
|
|
||||||
|
/** Hoist the current node to the highest scope possible and return a UID referencing it. */
|
||||||
|
hoist(scope: Scope): void;
|
||||||
|
|
||||||
|
// ------------------------- family -------------------------
|
||||||
|
getOpposite(): NodePath;
|
||||||
|
|
||||||
|
getCompletionRecords(): NodePath[];
|
||||||
|
|
||||||
|
getSibling(key: string | number): NodePath;
|
||||||
|
getAllPrevSiblings(): NodePath[];
|
||||||
|
getAllNextSiblings(): NodePath[];
|
||||||
|
|
||||||
|
get<K extends keyof T>(key: K, context?: boolean | TraversalContext):
|
||||||
|
T[K] extends Array<Node | null | undefined> ? Array<NodePath<T[K][number]>> :
|
||||||
|
T[K] extends Node | null | undefined ? NodePath<T[K]> :
|
||||||
|
never;
|
||||||
|
get(key: string, context?: boolean | TraversalContext): NodePath | NodePath[];
|
||||||
|
|
||||||
|
getBindingIdentifiers(duplicates?: boolean): Node[];
|
||||||
|
|
||||||
|
getOuterBindingIdentifiers(duplicates?: boolean): Node[];
|
||||||
|
|
||||||
|
// ------------------------- comments -------------------------
|
||||||
|
/** Share comments amongst siblings. */
|
||||||
|
shareCommentsWithSiblings(): void;
|
||||||
|
|
||||||
|
addComment(type: string, content: string, line?: boolean): void;
|
||||||
|
|
||||||
|
/** Give node `comments` of the specified `type`. */
|
||||||
|
addComments(type: string, comments: any[]): void;
|
||||||
|
|
||||||
|
// ------------------------- isXXX -------------------------
|
||||||
|
isArrayExpression(opts?: object): this is NodePath<t.ArrayExpression>;
|
||||||
|
isAssignmentExpression(opts?: object): this is NodePath<t.AssignmentExpression>;
|
||||||
|
isBinaryExpression(opts?: object): this is NodePath<t.BinaryExpression>;
|
||||||
|
isDirective(opts?: object): this is NodePath<t.Directive>;
|
||||||
|
isDirectiveLiteral(opts?: object): this is NodePath<t.DirectiveLiteral>;
|
||||||
|
isBlockStatement(opts?: object): this is NodePath<t.BlockStatement>;
|
||||||
|
isBreakStatement(opts?: object): this is NodePath<t.BreakStatement>;
|
||||||
|
isCallExpression(opts?: object): this is NodePath<t.CallExpression>;
|
||||||
|
isCatchClause(opts?: object): this is NodePath<t.CatchClause>;
|
||||||
|
isConditionalExpression(opts?: object): this is NodePath<t.ConditionalExpression>;
|
||||||
|
isContinueStatement(opts?: object): this is NodePath<t.ContinueStatement>;
|
||||||
|
isDebuggerStatement(opts?: object): this is NodePath<t.DebuggerStatement>;
|
||||||
|
isDoWhileStatement(opts?: object): this is NodePath<t.DoWhileStatement>;
|
||||||
|
isEmptyStatement(opts?: object): this is NodePath<t.EmptyStatement>;
|
||||||
|
isExpressionStatement(opts?: object): this is NodePath<t.ExpressionStatement>;
|
||||||
|
isFile(opts?: object): this is NodePath<t.File>;
|
||||||
|
isForInStatement(opts?: object): this is NodePath<t.ForInStatement>;
|
||||||
|
isForStatement(opts?: object): this is NodePath<t.ForStatement>;
|
||||||
|
isFunctionDeclaration(opts?: object): this is NodePath<t.FunctionDeclaration>;
|
||||||
|
isFunctionExpression(opts?: object): this is NodePath<t.FunctionExpression>;
|
||||||
|
isIdentifier(opts?: object): this is NodePath<t.Identifier>;
|
||||||
|
isIfStatement(opts?: object): this is NodePath<t.IfStatement>;
|
||||||
|
isLabeledStatement(opts?: object): this is NodePath<t.LabeledStatement>;
|
||||||
|
isStringLiteral(opts?: object): this is NodePath<t.StringLiteral>;
|
||||||
|
isNumericLiteral(opts?: object): this is NodePath<t.NumericLiteral>;
|
||||||
|
isNullLiteral(opts?: object): this is NodePath<t.NullLiteral>;
|
||||||
|
isBooleanLiteral(opts?: object): this is NodePath<t.BooleanLiteral>;
|
||||||
|
isRegExpLiteral(opts?: object): this is NodePath<t.RegExpLiteral>;
|
||||||
|
isLogicalExpression(opts?: object): this is NodePath<t.LogicalExpression>;
|
||||||
|
isMemberExpression(opts?: object): this is NodePath<t.MemberExpression>;
|
||||||
|
isNewExpression(opts?: object): this is NodePath<t.NewExpression>;
|
||||||
|
isProgram(opts?: object): this is NodePath<t.Program>;
|
||||||
|
isObjectExpression(opts?: object): this is NodePath<t.ObjectExpression>;
|
||||||
|
isObjectMethod(opts?: object): this is NodePath<t.ObjectMethod>;
|
||||||
|
isObjectProperty(opts?: object): this is NodePath<t.ObjectProperty>;
|
||||||
|
isRestElement(opts?: object): this is NodePath<t.RestElement>;
|
||||||
|
isReturnStatement(opts?: object): this is NodePath<t.ReturnStatement>;
|
||||||
|
isSequenceExpression(opts?: object): this is NodePath<t.SequenceExpression>;
|
||||||
|
isSwitchCase(opts?: object): this is NodePath<t.SwitchCase>;
|
||||||
|
isSwitchStatement(opts?: object): this is NodePath<t.SwitchStatement>;
|
||||||
|
isThisExpression(opts?: object): this is NodePath<t.ThisExpression>;
|
||||||
|
isThrowStatement(opts?: object): this is NodePath<t.ThrowStatement>;
|
||||||
|
isTryStatement(opts?: object): this is NodePath<t.TryStatement>;
|
||||||
|
isUnaryExpression(opts?: object): this is NodePath<t.UnaryExpression>;
|
||||||
|
isUpdateExpression(opts?: object): this is NodePath<t.UpdateExpression>;
|
||||||
|
isVariableDeclaration(opts?: object): this is NodePath<t.VariableDeclaration>;
|
||||||
|
isVariableDeclarator(opts?: object): this is NodePath<t.VariableDeclarator>;
|
||||||
|
isWhileStatement(opts?: object): this is NodePath<t.WhileStatement>;
|
||||||
|
isWithStatement(opts?: object): this is NodePath<t.WithStatement>;
|
||||||
|
isAssignmentPattern(opts?: object): this is NodePath<t.AssignmentPattern>;
|
||||||
|
isArrayPattern(opts?: object): this is NodePath<t.ArrayPattern>;
|
||||||
|
isArrowFunctionExpression(opts?: object): this is NodePath<t.ArrowFunctionExpression>;
|
||||||
|
isClassBody(opts?: object): this is NodePath<t.ClassBody>;
|
||||||
|
isClassDeclaration(opts?: object): this is NodePath<t.ClassDeclaration>;
|
||||||
|
isClassExpression(opts?: object): this is NodePath<t.ClassExpression>;
|
||||||
|
isExportAllDeclaration(opts?: object): this is NodePath<t.ExportAllDeclaration>;
|
||||||
|
isExportDefaultDeclaration(opts?: object): this is NodePath<t.ExportDefaultDeclaration>;
|
||||||
|
isExportNamedDeclaration(opts?: object): this is NodePath<t.ExportNamedDeclaration>;
|
||||||
|
isExportSpecifier(opts?: object): this is NodePath<t.ExportSpecifier>;
|
||||||
|
isForOfStatement(opts?: object): this is NodePath<t.ForOfStatement>;
|
||||||
|
isImportDeclaration(opts?: object): this is NodePath<t.ImportDeclaration>;
|
||||||
|
isImportDefaultSpecifier(opts?: object): this is NodePath<t.ImportDefaultSpecifier>;
|
||||||
|
isImportNamespaceSpecifier(opts?: object): this is NodePath<t.ImportNamespaceSpecifier>;
|
||||||
|
isImportSpecifier(opts?: object): this is NodePath<t.ImportSpecifier>;
|
||||||
|
isMetaProperty(opts?: object): this is NodePath<t.MetaProperty>;
|
||||||
|
isClassMethod(opts?: object): this is NodePath<t.ClassMethod>;
|
||||||
|
isObjectPattern(opts?: object): this is NodePath<t.ObjectPattern>;
|
||||||
|
isSpreadElement(opts?: object): this is NodePath<t.SpreadElement>;
|
||||||
|
isSuper(opts?: object): this is NodePath<t.Super>;
|
||||||
|
isTaggedTemplateExpression(opts?: object): this is NodePath<t.TaggedTemplateExpression>;
|
||||||
|
isTemplateElement(opts?: object): this is NodePath<t.TemplateElement>;
|
||||||
|
isTemplateLiteral(opts?: object): this is NodePath<t.TemplateLiteral>;
|
||||||
|
isYieldExpression(opts?: object): this is NodePath<t.YieldExpression>;
|
||||||
|
isAnyTypeAnnotation(opts?: object): this is NodePath<t.AnyTypeAnnotation>;
|
||||||
|
isArrayTypeAnnotation(opts?: object): this is NodePath<t.ArrayTypeAnnotation>;
|
||||||
|
isBooleanTypeAnnotation(opts?: object): this is NodePath<t.BooleanTypeAnnotation>;
|
||||||
|
isBooleanLiteralTypeAnnotation(opts?: object): this is NodePath<t.BooleanLiteralTypeAnnotation>;
|
||||||
|
isNullLiteralTypeAnnotation(opts?: object): this is NodePath<t.NullLiteralTypeAnnotation>;
|
||||||
|
isClassImplements(opts?: object): this is NodePath<t.ClassImplements>;
|
||||||
|
isClassProperty(opts?: object): this is NodePath<t.ClassProperty>;
|
||||||
|
isDeclareClass(opts?: object): this is NodePath<t.DeclareClass>;
|
||||||
|
isDeclareFunction(opts?: object): this is NodePath<t.DeclareFunction>;
|
||||||
|
isDeclareInterface(opts?: object): this is NodePath<t.DeclareInterface>;
|
||||||
|
isDeclareModule(opts?: object): this is NodePath<t.DeclareModule>;
|
||||||
|
isDeclareTypeAlias(opts?: object): this is NodePath<t.DeclareTypeAlias>;
|
||||||
|
isDeclareVariable(opts?: object): this is NodePath<t.DeclareVariable>;
|
||||||
|
isFunctionTypeAnnotation(opts?: object): this is NodePath<t.FunctionTypeAnnotation>;
|
||||||
|
isFunctionTypeParam(opts?: object): this is NodePath<t.FunctionTypeParam>;
|
||||||
|
isGenericTypeAnnotation(opts?: object): this is NodePath<t.GenericTypeAnnotation>;
|
||||||
|
isInterfaceExtends(opts?: object): this is NodePath<t.InterfaceExtends>;
|
||||||
|
isInterfaceDeclaration(opts?: object): this is NodePath<t.InterfaceDeclaration>;
|
||||||
|
isIntersectionTypeAnnotation(opts?: object): this is NodePath<t.IntersectionTypeAnnotation>;
|
||||||
|
isMixedTypeAnnotation(opts?: object): this is NodePath<t.MixedTypeAnnotation>;
|
||||||
|
isNullableTypeAnnotation(opts?: object): this is NodePath<t.NullableTypeAnnotation>;
|
||||||
|
isNumberTypeAnnotation(opts?: object): this is NodePath<t.NumberTypeAnnotation>;
|
||||||
|
isStringLiteralTypeAnnotation(opts?: object): this is NodePath<t.StringLiteralTypeAnnotation>;
|
||||||
|
isStringTypeAnnotation(opts?: object): this is NodePath<t.StringTypeAnnotation>;
|
||||||
|
isThisTypeAnnotation(opts?: object): this is NodePath<t.ThisTypeAnnotation>;
|
||||||
|
isTupleTypeAnnotation(opts?: object): this is NodePath<t.TupleTypeAnnotation>;
|
||||||
|
isTypeofTypeAnnotation(opts?: object): this is NodePath<t.TypeofTypeAnnotation>;
|
||||||
|
isTypeAlias(opts?: object): this is NodePath<t.TypeAlias>;
|
||||||
|
isTypeAnnotation(opts?: object): this is NodePath<t.TypeAnnotation>;
|
||||||
|
isTypeCastExpression(opts?: object): this is NodePath<t.TypeCastExpression>;
|
||||||
|
isTypeParameterDeclaration(opts?: object): this is NodePath<t.TypeParameterDeclaration>;
|
||||||
|
isTypeParameterInstantiation(opts?: object): this is NodePath<t.TypeParameterInstantiation>;
|
||||||
|
isObjectTypeAnnotation(opts?: object): this is NodePath<t.ObjectTypeAnnotation>;
|
||||||
|
isObjectTypeCallProperty(opts?: object): this is NodePath<t.ObjectTypeCallProperty>;
|
||||||
|
isObjectTypeIndexer(opts?: object): this is NodePath<t.ObjectTypeIndexer>;
|
||||||
|
isObjectTypeProperty(opts?: object): this is NodePath<t.ObjectTypeProperty>;
|
||||||
|
isQualifiedTypeIdentifier(opts?: object): this is NodePath<t.QualifiedTypeIdentifier>;
|
||||||
|
isUnionTypeAnnotation(opts?: object): this is NodePath<t.UnionTypeAnnotation>;
|
||||||
|
isVoidTypeAnnotation(opts?: object): this is NodePath<t.VoidTypeAnnotation>;
|
||||||
|
isJSXAttribute(opts?: object): this is NodePath<t.JSXAttribute>;
|
||||||
|
isJSXClosingElement(opts?: object): this is NodePath<t.JSXClosingElement>;
|
||||||
|
isJSXElement(opts?: object): this is NodePath<t.JSXElement>;
|
||||||
|
isJSXEmptyExpression(opts?: object): this is NodePath<t.JSXEmptyExpression>;
|
||||||
|
isJSXExpressionContainer(opts?: object): this is NodePath<t.JSXExpressionContainer>;
|
||||||
|
isJSXIdentifier(opts?: object): this is NodePath<t.JSXIdentifier>;
|
||||||
|
isJSXMemberExpression(opts?: object): this is NodePath<t.JSXMemberExpression>;
|
||||||
|
isJSXNamespacedName(opts?: object): this is NodePath<t.JSXNamespacedName>;
|
||||||
|
isJSXOpeningElement(opts?: object): this is NodePath<t.JSXOpeningElement>;
|
||||||
|
isJSXSpreadAttribute(opts?: object): this is NodePath<t.JSXSpreadAttribute>;
|
||||||
|
isJSXText(opts?: object): this is NodePath<t.JSXText>;
|
||||||
|
isNoop(opts?: object): this is NodePath<t.Noop>;
|
||||||
|
isParenthesizedExpression(opts?: object): this is NodePath<t.ParenthesizedExpression>;
|
||||||
|
isAwaitExpression(opts?: object): this is NodePath<t.AwaitExpression>;
|
||||||
|
isBindExpression(opts?: object): this is NodePath<t.BindExpression>;
|
||||||
|
isDecorator(opts?: object): this is NodePath<t.Decorator>;
|
||||||
|
isDoExpression(opts?: object): this is NodePath<t.DoExpression>;
|
||||||
|
isExportDefaultSpecifier(opts?: object): this is NodePath<t.ExportDefaultSpecifier>;
|
||||||
|
isExportNamespaceSpecifier(opts?: object): this is NodePath<t.ExportNamespaceSpecifier>;
|
||||||
|
isRestProperty(opts?: object): this is NodePath<t.RestProperty>;
|
||||||
|
isSpreadProperty(opts?: object): this is NodePath<t.SpreadProperty>;
|
||||||
|
isExpression(opts?: object): this is NodePath<t.Expression>;
|
||||||
|
isBinary(opts?: object): this is NodePath<t.Binary>;
|
||||||
|
isScopable(opts?: object): this is NodePath<t.Scopable>;
|
||||||
|
isBlockParent(opts?: object): this is NodePath<t.BlockParent>;
|
||||||
|
isBlock(opts?: object): this is NodePath<t.Block>;
|
||||||
|
isStatement(opts?: object): this is NodePath<t.Statement>;
|
||||||
|
isTerminatorless(opts?: object): this is NodePath<t.Terminatorless>;
|
||||||
|
isCompletionStatement(opts?: object): this is NodePath<t.CompletionStatement>;
|
||||||
|
isConditional(opts?: object): this is NodePath<t.Conditional>;
|
||||||
|
isLoop(opts?: object): this is NodePath<t.Loop>;
|
||||||
|
isWhile(opts?: object): this is NodePath<t.While>;
|
||||||
|
isExpressionWrapper(opts?: object): this is NodePath<t.ExpressionWrapper>;
|
||||||
|
isFor(opts?: object): this is NodePath<t.For>;
|
||||||
|
isForXStatement(opts?: object): this is NodePath<t.ForXStatement>;
|
||||||
|
isFunction(opts?: object): this is NodePath<t.Function>;
|
||||||
|
isFunctionParent(opts?: object): this is NodePath<t.FunctionParent>;
|
||||||
|
isPureish(opts?: object): this is NodePath<t.Pureish>;
|
||||||
|
isDeclaration(opts?: object): this is NodePath<t.Declaration>;
|
||||||
|
isLVal(opts?: object): this is NodePath<t.LVal>;
|
||||||
|
isLiteral(opts?: object): this is NodePath<t.Literal>;
|
||||||
|
isImmutable(opts?: object): this is NodePath<t.Immutable>;
|
||||||
|
isUserWhitespacable(opts?: object): this is NodePath<t.UserWhitespacable>;
|
||||||
|
isMethod(opts?: object): this is NodePath<t.Method>;
|
||||||
|
isObjectMember(opts?: object): this is NodePath<t.ObjectMember>;
|
||||||
|
isProperty(opts?: object): this is NodePath<t.Property>;
|
||||||
|
isUnaryLike(opts?: object): this is NodePath<t.UnaryLike>;
|
||||||
|
isPattern(opts?: object): this is NodePath<t.Pattern>;
|
||||||
|
isClass(opts?: object): this is NodePath<t.Class>;
|
||||||
|
isModuleDeclaration(opts?: object): this is NodePath<t.ModuleDeclaration>;
|
||||||
|
isExportDeclaration(opts?: object): this is NodePath<t.ExportDeclaration>;
|
||||||
|
isModuleSpecifier(opts?: object): this is NodePath<t.ModuleSpecifier>;
|
||||||
|
isFlow(opts?: object): this is NodePath<t.Flow>;
|
||||||
|
isFlowBaseAnnotation(opts?: object): this is NodePath<t.FlowBaseAnnotation>;
|
||||||
|
isFlowDeclaration(opts?: object): this is NodePath<t.FlowDeclaration>;
|
||||||
|
isJSX(opts?: object): this is NodePath<t.JSX>;
|
||||||
|
isNumberLiteral(opts?: object): this is NodePath<t.NumericLiteral>;
|
||||||
|
isRegexLiteral(opts?: object): this is NodePath<t.RegExpLiteral>;
|
||||||
|
isReferencedIdentifier(opts?: object): this is NodePath<t.Identifier | t.JSXIdentifier>;
|
||||||
|
isReferencedMemberExpression(opts?: object): this is NodePath<t.MemberExpression>;
|
||||||
|
isBindingIdentifier(opts?: object): this is NodePath<t.Identifier>;
|
||||||
|
isScope(opts?: object): this is NodePath<t.Scopable>;
|
||||||
|
isReferenced(opts?: object): boolean;
|
||||||
|
isBlockScoped(opts?: object): this is NodePath<t.FunctionDeclaration | t.ClassDeclaration | t.VariableDeclaration>;
|
||||||
|
isVar(opts?: object): this is NodePath<t.VariableDeclaration>;
|
||||||
|
isUser(opts?: object): boolean;
|
||||||
|
isGenerated(opts?: object): boolean;
|
||||||
|
isPure(opts?: object): boolean;
|
||||||
|
|
||||||
|
// ------------------------- assertXXX -------------------------
|
||||||
|
assertArrayExpression(opts?: object): void;
|
||||||
|
assertAssignmentExpression(opts?: object): void;
|
||||||
|
assertBinaryExpression(opts?: object): void;
|
||||||
|
assertDirective(opts?: object): void;
|
||||||
|
assertDirectiveLiteral(opts?: object): void;
|
||||||
|
assertBlockStatement(opts?: object): void;
|
||||||
|
assertBreakStatement(opts?: object): void;
|
||||||
|
assertCallExpression(opts?: object): void;
|
||||||
|
assertCatchClause(opts?: object): void;
|
||||||
|
assertConditionalExpression(opts?: object): void;
|
||||||
|
assertContinueStatement(opts?: object): void;
|
||||||
|
assertDebuggerStatement(opts?: object): void;
|
||||||
|
assertDoWhileStatement(opts?: object): void;
|
||||||
|
assertEmptyStatement(opts?: object): void;
|
||||||
|
assertExpressionStatement(opts?: object): void;
|
||||||
|
assertFile(opts?: object): void;
|
||||||
|
assertForInStatement(opts?: object): void;
|
||||||
|
assertForStatement(opts?: object): void;
|
||||||
|
assertFunctionDeclaration(opts?: object): void;
|
||||||
|
assertFunctionExpression(opts?: object): void;
|
||||||
|
assertIdentifier(opts?: object): void;
|
||||||
|
assertIfStatement(opts?: object): void;
|
||||||
|
assertLabeledStatement(opts?: object): void;
|
||||||
|
assertStringLiteral(opts?: object): void;
|
||||||
|
assertNumericLiteral(opts?: object): void;
|
||||||
|
assertNullLiteral(opts?: object): void;
|
||||||
|
assertBooleanLiteral(opts?: object): void;
|
||||||
|
assertRegExpLiteral(opts?: object): void;
|
||||||
|
assertLogicalExpression(opts?: object): void;
|
||||||
|
assertMemberExpression(opts?: object): void;
|
||||||
|
assertNewExpression(opts?: object): void;
|
||||||
|
assertProgram(opts?: object): void;
|
||||||
|
assertObjectExpression(opts?: object): void;
|
||||||
|
assertObjectMethod(opts?: object): void;
|
||||||
|
assertObjectProperty(opts?: object): void;
|
||||||
|
assertRestElement(opts?: object): void;
|
||||||
|
assertReturnStatement(opts?: object): void;
|
||||||
|
assertSequenceExpression(opts?: object): void;
|
||||||
|
assertSwitchCase(opts?: object): void;
|
||||||
|
assertSwitchStatement(opts?: object): void;
|
||||||
|
assertThisExpression(opts?: object): void;
|
||||||
|
assertThrowStatement(opts?: object): void;
|
||||||
|
assertTryStatement(opts?: object): void;
|
||||||
|
assertUnaryExpression(opts?: object): void;
|
||||||
|
assertUpdateExpression(opts?: object): void;
|
||||||
|
assertVariableDeclaration(opts?: object): void;
|
||||||
|
assertVariableDeclarator(opts?: object): void;
|
||||||
|
assertWhileStatement(opts?: object): void;
|
||||||
|
assertWithStatement(opts?: object): void;
|
||||||
|
assertAssignmentPattern(opts?: object): void;
|
||||||
|
assertArrayPattern(opts?: object): void;
|
||||||
|
assertArrowFunctionExpression(opts?: object): void;
|
||||||
|
assertClassBody(opts?: object): void;
|
||||||
|
assertClassDeclaration(opts?: object): void;
|
||||||
|
assertClassExpression(opts?: object): void;
|
||||||
|
assertExportAllDeclaration(opts?: object): void;
|
||||||
|
assertExportDefaultDeclaration(opts?: object): void;
|
||||||
|
assertExportNamedDeclaration(opts?: object): void;
|
||||||
|
assertExportSpecifier(opts?: object): void;
|
||||||
|
assertForOfStatement(opts?: object): void;
|
||||||
|
assertImportDeclaration(opts?: object): void;
|
||||||
|
assertImportDefaultSpecifier(opts?: object): void;
|
||||||
|
assertImportNamespaceSpecifier(opts?: object): void;
|
||||||
|
assertImportSpecifier(opts?: object): void;
|
||||||
|
assertMetaProperty(opts?: object): void;
|
||||||
|
assertClassMethod(opts?: object): void;
|
||||||
|
assertObjectPattern(opts?: object): void;
|
||||||
|
assertSpreadElement(opts?: object): void;
|
||||||
|
assertSuper(opts?: object): void;
|
||||||
|
assertTaggedTemplateExpression(opts?: object): void;
|
||||||
|
assertTemplateElement(opts?: object): void;
|
||||||
|
assertTemplateLiteral(opts?: object): void;
|
||||||
|
assertYieldExpression(opts?: object): void;
|
||||||
|
assertAnyTypeAnnotation(opts?: object): void;
|
||||||
|
assertArrayTypeAnnotation(opts?: object): void;
|
||||||
|
assertBooleanTypeAnnotation(opts?: object): void;
|
||||||
|
assertBooleanLiteralTypeAnnotation(opts?: object): void;
|
||||||
|
assertNullLiteralTypeAnnotation(opts?: object): void;
|
||||||
|
assertClassImplements(opts?: object): void;
|
||||||
|
assertClassProperty(opts?: object): void;
|
||||||
|
assertDeclareClass(opts?: object): void;
|
||||||
|
assertDeclareFunction(opts?: object): void;
|
||||||
|
assertDeclareInterface(opts?: object): void;
|
||||||
|
assertDeclareModule(opts?: object): void;
|
||||||
|
assertDeclareTypeAlias(opts?: object): void;
|
||||||
|
assertDeclareVariable(opts?: object): void;
|
||||||
|
assertExistentialTypeParam(opts?: object): void;
|
||||||
|
assertFunctionTypeAnnotation(opts?: object): void;
|
||||||
|
assertFunctionTypeParam(opts?: object): void;
|
||||||
|
assertGenericTypeAnnotation(opts?: object): void;
|
||||||
|
assertInterfaceExtends(opts?: object): void;
|
||||||
|
assertInterfaceDeclaration(opts?: object): void;
|
||||||
|
assertIntersectionTypeAnnotation(opts?: object): void;
|
||||||
|
assertMixedTypeAnnotation(opts?: object): void;
|
||||||
|
assertNullableTypeAnnotation(opts?: object): void;
|
||||||
|
assertNumericLiteralTypeAnnotation(opts?: object): void;
|
||||||
|
assertNumberTypeAnnotation(opts?: object): void;
|
||||||
|
assertStringLiteralTypeAnnotation(opts?: object): void;
|
||||||
|
assertStringTypeAnnotation(opts?: object): void;
|
||||||
|
assertThisTypeAnnotation(opts?: object): void;
|
||||||
|
assertTupleTypeAnnotation(opts?: object): void;
|
||||||
|
assertTypeofTypeAnnotation(opts?: object): void;
|
||||||
|
assertTypeAlias(opts?: object): void;
|
||||||
|
assertTypeAnnotation(opts?: object): void;
|
||||||
|
assertTypeCastExpression(opts?: object): void;
|
||||||
|
assertTypeParameterDeclaration(opts?: object): void;
|
||||||
|
assertTypeParameterInstantiation(opts?: object): void;
|
||||||
|
assertObjectTypeAnnotation(opts?: object): void;
|
||||||
|
assertObjectTypeCallProperty(opts?: object): void;
|
||||||
|
assertObjectTypeIndexer(opts?: object): void;
|
||||||
|
assertObjectTypeProperty(opts?: object): void;
|
||||||
|
assertQualifiedTypeIdentifier(opts?: object): void;
|
||||||
|
assertUnionTypeAnnotation(opts?: object): void;
|
||||||
|
assertVoidTypeAnnotation(opts?: object): void;
|
||||||
|
assertJSXAttribute(opts?: object): void;
|
||||||
|
assertJSXClosingElement(opts?: object): void;
|
||||||
|
assertJSXElement(opts?: object): void;
|
||||||
|
assertJSXEmptyExpression(opts?: object): void;
|
||||||
|
assertJSXExpressionContainer(opts?: object): void;
|
||||||
|
assertJSXIdentifier(opts?: object): void;
|
||||||
|
assertJSXMemberExpression(opts?: object): void;
|
||||||
|
assertJSXNamespacedName(opts?: object): void;
|
||||||
|
assertJSXOpeningElement(opts?: object): void;
|
||||||
|
assertJSXSpreadAttribute(opts?: object): void;
|
||||||
|
assertJSXText(opts?: object): void;
|
||||||
|
assertNoop(opts?: object): void;
|
||||||
|
assertParenthesizedExpression(opts?: object): void;
|
||||||
|
assertAwaitExpression(opts?: object): void;
|
||||||
|
assertBindExpression(opts?: object): void;
|
||||||
|
assertDecorator(opts?: object): void;
|
||||||
|
assertDoExpression(opts?: object): void;
|
||||||
|
assertExportDefaultSpecifier(opts?: object): void;
|
||||||
|
assertExportNamespaceSpecifier(opts?: object): void;
|
||||||
|
assertRestProperty(opts?: object): void;
|
||||||
|
assertSpreadProperty(opts?: object): void;
|
||||||
|
assertExpression(opts?: object): void;
|
||||||
|
assertBinary(opts?: object): void;
|
||||||
|
assertScopable(opts?: object): void;
|
||||||
|
assertBlockParent(opts?: object): void;
|
||||||
|
assertBlock(opts?: object): void;
|
||||||
|
assertStatement(opts?: object): void;
|
||||||
|
assertTerminatorless(opts?: object): void;
|
||||||
|
assertCompletionStatement(opts?: object): void;
|
||||||
|
assertConditional(opts?: object): void;
|
||||||
|
assertLoop(opts?: object): void;
|
||||||
|
assertWhile(opts?: object): void;
|
||||||
|
assertExpressionWrapper(opts?: object): void;
|
||||||
|
assertFor(opts?: object): void;
|
||||||
|
assertForXStatement(opts?: object): void;
|
||||||
|
assertFunction(opts?: object): void;
|
||||||
|
assertFunctionParent(opts?: object): void;
|
||||||
|
assertPureish(opts?: object): void;
|
||||||
|
assertDeclaration(opts?: object): void;
|
||||||
|
assertLVal(opts?: object): void;
|
||||||
|
assertLiteral(opts?: object): void;
|
||||||
|
assertImmutable(opts?: object): void;
|
||||||
|
assertUserWhitespacable(opts?: object): void;
|
||||||
|
assertMethod(opts?: object): void;
|
||||||
|
assertObjectMember(opts?: object): void;
|
||||||
|
assertProperty(opts?: object): void;
|
||||||
|
assertUnaryLike(opts?: object): void;
|
||||||
|
assertPattern(opts?: object): void;
|
||||||
|
assertClass(opts?: object): void;
|
||||||
|
assertModuleDeclaration(opts?: object): void;
|
||||||
|
assertExportDeclaration(opts?: object): void;
|
||||||
|
assertModuleSpecifier(opts?: object): void;
|
||||||
|
assertFlow(opts?: object): void;
|
||||||
|
assertFlowBaseAnnotation(opts?: object): void;
|
||||||
|
assertFlowDeclaration(opts?: object): void;
|
||||||
|
assertJSX(opts?: object): void;
|
||||||
|
assertNumberLiteral(opts?: object): void;
|
||||||
|
assertRegexLiteral(opts?: object): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Hub {
|
||||||
|
constructor(file: any, options: any);
|
||||||
|
file: any;
|
||||||
|
options: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TraversalContext {
|
||||||
|
parentPath: NodePath;
|
||||||
|
scope: Scope;
|
||||||
|
state: any;
|
||||||
|
opts: any;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
{
|
||||||
|
"name": "@types/babel__traverse",
|
||||||
|
"version": "7.0.7",
|
||||||
|
"description": "TypeScript definitions for @babel/traverse",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Troy Gerwien",
|
||||||
|
"url": "https://github.com/yortus",
|
||||||
|
"githubUsername": "yortus"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Marvin Hagemeister",
|
||||||
|
"url": "https://github.com/marvinhagemeister",
|
||||||
|
"githubUsername": "marvinhagemeister"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Ryan Petrich",
|
||||||
|
"url": "https://github.com/rpetrich",
|
||||||
|
"githubUsername": "rpetrich"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Melvin Groenhoff",
|
||||||
|
"url": "https://github.com/mgroenhoff",
|
||||||
|
"githubUsername": "mgroenhoff"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
|
"directory": "types/babel__traverse"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/types": "^7.3.0"
|
||||||
|
},
|
||||||
|
"typesPublisherContentHash": "37e6c080b57f5b07ab86b0af01352617892a3cd9fc9db8bd3c69fa0610672457",
|
||||||
|
"typeScriptVersion": "2.9"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.7.tgz"
|
||||||
|
,"_integrity": "sha512-CeBpmX1J8kWLcDEnI3Cl2Eo6RfbGvzUctA+CjZUhOKDFbLfcr7fc4usEqLNWetrlJd7RhAkyYe2czXop4fICpw=="
|
||||||
|
,"_from": "@types/babel__traverse@7.0.7"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/istanbul-lib-coverage`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for istanbul-lib-coverage ( https://istanbul.js.org ).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-lib-coverage
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Thu, 25 Apr 2019 23:07:43 GMT
|
||||||
|
* Dependencies: none
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by Jason Cheatham <https://github.com/jason0x43>, Lorenzo Rapetti <https://github.com/loryman>.
|
||||||
|
|
@ -0,0 +1,118 @@
|
||||||
|
// Type definitions for istanbul-lib-coverage 2.0
|
||||||
|
// Project: https://istanbul.js.org, https://github.com/istanbuljs/istanbuljs
|
||||||
|
// Definitions by: Jason Cheatham <https://github.com/jason0x43>
|
||||||
|
// Lorenzo Rapetti <https://github.com/loryman>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
// TypeScript Version: 2.4
|
||||||
|
|
||||||
|
export interface CoverageSummaryData {
|
||||||
|
lines: Totals;
|
||||||
|
statements: Totals;
|
||||||
|
branches: Totals;
|
||||||
|
functions: Totals;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CoverageSummary {
|
||||||
|
constructor(data: CoverageSummary | CoverageSummaryData);
|
||||||
|
merge(obj: CoverageSummary): CoverageSummary;
|
||||||
|
toJSON(): CoverageSummaryData;
|
||||||
|
isEmpty(): boolean;
|
||||||
|
data: CoverageSummaryData;
|
||||||
|
lines: Totals;
|
||||||
|
statements: Totals;
|
||||||
|
branches: Totals;
|
||||||
|
functions: Totals;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CoverageMapData {
|
||||||
|
[key: string]: FileCoverage;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CoverageMap {
|
||||||
|
constructor(data: CoverageMapData | CoverageMap);
|
||||||
|
addFileCoverage(pathOrObject: string | FileCoverage | FileCoverageData): void;
|
||||||
|
files(): string[];
|
||||||
|
fileCoverageFor(filename: string): FileCoverage;
|
||||||
|
filter(callback: (key: string) => boolean): void;
|
||||||
|
getCoverageSummary(): CoverageSummary;
|
||||||
|
merge(data: CoverageMapData | CoverageMap): void;
|
||||||
|
toJSON(): CoverageMapData;
|
||||||
|
data: CoverageMapData;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Location {
|
||||||
|
line: number;
|
||||||
|
column: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Range {
|
||||||
|
start: Location;
|
||||||
|
end: Location;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface BranchMapping {
|
||||||
|
loc: Range;
|
||||||
|
type: string;
|
||||||
|
locations: Range[];
|
||||||
|
line: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FunctionMapping {
|
||||||
|
name: string;
|
||||||
|
decl: Range;
|
||||||
|
loc: Range;
|
||||||
|
line: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FileCoverageData {
|
||||||
|
path: string;
|
||||||
|
statementMap: { [key: string]: Range };
|
||||||
|
fnMap: { [key: string]: FunctionMapping };
|
||||||
|
branchMap: { [key: string]: BranchMapping };
|
||||||
|
s: { [key: string]: number };
|
||||||
|
f: { [key: string]: number };
|
||||||
|
b: { [key: string]: number[] };
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Totals {
|
||||||
|
total: number;
|
||||||
|
covered: number;
|
||||||
|
skipped: number;
|
||||||
|
pct: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Coverage {
|
||||||
|
covered: number;
|
||||||
|
total: number;
|
||||||
|
coverage: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class FileCoverage implements FileCoverageData {
|
||||||
|
constructor(data: string | FileCoverage | FileCoverageData);
|
||||||
|
merge(other: FileCoverageData): void;
|
||||||
|
getBranchCoverageByLine(): { [line: number]: Coverage };
|
||||||
|
getLineCoverage(): { [line: number]: number };
|
||||||
|
getUncoveredLines(): number[];
|
||||||
|
resetHits(): void;
|
||||||
|
computeBranchTotals(): Totals;
|
||||||
|
computeSimpleTotals(): Totals;
|
||||||
|
toSummary(): CoverageSummary;
|
||||||
|
toJSON(): object;
|
||||||
|
|
||||||
|
data: FileCoverageData;
|
||||||
|
path: string;
|
||||||
|
statementMap: { [key: string]: Range };
|
||||||
|
fnMap: { [key: string]: FunctionMapping };
|
||||||
|
branchMap: { [key: string]: BranchMapping };
|
||||||
|
s: { [key: string]: number };
|
||||||
|
f: { [key: string]: number };
|
||||||
|
b: { [key: string]: number[] };
|
||||||
|
}
|
||||||
|
|
||||||
|
export const classes: {
|
||||||
|
FileCoverage: FileCoverage;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function createCoverageMap(data?: CoverageMap | CoverageMapData): CoverageMap;
|
||||||
|
export function createCoverageSummary(obj?: CoverageSummary | CoverageSummaryData): CoverageSummary;
|
||||||
|
export function createFileCoverage(pathOrObject: string | FileCoverage | FileCoverageData): FileCoverage;
|
||||||
|
|
@ -0,0 +1,33 @@
|
||||||
|
{
|
||||||
|
"name": "@types/istanbul-lib-coverage",
|
||||||
|
"version": "2.0.1",
|
||||||
|
"description": "TypeScript definitions for istanbul-lib-coverage",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Jason Cheatham",
|
||||||
|
"url": "https://github.com/jason0x43",
|
||||||
|
"githubUsername": "jason0x43"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Lorenzo Rapetti",
|
||||||
|
"url": "https://github.com/loryman",
|
||||||
|
"githubUsername": "loryman"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
|
"directory": "types/istanbul-lib-coverage"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {},
|
||||||
|
"typesPublisherContentHash": "fb2cf9603945473dc60dede8472e884daa070938a01b09aa816ca0cc979213ba",
|
||||||
|
"typeScriptVersion": "2.4"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.1.tgz"
|
||||||
|
,"_integrity": "sha512-hRJD2ahnnpLgsj6KWMYSrmXkM3rm2Dl1qkx6IOFD5FnuNPXJIG5L0dhgKXCYTRMGzU4n0wImQ/xfmRc4POUFlg=="
|
||||||
|
,"_from": "@types/istanbul-lib-coverage@2.0.1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/istanbul-lib-report`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for istanbul-lib-report ( https://istanbul.js.org ).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-lib-report
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Thu, 25 Apr 2019 23:07:44 GMT
|
||||||
|
* Dependencies: @types/istanbul-lib-coverage
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by Jason Cheatham <https://github.com/jason0x43>.
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
// Type definitions for istanbul-lib-report 1.1
|
||||||
|
// Project: https://istanbul.js.org, https://github.com/istanbuljs/istanbuljs
|
||||||
|
// Definitions by: Jason Cheatham <https://github.com/jason0x43>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
// TypeScript Version: 2.4
|
||||||
|
|
||||||
|
import { CoverageMap, FileCoverage, CoverageSummary } from 'istanbul-lib-coverage';
|
||||||
|
|
||||||
|
export function createContext(options?: Partial<ContextOptions>): Context;
|
||||||
|
export function getDefaultWatermarks(): Watermarks;
|
||||||
|
|
||||||
|
export const summarizers: {
|
||||||
|
flat(coverageMap: CoverageMap): Tree;
|
||||||
|
nested(coverageMap: CoverageMap): Tree;
|
||||||
|
pkg(coverageMap: CoverageMap): Tree;
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface ContextOptions {
|
||||||
|
dir: string;
|
||||||
|
watermarks: Watermarks;
|
||||||
|
sourceFinder(filepath: string): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Context extends ContextOptions {
|
||||||
|
data: any;
|
||||||
|
writer: FileWriter;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ContentWriter {
|
||||||
|
write(str: string): void;
|
||||||
|
colorize(str: string, cls?: string): string;
|
||||||
|
println(str: string): void;
|
||||||
|
close(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FileWriter {
|
||||||
|
writeForDir(subdir: string): FileWriter;
|
||||||
|
copyFile(source: string, dest: string): void;
|
||||||
|
writeFile(file: string | null): ContentWriter;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Watermarks {
|
||||||
|
statements: number[];
|
||||||
|
functions: number[];
|
||||||
|
branches: number[];
|
||||||
|
lines: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Node {
|
||||||
|
getQualifiedName(): string;
|
||||||
|
getRelativeName(): string;
|
||||||
|
isRoot(): boolean;
|
||||||
|
getParent(): Node;
|
||||||
|
getChildren(): Node[];
|
||||||
|
isSummary(): boolean;
|
||||||
|
getCoverageSummary(filesOnly: boolean): CoverageSummary;
|
||||||
|
getFileCoverage(): FileCoverage;
|
||||||
|
visit(visitor: Visitor, state: any): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ReportNode extends Node {
|
||||||
|
path: string;
|
||||||
|
parent: ReportNode | null;
|
||||||
|
fileCoverage: FileCoverage;
|
||||||
|
children: ReportNode[];
|
||||||
|
addChild(child: ReportNode): void;
|
||||||
|
asRelative(p: string): string;
|
||||||
|
visit(visitor: Visitor<ReportNode>, state: any): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Visitor<N extends Node = Node> {
|
||||||
|
onStart(root: N, state: any): void;
|
||||||
|
onSummary(root: N, state: any): void;
|
||||||
|
onDetail(root: N, state: any): void;
|
||||||
|
onSummaryEnd(root: N, state: any): void;
|
||||||
|
onEnd(root: N, state: any): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Tree<N extends Node = Node> {
|
||||||
|
getRoot(): N;
|
||||||
|
visit(visitor: Partial<Visitor<N>>, state: any): void;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"name": "@types/istanbul-lib-report",
|
||||||
|
"version": "1.1.1",
|
||||||
|
"description": "TypeScript definitions for istanbul-lib-report",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Jason Cheatham",
|
||||||
|
"url": "https://github.com/jason0x43",
|
||||||
|
"githubUsername": "jason0x43"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
|
"directory": "types/istanbul-lib-report"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/istanbul-lib-coverage": "*"
|
||||||
|
},
|
||||||
|
"typesPublisherContentHash": "64af305d196bdbb3cc44bc664daf0546df5c55bce234d53c29f97d0883da2f32",
|
||||||
|
"typeScriptVersion": "2.4"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-1.1.1.tgz"
|
||||||
|
,"_integrity": "sha512-3BUTyMzbZa2DtDI2BkERNC6jJw2Mr2Y0oGI7mRxYNBPxppbtEK1F66u3bKwU2g+wxwWI7PAoRpJnOY1grJqzHg=="
|
||||||
|
,"_from": "@types/istanbul-lib-report@1.1.1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/istanbul-reports`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for istanbul-reports ( https://github.com/istanbuljs/istanbuljs ).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/istanbul-reports
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Wed, 17 Apr 2019 17:14:08 GMT
|
||||||
|
* Dependencies: @types/istanbul-lib-report, @types/istanbul-lib-coverage
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by Jason Cheatham <https://github.com/jason0x43>.
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
// Type definitions for istanbul-reports 1.1
|
||||||
|
// Project: https://github.com/istanbuljs/istanbuljs, https://istanbul.js.org
|
||||||
|
// Definitions by: Jason Cheatham <https://github.com/jason0x43>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
// TypeScript Version: 2.4
|
||||||
|
|
||||||
|
import { Context, Node, FileWriter, Visitor } from 'istanbul-lib-report';
|
||||||
|
import { CoverageSummary } from 'istanbul-lib-coverage';
|
||||||
|
|
||||||
|
export function create<T extends keyof ReportOptions>(
|
||||||
|
name: T,
|
||||||
|
options?: Partial<ReportOptions[T]>
|
||||||
|
): Visitor;
|
||||||
|
|
||||||
|
export interface ReportOptions {
|
||||||
|
clover: RootedOptions;
|
||||||
|
cobertura: RootedOptions;
|
||||||
|
html: HtmlOptions;
|
||||||
|
json: Options;
|
||||||
|
'json-summary': Options;
|
||||||
|
lcov: never;
|
||||||
|
lcovonly: Options;
|
||||||
|
none: RootedOptions;
|
||||||
|
teamcity: Options & { blockName: string };
|
||||||
|
text: Options & { maxCols: number };
|
||||||
|
'text-lcov': Options;
|
||||||
|
'text-summary': Options;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type ReportType = keyof ReportOptions;
|
||||||
|
|
||||||
|
export interface Options {
|
||||||
|
file: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RootedOptions extends Options {
|
||||||
|
projectRoot: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HtmlOptions {
|
||||||
|
verbose: boolean;
|
||||||
|
linkMapper: LinkMapper;
|
||||||
|
subdir: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface LinkMapper {
|
||||||
|
getPath(node: string | Node): string;
|
||||||
|
relativePath(source: string | Node, target: string | Node): string;
|
||||||
|
assetPath(node: Node, name: string): string;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
"name": "@types/istanbul-reports",
|
||||||
|
"version": "1.1.1",
|
||||||
|
"description": "TypeScript definitions for istanbul-reports",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Jason Cheatham",
|
||||||
|
"url": "https://github.com/jason0x43",
|
||||||
|
"githubUsername": "jason0x43"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
|
"directory": "types/istanbul-reports"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/istanbul-lib-coverage": "*",
|
||||||
|
"@types/istanbul-lib-report": "*"
|
||||||
|
},
|
||||||
|
"typesPublisherContentHash": "48ffb8b28b9f445ebd12c748ea4cf877e1b802bee7fa18c4392b793e84bfce5a",
|
||||||
|
"typeScriptVersion": "2.4"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-1.1.1.tgz"
|
||||||
|
,"_integrity": "sha512-UpYjBi8xefVChsCoBpKShdxTllC9pwISirfoZsUa2AAdQg/Jd2KQGtSbw+ya7GPo7x/wAPlH6JBhKhAsXUEZNA=="
|
||||||
|
,"_from": "@types/istanbul-reports@1.1.1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/jest-diff`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for jest-diff ( https://github.com/facebook/jest/tree/master/packages/jest-diff ).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest-diff
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Wed, 13 Feb 2019 18:42:15 GMT
|
||||||
|
* Dependencies: none
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by Alex Coles <https://github.com/myabc>.
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
// Type definitions for jest-diff 20.0
|
||||||
|
// Project: https://github.com/facebook/jest/tree/master/packages/jest-diff, https://github.com/facebook/jest
|
||||||
|
// Definitions by: Alex Coles <https://github.com/myabc>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
// TypeScript Version: 2.2
|
||||||
|
|
||||||
|
declare namespace diff {
|
||||||
|
interface DiffOptions {
|
||||||
|
aAnnotation?: string;
|
||||||
|
bAnnotation?: string;
|
||||||
|
expand?: boolean;
|
||||||
|
contextLines?: number;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare function diff(a: any, b: any, options?: diff.DiffOptions): string;
|
||||||
|
|
||||||
|
export = diff;
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
{
|
||||||
|
"name": "@types/jest-diff",
|
||||||
|
"version": "20.0.1",
|
||||||
|
"description": "TypeScript definitions for jest-diff",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Alex Coles",
|
||||||
|
"url": "https://github.com/myabc",
|
||||||
|
"githubUsername": "myabc"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {},
|
||||||
|
"typesPublisherContentHash": "c870fcddd40540a283942f82f668244cf72de020fb0110ae019708cb06b19ce2",
|
||||||
|
"typeScriptVersion": "2.2"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@types/jest-diff/-/jest-diff-20.0.1.tgz"
|
||||||
|
,"_integrity": "sha512-yALhelO3i0hqZwhjtcr6dYyaLoCHbAMshwtj6cGxTvHZAKXHsYGdff6E8EPw3xLKY0ELUTQ69Q1rQiJENnccMA=="
|
||||||
|
,"_from": "@types/jest-diff@20.0.1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/jest`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for Jest ( https://jestjs.io/ ).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Sun, 16 Jun 2019 06:12:11 GMT
|
||||||
|
* Dependencies: @types/jest-diff
|
||||||
|
* Global values: afterAll, afterEach, beforeAll, beforeEach, describe, expect, fail, fdescribe, fit, it, jasmine, jest, pending, spyOn, test, xdescribe, xit, xtest
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by Asana (https://asana.com)
|
||||||
|
// Ivo Stratev <https://github.com/NoHomey>, jwbay <https://github.com/jwbay>, Alexey Svetliakov <https://github.com/asvetliakov>, Alex Jover Morales <https://github.com/alexjoverm>, Allan Lukwago <https://github.com/epicallan>, Ika <https://github.com/ikatyang>, Waseem Dahman <https://github.com/wsmd>, Jamie Mason <https://github.com/JamieMason>, Douglas Duteil <https://github.com/douglasduteil>, Ahn <https://github.com/ahnpnl>, Josh Goldberg <https://github.com/joshuakgoldberg>, Jeff Lau <https://github.com/UselessPickles>, Andrew Makarov <https://github.com/r3nya>, Martin Hochel <https://github.com/hotell>, Sebastian Sebald <https://github.com/sebald>, Andy <https://github.com/andys8>, Antoine Brault <https://github.com/antoinebrault>, Jeroen Claassens <https://github.com/favna>, Gregor Stamać <https://github.com/gstamac>, ExE Boss <https://github.com/ExE-Boss>.
|
||||||
|
|
@ -0,0 +1,1779 @@
|
||||||
|
// Type definitions for Jest 24.0
|
||||||
|
// Project: https://jestjs.io/
|
||||||
|
// Definitions by: Asana (https://asana.com)
|
||||||
|
// Ivo Stratev <https://github.com/NoHomey>
|
||||||
|
// jwbay <https://github.com/jwbay>
|
||||||
|
// Alexey Svetliakov <https://github.com/asvetliakov>
|
||||||
|
// Alex Jover Morales <https://github.com/alexjoverm>
|
||||||
|
// Allan Lukwago <https://github.com/epicallan>
|
||||||
|
// Ika <https://github.com/ikatyang>
|
||||||
|
// Waseem Dahman <https://github.com/wsmd>
|
||||||
|
// Jamie Mason <https://github.com/JamieMason>
|
||||||
|
// Douglas Duteil <https://github.com/douglasduteil>
|
||||||
|
// Ahn <https://github.com/ahnpnl>
|
||||||
|
// Josh Goldberg <https://github.com/joshuakgoldberg>
|
||||||
|
// Jeff Lau <https://github.com/UselessPickles>
|
||||||
|
// Andrew Makarov <https://github.com/r3nya>
|
||||||
|
// Martin Hochel <https://github.com/hotell>
|
||||||
|
// Sebastian Sebald <https://github.com/sebald>
|
||||||
|
// Andy <https://github.com/andys8>
|
||||||
|
// Antoine Brault <https://github.com/antoinebrault>
|
||||||
|
// Jeroen Claassens <https://github.com/favna>
|
||||||
|
// Gregor Stamać <https://github.com/gstamac>
|
||||||
|
// ExE Boss <https://github.com/ExE-Boss>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
// TypeScript Version: 3.0
|
||||||
|
|
||||||
|
/// <reference types="jest-diff" />
|
||||||
|
|
||||||
|
declare var beforeAll: jest.Lifecycle;
|
||||||
|
declare var beforeEach: jest.Lifecycle;
|
||||||
|
declare var afterAll: jest.Lifecycle;
|
||||||
|
declare var afterEach: jest.Lifecycle;
|
||||||
|
declare var describe: jest.Describe;
|
||||||
|
declare var fdescribe: jest.Describe;
|
||||||
|
declare var xdescribe: jest.Describe;
|
||||||
|
declare var it: jest.It;
|
||||||
|
declare var fit: jest.It;
|
||||||
|
declare var xit: jest.It;
|
||||||
|
declare var test: jest.It;
|
||||||
|
declare var xtest: jest.It;
|
||||||
|
|
||||||
|
declare const expect: jest.Expect;
|
||||||
|
|
||||||
|
interface NodeRequire {
|
||||||
|
/**
|
||||||
|
* Returns the actual module instead of a mock, bypassing all checks on
|
||||||
|
* whether the module should receive a mock implementation or not.
|
||||||
|
*
|
||||||
|
* @deprecated Use `jest.requireActual` instead.
|
||||||
|
*/
|
||||||
|
requireActual(moduleName: string): any;
|
||||||
|
/**
|
||||||
|
* Returns a mock module instead of the actual module, bypassing all checks
|
||||||
|
* on whether the module should be required normally or not.
|
||||||
|
*
|
||||||
|
* @deprecated Use `jest.requireMock`instead.
|
||||||
|
*/
|
||||||
|
requireMock(moduleName: string): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare namespace jest {
|
||||||
|
/**
|
||||||
|
* Provides a way to add Jasmine-compatible matchers into your Jest context.
|
||||||
|
*/
|
||||||
|
function addMatchers(matchers: jasmine.CustomMatcherFactories): typeof jest;
|
||||||
|
/**
|
||||||
|
* Disables automatic mocking in the module loader.
|
||||||
|
*/
|
||||||
|
function autoMockOff(): typeof jest;
|
||||||
|
/**
|
||||||
|
* Enables automatic mocking in the module loader.
|
||||||
|
*/
|
||||||
|
function autoMockOn(): typeof jest;
|
||||||
|
/**
|
||||||
|
* Clears the mock.calls and mock.instances properties of all mocks.
|
||||||
|
* Equivalent to calling .mockClear() on every mocked function.
|
||||||
|
*/
|
||||||
|
function clearAllMocks(): typeof jest;
|
||||||
|
/**
|
||||||
|
* Resets the state of all mocks.
|
||||||
|
* Equivalent to calling .mockReset() on every mocked function.
|
||||||
|
*/
|
||||||
|
function resetAllMocks(): typeof jest;
|
||||||
|
/**
|
||||||
|
* available since Jest 21.1.0
|
||||||
|
* Restores all mocks back to their original value.
|
||||||
|
* Equivalent to calling .mockRestore on every mocked function.
|
||||||
|
* Beware that jest.restoreAllMocks() only works when mock was created with
|
||||||
|
* jest.spyOn; other mocks will require you to manually restore them.
|
||||||
|
*/
|
||||||
|
function restoreAllMocks(): typeof jest;
|
||||||
|
/**
|
||||||
|
* Removes any pending timers from the timer system. If any timers have
|
||||||
|
* been scheduled, they will be cleared and will never have the opportunity
|
||||||
|
* to execute in the future.
|
||||||
|
*/
|
||||||
|
function clearAllTimers(): typeof jest;
|
||||||
|
/**
|
||||||
|
* Indicates that the module system should never return a mocked version
|
||||||
|
* of the specified module, including all of the specificied module's dependencies.
|
||||||
|
*/
|
||||||
|
function deepUnmock(moduleName: string): typeof jest;
|
||||||
|
/**
|
||||||
|
* Disables automatic mocking in the module loader.
|
||||||
|
*/
|
||||||
|
function disableAutomock(): typeof jest;
|
||||||
|
/**
|
||||||
|
* Mocks a module with an auto-mocked version when it is being required.
|
||||||
|
*/
|
||||||
|
function doMock(moduleName: string, factory?: () => unknown, options?: MockOptions): typeof jest;
|
||||||
|
/**
|
||||||
|
* Indicates that the module system should never return a mocked version
|
||||||
|
* of the specified module from require() (e.g. that it should always return the real module).
|
||||||
|
*/
|
||||||
|
function dontMock(moduleName: string): typeof jest;
|
||||||
|
/**
|
||||||
|
* Enables automatic mocking in the module loader.
|
||||||
|
*/
|
||||||
|
function enableAutomock(): typeof jest;
|
||||||
|
/**
|
||||||
|
* Creates a mock function. Optionally takes a mock implementation.
|
||||||
|
*/
|
||||||
|
function fn(): Mock;
|
||||||
|
/**
|
||||||
|
* Creates a mock function. Optionally takes a mock implementation.
|
||||||
|
*/
|
||||||
|
function fn<T, Y extends any[]>(implementation?: (...args: Y) => T): Mock<T, Y>;
|
||||||
|
/**
|
||||||
|
* Use the automatic mocking system to generate a mocked version of the given module.
|
||||||
|
*/
|
||||||
|
function genMockFromModule<T>(moduleName: string): T;
|
||||||
|
/**
|
||||||
|
* Returns whether the given function is a mock function.
|
||||||
|
*/
|
||||||
|
function isMockFunction(fn: any): fn is Mock;
|
||||||
|
/**
|
||||||
|
* Mocks a module with an auto-mocked version when it is being required.
|
||||||
|
*/
|
||||||
|
function mock(moduleName: string, factory?: () => unknown, options?: MockOptions): typeof jest;
|
||||||
|
/**
|
||||||
|
* Returns the actual module instead of a mock, bypassing all checks on
|
||||||
|
* whether the module should receive a mock implementation or not.
|
||||||
|
*/
|
||||||
|
function requireActual(moduleName: string): any;
|
||||||
|
/**
|
||||||
|
* Returns a mock module instead of the actual module, bypassing all checks
|
||||||
|
* on whether the module should be required normally or not.
|
||||||
|
*/
|
||||||
|
function requireMock(moduleName: string): any;
|
||||||
|
/**
|
||||||
|
* Resets the module registry - the cache of all required modules. This is
|
||||||
|
* useful to isolate modules where local state might conflict between tests.
|
||||||
|
*/
|
||||||
|
function resetModuleRegistry(): typeof jest;
|
||||||
|
/**
|
||||||
|
* Resets the module registry - the cache of all required modules. This is
|
||||||
|
* useful to isolate modules where local state might conflict between tests.
|
||||||
|
*/
|
||||||
|
function resetModules(): typeof jest;
|
||||||
|
/**
|
||||||
|
* Creates a sandbox registry for the modules that are loaded inside the callback function..
|
||||||
|
* This is useful to isolate specific modules for every test so that local module state doesn't conflict between tests.
|
||||||
|
*/
|
||||||
|
function isolateModules(fn: () => void): typeof jest;
|
||||||
|
/**
|
||||||
|
* Runs failed tests n-times until they pass or until the max number of retries is exhausted.
|
||||||
|
* This only works with jest-circus!
|
||||||
|
*/
|
||||||
|
function retryTimes(numRetries: number): typeof jest;
|
||||||
|
/**
|
||||||
|
* Exhausts tasks queued by setImmediate().
|
||||||
|
*/
|
||||||
|
function runAllImmediates(): typeof jest;
|
||||||
|
/**
|
||||||
|
* Exhausts the micro-task queue (usually interfaced in node via process.nextTick).
|
||||||
|
*/
|
||||||
|
function runAllTicks(): typeof jest;
|
||||||
|
/**
|
||||||
|
* Exhausts the macro-task queue (i.e., all tasks queued by setTimeout() and setInterval()).
|
||||||
|
*/
|
||||||
|
function runAllTimers(): typeof jest;
|
||||||
|
/**
|
||||||
|
* Executes only the macro-tasks that are currently pending (i.e., only the
|
||||||
|
* tasks that have been queued by setTimeout() or setInterval() up to this point).
|
||||||
|
* If any of the currently pending macro-tasks schedule new macro-tasks,
|
||||||
|
* those new tasks will not be executed by this call.
|
||||||
|
*/
|
||||||
|
function runOnlyPendingTimers(): typeof jest;
|
||||||
|
/**
|
||||||
|
* (renamed to `advanceTimersByTime` in Jest 21.3.0+) Executes only the macro
|
||||||
|
* task queue (i.e. all tasks queued by setTimeout() or setInterval() and setImmediate()).
|
||||||
|
*/
|
||||||
|
function runTimersToTime(msToRun: number): typeof jest;
|
||||||
|
/**
|
||||||
|
* Advances all timers by msToRun milliseconds. All pending "macro-tasks" that have been
|
||||||
|
* queued via setTimeout() or setInterval(), and would be executed within this timeframe
|
||||||
|
* will be executed.
|
||||||
|
*/
|
||||||
|
function advanceTimersByTime(msToRun: number): typeof jest;
|
||||||
|
/**
|
||||||
|
* Explicitly supplies the mock object that the module system should return
|
||||||
|
* for the specified module.
|
||||||
|
*/
|
||||||
|
function setMock<T>(moduleName: string, moduleExports: T): typeof jest;
|
||||||
|
/**
|
||||||
|
* Set the default timeout interval for tests and before/after hooks in milliseconds.
|
||||||
|
* Note: The default timeout interval is 5 seconds if this method is not called.
|
||||||
|
*/
|
||||||
|
function setTimeout(timeout: number): typeof jest;
|
||||||
|
/**
|
||||||
|
* Creates a mock function similar to jest.fn but also tracks calls to `object[methodName]`
|
||||||
|
*
|
||||||
|
* Note: By default, jest.spyOn also calls the spied method. This is different behavior from most
|
||||||
|
* other test libraries.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* const video = require('./video');
|
||||||
|
*
|
||||||
|
* test('plays video', () => {
|
||||||
|
* const spy = jest.spyOn(video, 'play');
|
||||||
|
* const isPlaying = video.play();
|
||||||
|
*
|
||||||
|
* expect(spy).toHaveBeenCalled();
|
||||||
|
* expect(isPlaying).toBe(true);
|
||||||
|
*
|
||||||
|
* spy.mockReset();
|
||||||
|
* spy.mockRestore();
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
function spyOn<T extends {}, M extends NonFunctionPropertyNames<Required<T>>>(object: T, method: M, accessType: 'get'): SpyInstance<Required<T>[M], []>;
|
||||||
|
function spyOn<T extends {}, M extends NonFunctionPropertyNames<Required<T>>>(object: T, method: M, accessType: 'set'): SpyInstance<void, [Required<T>[M]]>;
|
||||||
|
function spyOn<T extends {}, M extends FunctionPropertyNames<Required<T>>>(object: T, method: M): Required<T>[M] extends (...args: any[]) => any ?
|
||||||
|
SpyInstance<ReturnType<Required<T>[M]>, ArgsType<Required<T>[M]>> : never;
|
||||||
|
/**
|
||||||
|
* Indicates that the module system should never return a mocked version of
|
||||||
|
* the specified module from require() (e.g. that it should always return the real module).
|
||||||
|
*/
|
||||||
|
function unmock(moduleName: string): typeof jest;
|
||||||
|
/**
|
||||||
|
* Instructs Jest to use fake versions of the standard timer functions.
|
||||||
|
*/
|
||||||
|
function useFakeTimers(): typeof jest;
|
||||||
|
/**
|
||||||
|
* Instructs Jest to use the real versions of the standard timer functions.
|
||||||
|
*/
|
||||||
|
function useRealTimers(): typeof jest;
|
||||||
|
|
||||||
|
interface MockOptions {
|
||||||
|
virtual?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
type EmptyFunction = () => void;
|
||||||
|
type ArgsType<T> = T extends (...args: infer A) => any ? A : never;
|
||||||
|
type RejectedValue<T> = T extends PromiseLike<any> ? any : never;
|
||||||
|
type ResolvedValue<T> = T extends PromiseLike<infer U> ? U | T : never;
|
||||||
|
// see https://github.com/Microsoft/TypeScript/issues/25215
|
||||||
|
type NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends (...args: any[]) => any ? never : K }[keyof T] & string;
|
||||||
|
type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends (...args: any[]) => any ? K : never }[keyof T] & string;
|
||||||
|
|
||||||
|
interface DoneCallback {
|
||||||
|
(...args: any[]): any;
|
||||||
|
fail(error?: string | { message: string }): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProvidesCallback = (cb: DoneCallback) => any;
|
||||||
|
|
||||||
|
type Lifecycle = (fn: ProvidesCallback, timeout?: number) => any;
|
||||||
|
|
||||||
|
interface FunctionLike {
|
||||||
|
readonly name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Each {
|
||||||
|
// Exclusively arrays.
|
||||||
|
<T extends any[]>(cases: ReadonlyArray<T>): (
|
||||||
|
name: string,
|
||||||
|
fn: (...args: T) => any,
|
||||||
|
timeout?: number
|
||||||
|
) => void;
|
||||||
|
// Not arrays.
|
||||||
|
<T>(cases: ReadonlyArray<T>): (
|
||||||
|
name: string,
|
||||||
|
fn: (...args: T[]) => any,
|
||||||
|
timeout?: number
|
||||||
|
) => void;
|
||||||
|
(cases: ReadonlyArray<ReadonlyArray<any>>): (
|
||||||
|
name: string,
|
||||||
|
fn: (...args: any[]) => any,
|
||||||
|
timeout?: number
|
||||||
|
) => void;
|
||||||
|
(strings: TemplateStringsArray, ...placeholders: any[]): (
|
||||||
|
name: string,
|
||||||
|
fn: (arg: any) => any,
|
||||||
|
timeout?: number
|
||||||
|
) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a test closure
|
||||||
|
*/
|
||||||
|
interface It {
|
||||||
|
/**
|
||||||
|
* Creates a test closure.
|
||||||
|
*
|
||||||
|
* @param name The name of your test
|
||||||
|
* @param fn The function for your test
|
||||||
|
* @param timeout The timeout for an async function test
|
||||||
|
*/
|
||||||
|
(name: string, fn?: ProvidesCallback, timeout?: number): void;
|
||||||
|
/**
|
||||||
|
* Only runs this test in the current file.
|
||||||
|
*/
|
||||||
|
only: It;
|
||||||
|
/**
|
||||||
|
* Skips running this test in the current file.
|
||||||
|
*/
|
||||||
|
skip: It;
|
||||||
|
/**
|
||||||
|
* Sketch out which tests to write in the future.
|
||||||
|
*/
|
||||||
|
todo: It;
|
||||||
|
/**
|
||||||
|
* Experimental and should be avoided.
|
||||||
|
*/
|
||||||
|
concurrent: It;
|
||||||
|
/**
|
||||||
|
* Use if you keep duplicating the same test with different data. `.each` allows you to write the
|
||||||
|
* test once and pass data in.
|
||||||
|
*
|
||||||
|
* `.each` is available with two APIs:
|
||||||
|
*
|
||||||
|
* #### 1 `test.each(table)(name, fn)`
|
||||||
|
*
|
||||||
|
* - `table`: Array of Arrays with the arguments that are passed into the test fn for each row.
|
||||||
|
* - `name`: String the title of the test block.
|
||||||
|
* - `fn`: Function the test to be ran, this is the function that will receive the parameters in each row as function arguments.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* #### 2 `test.each table(name, fn)`
|
||||||
|
*
|
||||||
|
* - `table`: Tagged Template Literal
|
||||||
|
* - `name`: String the title of the test, use `$variable` to inject test data into the test title from the tagged template expressions.
|
||||||
|
* - `fn`: Function the test to be ran, this is the function that will receive the test data object..
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* // API 1
|
||||||
|
* test.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(
|
||||||
|
* '.add(%i, %i)',
|
||||||
|
* (a, b, expected) => {
|
||||||
|
* expect(a + b).toBe(expected);
|
||||||
|
* },
|
||||||
|
* );
|
||||||
|
*
|
||||||
|
* // API 2
|
||||||
|
* test.each`
|
||||||
|
* a | b | expected
|
||||||
|
* ${1} | ${1} | ${2}
|
||||||
|
* ${1} | ${2} | ${3}
|
||||||
|
* ${2} | ${1} | ${3}
|
||||||
|
* `('returns $expected when $a is added $b', ({a, b, expected}) => {
|
||||||
|
* expect(a + b).toBe(expected);
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
each: Each;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Describe {
|
||||||
|
// tslint:disable-next-line ban-types
|
||||||
|
(name: number | string | Function | FunctionLike, fn: EmptyFunction): void;
|
||||||
|
/** Only runs the tests inside this `describe` for the current file */
|
||||||
|
only: Describe;
|
||||||
|
/** Skips running the tests inside this `describe` for the current file */
|
||||||
|
skip: Describe;
|
||||||
|
each: Each;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface MatcherUtils {
|
||||||
|
readonly expand: boolean;
|
||||||
|
readonly isNot: boolean;
|
||||||
|
utils: {
|
||||||
|
readonly EXPECTED_COLOR: (text: string) => string;
|
||||||
|
readonly RECEIVED_COLOR: (text: string) => string;
|
||||||
|
diff: typeof import('jest-diff');
|
||||||
|
ensureActualIsNumber(actual: any, matcherName?: string): void;
|
||||||
|
ensureExpectedIsNumber(actual: any, matcherName?: string): void;
|
||||||
|
ensureNoExpected(actual: any, matcherName?: string): void;
|
||||||
|
ensureNumbers(actual: any, expected: any, matcherName?: string): void;
|
||||||
|
/**
|
||||||
|
* get the type of a value with handling of edge cases like `typeof []` and `typeof null`
|
||||||
|
*/
|
||||||
|
getType(value: any): string;
|
||||||
|
matcherHint(matcherName: string, received?: string, expected?: string, options?: { secondArgument?: string, isDirectExpectCall?: boolean }): string;
|
||||||
|
pluralize(word: string, count: number): string;
|
||||||
|
printExpected(value: any): string;
|
||||||
|
printReceived(value: any): string;
|
||||||
|
printWithType(name: string, received: any, print: (value: any) => string): string;
|
||||||
|
stringify(object: {}, maxDepth?: number): string;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* This is a deep-equality function that will return true if two objects have the same values (recursively).
|
||||||
|
*/
|
||||||
|
equals(a: any, b: any): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ExpectExtendMap {
|
||||||
|
[key: string]: CustomMatcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomMatcher = (this: MatcherUtils, received: any, ...actual: any[]) => CustomMatcherResult | Promise<CustomMatcherResult>;
|
||||||
|
|
||||||
|
interface CustomMatcherResult {
|
||||||
|
pass: boolean;
|
||||||
|
message: string | (() => string);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SnapshotSerializerOptions {
|
||||||
|
callToJSON?: boolean;
|
||||||
|
edgeSpacing?: string;
|
||||||
|
spacing?: string;
|
||||||
|
escapeRegex?: boolean;
|
||||||
|
highlight?: boolean;
|
||||||
|
indent?: number;
|
||||||
|
maxDepth?: number;
|
||||||
|
min?: boolean;
|
||||||
|
plugins?: SnapshotSerializerPlugin[];
|
||||||
|
printFunctionName?: boolean;
|
||||||
|
theme?: SnapshotSerializerOptionsTheme;
|
||||||
|
|
||||||
|
// see https://github.com/facebook/jest/blob/e56103cf142d2e87542ddfb6bd892bcee262c0e6/types/PrettyFormat.js
|
||||||
|
}
|
||||||
|
interface SnapshotSerializerOptionsTheme {
|
||||||
|
comment?: string;
|
||||||
|
content?: string;
|
||||||
|
prop?: string;
|
||||||
|
tag?: string;
|
||||||
|
value?: string;
|
||||||
|
}
|
||||||
|
interface SnapshotSerializerColor {
|
||||||
|
close: string;
|
||||||
|
open: string;
|
||||||
|
}
|
||||||
|
interface SnapshotSerializerColors {
|
||||||
|
comment: SnapshotSerializerColor;
|
||||||
|
content: SnapshotSerializerColor;
|
||||||
|
prop: SnapshotSerializerColor;
|
||||||
|
tag: SnapshotSerializerColor;
|
||||||
|
value: SnapshotSerializerColor;
|
||||||
|
}
|
||||||
|
interface SnapshotSerializerPlugin {
|
||||||
|
print(val: any, serialize: ((val: any) => string), indent: ((str: string) => string), opts: SnapshotSerializerOptions, colors: SnapshotSerializerColors): string;
|
||||||
|
test(val: any): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface InverseAsymmetricMatchers {
|
||||||
|
/**
|
||||||
|
* `expect.not.arrayContaining(array)` matches a received array which
|
||||||
|
* does not contain all of the elements in the expected array. That is,
|
||||||
|
* the expected array is not a subset of the received array. It is the
|
||||||
|
* inverse of `expect.arrayContaining`.
|
||||||
|
*/
|
||||||
|
arrayContaining(arr: any[]): any;
|
||||||
|
/**
|
||||||
|
* `expect.not.objectContaining(object)` matches any received object
|
||||||
|
* that does not recursively match the expected properties. That is, the
|
||||||
|
* expected object is not a subset of the received object. Therefore,
|
||||||
|
* it matches a received object which contains properties that are not
|
||||||
|
* in the expected object. It is the inverse of `expect.objectContaining`.
|
||||||
|
*/
|
||||||
|
objectContaining(obj: {}): any;
|
||||||
|
/**
|
||||||
|
* `expect.not.stringMatching(string | regexp)` matches the received
|
||||||
|
* string that does not match the expected regexp. It is the inverse of
|
||||||
|
* `expect.stringMatching`.
|
||||||
|
*/
|
||||||
|
stringMatching(str: string | RegExp): any;
|
||||||
|
/**
|
||||||
|
* `expect.not.stringContaining(string)` matches the received string
|
||||||
|
* that does not contain the exact expected string. It is the inverse of
|
||||||
|
* `expect.stringContaining`.
|
||||||
|
*/
|
||||||
|
stringContaining(str: string): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The `expect` function is used every time you want to test a value.
|
||||||
|
* You will rarely call `expect` by itself.
|
||||||
|
*/
|
||||||
|
interface Expect {
|
||||||
|
/**
|
||||||
|
* The `expect` function is used every time you want to test a value.
|
||||||
|
* You will rarely call `expect` by itself.
|
||||||
|
*
|
||||||
|
* @param actual The value to apply matchers against.
|
||||||
|
*/
|
||||||
|
<T = any>(actual: T): Matchers<T>;
|
||||||
|
/**
|
||||||
|
* Matches anything but null or undefined. You can use it inside `toEqual` or `toBeCalledWith` instead
|
||||||
|
* of a literal value. For example, if you want to check that a mock function is called with a
|
||||||
|
* non-null argument:
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* test('map calls its argument with a non-null argument', () => {
|
||||||
|
* const mock = jest.fn();
|
||||||
|
* [1].map(x => mock(x));
|
||||||
|
* expect(mock).toBeCalledWith(expect.anything());
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
anything(): any;
|
||||||
|
/**
|
||||||
|
* Matches anything that was created with the given constructor.
|
||||||
|
* You can use it inside `toEqual` or `toBeCalledWith` instead of a literal value.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* function randocall(fn) {
|
||||||
|
* return fn(Math.floor(Math.random() * 6 + 1));
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* test('randocall calls its callback with a number', () => {
|
||||||
|
* const mock = jest.fn();
|
||||||
|
* randocall(mock);
|
||||||
|
* expect(mock).toBeCalledWith(expect.any(Number));
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
any(classType: any): any;
|
||||||
|
/**
|
||||||
|
* Matches any array made up entirely of elements in the provided array.
|
||||||
|
* You can use it inside `toEqual` or `toBeCalledWith` instead of a literal value.
|
||||||
|
*/
|
||||||
|
arrayContaining(arr: any[]): any;
|
||||||
|
/**
|
||||||
|
* Verifies that a certain number of assertions are called during a test.
|
||||||
|
* This is often useful when testing asynchronous code, in order to
|
||||||
|
* make sure that assertions in a callback actually got called.
|
||||||
|
*/
|
||||||
|
assertions(num: number): void;
|
||||||
|
/**
|
||||||
|
* Verifies that at least one assertion is called during a test.
|
||||||
|
* This is often useful when testing asynchronous code, in order to
|
||||||
|
* make sure that assertions in a callback actually got called.
|
||||||
|
*/
|
||||||
|
hasAssertions(): void;
|
||||||
|
/**
|
||||||
|
* You can use `expect.extend` to add your own matchers to Jest.
|
||||||
|
*/
|
||||||
|
extend(obj: ExpectExtendMap): void;
|
||||||
|
/**
|
||||||
|
* Adds a module to format application-specific data structures for serialization.
|
||||||
|
*/
|
||||||
|
addSnapshotSerializer(serializer: SnapshotSerializerPlugin): void;
|
||||||
|
/**
|
||||||
|
* Matches any object that recursively matches the provided keys.
|
||||||
|
* This is often handy in conjunction with other asymmetric matchers.
|
||||||
|
*/
|
||||||
|
objectContaining(obj: {}): any;
|
||||||
|
/**
|
||||||
|
* Matches any string that contains the exact provided string
|
||||||
|
*/
|
||||||
|
stringMatching(str: string | RegExp): any;
|
||||||
|
/**
|
||||||
|
* Matches any received string that contains the exact expected string
|
||||||
|
*/
|
||||||
|
stringContaining(str: string): any;
|
||||||
|
|
||||||
|
not: InverseAsymmetricMatchers;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Matchers<R> {
|
||||||
|
/**
|
||||||
|
* Ensures the last call to a mock function was provided specific args.
|
||||||
|
*/
|
||||||
|
lastCalledWith(...args: any[]): R;
|
||||||
|
/**
|
||||||
|
* Ensure that the last call to a mock function has returned a specified value.
|
||||||
|
*/
|
||||||
|
lastReturnedWith(value: any): R;
|
||||||
|
/**
|
||||||
|
* If you know how to test something, `.not` lets you test its opposite.
|
||||||
|
*/
|
||||||
|
not: Matchers<R>;
|
||||||
|
/**
|
||||||
|
* Ensure that a mock function is called with specific arguments on an Nth call.
|
||||||
|
*/
|
||||||
|
nthCalledWith(nthCall: number, ...params: any[]): R;
|
||||||
|
/**
|
||||||
|
* Ensure that the nth call to a mock function has returned a specified value.
|
||||||
|
*/
|
||||||
|
nthReturnedWith(n: number, value: any): R;
|
||||||
|
/**
|
||||||
|
* Use resolves to unwrap the value of a fulfilled promise so any other
|
||||||
|
* matcher can be chained. If the promise is rejected the assertion fails.
|
||||||
|
*/
|
||||||
|
resolves: Matchers<Promise<R>>;
|
||||||
|
/**
|
||||||
|
* Unwraps the reason of a rejected promise so any other matcher can be chained.
|
||||||
|
* If the promise is fulfilled the assertion fails.
|
||||||
|
*/
|
||||||
|
rejects: Matchers<Promise<R>>;
|
||||||
|
/**
|
||||||
|
* Checks that a value is what you expect. It uses `===` to check strict equality.
|
||||||
|
* Don't use `toBe` with floating-point numbers.
|
||||||
|
*/
|
||||||
|
toBe(expected: any): R;
|
||||||
|
/**
|
||||||
|
* Ensures that a mock function is called.
|
||||||
|
*/
|
||||||
|
toBeCalled(): R;
|
||||||
|
/**
|
||||||
|
* Ensures that a mock function is called an exact number of times.
|
||||||
|
*/
|
||||||
|
toBeCalledTimes(expected: number): R;
|
||||||
|
/**
|
||||||
|
* Ensure that a mock function is called with specific arguments.
|
||||||
|
*/
|
||||||
|
toBeCalledWith(...args: any[]): R;
|
||||||
|
/**
|
||||||
|
* Using exact equality with floating point numbers is a bad idea.
|
||||||
|
* Rounding means that intuitive things fail.
|
||||||
|
* The default for numDigits is 2.
|
||||||
|
*/
|
||||||
|
toBeCloseTo(expected: number, numDigits?: number): R;
|
||||||
|
/**
|
||||||
|
* Ensure that a variable is not undefined.
|
||||||
|
*/
|
||||||
|
toBeDefined(): R;
|
||||||
|
/**
|
||||||
|
* When you don't care what a value is, you just want to
|
||||||
|
* ensure a value is false in a boolean context.
|
||||||
|
*/
|
||||||
|
toBeFalsy(): R;
|
||||||
|
/**
|
||||||
|
* For comparing floating point numbers.
|
||||||
|
*/
|
||||||
|
toBeGreaterThan(expected: number): R;
|
||||||
|
/**
|
||||||
|
* For comparing floating point numbers.
|
||||||
|
*/
|
||||||
|
toBeGreaterThanOrEqual(expected: number): R;
|
||||||
|
/**
|
||||||
|
* Ensure that an object is an instance of a class.
|
||||||
|
* This matcher uses `instanceof` underneath.
|
||||||
|
*/
|
||||||
|
toBeInstanceOf(expected: any): R;
|
||||||
|
/**
|
||||||
|
* For comparing floating point numbers.
|
||||||
|
*/
|
||||||
|
toBeLessThan(expected: number): R;
|
||||||
|
/**
|
||||||
|
* For comparing floating point numbers.
|
||||||
|
*/
|
||||||
|
toBeLessThanOrEqual(expected: number): R;
|
||||||
|
/**
|
||||||
|
* This is the same as `.toBe(null)` but the error messages are a bit nicer.
|
||||||
|
* So use `.toBeNull()` when you want to check that something is null.
|
||||||
|
*/
|
||||||
|
toBeNull(): R;
|
||||||
|
/**
|
||||||
|
* Use when you don't care what a value is, you just want to ensure a value
|
||||||
|
* is true in a boolean context. In JavaScript, there are six falsy values:
|
||||||
|
* `false`, `0`, `''`, `null`, `undefined`, and `NaN`. Everything else is truthy.
|
||||||
|
*/
|
||||||
|
toBeTruthy(): R;
|
||||||
|
/**
|
||||||
|
* Used to check that a variable is undefined.
|
||||||
|
*/
|
||||||
|
toBeUndefined(): R;
|
||||||
|
/**
|
||||||
|
* Used to check that a variable is NaN.
|
||||||
|
*/
|
||||||
|
toBeNaN(): R;
|
||||||
|
/**
|
||||||
|
* Used when you want to check that an item is in a list.
|
||||||
|
* For testing the items in the list, this uses `===`, a strict equality check.
|
||||||
|
*/
|
||||||
|
toContain(expected: any): R;
|
||||||
|
/**
|
||||||
|
* Used when you want to check that an item is in a list.
|
||||||
|
* For testing the items in the list, this matcher recursively checks the
|
||||||
|
* equality of all fields, rather than checking for object identity.
|
||||||
|
*/
|
||||||
|
toContainEqual(expected: any): R;
|
||||||
|
/**
|
||||||
|
* Used when you want to check that two objects have the same value.
|
||||||
|
* This matcher recursively checks the equality of all fields, rather than checking for object identity.
|
||||||
|
*/
|
||||||
|
toEqual(expected: any): R;
|
||||||
|
/**
|
||||||
|
* Ensures that a mock function is called.
|
||||||
|
*/
|
||||||
|
toHaveBeenCalled(): R;
|
||||||
|
/**
|
||||||
|
* Ensures that a mock function is called an exact number of times.
|
||||||
|
*/
|
||||||
|
toHaveBeenCalledTimes(expected: number): R;
|
||||||
|
/**
|
||||||
|
* Ensure that a mock function is called with specific arguments.
|
||||||
|
*/
|
||||||
|
toHaveBeenCalledWith(...params: any[]): R;
|
||||||
|
/**
|
||||||
|
* Ensure that a mock function is called with specific arguments on an Nth call.
|
||||||
|
*/
|
||||||
|
toHaveBeenNthCalledWith(nthCall: number, ...params: any[]): R;
|
||||||
|
/**
|
||||||
|
* If you have a mock function, you can use `.toHaveBeenLastCalledWith`
|
||||||
|
* to test what arguments it was last called with.
|
||||||
|
*/
|
||||||
|
toHaveBeenLastCalledWith(...params: any[]): R;
|
||||||
|
/**
|
||||||
|
* Use to test the specific value that a mock function last returned.
|
||||||
|
* If the last call to the mock function threw an error, then this matcher will fail
|
||||||
|
* no matter what value you provided as the expected return value.
|
||||||
|
*/
|
||||||
|
toHaveLastReturnedWith(expected: any): R;
|
||||||
|
/**
|
||||||
|
* Used to check that an object has a `.length` property
|
||||||
|
* and it is set to a certain numeric value.
|
||||||
|
*/
|
||||||
|
toHaveLength(expected: number): R;
|
||||||
|
/**
|
||||||
|
* Use to test the specific value that a mock function returned for the nth call.
|
||||||
|
* If the nth call to the mock function threw an error, then this matcher will fail
|
||||||
|
* no matter what value you provided as the expected return value.
|
||||||
|
*/
|
||||||
|
toHaveNthReturnedWith(nthCall: number, expected: any): R;
|
||||||
|
/**
|
||||||
|
* Use to check if property at provided reference keyPath exists for an object.
|
||||||
|
* For checking deeply nested properties in an object you may use dot notation or an array containing
|
||||||
|
* the keyPath for deep references.
|
||||||
|
*
|
||||||
|
* Optionally, you can provide a value to check if it's equal to the value present at keyPath
|
||||||
|
* on the target object. This matcher uses 'deep equality' (like `toEqual()`) and recursively checks
|
||||||
|
* the equality of all fields.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* expect(houseForSale).toHaveProperty('kitchen.area', 20);
|
||||||
|
*/
|
||||||
|
toHaveProperty(propertyPath: string | any[], value?: any): R;
|
||||||
|
/**
|
||||||
|
* Use to test that the mock function successfully returned (i.e., did not throw an error) at least one time
|
||||||
|
*/
|
||||||
|
toHaveReturned(): R;
|
||||||
|
/**
|
||||||
|
* Use to ensure that a mock function returned successfully (i.e., did not throw an error) an exact number of times.
|
||||||
|
* Any calls to the mock function that throw an error are not counted toward the number of times the function returned.
|
||||||
|
*/
|
||||||
|
toHaveReturnedTimes(expected: number): R;
|
||||||
|
/**
|
||||||
|
* Use to ensure that a mock function returned a specific value.
|
||||||
|
*/
|
||||||
|
toHaveReturnedWith(expected: any): R;
|
||||||
|
/**
|
||||||
|
* Check that a string matches a regular expression.
|
||||||
|
*/
|
||||||
|
toMatch(expected: string | RegExp): R;
|
||||||
|
/**
|
||||||
|
* Used to check that a JavaScript object matches a subset of the properties of an object
|
||||||
|
*
|
||||||
|
* Optionally, you can provide an object to use as Generic type for the expected value.
|
||||||
|
* This ensures that the matching object matches the structure of the provided object-like type.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* type House = {
|
||||||
|
* bath: boolean;
|
||||||
|
* bedrooms: number;
|
||||||
|
* kitchen: {
|
||||||
|
* amenities: string[];
|
||||||
|
* area: number;
|
||||||
|
* wallColor: string;
|
||||||
|
* }
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* expect(desiredHouse).toMatchObject<House>(...standardHouse, kitchen: {area: 20}) // wherein standardHouse is some base object of type House
|
||||||
|
*/
|
||||||
|
toMatchObject<E extends {} | any[]>(expected: E): R;
|
||||||
|
/**
|
||||||
|
* This ensures that a value matches the most recent snapshot with property matchers.
|
||||||
|
* Check out [the Snapshot Testing guide](http://facebook.github.io/jest/docs/snapshot-testing.html) for more information.
|
||||||
|
*/
|
||||||
|
toMatchSnapshot<T extends {[P in keyof R]: any}>(propertyMatchers: Partial<T>, snapshotName?: string): R;
|
||||||
|
/**
|
||||||
|
* This ensures that a value matches the most recent snapshot.
|
||||||
|
* Check out [the Snapshot Testing guide](http://facebook.github.io/jest/docs/snapshot-testing.html) for more information.
|
||||||
|
*/
|
||||||
|
toMatchSnapshot(snapshotName?: string): R;
|
||||||
|
/**
|
||||||
|
* This ensures that a value matches the most recent snapshot with property matchers.
|
||||||
|
* Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically.
|
||||||
|
* Check out [the Snapshot Testing guide](http://facebook.github.io/jest/docs/snapshot-testing.html) for more information.
|
||||||
|
*/
|
||||||
|
toMatchInlineSnapshot<T extends {[P in keyof R]: any}>(propertyMatchers: Partial<T>, snapshot?: string): R;
|
||||||
|
/**
|
||||||
|
* This ensures that a value matches the most recent snapshot with property matchers.
|
||||||
|
* Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically.
|
||||||
|
* Check out [the Snapshot Testing guide](http://facebook.github.io/jest/docs/snapshot-testing.html) for more information.
|
||||||
|
*/
|
||||||
|
toMatchInlineSnapshot(snapshot?: string): R;
|
||||||
|
/**
|
||||||
|
* Ensure that a mock function has returned (as opposed to thrown) at least once.
|
||||||
|
*/
|
||||||
|
toReturn(): R;
|
||||||
|
/**
|
||||||
|
* Ensure that a mock function has returned (as opposed to thrown) a specified number of times.
|
||||||
|
*/
|
||||||
|
toReturnTimes(count: number): R;
|
||||||
|
/**
|
||||||
|
* Ensure that a mock function has returned a specified value at least once.
|
||||||
|
*/
|
||||||
|
toReturnWith(value: any): R;
|
||||||
|
/**
|
||||||
|
* Use to test that objects have the same types as well as structure.
|
||||||
|
*/
|
||||||
|
toStrictEqual(expected: {}): R;
|
||||||
|
/**
|
||||||
|
* Used to test that a function throws when it is called.
|
||||||
|
*/
|
||||||
|
toThrow(error?: string | Constructable | RegExp | Error): R;
|
||||||
|
/**
|
||||||
|
* If you want to test that a specific error is thrown inside a function.
|
||||||
|
*/
|
||||||
|
toThrowError(error?: string | Constructable | RegExp | Error): R;
|
||||||
|
/**
|
||||||
|
* Used to test that a function throws a error matching the most recent snapshot when it is called.
|
||||||
|
*/
|
||||||
|
toThrowErrorMatchingSnapshot(): R;
|
||||||
|
/**
|
||||||
|
* Used to test that a function throws a error matching the most recent snapshot when it is called.
|
||||||
|
* Instead of writing the snapshot value to a .snap file, it will be written into the source code automatically.
|
||||||
|
*/
|
||||||
|
toThrowErrorMatchingInlineSnapshot(snapshot?: string): R;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Constructable {
|
||||||
|
new (...args: any[]): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Mock<T = any, Y extends any[] = any> extends Function, MockInstance<T, Y> {
|
||||||
|
new (...args: Y): T;
|
||||||
|
(...args: Y): T;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SpyInstance<T = any, Y extends any[] = any> extends MockInstance<T, Y> {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrap module with mock definitions
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* jest.mock("../api");
|
||||||
|
* import { Api } from "../api";
|
||||||
|
*
|
||||||
|
* const myApi: jest.Mocked<Api> = new Api() as any;
|
||||||
|
* myApi.myApiMethod.mockImplementation(() => "test");
|
||||||
|
*/
|
||||||
|
type Mocked<T> = {
|
||||||
|
[P in keyof T]: T[P] extends (...args: any[]) => any ? MockInstance<ReturnType<T[P]>, ArgsType<T[P]>>: T[P];
|
||||||
|
} & T;
|
||||||
|
|
||||||
|
interface MockInstance<T, Y extends any[]> {
|
||||||
|
/** Returns the mock name string set by calling `mockFn.mockName(value)`. */
|
||||||
|
getMockName(): string;
|
||||||
|
/** Provides access to the mock's metadata */
|
||||||
|
mock: MockContext<T, Y>;
|
||||||
|
/**
|
||||||
|
* Resets all information stored in the mockFn.mock.calls and mockFn.mock.instances arrays.
|
||||||
|
*
|
||||||
|
* Often this is useful when you want to clean up a mock's usage data between two assertions.
|
||||||
|
*
|
||||||
|
* Beware that `mockClear` will replace `mockFn.mock`, not just `mockFn.mock.calls` and `mockFn.mock.instances`.
|
||||||
|
* You should therefore avoid assigning mockFn.mock to other variables, temporary or not, to make sure you
|
||||||
|
* don't access stale data.
|
||||||
|
*/
|
||||||
|
mockClear(): void;
|
||||||
|
/**
|
||||||
|
* Resets all information stored in the mock, including any initial implementation and mock name given.
|
||||||
|
*
|
||||||
|
* This is useful when you want to completely restore a mock back to its initial state.
|
||||||
|
*
|
||||||
|
* Beware that `mockReset` will replace `mockFn.mock`, not just `mockFn.mock.calls` and `mockFn.mock.instances`.
|
||||||
|
* You should therefore avoid assigning mockFn.mock to other variables, temporary or not, to make sure you
|
||||||
|
* don't access stale data.
|
||||||
|
*/
|
||||||
|
mockReset(): void;
|
||||||
|
/**
|
||||||
|
* Does everything that `mockFn.mockReset()` does, and also restores the original (non-mocked) implementation.
|
||||||
|
*
|
||||||
|
* This is useful when you want to mock functions in certain test cases and restore the original implementation in others.
|
||||||
|
*
|
||||||
|
* Beware that `mockFn.mockRestore` only works when mock was created with `jest.spyOn`. Thus you have to take care of restoration
|
||||||
|
* yourself when manually assigning `jest.fn()`.
|
||||||
|
*
|
||||||
|
* The [`restoreMocks`](https://jestjs.io/docs/en/configuration.html#restoremocks-boolean) configuration option is available
|
||||||
|
* to restore mocks automatically between tests.
|
||||||
|
*/
|
||||||
|
mockRestore(): void;
|
||||||
|
/**
|
||||||
|
* Accepts a function that should be used as the implementation of the mock. The mock itself will still record
|
||||||
|
* all calls that go into and instances that come from itself – the only difference is that the implementation
|
||||||
|
* will also be executed when the mock is called.
|
||||||
|
*
|
||||||
|
* Note: `jest.fn(implementation)` is a shorthand for `jest.fn().mockImplementation(implementation)`.
|
||||||
|
*/
|
||||||
|
mockImplementation(fn?: (...args: Y) => T): this;
|
||||||
|
/**
|
||||||
|
* Accepts a function that will be used as an implementation of the mock for one call to the mocked function.
|
||||||
|
* Can be chained so that multiple function calls produce different results.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* const myMockFn = jest
|
||||||
|
* .fn()
|
||||||
|
* .mockImplementationOnce(cb => cb(null, true))
|
||||||
|
* .mockImplementationOnce(cb => cb(null, false));
|
||||||
|
*
|
||||||
|
* myMockFn((err, val) => console.log(val)); // true
|
||||||
|
*
|
||||||
|
* myMockFn((err, val) => console.log(val)); // false
|
||||||
|
*/
|
||||||
|
mockImplementationOnce(fn: (...args: Y) => T): this;
|
||||||
|
/** Sets the name of the mock`. */
|
||||||
|
mockName(name: string): this;
|
||||||
|
/**
|
||||||
|
* Just a simple sugar function for:
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* jest.fn(function() {
|
||||||
|
* return this;
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
mockReturnThis(): this;
|
||||||
|
/**
|
||||||
|
* Accepts a value that will be returned whenever the mock function is called.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* const mock = jest.fn();
|
||||||
|
* mock.mockReturnValue(42);
|
||||||
|
* mock(); // 42
|
||||||
|
* mock.mockReturnValue(43);
|
||||||
|
* mock(); // 43
|
||||||
|
*/
|
||||||
|
mockReturnValue(value: T): this;
|
||||||
|
/**
|
||||||
|
* Accepts a value that will be returned for one call to the mock function. Can be chained so that
|
||||||
|
* successive calls to the mock function return different values. When there are no more
|
||||||
|
* `mockReturnValueOnce` values to use, calls will return a value specified by `mockReturnValue`.
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* const myMockFn = jest.fn()
|
||||||
|
* .mockReturnValue('default')
|
||||||
|
* .mockReturnValueOnce('first call')
|
||||||
|
* .mockReturnValueOnce('second call');
|
||||||
|
*
|
||||||
|
* // 'first call', 'second call', 'default', 'default'
|
||||||
|
* console.log(myMockFn(), myMockFn(), myMockFn(), myMockFn());
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
mockReturnValueOnce(value: T): this;
|
||||||
|
/**
|
||||||
|
* Simple sugar function for: `jest.fn().mockImplementation(() => Promise.resolve(value));`
|
||||||
|
*/
|
||||||
|
mockResolvedValue(value: ResolvedValue<T>): this;
|
||||||
|
/**
|
||||||
|
* Simple sugar function for: `jest.fn().mockImplementationOnce(() => Promise.resolve(value));`
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* test('async test', async () => {
|
||||||
|
* const asyncMock = jest
|
||||||
|
* .fn()
|
||||||
|
* .mockResolvedValue('default')
|
||||||
|
* .mockResolvedValueOnce('first call')
|
||||||
|
* .mockResolvedValueOnce('second call');
|
||||||
|
*
|
||||||
|
* await asyncMock(); // first call
|
||||||
|
* await asyncMock(); // second call
|
||||||
|
* await asyncMock(); // default
|
||||||
|
* await asyncMock(); // default
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
mockResolvedValueOnce(value: ResolvedValue<T>): this;
|
||||||
|
/**
|
||||||
|
* Simple sugar function for: `jest.fn().mockImplementation(() => Promise.reject(value));`
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* test('async test', async () => {
|
||||||
|
* const asyncMock = jest.fn().mockRejectedValue(new Error('Async error'));
|
||||||
|
*
|
||||||
|
* await asyncMock(); // throws "Async error"
|
||||||
|
* });
|
||||||
|
*/
|
||||||
|
mockRejectedValue(value: RejectedValue<T>): this;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple sugar function for: `jest.fn().mockImplementationOnce(() => Promise.reject(value));`
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
*
|
||||||
|
* test('async test', async () => {
|
||||||
|
* const asyncMock = jest
|
||||||
|
* .fn()
|
||||||
|
* .mockResolvedValueOnce('first call')
|
||||||
|
* .mockRejectedValueOnce(new Error('Async error'));
|
||||||
|
*
|
||||||
|
* await asyncMock(); // first call
|
||||||
|
* await asyncMock(); // throws "Async error"
|
||||||
|
* });
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
mockRejectedValueOnce(value: RejectedValue<T>): this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the result of a single call to a mock function with a return value.
|
||||||
|
*/
|
||||||
|
interface MockResultReturn<T> {
|
||||||
|
type: 'return';
|
||||||
|
value: T;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Represents the result of a single incomplete call to a mock function.
|
||||||
|
*/
|
||||||
|
interface MockResultIncomplete {
|
||||||
|
type: 'incomplete';
|
||||||
|
value: undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Represents the result of a single call to a mock function with a thrown error.
|
||||||
|
*/
|
||||||
|
interface MockResultThrow {
|
||||||
|
type: 'throw';
|
||||||
|
value: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
|
||||||
|
|
||||||
|
interface MockContext<T, Y extends any[]> {
|
||||||
|
calls: Y[];
|
||||||
|
instances: T[];
|
||||||
|
invocationCallOrder: number[];
|
||||||
|
/**
|
||||||
|
* List of results of calls to the mock function.
|
||||||
|
*/
|
||||||
|
results: Array<MockResult<T>>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Jest ships with a copy of Jasmine. They monkey-patch its APIs and divergence/deprecation are expected.
|
||||||
|
// Relevant parts of Jasmine's API are below so they can be changed and removed over time.
|
||||||
|
// This file can't reference jasmine.d.ts since the globals aren't compatible.
|
||||||
|
|
||||||
|
declare function spyOn<T>(object: T, method: keyof T): jasmine.Spy;
|
||||||
|
/**
|
||||||
|
* If you call the function pending anywhere in the spec body,
|
||||||
|
* no matter the expectations, the spec will be marked pending.
|
||||||
|
*/
|
||||||
|
declare function pending(reason?: string): void;
|
||||||
|
/**
|
||||||
|
* Fails a test when called within one.
|
||||||
|
*/
|
||||||
|
declare function fail(error?: any): never;
|
||||||
|
declare namespace jasmine {
|
||||||
|
let DEFAULT_TIMEOUT_INTERVAL: number;
|
||||||
|
function clock(): Clock;
|
||||||
|
function any(aclass: any): Any;
|
||||||
|
function anything(): Any;
|
||||||
|
function arrayContaining(sample: any[]): ArrayContaining;
|
||||||
|
function objectContaining(sample: any): ObjectContaining;
|
||||||
|
function createSpy(name?: string, originalFn?: (...args: any[]) => any): Spy;
|
||||||
|
function createSpyObj(baseName: string, methodNames: any[]): any;
|
||||||
|
function createSpyObj<T>(baseName: string, methodNames: any[]): T;
|
||||||
|
function pp(value: any): string;
|
||||||
|
function addCustomEqualityTester(equalityTester: CustomEqualityTester): void;
|
||||||
|
function addMatchers(matchers: CustomMatcherFactories): void;
|
||||||
|
function stringMatching(value: string | RegExp): Any;
|
||||||
|
|
||||||
|
interface Clock {
|
||||||
|
install(): void;
|
||||||
|
uninstall(): void;
|
||||||
|
/**
|
||||||
|
* Calls to any registered callback are triggered when the clock isticked forward
|
||||||
|
* via the jasmine.clock().tick function, which takes a number of milliseconds.
|
||||||
|
*/
|
||||||
|
tick(ms: number): void;
|
||||||
|
mockDate(date?: Date): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Any {
|
||||||
|
new (expectedClass: any): any;
|
||||||
|
jasmineMatches(other: any): boolean;
|
||||||
|
jasmineToString(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ArrayContaining {
|
||||||
|
new (sample: any[]): any;
|
||||||
|
asymmetricMatch(other: any): boolean;
|
||||||
|
jasmineToString(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ObjectContaining {
|
||||||
|
new (sample: any): any;
|
||||||
|
jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
|
||||||
|
jasmineToString(): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Spy {
|
||||||
|
(...params: any[]): any;
|
||||||
|
identity: string;
|
||||||
|
and: SpyAnd;
|
||||||
|
calls: Calls;
|
||||||
|
mostRecentCall: { args: any[]; };
|
||||||
|
argsForCall: any[];
|
||||||
|
wasCalled: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SpyAnd {
|
||||||
|
/**
|
||||||
|
* By chaining the spy with and.callThrough, the spy will still track all
|
||||||
|
* calls to it but in addition it will delegate to the actual implementation.
|
||||||
|
*/
|
||||||
|
callThrough(): Spy;
|
||||||
|
/**
|
||||||
|
* By chaining the spy with and.returnValue, all calls to the function
|
||||||
|
* will return a specific value.
|
||||||
|
*/
|
||||||
|
returnValue(val: any): Spy;
|
||||||
|
/**
|
||||||
|
* By chaining the spy with and.returnValues, all calls to the function
|
||||||
|
* will return specific values in order until it reaches the end of the return values list.
|
||||||
|
*/
|
||||||
|
returnValues(...values: any[]): Spy;
|
||||||
|
/**
|
||||||
|
* By chaining the spy with and.callFake, all calls to the spy
|
||||||
|
* will delegate to the supplied function.
|
||||||
|
*/
|
||||||
|
callFake(fn: (...args: any[]) => any): Spy;
|
||||||
|
/**
|
||||||
|
* By chaining the spy with and.throwError, all calls to the spy
|
||||||
|
* will throw the specified value.
|
||||||
|
*/
|
||||||
|
throwError(msg: string): Spy;
|
||||||
|
/**
|
||||||
|
* When a calling strategy is used for a spy, the original stubbing
|
||||||
|
* behavior can be returned at any time with and.stub.
|
||||||
|
*/
|
||||||
|
stub(): Spy;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Calls {
|
||||||
|
/**
|
||||||
|
* By chaining the spy with calls.any(),
|
||||||
|
* will return false if the spy has not been called at all,
|
||||||
|
* and then true once at least one call happens.
|
||||||
|
*/
|
||||||
|
any(): boolean;
|
||||||
|
/**
|
||||||
|
* By chaining the spy with calls.count(),
|
||||||
|
* will return the number of times the spy was called
|
||||||
|
*/
|
||||||
|
count(): number;
|
||||||
|
/**
|
||||||
|
* By chaining the spy with calls.argsFor(),
|
||||||
|
* will return the arguments passed to call number index
|
||||||
|
*/
|
||||||
|
argsFor(index: number): any[];
|
||||||
|
/**
|
||||||
|
* By chaining the spy with calls.allArgs(),
|
||||||
|
* will return the arguments to all calls
|
||||||
|
*/
|
||||||
|
allArgs(): any[];
|
||||||
|
/**
|
||||||
|
* By chaining the spy with calls.all(), will return the
|
||||||
|
* context (the this) and arguments passed all calls
|
||||||
|
*/
|
||||||
|
all(): CallInfo[];
|
||||||
|
/**
|
||||||
|
* By chaining the spy with calls.mostRecent(), will return the
|
||||||
|
* context (the this) and arguments for the most recent call
|
||||||
|
*/
|
||||||
|
mostRecent(): CallInfo;
|
||||||
|
/**
|
||||||
|
* By chaining the spy with calls.first(), will return the
|
||||||
|
* context (the this) and arguments for the first call
|
||||||
|
*/
|
||||||
|
first(): CallInfo;
|
||||||
|
/**
|
||||||
|
* By chaining the spy with calls.reset(), will clears all tracking for a spy
|
||||||
|
*/
|
||||||
|
reset(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CallInfo {
|
||||||
|
/**
|
||||||
|
* The context (the this) for the call
|
||||||
|
*/
|
||||||
|
object: any;
|
||||||
|
/**
|
||||||
|
* All arguments passed to the call
|
||||||
|
*/
|
||||||
|
args: any[];
|
||||||
|
/**
|
||||||
|
* The return value of the call
|
||||||
|
*/
|
||||||
|
returnValue: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CustomMatcherFactories {
|
||||||
|
[index: string]: CustomMatcherFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomMatcherFactory = (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]) => CustomMatcher;
|
||||||
|
|
||||||
|
interface MatchersUtil {
|
||||||
|
equals(a: any, b: any, customTesters?: CustomEqualityTester[]): boolean;
|
||||||
|
contains<T>(haystack: ArrayLike<T> | string, needle: any, customTesters?: CustomEqualityTester[]): boolean;
|
||||||
|
buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: any[]): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type CustomEqualityTester = (first: any, second: any) => boolean;
|
||||||
|
|
||||||
|
interface CustomMatcher {
|
||||||
|
compare<T>(actual: T, expected: T, ...args: any[]): CustomMatcherResult;
|
||||||
|
compare(actual: any, ...expected: any[]): CustomMatcherResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CustomMatcherResult {
|
||||||
|
pass: boolean;
|
||||||
|
message: string | (() => string);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ArrayLike<T> {
|
||||||
|
length: number;
|
||||||
|
[n: number]: T;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare namespace jest {
|
||||||
|
// types for implementing custom interfaces, from https://github.com/facebook/jest/tree/dd6c5c4/types
|
||||||
|
|
||||||
|
// https://facebook.github.io/jest/docs/en/configuration.html#transform-object-string-string
|
||||||
|
// const transformer: Transformer;
|
||||||
|
|
||||||
|
// https://facebook.github.io/jest/docs/en/configuration.html#reporters-array-modulename-modulename-options
|
||||||
|
// const reporter: Reporter;
|
||||||
|
|
||||||
|
// https://facebook.github.io/jest/docs/en/configuration.html#testrunner-string
|
||||||
|
// const testRunner: TestFramework;
|
||||||
|
|
||||||
|
// https://facebook.github.io/jest/docs/en/configuration.html#testresultsprocessor-string
|
||||||
|
// const testResultsProcessor: TestResultsProcessor;
|
||||||
|
|
||||||
|
// leave above declarations for referening type-dependencies
|
||||||
|
// .vscode/settings.json: "typescript.referencesCodeLens.enabled": true
|
||||||
|
|
||||||
|
// custom
|
||||||
|
|
||||||
|
// flow's Maybe type https://flow.org/en/docs/types/primitives/#toc-maybe-types
|
||||||
|
type Maybe<T> = void | null | undefined | T; // tslint:disable-line:void-return
|
||||||
|
|
||||||
|
type TestResultsProcessor = (testResult: AggregatedResult) => AggregatedResult;
|
||||||
|
|
||||||
|
type HasteResolver = any; // import HasteResolver from 'jest-resolve';
|
||||||
|
type ModuleMocker = any; // import { ModuleMocker } from 'jest-mock';
|
||||||
|
type ModuleMap = any; // import {ModuleMap} from 'jest-haste-map';
|
||||||
|
type HasteFS = any; // import {FS as HasteFS} from 'jest-haste-map';
|
||||||
|
type Runtime = any; // import Runtime from 'jest-runtime';
|
||||||
|
type Script = any; // import {Script} from 'vm';
|
||||||
|
|
||||||
|
// Config
|
||||||
|
|
||||||
|
type Path = string;
|
||||||
|
type Glob = string;
|
||||||
|
|
||||||
|
interface HasteConfig {
|
||||||
|
defaultPlatform?: Maybe<string>;
|
||||||
|
hasteImplModulePath?: string;
|
||||||
|
platforms?: string[];
|
||||||
|
providesModuleNodeModules: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReporterConfig = [string, object];
|
||||||
|
|
||||||
|
type ConfigGlobals = object;
|
||||||
|
|
||||||
|
type SnapshotUpdateState = 'all' | 'new' | 'none';
|
||||||
|
|
||||||
|
interface DefaultOptions {
|
||||||
|
automock: boolean;
|
||||||
|
bail: boolean;
|
||||||
|
browser: boolean;
|
||||||
|
cache: boolean;
|
||||||
|
cacheDirectory: Path;
|
||||||
|
changedFilesWithAncestor: boolean;
|
||||||
|
clearMocks: boolean;
|
||||||
|
collectCoverage: boolean;
|
||||||
|
collectCoverageFrom: Maybe<string[]>;
|
||||||
|
coverageDirectory: Maybe<string>;
|
||||||
|
coveragePathIgnorePatterns: string[];
|
||||||
|
coverageReporters: string[];
|
||||||
|
coverageThreshold: Maybe<{global: {[key: string]: number}}>;
|
||||||
|
errorOnDeprecated: boolean;
|
||||||
|
expand: boolean;
|
||||||
|
filter: Maybe<Path>;
|
||||||
|
forceCoverageMatch: Glob[];
|
||||||
|
globals: ConfigGlobals;
|
||||||
|
globalSetup: Maybe<string>;
|
||||||
|
globalTeardown: Maybe<string>;
|
||||||
|
haste: HasteConfig;
|
||||||
|
detectLeaks: boolean;
|
||||||
|
detectOpenHandles: boolean;
|
||||||
|
moduleDirectories: string[];
|
||||||
|
moduleFileExtensions: string[];
|
||||||
|
moduleNameMapper: {[key: string]: string};
|
||||||
|
modulePathIgnorePatterns: string[];
|
||||||
|
noStackTrace: boolean;
|
||||||
|
notify: boolean;
|
||||||
|
notifyMode: string;
|
||||||
|
preset: Maybe<string>;
|
||||||
|
projects: Maybe<Array<string | ProjectConfig>>;
|
||||||
|
resetMocks: boolean;
|
||||||
|
resetModules: boolean;
|
||||||
|
resolver: Maybe<Path>;
|
||||||
|
restoreMocks: boolean;
|
||||||
|
rootDir: Maybe<Path>;
|
||||||
|
roots: Maybe<Path[]>;
|
||||||
|
runner: string;
|
||||||
|
runTestsByPath: boolean;
|
||||||
|
setupFiles: Path[];
|
||||||
|
setupTestFrameworkScriptFile: Maybe<Path>;
|
||||||
|
skipFilter: boolean;
|
||||||
|
snapshotSerializers: Path[];
|
||||||
|
testEnvironment: string;
|
||||||
|
testEnvironmentOptions: object;
|
||||||
|
testFailureExitCode: string | number;
|
||||||
|
testLocationInResults: boolean;
|
||||||
|
testMatch: Glob[];
|
||||||
|
testPathIgnorePatterns: string[];
|
||||||
|
testRegex: string;
|
||||||
|
testResultsProcessor: Maybe<string>;
|
||||||
|
testRunner: Maybe<string>;
|
||||||
|
testURL: string;
|
||||||
|
timers: 'real' | 'fake';
|
||||||
|
transform: Maybe<{[key: string]: string}>;
|
||||||
|
transformIgnorePatterns: Glob[];
|
||||||
|
watchPathIgnorePatterns: string[];
|
||||||
|
useStderr: boolean;
|
||||||
|
verbose: Maybe<boolean>;
|
||||||
|
watch: boolean;
|
||||||
|
watchman: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface InitialOptions {
|
||||||
|
automock?: boolean;
|
||||||
|
bail?: boolean;
|
||||||
|
browser?: boolean;
|
||||||
|
cache?: boolean;
|
||||||
|
cacheDirectory?: Path;
|
||||||
|
clearMocks?: boolean;
|
||||||
|
changedFilesWithAncestor?: boolean;
|
||||||
|
changedSince?: string;
|
||||||
|
collectCoverage?: boolean;
|
||||||
|
collectCoverageFrom?: Glob[];
|
||||||
|
collectCoverageOnlyFrom?: {[key: string]: boolean};
|
||||||
|
coverageDirectory?: string;
|
||||||
|
coveragePathIgnorePatterns?: string[];
|
||||||
|
coverageReporters?: string[];
|
||||||
|
coverageThreshold?: {global: {[key: string]: number}};
|
||||||
|
detectLeaks?: boolean;
|
||||||
|
detectOpenHandles?: boolean;
|
||||||
|
displayName?: string;
|
||||||
|
expand?: boolean;
|
||||||
|
filter?: Path;
|
||||||
|
findRelatedTests?: boolean;
|
||||||
|
forceCoverageMatch?: Glob[];
|
||||||
|
forceExit?: boolean;
|
||||||
|
json?: boolean;
|
||||||
|
globals?: ConfigGlobals;
|
||||||
|
globalSetup?: Maybe<string>;
|
||||||
|
globalTeardown?: Maybe<string>;
|
||||||
|
haste?: HasteConfig;
|
||||||
|
reporters?: Array<ReporterConfig | string>;
|
||||||
|
logHeapUsage?: boolean;
|
||||||
|
lastCommit?: boolean;
|
||||||
|
listTests?: boolean;
|
||||||
|
mapCoverage?: boolean;
|
||||||
|
moduleDirectories?: string[];
|
||||||
|
moduleFileExtensions?: string[];
|
||||||
|
moduleLoader?: Path;
|
||||||
|
moduleNameMapper?: {[key: string]: string};
|
||||||
|
modulePathIgnorePatterns?: string[];
|
||||||
|
modulePaths?: string[];
|
||||||
|
name?: string;
|
||||||
|
noStackTrace?: boolean;
|
||||||
|
notify?: boolean;
|
||||||
|
notifyMode?: string;
|
||||||
|
onlyChanged?: boolean;
|
||||||
|
outputFile?: Path;
|
||||||
|
passWithNoTests?: boolean;
|
||||||
|
preprocessorIgnorePatterns?: Glob[];
|
||||||
|
preset?: Maybe<string>;
|
||||||
|
projects?: Glob[];
|
||||||
|
replname?: Maybe<string>;
|
||||||
|
resetMocks?: boolean;
|
||||||
|
resetModules?: boolean;
|
||||||
|
resolver?: Maybe<Path>;
|
||||||
|
restoreMocks?: boolean;
|
||||||
|
rootDir?: Path;
|
||||||
|
roots?: Path[];
|
||||||
|
runner?: string;
|
||||||
|
runTestsByPath?: boolean;
|
||||||
|
scriptPreprocessor?: string;
|
||||||
|
setupFiles?: Path[];
|
||||||
|
setupFilesAfterEnv?: Path[];
|
||||||
|
setupTestFrameworkScriptFile?: Path;
|
||||||
|
silent?: boolean;
|
||||||
|
skipFilter?: boolean;
|
||||||
|
skipNodeResolution?: boolean;
|
||||||
|
snapshotSerializers?: Path[];
|
||||||
|
errorOnDeprecated?: boolean;
|
||||||
|
testEnvironment?: string;
|
||||||
|
testEnvironmentOptions?: object;
|
||||||
|
testFailureExitCode?: string | number;
|
||||||
|
testLocationInResults?: boolean;
|
||||||
|
testMatch?: Glob[];
|
||||||
|
testNamePattern?: string;
|
||||||
|
testPathDirs?: Path[];
|
||||||
|
testPathIgnorePatterns?: string[];
|
||||||
|
testRegex?: string;
|
||||||
|
testResultsProcessor?: Maybe<string>;
|
||||||
|
testRunner?: string;
|
||||||
|
testURL?: string;
|
||||||
|
timers?: 'real' | 'fake';
|
||||||
|
transform?: {[key: string]: string};
|
||||||
|
transformIgnorePatterns?: Glob[];
|
||||||
|
watchPathIgnorePatterns?: string[];
|
||||||
|
unmockedModulePathPatterns?: string[];
|
||||||
|
updateSnapshot?: boolean;
|
||||||
|
useStderr?: boolean;
|
||||||
|
verbose?: Maybe<boolean>;
|
||||||
|
watch?: boolean;
|
||||||
|
watchAll?: boolean;
|
||||||
|
watchman?: boolean;
|
||||||
|
watchPlugins?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface GlobalConfig {
|
||||||
|
bail: boolean;
|
||||||
|
collectCoverage: boolean;
|
||||||
|
collectCoverageFrom: Glob[];
|
||||||
|
collectCoverageOnlyFrom: Maybe<{[key: string]: boolean}>;
|
||||||
|
coverageDirectory: string;
|
||||||
|
coverageReporters: string[];
|
||||||
|
coverageThreshold: {global: {[key: string]: number}};
|
||||||
|
expand: boolean;
|
||||||
|
forceExit: boolean;
|
||||||
|
logHeapUsage: boolean;
|
||||||
|
mapCoverage: boolean;
|
||||||
|
noStackTrace: boolean;
|
||||||
|
notify: boolean;
|
||||||
|
projects: Glob[];
|
||||||
|
replname: Maybe<string>;
|
||||||
|
reporters: ReporterConfig[];
|
||||||
|
rootDir: Path;
|
||||||
|
silent: boolean;
|
||||||
|
testNamePattern: string;
|
||||||
|
testPathPattern: string;
|
||||||
|
testResultsProcessor: Maybe<string>;
|
||||||
|
updateSnapshot: SnapshotUpdateState;
|
||||||
|
useStderr: boolean;
|
||||||
|
verbose: Maybe<boolean>;
|
||||||
|
watch: boolean;
|
||||||
|
watchman: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ProjectConfig {
|
||||||
|
automock: boolean;
|
||||||
|
browser: boolean;
|
||||||
|
cache: boolean;
|
||||||
|
cacheDirectory: Path;
|
||||||
|
clearMocks: boolean;
|
||||||
|
coveragePathIgnorePatterns: string[];
|
||||||
|
cwd: Path;
|
||||||
|
detectLeaks: boolean;
|
||||||
|
displayName: Maybe<string>;
|
||||||
|
forceCoverageMatch: Glob[];
|
||||||
|
globals: ConfigGlobals;
|
||||||
|
haste: HasteConfig;
|
||||||
|
moduleDirectories: string[];
|
||||||
|
moduleFileExtensions: string[];
|
||||||
|
moduleLoader: Path;
|
||||||
|
moduleNameMapper: Array<[string, string]>;
|
||||||
|
modulePathIgnorePatterns: string[];
|
||||||
|
modulePaths: string[];
|
||||||
|
name: string;
|
||||||
|
resetMocks: boolean;
|
||||||
|
resetModules: boolean;
|
||||||
|
resolver: Maybe<Path>;
|
||||||
|
rootDir: Path;
|
||||||
|
roots: Path[];
|
||||||
|
runner: string;
|
||||||
|
setupFiles: Path[];
|
||||||
|
setupTestFrameworkScriptFile: Path;
|
||||||
|
skipNodeResolution: boolean;
|
||||||
|
snapshotSerializers: Path[];
|
||||||
|
testEnvironment: string;
|
||||||
|
testEnvironmentOptions: object;
|
||||||
|
testLocationInResults: boolean;
|
||||||
|
testMatch: Glob[];
|
||||||
|
testPathIgnorePatterns: string[];
|
||||||
|
testRegex: string;
|
||||||
|
testRunner: string;
|
||||||
|
testURL: string;
|
||||||
|
timers: 'real' | 'fake';
|
||||||
|
transform: Array<[string, Path]>;
|
||||||
|
transformIgnorePatterns: Glob[];
|
||||||
|
unmockedModulePathPatterns: Maybe<string[]>;
|
||||||
|
watchPathIgnorePatterns: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Console
|
||||||
|
|
||||||
|
type LogMessage = string;
|
||||||
|
interface LogEntry {
|
||||||
|
message: LogMessage;
|
||||||
|
origin: string;
|
||||||
|
type: LogType;
|
||||||
|
}
|
||||||
|
type LogType = 'log' | 'info' | 'warn' | 'error';
|
||||||
|
type ConsoleBuffer = LogEntry[];
|
||||||
|
|
||||||
|
// Context
|
||||||
|
|
||||||
|
interface Context {
|
||||||
|
config: ProjectConfig;
|
||||||
|
hasteFS: HasteFS;
|
||||||
|
moduleMap: ModuleMap;
|
||||||
|
resolver: HasteResolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Environment
|
||||||
|
|
||||||
|
interface FakeTimers {
|
||||||
|
clearAllTimers(): void;
|
||||||
|
runAllImmediates(): void;
|
||||||
|
runAllTicks(): void;
|
||||||
|
runAllTimers(): void;
|
||||||
|
runTimersToTime(msToRun: number): void;
|
||||||
|
advanceTimersByTime(msToRun: number): void;
|
||||||
|
runOnlyPendingTimers(): void;
|
||||||
|
runWithRealTimers(callback: any): void;
|
||||||
|
useFakeTimers(): void;
|
||||||
|
useRealTimers(): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface $JestEnvironment {
|
||||||
|
global: Global;
|
||||||
|
fakeTimers: FakeTimers;
|
||||||
|
testFilePath: string;
|
||||||
|
moduleMocker: ModuleMocker;
|
||||||
|
|
||||||
|
dispose(): void;
|
||||||
|
runScript(script: Script): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Environment = $JestEnvironment;
|
||||||
|
|
||||||
|
// Global
|
||||||
|
|
||||||
|
type Global = object;
|
||||||
|
|
||||||
|
// Reporter
|
||||||
|
|
||||||
|
interface ReporterOnStartOptions {
|
||||||
|
estimatedTime: number;
|
||||||
|
showStatus: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestResult
|
||||||
|
|
||||||
|
interface RawFileCoverage {
|
||||||
|
path: string;
|
||||||
|
s: {[statementId: number]: number};
|
||||||
|
b: {[branchId: number]: number};
|
||||||
|
f: {[functionId: number]: number};
|
||||||
|
l: {[lineId: number]: number};
|
||||||
|
fnMap: {[functionId: number]: any};
|
||||||
|
statementMap: {[statementId: number]: any};
|
||||||
|
branchMap: {[branchId: number]: any};
|
||||||
|
inputSourceMap?: object;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RawCoverage {
|
||||||
|
[filePath: string]: RawFileCoverage;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FileCoverageTotal {
|
||||||
|
total: number;
|
||||||
|
covered: number;
|
||||||
|
skipped: number;
|
||||||
|
pct?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CoverageSummary {
|
||||||
|
lines: FileCoverageTotal;
|
||||||
|
statements: FileCoverageTotal;
|
||||||
|
branches: FileCoverageTotal;
|
||||||
|
functions: FileCoverageTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface FileCoverage {
|
||||||
|
getLineCoverage(): object;
|
||||||
|
getUncoveredLines(): number[];
|
||||||
|
getBranchCoverageByLine(): object;
|
||||||
|
toJSON(): object;
|
||||||
|
merge(other: object): void;
|
||||||
|
computeSimpleTotals(property: string): FileCoverageTotal;
|
||||||
|
computeBranchTotals(): FileCoverageTotal;
|
||||||
|
resetHits(): void;
|
||||||
|
toSummary(): CoverageSummary;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CoverageMap {
|
||||||
|
merge(data: object): void;
|
||||||
|
getCoverageSummary(): FileCoverage;
|
||||||
|
data: RawCoverage;
|
||||||
|
addFileCoverage(fileCoverage: RawFileCoverage): void;
|
||||||
|
files(): string[];
|
||||||
|
fileCoverageFor(file: string): FileCoverage;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SerializableError {
|
||||||
|
code?: any;
|
||||||
|
message: string;
|
||||||
|
stack: Maybe<string>;
|
||||||
|
type?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Status = 'passed' | 'failed' | 'skipped' | 'pending';
|
||||||
|
|
||||||
|
type Bytes = number;
|
||||||
|
type Milliseconds = number;
|
||||||
|
|
||||||
|
interface AssertionResult {
|
||||||
|
ancestorTitles: string[];
|
||||||
|
duration?: Maybe<Milliseconds>;
|
||||||
|
failureMessages: string[];
|
||||||
|
fullName: string;
|
||||||
|
numPassingAsserts: number;
|
||||||
|
status: Status;
|
||||||
|
title: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface AggregatedResult {
|
||||||
|
coverageMap?: Maybe<CoverageMap>;
|
||||||
|
numFailedTests: number;
|
||||||
|
numFailedTestSuites: number;
|
||||||
|
numPassedTests: number;
|
||||||
|
numPassedTestSuites: number;
|
||||||
|
numPendingTests: number;
|
||||||
|
numPendingTestSuites: number;
|
||||||
|
numRuntimeErrorTestSuites: number;
|
||||||
|
numTodoTests: number;
|
||||||
|
numTotalTests: number;
|
||||||
|
numTotalTestSuites: number;
|
||||||
|
snapshot: SnapshotSummary;
|
||||||
|
startTime: number;
|
||||||
|
success: boolean;
|
||||||
|
testResults: TestResult[];
|
||||||
|
wasInterrupted: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TestResult {
|
||||||
|
console: Maybe<ConsoleBuffer>;
|
||||||
|
coverage?: RawCoverage;
|
||||||
|
memoryUsage?: Bytes;
|
||||||
|
failureMessage: Maybe<string>;
|
||||||
|
numFailingTests: number;
|
||||||
|
numPassingTests: number;
|
||||||
|
numPendingTests: number;
|
||||||
|
perfStats: {
|
||||||
|
end: Milliseconds,
|
||||||
|
start: Milliseconds,
|
||||||
|
};
|
||||||
|
skipped: boolean;
|
||||||
|
snapshot: {
|
||||||
|
added: number,
|
||||||
|
fileDeleted: boolean,
|
||||||
|
matched: number,
|
||||||
|
unchecked: number,
|
||||||
|
unmatched: number,
|
||||||
|
updated: number,
|
||||||
|
};
|
||||||
|
sourceMaps: {[sourcePath: string]: string};
|
||||||
|
testExecError?: SerializableError;
|
||||||
|
testFilePath: string;
|
||||||
|
testResults: AssertionResult[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SnapshotSummary {
|
||||||
|
added: number;
|
||||||
|
didUpdate: boolean;
|
||||||
|
failure: boolean;
|
||||||
|
filesAdded: number;
|
||||||
|
filesRemoved: number;
|
||||||
|
filesUnmatched: number;
|
||||||
|
filesUpdated: number;
|
||||||
|
matched: number;
|
||||||
|
total: number;
|
||||||
|
unchecked: number;
|
||||||
|
unmatched: number;
|
||||||
|
updated: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestRunner
|
||||||
|
|
||||||
|
interface Test {
|
||||||
|
context: Context;
|
||||||
|
duration?: number;
|
||||||
|
path: Path;
|
||||||
|
}
|
||||||
|
|
||||||
|
// tslint:disable-next-line:no-empty-interface
|
||||||
|
interface Set<T> {} // To allow non-ES6 users the Set below
|
||||||
|
interface Reporter {
|
||||||
|
onTestResult?(test: Test, testResult: TestResult, aggregatedResult: AggregatedResult): void;
|
||||||
|
onRunStart?(results: AggregatedResult, options: ReporterOnStartOptions): void;
|
||||||
|
onTestStart?(test: Test): void;
|
||||||
|
onRunComplete?(contexts: Set<Context>, results: AggregatedResult): Maybe<Promise<void>>;
|
||||||
|
getLastError?(): Maybe<Error>;
|
||||||
|
}
|
||||||
|
|
||||||
|
type TestFramework = (
|
||||||
|
globalConfig: GlobalConfig,
|
||||||
|
config: ProjectConfig,
|
||||||
|
environment: Environment,
|
||||||
|
runtime: Runtime,
|
||||||
|
testPath: string,
|
||||||
|
) => Promise<TestResult>;
|
||||||
|
|
||||||
|
// Transform
|
||||||
|
|
||||||
|
interface TransformedSource {
|
||||||
|
code: string;
|
||||||
|
map: Maybe<object | string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TransformOptions {
|
||||||
|
instrument: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Transformer {
|
||||||
|
canInstrument?: boolean;
|
||||||
|
createTransformer?(options: any): Transformer;
|
||||||
|
|
||||||
|
getCacheKey?(
|
||||||
|
fileData: string,
|
||||||
|
filePath: Path,
|
||||||
|
configStr: string,
|
||||||
|
options: TransformOptions,
|
||||||
|
): string;
|
||||||
|
|
||||||
|
process(
|
||||||
|
sourceText: string,
|
||||||
|
sourcePath: Path,
|
||||||
|
config: ProjectConfig,
|
||||||
|
options?: TransformOptions,
|
||||||
|
): string | TransformedSource;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,125 @@
|
||||||
|
{
|
||||||
|
"name": "@types/jest",
|
||||||
|
"version": "24.0.15",
|
||||||
|
"description": "TypeScript definitions for Jest",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Asana (https://asana.com)\n// Ivo Stratev",
|
||||||
|
"url": "https://github.com/NoHomey",
|
||||||
|
"githubUsername": "NoHomey"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "jwbay",
|
||||||
|
"url": "https://github.com/jwbay",
|
||||||
|
"githubUsername": "jwbay"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Alexey Svetliakov",
|
||||||
|
"url": "https://github.com/asvetliakov",
|
||||||
|
"githubUsername": "asvetliakov"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Alex Jover Morales",
|
||||||
|
"url": "https://github.com/alexjoverm",
|
||||||
|
"githubUsername": "alexjoverm"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Allan Lukwago",
|
||||||
|
"url": "https://github.com/epicallan",
|
||||||
|
"githubUsername": "epicallan"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Ika",
|
||||||
|
"url": "https://github.com/ikatyang",
|
||||||
|
"githubUsername": "ikatyang"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Waseem Dahman",
|
||||||
|
"url": "https://github.com/wsmd",
|
||||||
|
"githubUsername": "wsmd"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jamie Mason",
|
||||||
|
"url": "https://github.com/JamieMason",
|
||||||
|
"githubUsername": "JamieMason"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Douglas Duteil",
|
||||||
|
"url": "https://github.com/douglasduteil",
|
||||||
|
"githubUsername": "douglasduteil"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Ahn",
|
||||||
|
"url": "https://github.com/ahnpnl",
|
||||||
|
"githubUsername": "ahnpnl"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Josh Goldberg",
|
||||||
|
"url": "https://github.com/joshuakgoldberg",
|
||||||
|
"githubUsername": "joshuakgoldberg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jeff Lau",
|
||||||
|
"url": "https://github.com/UselessPickles",
|
||||||
|
"githubUsername": "UselessPickles"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Andrew Makarov",
|
||||||
|
"url": "https://github.com/r3nya",
|
||||||
|
"githubUsername": "r3nya"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Martin Hochel",
|
||||||
|
"url": "https://github.com/hotell",
|
||||||
|
"githubUsername": "hotell"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Sebastian Sebald",
|
||||||
|
"url": "https://github.com/sebald",
|
||||||
|
"githubUsername": "sebald"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Andy",
|
||||||
|
"url": "https://github.com/andys8",
|
||||||
|
"githubUsername": "andys8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Antoine Brault",
|
||||||
|
"url": "https://github.com/antoinebrault",
|
||||||
|
"githubUsername": "antoinebrault"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jeroen Claassens",
|
||||||
|
"url": "https://github.com/favna",
|
||||||
|
"githubUsername": "favna"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Gregor Stamać",
|
||||||
|
"url": "https://github.com/gstamac",
|
||||||
|
"githubUsername": "gstamac"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ExE Boss",
|
||||||
|
"url": "https://github.com/ExE-Boss",
|
||||||
|
"githubUsername": "ExE-Boss"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
|
"directory": "types/jest"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/jest-diff": "*"
|
||||||
|
},
|
||||||
|
"typesPublisherContentHash": "cac349662faf97b0b34c42324afbb9a9b5972d64215a0892229785c315a2f836",
|
||||||
|
"typeScriptVersion": "3.0"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.15.tgz"
|
||||||
|
,"_integrity": "sha512-MU1HIvWUme74stAoc3mgAi+aMlgKOudgEvQDIm1v4RkrDudBh1T+NFp5sftpBAdXdx1J0PbdpJ+M2EsSOi1djA=="
|
||||||
|
,"_from": "@types/jest@24.0.15"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/normalize-package-data`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for normalize-package-data (https://github.com/npm/normalize-package-data#readme).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/normalize-package-data
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Sun, 07 Jan 2018 07:34:38 GMT
|
||||||
|
* Dependencies: none
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by Jeff Dickey <https://github.com/jdxcode>.
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
// Type definitions for normalize-package-data 2.4
|
||||||
|
// Project: https://github.com/npm/normalize-package-data#readme
|
||||||
|
// Definitions by: Jeff Dickey <https://github.com/jdxcode>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
|
||||||
|
export = normalize;
|
||||||
|
|
||||||
|
declare function normalize(data: normalize.Input, warn?: normalize.WarnFn, strict?: boolean): void;
|
||||||
|
declare function normalize(data: normalize.Input, strict?: boolean): void;
|
||||||
|
|
||||||
|
declare namespace normalize {
|
||||||
|
type WarnFn = (msg: string) => void;
|
||||||
|
interface Input {[k: string]: any; }
|
||||||
|
|
||||||
|
interface Person {
|
||||||
|
name?: string;
|
||||||
|
email?: string;
|
||||||
|
url?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Package {
|
||||||
|
[k: string]: any;
|
||||||
|
name: string;
|
||||||
|
version: string;
|
||||||
|
files?: string[];
|
||||||
|
bin?: {[k: string]: string };
|
||||||
|
man?: string[];
|
||||||
|
keywords?: string[];
|
||||||
|
author?: Person;
|
||||||
|
maintainers?: Person[];
|
||||||
|
contributors?: Person[];
|
||||||
|
bundleDependencies?: {[name: string]: string; };
|
||||||
|
dependencies?: {[name: string]: string; };
|
||||||
|
devDependencies?: {[name: string]: string; };
|
||||||
|
optionalDependencies?: {[name: string]: string; };
|
||||||
|
description?: string;
|
||||||
|
engines?: {[type: string]: string };
|
||||||
|
license?: string;
|
||||||
|
repository?: { type: string, url: string };
|
||||||
|
bugs?: { url: string, email?: string } | { url?: string, email: string };
|
||||||
|
homepage?: string;
|
||||||
|
scripts?: {[k: string]: string};
|
||||||
|
readme: string;
|
||||||
|
_id: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"name": "@types/normalize-package-data",
|
||||||
|
"version": "2.4.0",
|
||||||
|
"description": "TypeScript definitions for normalize-package-data",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Jeff Dickey",
|
||||||
|
"url": "https://github.com/jdxcode",
|
||||||
|
"githubUsername": "jdxcode"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {},
|
||||||
|
"typesPublisherContentHash": "5d2101e9e55c73e1d649a6c311e0d40bdfaa25bb06bb75ea6f3bb0d149c1303b",
|
||||||
|
"typeScriptVersion": "2.0"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz"
|
||||||
|
,"_integrity": "sha512-f5j5b/Gf71L+dbqxIpQ4Z2WlmI/mPJ0fOkGGmFgtb6sAu97EPczzbS3/tJKxmcYDj55OX6ssqwDAWOHIYDRDGA=="
|
||||||
|
,"_from": "@types/normalize-package-data@2.4.0"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/semver`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for semver (https://github.com/npm/node-semver).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/semver
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Fri, 21 Jun 2019 00:42:59 GMT
|
||||||
|
* Dependencies: none
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by Bart van der Schoor <https://github.com/Bartvds>, BendingBender <https://github.com/BendingBender>, Lucian Buzzo <https://github.com/LucianBuzzo>, and Klaus Meinhardt <https://github.com/ajafff>.
|
||||||
|
|
@ -0,0 +1,212 @@
|
||||||
|
// Type definitions for semver 6.0
|
||||||
|
// Project: https://github.com/npm/node-semver
|
||||||
|
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||||
|
// BendingBender <https://github.com/BendingBender>
|
||||||
|
// Lucian Buzzo <https://github.com/LucianBuzzo>
|
||||||
|
// Klaus Meinhardt <https://github.com/ajafff>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/semver
|
||||||
|
|
||||||
|
export const SEMVER_SPEC_VERSION: "2.0.0";
|
||||||
|
|
||||||
|
export type ReleaseType = "major" | "premajor" | "minor" | "preminor" | "patch" | "prepatch" | "prerelease";
|
||||||
|
|
||||||
|
export interface Options {
|
||||||
|
loose?: boolean;
|
||||||
|
includePrerelease?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the parsed version as a SemVer object, or null if it's not valid.
|
||||||
|
*/
|
||||||
|
export function parse(v: string | SemVer, optionsOrLoose?: boolean | Options): SemVer | null;
|
||||||
|
/**
|
||||||
|
* Return the parsed version, or null if it's not valid.
|
||||||
|
*/
|
||||||
|
export function valid(v: string | SemVer, optionsOrLoose?: boolean | Options): string | null;
|
||||||
|
/**
|
||||||
|
* Returns cleaned (removed leading/trailing whitespace, remove '=v' prefix) and parsed version, or null if version is invalid.
|
||||||
|
*/
|
||||||
|
export function clean(version: string, optionsOrLoose?: boolean | Options): string | null;
|
||||||
|
/**
|
||||||
|
* Return the version incremented by the release type (major, minor, patch, or prerelease), or null if it's not valid.
|
||||||
|
*/
|
||||||
|
export function inc(v: string | SemVer, release: ReleaseType, optionsOrLoose?: boolean | Options, identifier?: string): string | null;
|
||||||
|
/**
|
||||||
|
* Return the major version number.
|
||||||
|
*/
|
||||||
|
export function major(v: string | SemVer, optionsOrLoose?: boolean | Options): number;
|
||||||
|
/**
|
||||||
|
* Return the minor version number.
|
||||||
|
*/
|
||||||
|
export function minor(v: string | SemVer, optionsOrLoose?: boolean | Options): number;
|
||||||
|
/**
|
||||||
|
* Return the patch version number.
|
||||||
|
*/
|
||||||
|
export function patch(v: string | SemVer, optionsOrLoose?: boolean | Options): number;
|
||||||
|
/**
|
||||||
|
* Returns an array of prerelease components, or null if none exist.
|
||||||
|
*/
|
||||||
|
export function prerelease(v: string | SemVer, optionsOrLoose?: boolean | Options): ReadonlyArray<string> | null;
|
||||||
|
|
||||||
|
// Comparison
|
||||||
|
/**
|
||||||
|
* v1 > v2
|
||||||
|
*/
|
||||||
|
export function gt(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): boolean;
|
||||||
|
/**
|
||||||
|
* v1 >= v2
|
||||||
|
*/
|
||||||
|
export function gte(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): boolean;
|
||||||
|
/**
|
||||||
|
* v1 < v2
|
||||||
|
*/
|
||||||
|
export function lt(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): boolean;
|
||||||
|
/**
|
||||||
|
* v1 <= v2
|
||||||
|
*/
|
||||||
|
export function lte(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): boolean;
|
||||||
|
/**
|
||||||
|
* v1 == v2 This is true if they're logically equivalent, even if they're not the exact same string. You already know how to compare strings.
|
||||||
|
*/
|
||||||
|
export function eq(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): boolean;
|
||||||
|
/**
|
||||||
|
* v1 != v2 The opposite of eq.
|
||||||
|
*/
|
||||||
|
export function neq(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pass in a comparison string, and it'll call the corresponding semver comparison function.
|
||||||
|
* "===" and "!==" do simple string comparison, but are included for completeness.
|
||||||
|
* Throws if an invalid comparison string is provided.
|
||||||
|
*/
|
||||||
|
export function cmp(v1: string | SemVer, operator: Operator, v2: string | SemVer, optionsOrLoose?: boolean | Options): boolean;
|
||||||
|
export type Operator = '===' | '!==' | '' | '=' | '==' | '!=' | '>' | '>=' | '<' | '<=';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if v2 is greater. Sorts in ascending order if passed to Array.sort().
|
||||||
|
*/
|
||||||
|
export function compare(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): 1 | 0 | -1;
|
||||||
|
/**
|
||||||
|
* The reverse of compare. Sorts an array of versions in descending order when passed to Array.sort().
|
||||||
|
*/
|
||||||
|
export function rcompare(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): 1 | 0 | -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares two identifiers, must be numeric strings or truthy/falsy values. Sorts in ascending order if passed to Array.sort().
|
||||||
|
*/
|
||||||
|
export function compareIdentifiers(a: string | null, b: string | null): 1 | 0 | -1;
|
||||||
|
/**
|
||||||
|
* The reverse of compareIdentifiers. Sorts in descending order when passed to Array.sort().
|
||||||
|
*/
|
||||||
|
export function rcompareIdentifiers(a: string | null, b: string | null): 1 | 0 | -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sorts an array of semver entries in ascending order.
|
||||||
|
*/
|
||||||
|
export function sort<T extends string | SemVer>(list: T[], optionsOrLoose?: boolean | Options): T[];
|
||||||
|
/**
|
||||||
|
* Sorts an array of semver entries in descending order.
|
||||||
|
*/
|
||||||
|
export function rsort<T extends string | SemVer>(list: T[], optionsOrLoose?: boolean | Options): T[];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns difference between two versions by the release type (major, premajor, minor, preminor, patch, prepatch, or prerelease), or null if the versions are the same.
|
||||||
|
*/
|
||||||
|
export function diff(v1: string | SemVer, v2: string | SemVer, optionsOrLoose?: boolean | Options): ReleaseType | null;
|
||||||
|
|
||||||
|
// Ranges
|
||||||
|
/**
|
||||||
|
* Return the valid range or null if it's not valid
|
||||||
|
*/
|
||||||
|
export function validRange(range: string | Range, optionsOrLoose?: boolean | Options): string;
|
||||||
|
/**
|
||||||
|
* Return true if the version satisfies the range.
|
||||||
|
*/
|
||||||
|
export function satisfies(version: string | SemVer, range: string | Range, optionsOrLoose?: boolean | Options): boolean;
|
||||||
|
/**
|
||||||
|
* Return the highest version in the list that satisfies the range, or null if none of them do.
|
||||||
|
*/
|
||||||
|
export function maxSatisfying<T extends string | SemVer>(versions: ReadonlyArray<T>, range: string | Range, optionsOrLoose?: boolean | Options): T | null;
|
||||||
|
/**
|
||||||
|
* Return the lowest version in the list that satisfies the range, or null if none of them do.
|
||||||
|
*/
|
||||||
|
export function minSatisfying<T extends string | SemVer>(versions: ReadonlyArray<T>, range: string | Range, optionsOrLoose?: boolean | Options): T | null;
|
||||||
|
/**
|
||||||
|
* Return the lowest version that can possibly match the given range.
|
||||||
|
*/
|
||||||
|
export function minVersion(range: string | Range, optionsOrLoose?: boolean | Options): SemVer | null;
|
||||||
|
/**
|
||||||
|
* Return true if version is greater than all the versions possible in the range.
|
||||||
|
*/
|
||||||
|
export function gtr(version: string | SemVer, range: string | Range, optionsOrLoose?: boolean | Options): boolean;
|
||||||
|
/**
|
||||||
|
* Return true if version is less than all the versions possible in the range.
|
||||||
|
*/
|
||||||
|
export function ltr(version: string | SemVer, range: string | Range, optionsOrLoose?: boolean | Options): boolean;
|
||||||
|
/**
|
||||||
|
* Return true if the version is outside the bounds of the range in either the high or low direction.
|
||||||
|
* The hilo argument must be either the string '>' or '<'. (This is the function called by gtr and ltr.)
|
||||||
|
*/
|
||||||
|
export function outside(version: string | SemVer, range: string | Range, hilo: '>' | '<', optionsOrLoose?: boolean | Options): boolean;
|
||||||
|
/**
|
||||||
|
* Return true if any of the ranges comparators intersect
|
||||||
|
*/
|
||||||
|
export function intersects(range1: string | Range, range2: string | Range, optionsOrLoose?: boolean | Options): boolean;
|
||||||
|
|
||||||
|
// Coercion
|
||||||
|
/**
|
||||||
|
* Coerces a string to semver if possible
|
||||||
|
*/
|
||||||
|
export function coerce(version: string | SemVer): SemVer | null;
|
||||||
|
|
||||||
|
export class SemVer {
|
||||||
|
constructor(version: string | SemVer, optionsOrLoose?: boolean | Options);
|
||||||
|
|
||||||
|
raw: string;
|
||||||
|
loose: boolean;
|
||||||
|
options: Options;
|
||||||
|
format(): string;
|
||||||
|
inspect(): string;
|
||||||
|
|
||||||
|
major: number;
|
||||||
|
minor: number;
|
||||||
|
patch: number;
|
||||||
|
version: string;
|
||||||
|
build: ReadonlyArray<string>;
|
||||||
|
prerelease: ReadonlyArray<string | number>;
|
||||||
|
|
||||||
|
compare(other: string | SemVer): 1 | 0 | -1;
|
||||||
|
compareMain(other: string | SemVer): 1 | 0 | -1;
|
||||||
|
comparePre(other: string | SemVer): 1 | 0 | -1;
|
||||||
|
inc(release: ReleaseType, identifier?: string): SemVer;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Comparator {
|
||||||
|
constructor(comp: string | Comparator, optionsOrLoose?: boolean | Options);
|
||||||
|
|
||||||
|
semver: SemVer;
|
||||||
|
operator: '' | '=' | '<' | '>' | '<=' | '>=';
|
||||||
|
value: string;
|
||||||
|
loose: boolean;
|
||||||
|
options: Options;
|
||||||
|
parse(comp: string): void;
|
||||||
|
test(version: string | SemVer): boolean;
|
||||||
|
intersects(comp: Comparator, optionsOrLoose?: boolean | Options): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Range {
|
||||||
|
constructor(range: string | Range, optionsOrLoose?: boolean | Options);
|
||||||
|
|
||||||
|
range: string;
|
||||||
|
raw: string;
|
||||||
|
loose: boolean;
|
||||||
|
options: Options;
|
||||||
|
includePrerelease: boolean;
|
||||||
|
format(): string;
|
||||||
|
inspect(): string;
|
||||||
|
|
||||||
|
set: ReadonlyArray<ReadonlyArray<Comparator>>;
|
||||||
|
parseRange(range: string): ReadonlyArray<Comparator>;
|
||||||
|
test(version: string | SemVer): boolean;
|
||||||
|
intersects(range: Range, optionsOrLoose?: boolean | Options): boolean;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,43 @@
|
||||||
|
{
|
||||||
|
"name": "@types/semver",
|
||||||
|
"version": "6.0.1",
|
||||||
|
"description": "TypeScript definitions for semver",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Bart van der Schoor",
|
||||||
|
"url": "https://github.com/Bartvds",
|
||||||
|
"githubUsername": "Bartvds"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "BendingBender",
|
||||||
|
"url": "https://github.com/BendingBender",
|
||||||
|
"githubUsername": "BendingBender"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Lucian Buzzo",
|
||||||
|
"url": "https://github.com/LucianBuzzo",
|
||||||
|
"githubUsername": "LucianBuzzo"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Klaus Meinhardt",
|
||||||
|
"url": "https://github.com/ajafff",
|
||||||
|
"githubUsername": "ajafff"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
|
"directory": "types/semver"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {},
|
||||||
|
"typesPublisherContentHash": "2fbf12f1845229c1b285bd981b793f64bc89a14bb6f2d36a44eccb80c34cc946",
|
||||||
|
"typeScriptVersion": "2.0"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@types/semver/-/semver-6.0.1.tgz"
|
||||||
|
,"_integrity": "sha512-ffCdcrEE5h8DqVxinQjo+2d1q+FV5z7iNtPofw3JsrltSoSVlOGaW0rY8XxtO9XukdTn8TaCGWmk2VFGhI70mg=="
|
||||||
|
,"_from": "@types/semver@6.0.1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/stack-utils`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for stack-utils (https://github.com/tapjs/stack-utils#readme).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/stack-utils
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Tue, 07 Nov 2017 17:49:01 GMT
|
||||||
|
* Dependencies: none
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by BendingBender <https://github.com/BendingBender>.
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
// Type definitions for stack-utils 1.0
|
||||||
|
// Project: https://github.com/tapjs/stack-utils#readme
|
||||||
|
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
// TypeScript Version: 2.2
|
||||||
|
|
||||||
|
export = StackUtils;
|
||||||
|
|
||||||
|
declare class StackUtils {
|
||||||
|
static nodeInternals(): RegExp[];
|
||||||
|
constructor(options?: StackUtils.Options);
|
||||||
|
clean(stack: string | string[]): string;
|
||||||
|
capture(limit?: number, startStackFunction?: Function): StackUtils.CallSite[];
|
||||||
|
capture(startStackFunction: Function): StackUtils.CallSite[];
|
||||||
|
captureString(limit?: number, startStackFunction?: Function): string;
|
||||||
|
captureString(startStackFunction: Function): string;
|
||||||
|
at(startStackFunction?: Function): StackUtils.CallSiteLike;
|
||||||
|
parseLine(line: string): StackUtils.StackLineData | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare namespace StackUtils {
|
||||||
|
interface Options {
|
||||||
|
internals?: RegExp[];
|
||||||
|
cwd?: string;
|
||||||
|
wrapCallSite?(callSite: CallSite): CallSite;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CallSite {
|
||||||
|
getThis(): object | undefined;
|
||||||
|
getTypeName(): string;
|
||||||
|
getFunction(): Function | undefined;
|
||||||
|
getFunctionName(): string;
|
||||||
|
getMethodName(): string | null;
|
||||||
|
getFileName(): string | undefined;
|
||||||
|
getLineNumber(): number;
|
||||||
|
getColumnNumber(): number;
|
||||||
|
getEvalOrigin(): CallSite | string;
|
||||||
|
isToplevel(): boolean;
|
||||||
|
isEval(): boolean;
|
||||||
|
isNative(): boolean;
|
||||||
|
isConstructor(): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CallSiteLike extends StackData {
|
||||||
|
type?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StackLineData extends StackData {
|
||||||
|
evalLine?: number;
|
||||||
|
evalColumn?: number;
|
||||||
|
evalFile?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface StackData {
|
||||||
|
line?: number;
|
||||||
|
column?: number;
|
||||||
|
file?: string;
|
||||||
|
constructor?: boolean;
|
||||||
|
evalOrigin?: string;
|
||||||
|
native?: boolean;
|
||||||
|
function?: string;
|
||||||
|
method?: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"name": "@types/stack-utils",
|
||||||
|
"version": "1.0.1",
|
||||||
|
"description": "TypeScript definitions for stack-utils",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "BendingBender",
|
||||||
|
"url": "https://github.com/BendingBender",
|
||||||
|
"githubUsername": "BendingBender"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {},
|
||||||
|
"typesPublisherContentHash": "c3d5963386c8535320c11b5edfb22c4bf60fb3e4bcbca34f094f7026b9749d86",
|
||||||
|
"typeScriptVersion": "2.2"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz"
|
||||||
|
,"_integrity": "sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw=="
|
||||||
|
,"_from": "@types/stack-utils@1.0.1"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
# Installation
|
||||||
|
> `npm install --save @types/yargs`
|
||||||
|
|
||||||
|
# Summary
|
||||||
|
This package contains type definitions for yargs ( https://github.com/chevex/yargs ).
|
||||||
|
|
||||||
|
# Details
|
||||||
|
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/yargs/v12
|
||||||
|
|
||||||
|
Additional Details
|
||||||
|
* Last updated: Mon, 08 Apr 2019 01:51:31 GMT
|
||||||
|
* Dependencies: none
|
||||||
|
* Global values: none
|
||||||
|
|
||||||
|
# Credits
|
||||||
|
These definitions were written by Martin Poelstra <https://github.com/poelstra>, Mizunashi Mana <https://github.com/mizunashi-mana>, Jeffery Grajkowski <https://github.com/pushplay>, Jeff Kenney <https://github.com/jeffkenney>, Jimi (Dimitris) Charalampidis <https://github.com/JimiC>, Steffen Viken Valvåg <https://github.com/steffenvv>, Emily Marigold Klassen <https://github.com/forivall>.
|
||||||
|
|
@ -0,0 +1,425 @@
|
||||||
|
// Type definitions for yargs 12.0
|
||||||
|
// Project: https://github.com/chevex/yargs, https://yargs.js.org
|
||||||
|
// Definitions by: Martin Poelstra <https://github.com/poelstra>
|
||||||
|
// Mizunashi Mana <https://github.com/mizunashi-mana>
|
||||||
|
// Jeffery Grajkowski <https://github.com/pushplay>
|
||||||
|
// Jeff Kenney <https://github.com/jeffkenney>
|
||||||
|
// Jimi (Dimitris) Charalampidis <https://github.com/JimiC>
|
||||||
|
// Steffen Viken Valvåg <https://github.com/steffenvv>
|
||||||
|
// Emily Marigold Klassen <https://github.com/forivall>
|
||||||
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||||
|
// TypeScript Version: 3.0
|
||||||
|
|
||||||
|
// The following TSLint rules have been disabled:
|
||||||
|
// unified-signatures: Because there is useful information in the argument names of the overloaded signatures
|
||||||
|
|
||||||
|
// Convention:
|
||||||
|
// Use 'union types' when:
|
||||||
|
// - parameter types have similar signature type (i.e. 'string | ReadonlyArray<string>')
|
||||||
|
// - parameter names have the same semantic meaning (i.e. ['command', 'commands'] , ['key', 'keys'])
|
||||||
|
// An example for not using 'union types' is the declaration of 'env' where `prefix` and `enable` parameters
|
||||||
|
// have different semantics. On the other hand, in the declaration of 'usage', a `command: string` parameter
|
||||||
|
// has the same semantic meaning with declaring an overload method by using `commands: ReadonlyArray<string>`,
|
||||||
|
// thus it's preferred to use `command: string | ReadonlyArray<string>`
|
||||||
|
// Use parameterless declaration instead of declaring all parameters optional,
|
||||||
|
// when all parameters are optional and more than one
|
||||||
|
|
||||||
|
declare namespace yargs {
|
||||||
|
// The type parameter T is the expected shape of the parsed options.
|
||||||
|
// Arguments<T> is those options plus _ and $0, and an indexer falling
|
||||||
|
// back to unknown for unknown options.
|
||||||
|
//
|
||||||
|
// For the return type / argv property, we create a mapped type over
|
||||||
|
// Arguments<T> to simplify the inferred type signature in client code.
|
||||||
|
interface Argv<T = {}> {
|
||||||
|
(): { [key in keyof Arguments<T>]: Arguments<T>[key] };
|
||||||
|
(args: ReadonlyArray<string>, cwd?: string): Argv<T>;
|
||||||
|
|
||||||
|
// Aliases for previously declared options can inherit the types of those options.
|
||||||
|
alias<K1 extends keyof T, K2 extends string>(shortName: K1, longName: K2 | ReadonlyArray<K2>): Argv<T & { [key in K2]: T[K1] }>;
|
||||||
|
alias<K1 extends keyof T, K2 extends string>(shortName: K2, longName: K1 | ReadonlyArray<K1>): Argv<T & { [key in K2]: T[K1] }>;
|
||||||
|
alias(shortName: string | ReadonlyArray<string>, longName: string | ReadonlyArray<string>): Argv<T>;
|
||||||
|
alias(aliases: { [shortName: string]: string | ReadonlyArray<string> }): Argv<T>;
|
||||||
|
|
||||||
|
argv: { [key in keyof Arguments<T>]: Arguments<T>[key] };
|
||||||
|
|
||||||
|
array<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: ToArray<T[key]> }>;
|
||||||
|
array<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: Array<string | number> | undefined }>;
|
||||||
|
|
||||||
|
boolean<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: boolean | undefined }>;
|
||||||
|
boolean<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: boolean | undefined }>;
|
||||||
|
|
||||||
|
check(func: (argv: Arguments<T>, aliases: { [alias: string]: string }) => any, global?: boolean): Argv<T>;
|
||||||
|
|
||||||
|
choices<K extends keyof T, C extends ReadonlyArray<any>>(key: K, values: C): Argv<Omit<T, K> & { [key in K]: C[number] | undefined }>;
|
||||||
|
choices<K extends string, C extends ReadonlyArray<any>>(key: K, values: C): Argv<T & { [key in K]: C[number] | undefined }>;
|
||||||
|
choices<C extends { [key: string]: ReadonlyArray<any> }>(choices: C): Argv<Omit<T, keyof C> & { [key in keyof C]: C[key][number] | undefined }>;
|
||||||
|
|
||||||
|
coerce<K extends keyof T, V>(key: K | ReadonlyArray<K>, func: (arg: any) => V): Argv<Omit<T, K> & { [key in K]: V | undefined }>;
|
||||||
|
coerce<K extends string, V>(key: K | ReadonlyArray<K>, func: (arg: any) => V): Argv<T & { [key in K]: V | undefined }>;
|
||||||
|
coerce<O extends { [key: string]: (arg: any) => any }>(opts: O): Argv<Omit<T, keyof O> & { [key in keyof O]: ReturnType<O[key]> | undefined }>;
|
||||||
|
|
||||||
|
command<U>(command: string | ReadonlyArray<string>, description: string, builder?: (args: Argv<T>) => Argv<U>, handler?: (args: Arguments<U>) => void): Argv<T>;
|
||||||
|
command<O extends { [key: string]: Options }>(command: string | ReadonlyArray<string>, description: string, builder?: O, handler?: (args: Arguments<InferredOptionTypes<O>>) => void): Argv<T>;
|
||||||
|
command<U>(command: string | ReadonlyArray<string>, description: string, module: CommandModule<T, U>): Argv<U>;
|
||||||
|
command<U>(command: string | ReadonlyArray<string>, showInHelp: false, builder?: (args: Argv<T>) => Argv<U>, handler?: (args: Arguments<U>) => void): Argv<T>;
|
||||||
|
command<O extends { [key: string]: Options }>(command: string | ReadonlyArray<string>, showInHelp: false, builder?: O, handler?: (args: Arguments<InferredOptionTypes<O>>) => void): Argv<T>;
|
||||||
|
command<U>(command: string | ReadonlyArray<string>, showInHelp: false, module: CommandModule<T, U>): Argv<U>;
|
||||||
|
command<U>(module: CommandModule<T, U>): Argv<U>;
|
||||||
|
|
||||||
|
// Advanced API
|
||||||
|
commandDir(dir: string, opts?: RequireDirectoryOptions): Argv<T>;
|
||||||
|
|
||||||
|
completion(): Argv<T>;
|
||||||
|
completion(cmd: string, func?: AsyncCompletionFunction): Argv<T>;
|
||||||
|
completion(cmd: string, func?: SyncCompletionFunction): Argv<T>;
|
||||||
|
completion(cmd: string, description?: string, func?: AsyncCompletionFunction): Argv<T>;
|
||||||
|
completion(cmd: string, description?: string, func?: SyncCompletionFunction): Argv<T>;
|
||||||
|
|
||||||
|
config(): Argv<T>;
|
||||||
|
config(key: string | ReadonlyArray<string>, description?: string, parseFn?: (configPath: string) => object): Argv<T>;
|
||||||
|
config(key: string | ReadonlyArray<string>, parseFn: (configPath: string) => object): Argv<T>;
|
||||||
|
config(explicitConfigurationObject: object): Argv<T>;
|
||||||
|
|
||||||
|
conflicts(key: string, value: string | ReadonlyArray<string>): Argv<T>;
|
||||||
|
conflicts(conflicts: { [key: string]: string | ReadonlyArray<string> }): Argv<T>;
|
||||||
|
|
||||||
|
count<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: number }>;
|
||||||
|
count<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: number }>;
|
||||||
|
|
||||||
|
default<K extends keyof T, V>(key: K, value: V, description?: string): Argv<Omit<T, K> & { [key in K]: V }>;
|
||||||
|
default<K extends string, V>(key: K, value: V, description?: string): Argv<T & { [key in K]: V }>;
|
||||||
|
default<D extends { [key: string]: any }>(defaults: D, description?: string): Argv<Omit<T, keyof D> & D>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 6.6.0
|
||||||
|
* Use '.demandCommand()' or '.demandOption()' instead
|
||||||
|
*/
|
||||||
|
demand<K extends keyof T>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<Defined<T, K>>;
|
||||||
|
demand<K extends string>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<T & { [key in K]: unknown }>;
|
||||||
|
demand(key: string | ReadonlyArray<string>, required?: boolean): Argv<T>;
|
||||||
|
demand(positionals: number, msg: string): Argv<T>;
|
||||||
|
demand(positionals: number, required?: boolean): Argv<T>;
|
||||||
|
demand(positionals: number, max: number, msg?: string): Argv<T>;
|
||||||
|
|
||||||
|
demandOption<K extends keyof T>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<Defined<T, K>>;
|
||||||
|
demandOption<K extends string>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<T & { [key in K]: unknown }>;
|
||||||
|
demandOption(key: string | ReadonlyArray<string>, demand?: boolean): Argv<T>;
|
||||||
|
|
||||||
|
demandCommand(): Argv<T>;
|
||||||
|
demandCommand(min: number, minMsg?: string): Argv<T>;
|
||||||
|
demandCommand(min: number, max?: number, minMsg?: string, maxMsg?: string): Argv<T>;
|
||||||
|
|
||||||
|
describe(key: string | ReadonlyArray<string>, description: string): Argv<T>;
|
||||||
|
describe(descriptions: { [key: string]: string }): Argv<T>;
|
||||||
|
|
||||||
|
detectLocale(detect: boolean): Argv<T>;
|
||||||
|
|
||||||
|
env(): Argv<T>;
|
||||||
|
env(prefix: string): Argv<T>;
|
||||||
|
env(enable: boolean): Argv<T>;
|
||||||
|
|
||||||
|
epilog(msg: string): Argv<T>;
|
||||||
|
|
||||||
|
epilogue(msg: string): Argv<T>;
|
||||||
|
|
||||||
|
example(command: string, description: string): Argv<T>;
|
||||||
|
|
||||||
|
exit(code: number, err: Error): void;
|
||||||
|
|
||||||
|
exitProcess(enabled: boolean): Argv<T>;
|
||||||
|
|
||||||
|
fail(func: (msg: string, err: Error) => any): Argv<T>;
|
||||||
|
|
||||||
|
getCompletion(args: ReadonlyArray<string>, done: (completions: ReadonlyArray<string>) => void): Argv<T>;
|
||||||
|
|
||||||
|
global(key: string | ReadonlyArray<string>): Argv<T>;
|
||||||
|
|
||||||
|
group(key: string | ReadonlyArray<string>, groupName: string): Argv<T>;
|
||||||
|
|
||||||
|
hide(key: string): Argv<T>;
|
||||||
|
|
||||||
|
help(): Argv<T>;
|
||||||
|
help(enableExplicit: boolean): Argv<T>;
|
||||||
|
help(option: string, enableExplicit: boolean): Argv<T>;
|
||||||
|
help(option: string, description?: string, enableExplicit?: boolean): Argv<T>;
|
||||||
|
|
||||||
|
implies(key: string, value: string | ReadonlyArray<string>): Argv<T>;
|
||||||
|
implies(implies: { [key: string]: string | ReadonlyArray<string> }): Argv<T>;
|
||||||
|
|
||||||
|
locale(): string;
|
||||||
|
locale(loc: string): Argv<T>;
|
||||||
|
|
||||||
|
middleware(callbacks: MiddlewareFunction<T> | ReadonlyArray<MiddlewareFunction<T>>): Argv<T>;
|
||||||
|
|
||||||
|
nargs(key: string, count: number): Argv<T>;
|
||||||
|
nargs(nargs: { [key: string]: number }): Argv<T>;
|
||||||
|
|
||||||
|
normalize<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: ToString<T[key]> }>;
|
||||||
|
normalize<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: string | undefined }>;
|
||||||
|
|
||||||
|
number<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: ToNumber<T[key]> }>;
|
||||||
|
number<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: number | undefined }>;
|
||||||
|
|
||||||
|
option<K extends keyof T, O extends Options>(key: K, options: O): Argv<Omit<T, K> & { [key in K]: InferredOptionType<O> }>;
|
||||||
|
option<K extends string, O extends Options>(key: K, options: O): Argv<T & { [key in K]: InferredOptionType<O> }>;
|
||||||
|
option<O extends { [key: string]: Options }>(options: O): Argv<Omit<T, keyof O> & InferredOptionTypes<O>>;
|
||||||
|
|
||||||
|
options<K extends keyof T, O extends Options>(key: K, options: O): Argv<Omit<T, K> & { [key in K]: InferredOptionType<O> }>;
|
||||||
|
options<K extends string, O extends Options>(key: K, options: O): Argv<T & { [key in K]: InferredOptionType<O> }>;
|
||||||
|
options<O extends { [key: string]: Options }>(options: O): Argv<Omit<T, keyof O> & InferredOptionTypes<O>>;
|
||||||
|
|
||||||
|
parse(): { [key in keyof Arguments<T>]: Arguments<T>[key] };
|
||||||
|
parse(arg: string | ReadonlyArray<string>, context?: object, parseCallback?: ParseCallback<T>): { [key in keyof Arguments<T>]: Arguments<T>[key] };
|
||||||
|
|
||||||
|
parsed: DetailedArguments | false;
|
||||||
|
|
||||||
|
pkgConf(key: string | ReadonlyArray<string>, cwd?: string): Argv<T>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 'positional' should be called in a command's builder function, and is not
|
||||||
|
* available on the top-level yargs instance. If so, it will throw an error.
|
||||||
|
*/
|
||||||
|
positional<K extends keyof T, O extends PositionalOptions>(key: K, opt: O): Argv<Omit<T, K> & { [key in K]: InferredOptionType<O> }>;
|
||||||
|
positional<K extends string, O extends PositionalOptions>(key: K, opt: O): Argv<T & { [key in K]: InferredOptionType<O> }>;
|
||||||
|
|
||||||
|
recommendCommands(): Argv<T>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 6.6.0
|
||||||
|
* Use '.demandCommand()' or '.demandOption()' instead
|
||||||
|
*/
|
||||||
|
require<K extends keyof T>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<Defined<T, K>>;
|
||||||
|
require(key: string, msg: string): Argv<T>;
|
||||||
|
require(key: string, required: boolean): Argv<T>;
|
||||||
|
require(keys: ReadonlyArray<number>, msg: string): Argv<T>;
|
||||||
|
require(keys: ReadonlyArray<number>, required: boolean): Argv<T>;
|
||||||
|
require(positionals: number, required: boolean): Argv<T>;
|
||||||
|
require(positionals: number, msg: string): Argv<T>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 6.6.0
|
||||||
|
* Use '.demandCommand()' or '.demandOption()' instead
|
||||||
|
*/
|
||||||
|
required<K extends keyof T>(key: K | ReadonlyArray<K>, msg?: string | true): Argv<Defined<T, K>>;
|
||||||
|
required(key: string, msg: string): Argv<T>;
|
||||||
|
required(key: string, required: boolean): Argv<T>;
|
||||||
|
required(keys: ReadonlyArray<number>, msg: string): Argv<T>;
|
||||||
|
required(keys: ReadonlyArray<number>, required: boolean): Argv<T>;
|
||||||
|
required(positionals: number, required: boolean): Argv<T>;
|
||||||
|
required(positionals: number, msg: string): Argv<T>;
|
||||||
|
|
||||||
|
requiresArg(key: string | ReadonlyArray<string>): Argv<T>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated since version 6.6.0
|
||||||
|
* Use '.global()' instead
|
||||||
|
*/
|
||||||
|
reset(): Argv<T>;
|
||||||
|
|
||||||
|
scriptName($0: string): Argv<T>;
|
||||||
|
|
||||||
|
showCompletionScript(): Argv<T>;
|
||||||
|
|
||||||
|
showHidden(option?: string | boolean): Argv<T>;
|
||||||
|
showHidden(option: string, description?: string): Argv<T>;
|
||||||
|
|
||||||
|
showHelp(consoleLevel?: string): Argv<T>;
|
||||||
|
|
||||||
|
showHelpOnFail(enable: boolean, message?: string): Argv<T>;
|
||||||
|
|
||||||
|
skipValidation(key: string | ReadonlyArray<string>): Argv<T>;
|
||||||
|
|
||||||
|
strict(): Argv<T>;
|
||||||
|
strict(enabled: boolean): Argv<T>;
|
||||||
|
|
||||||
|
string<K extends keyof T>(key: K | ReadonlyArray<K>): Argv<Omit<T, K> & { [key in K]: ToString<T[key]> }>;
|
||||||
|
string<K extends string>(key: K | ReadonlyArray<K>): Argv<T & { [key in K]: string | undefined }>;
|
||||||
|
|
||||||
|
// Intended to be used with '.wrap()'
|
||||||
|
terminalWidth(): number;
|
||||||
|
|
||||||
|
updateLocale(obj: { [key: string]: string }): Argv<T>;
|
||||||
|
|
||||||
|
updateStrings(obj: { [key: string]: string }): Argv<T>;
|
||||||
|
|
||||||
|
usage(message: string): Argv<T>;
|
||||||
|
usage<U>(command: string | ReadonlyArray<string>, description: string, builder?: (args: Argv<T>) => Argv<U>, handler?: (args: Arguments<U>) => void): Argv<T>;
|
||||||
|
usage<U>(command: string | ReadonlyArray<string>, showInHelp: boolean, builder?: (args: Argv<T>) => Argv<U>, handler?: (args: Arguments<U>) => void): Argv<T>;
|
||||||
|
usage<O extends { [key: string]: Options }>(command: string | ReadonlyArray<string>, description: string, builder?: O, handler?: (args: Arguments<InferredOptionTypes<O>>) => void): Argv<T>;
|
||||||
|
usage<O extends { [key: string]: Options }>(command: string | ReadonlyArray<string>, showInHelp: boolean, builder?: O, handler?: (args: Arguments<InferredOptionTypes<O>>) => void): Argv<T>;
|
||||||
|
|
||||||
|
version(): Argv<T>;
|
||||||
|
version(version: string): Argv<T>;
|
||||||
|
version(enable: boolean): Argv<T>;
|
||||||
|
version(optionKey: string, version: string): Argv<T>;
|
||||||
|
version(optionKey: string, description: string, version: string): Argv<T>;
|
||||||
|
|
||||||
|
wrap(columns: number | null): Argv<T>;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Arguments<T = {}> = T & {
|
||||||
|
/** Non-option arguments */
|
||||||
|
_: string[];
|
||||||
|
/** The script name or node command */
|
||||||
|
$0: string;
|
||||||
|
/** All remaining options */
|
||||||
|
[argName: string]: unknown;
|
||||||
|
};
|
||||||
|
|
||||||
|
interface DetailedArguments {
|
||||||
|
argv: Arguments;
|
||||||
|
error: Error | null;
|
||||||
|
aliases: {[alias: string]: string[]};
|
||||||
|
newAliases: {[alias: string]: boolean};
|
||||||
|
configuration: Configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Configuration {
|
||||||
|
'boolean-negation': boolean;
|
||||||
|
'camel-case-expansion': boolean;
|
||||||
|
'combine-arrays': boolean;
|
||||||
|
'dot-notation': boolean;
|
||||||
|
'duplicate-arguments-array': boolean;
|
||||||
|
'flatten-duplicate-arrays': boolean;
|
||||||
|
'negation-prefix': string;
|
||||||
|
'parse-numbers': boolean;
|
||||||
|
'populate--': boolean;
|
||||||
|
'set-placeholder-key': boolean;
|
||||||
|
'short-option-groups': boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RequireDirectoryOptions {
|
||||||
|
recurse?: boolean;
|
||||||
|
extensions?: ReadonlyArray<string>;
|
||||||
|
visit?: (commandObject: any, pathToFile?: string, filename?: string) => any;
|
||||||
|
include?: RegExp | ((pathToFile: string) => boolean);
|
||||||
|
exclude?: RegExp | ((pathToFile: string) => boolean);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Options {
|
||||||
|
alias?: string | ReadonlyArray<string>;
|
||||||
|
array?: boolean;
|
||||||
|
boolean?: boolean;
|
||||||
|
choices?: Choices;
|
||||||
|
coerce?: (arg: any) => any;
|
||||||
|
config?: boolean;
|
||||||
|
configParser?: (configPath: string) => object;
|
||||||
|
conflicts?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> };
|
||||||
|
count?: boolean;
|
||||||
|
default?: any;
|
||||||
|
defaultDescription?: string;
|
||||||
|
/**
|
||||||
|
* @deprecated since version 6.6.0
|
||||||
|
* Use 'demandOption' instead
|
||||||
|
*/
|
||||||
|
demand?: boolean | string;
|
||||||
|
demandOption?: boolean | string;
|
||||||
|
desc?: string;
|
||||||
|
describe?: string;
|
||||||
|
description?: string;
|
||||||
|
global?: boolean;
|
||||||
|
group?: string;
|
||||||
|
hidden?: boolean;
|
||||||
|
implies?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> };
|
||||||
|
nargs?: number;
|
||||||
|
normalize?: boolean;
|
||||||
|
number?: boolean;
|
||||||
|
/**
|
||||||
|
* @deprecated since version 6.6.0
|
||||||
|
* Use 'demandOption' instead
|
||||||
|
*/
|
||||||
|
require?: boolean | string;
|
||||||
|
/**
|
||||||
|
* @deprecated since version 6.6.0
|
||||||
|
* Use 'demandOption' instead
|
||||||
|
*/
|
||||||
|
required?: boolean | string;
|
||||||
|
requiresArg?: boolean;
|
||||||
|
skipValidation?: boolean;
|
||||||
|
string?: boolean;
|
||||||
|
type?: "array" | "count" | PositionalOptionsType;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface PositionalOptions {
|
||||||
|
alias?: string | ReadonlyArray<string>;
|
||||||
|
choices?: Choices;
|
||||||
|
coerce?: (arg: any) => any;
|
||||||
|
conflicts?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> };
|
||||||
|
default?: any;
|
||||||
|
desc?: string;
|
||||||
|
describe?: string;
|
||||||
|
description?: string;
|
||||||
|
implies?: string | ReadonlyArray<string> | { [key: string]: string | ReadonlyArray<string> };
|
||||||
|
normalize?: boolean;
|
||||||
|
type?: PositionalOptionsType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Remove keys K in T */
|
||||||
|
type Omit<T, K> = { [key in Exclude<keyof T, K>]: T[key] };
|
||||||
|
|
||||||
|
/** Remove undefined as a possible value for keys K in T */
|
||||||
|
type Defined<T, K extends keyof T> = Omit<T, K> & { [key in K]: Exclude<T[key], undefined> };
|
||||||
|
|
||||||
|
/** Convert T to T[] and T | undefined to T[] | undefined */
|
||||||
|
type ToArray<T> = Array<Exclude<T, undefined>> | Extract<T, undefined>;
|
||||||
|
|
||||||
|
/** Gives string[] if T is an array type, otherwise string. Preserves | undefined. */
|
||||||
|
type ToString<T> = (Exclude<T, undefined> extends any[] ? string[] : string) | Extract<T, undefined>;
|
||||||
|
|
||||||
|
/** Gives number[] if T is an array type, otherwise number. Preserves | undefined. */
|
||||||
|
type ToNumber<T> = (Exclude<T, undefined> extends any[] ? number[] : number) | Extract<T, undefined>;
|
||||||
|
|
||||||
|
type InferredOptionType<O extends Options | PositionalOptions> =
|
||||||
|
O extends { default: infer D } ? D :
|
||||||
|
O extends { type: "count" } ? number :
|
||||||
|
O extends { count: true } ? number :
|
||||||
|
O extends { required: string | true } ? RequiredOptionType<O> :
|
||||||
|
O extends { require: string | true } ? RequiredOptionType<O> :
|
||||||
|
O extends { demand: string | true } ? RequiredOptionType<O> :
|
||||||
|
O extends { demandOption: string | true } ? RequiredOptionType<O> :
|
||||||
|
RequiredOptionType<O> | undefined;
|
||||||
|
|
||||||
|
type RequiredOptionType<O extends Options | PositionalOptions> =
|
||||||
|
O extends { type: "array", string: true } ? string[] :
|
||||||
|
O extends { type: "array", number: true } ? number[] :
|
||||||
|
O extends { type: "array", normalize: true } ? string[] :
|
||||||
|
O extends { type: "string", array: true } ? string[] :
|
||||||
|
O extends { type: "number", array: true } ? number[] :
|
||||||
|
O extends { string: true, array: true } ? string[] :
|
||||||
|
O extends { number: true, array: true } ? number[] :
|
||||||
|
O extends { normalize: true, array: true } ? string[] :
|
||||||
|
O extends { type: "array" } ? Array<string | number> :
|
||||||
|
O extends { type: "boolean" } ? boolean :
|
||||||
|
O extends { type: "number" } ? number :
|
||||||
|
O extends { type: "string" } ? string :
|
||||||
|
O extends { array: true } ? Array<string | number> :
|
||||||
|
O extends { boolean: true } ? boolean :
|
||||||
|
O extends { number: true } ? number :
|
||||||
|
O extends { string: true } ? string :
|
||||||
|
O extends { normalize: true } ? string :
|
||||||
|
O extends { choices: ReadonlyArray<infer C> } ? C :
|
||||||
|
O extends { coerce: (arg: any) => infer T } ? T :
|
||||||
|
unknown;
|
||||||
|
|
||||||
|
type InferredOptionTypes<O extends { [key: string]: Options }> = { [key in keyof O]: InferredOptionType<O[key]> };
|
||||||
|
|
||||||
|
interface CommandModule<T = {}, U = {}> {
|
||||||
|
aliases?: ReadonlyArray<string> | string;
|
||||||
|
builder?: CommandBuilder<T, U>;
|
||||||
|
command?: ReadonlyArray<string> | string;
|
||||||
|
describe?: string | false;
|
||||||
|
handler: (args: Arguments<U>) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
type ParseCallback<T = {}> = (err: Error | undefined, argv: Arguments<T>, output: string) => void;
|
||||||
|
type CommandBuilder<T = {}, U = {}> = { [key: string]: Options } | ((args: Argv<T>) => Argv<U>);
|
||||||
|
type SyncCompletionFunction = (current: string, argv: any) => string[];
|
||||||
|
type AsyncCompletionFunction = (current: string, argv: any, done: (completion: ReadonlyArray<string>) => void) => void;
|
||||||
|
type MiddlewareFunction<T = {}> = (args: Arguments<T>) => void;
|
||||||
|
type Choices = ReadonlyArray<string | true | undefined>;
|
||||||
|
type PositionalOptionsType = "boolean" | "number" | "string";
|
||||||
|
}
|
||||||
|
|
||||||
|
declare var yargs: yargs.Argv;
|
||||||
|
export = yargs;
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
{
|
||||||
|
"name": "@types/yargs",
|
||||||
|
"version": "12.0.12",
|
||||||
|
"description": "TypeScript definitions for yargs",
|
||||||
|
"license": "MIT",
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"name": "Martin Poelstra",
|
||||||
|
"url": "https://github.com/poelstra",
|
||||||
|
"githubUsername": "poelstra"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Mizunashi Mana",
|
||||||
|
"url": "https://github.com/mizunashi-mana",
|
||||||
|
"githubUsername": "mizunashi-mana"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jeffery Grajkowski",
|
||||||
|
"url": "https://github.com/pushplay",
|
||||||
|
"githubUsername": "pushplay"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jeff Kenney",
|
||||||
|
"url": "https://github.com/jeffkenney",
|
||||||
|
"githubUsername": "jeffkenney"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Jimi (Dimitris) Charalampidis",
|
||||||
|
"url": "https://github.com/JimiC",
|
||||||
|
"githubUsername": "JimiC"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Steffen Viken Valvåg",
|
||||||
|
"url": "https://github.com/steffenvv",
|
||||||
|
"githubUsername": "steffenvv"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Emily Marigold Klassen",
|
||||||
|
"url": "https://github.com/forivall",
|
||||||
|
"githubUsername": "forivall"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"main": "",
|
||||||
|
"types": "index",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
||||||
|
"directory": "types/yargs"
|
||||||
|
},
|
||||||
|
"scripts": {},
|
||||||
|
"dependencies": {},
|
||||||
|
"typesPublisherContentHash": "797da61a576678d4a7247c12796a39175a72c67c12a6b2e34a47306ad6c42cdf",
|
||||||
|
"typeScriptVersion": "3.0"
|
||||||
|
|
||||||
|
,"_resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-12.0.12.tgz"
|
||||||
|
,"_integrity": "sha512-SOhuU4wNBxhhTHxYaiG5NY4HBhDIDnJF60GU+2LqHAdKKer86//e4yg69aENCtQ04n0ovz+tq2YPME5t5yp4pw=="
|
||||||
|
,"_from": "@types/yargs@12.0.12"
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { Argv } from '.';
|
||||||
|
|
||||||
|
export = Yargs;
|
||||||
|
|
||||||
|
declare function Yargs(
|
||||||
|
processArgs?: ReadonlyArray<string>,
|
||||||
|
cwd?: string,
|
||||||
|
parentRequire?: NodeRequireFunction,
|
||||||
|
): Argv;
|
||||||
Loading…
Reference in New Issue