mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 04:01:52 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
/// <reference path="babel-core.d.ts" />
|
||||
import * as babel from "babel-core";
|
||||
|
||||
|
||||
// Example from https://github.com/babel/babel/tree/master/packages/babel-core
|
||||
const code = `class Example {}`;
|
||||
const result = babel.transform(code, { /* options */ });
|
||||
result.code; // Generated code
|
||||
result.map; // Sourcemap
|
||||
result.ast; // AST
|
||||
|
||||
|
||||
// Examples from http://babeljs.io/docs/usage/api/
|
||||
let options: babel.TransformOptions = {
|
||||
plugins: [
|
||||
"es2015-arrow-functions",
|
||||
"es2015-block-scoped-functions",
|
||||
"es2015-block-scoping",
|
||||
"es2015-classes",
|
||||
],
|
||||
only: /.*\.js/,
|
||||
ast: false,
|
||||
sourceMaps: true
|
||||
};
|
||||
|
||||
babel.transformFile("filename.js", options, function (err, result) {
|
||||
result.code;
|
||||
result.map;
|
||||
result.ast;
|
||||
});
|
||||
|
||||
babel.transformFileSync("filename.js", options).code;
|
||||
Vendored
+144
@@ -0,0 +1,144 @@
|
||||
// Type definitions for babel-core v6.7
|
||||
// Project: https://github.com/babel/babel/tree/master/packages/babel-core
|
||||
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../babel-template/babel-template.d.ts" />
|
||||
/// <reference path="../babel-traverse/babel-traverse.d.ts" />
|
||||
/// <reference path="../babel-types/babel-types.d.ts" />
|
||||
|
||||
declare module "babel-core" {
|
||||
import * as t from 'babel-types';
|
||||
export {t as types};
|
||||
type Node = t.Node;
|
||||
export import template = require('babel-template');
|
||||
export var version: string;
|
||||
import traverse, {Visitor} from "babel-traverse";
|
||||
export {traverse, Visitor};
|
||||
|
||||
|
||||
/** Transforms the passed in `code`. Returning an object with the generated code, source map, and AST. */
|
||||
export function transform(code: string, opts?: TransformOptions): BabelFileResult;
|
||||
|
||||
/** Asynchronously transforms the entire contents of a file. */
|
||||
export function transformFile(filename: string, opts: TransformOptions, callback: (err: any, result: BabelFileResult) => void): void;
|
||||
|
||||
/** Synchronous version of `babel.transformFile`. Returns the transformed contents of the `filename`. */
|
||||
export function transformFileSync(filename: string, opts?: TransformOptions): BabelFileResult;
|
||||
|
||||
export function transformFromAst(ast: Node, code?: string, opts?: TransformOptions): BabelFileResult;
|
||||
|
||||
export interface TransformOptions {
|
||||
|
||||
/** Filename to use when reading from stdin - this will be used in source-maps, errors etc. Default: "unknown". */
|
||||
filename?: string;
|
||||
|
||||
/** Filename relative to `sourceRoot`. */
|
||||
filenameRelative?: string;
|
||||
|
||||
/** A source map object that the output source map will be based on. */
|
||||
inputSourceMap?: Object;
|
||||
|
||||
/**
|
||||
* 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 enviroment variable `BABEL_ENV` is set to `"production"`.
|
||||
* If `BABEL_ENV` isn't set then `NODE_ENV` will be used, if it's not set then it defaults to `"development"`.
|
||||
*/
|
||||
env?: Object;
|
||||
|
||||
/** Retain line numbers - will result in really ugly code. Default: `false` */
|
||||
retainLines?: boolean;
|
||||
|
||||
/** Enable/disable ANSI syntax highlighting of code frames. Default: `true`. */
|
||||
highlightCode?: boolean;
|
||||
|
||||
/** List of presets (a set of plugins) to load and use. */
|
||||
presets?: any[];
|
||||
|
||||
/** List of plugins to load and use. */
|
||||
plugins?: any[];
|
||||
|
||||
/** list of glob paths to **not** compile. Opposite to the `only` option. */
|
||||
ignore?: string[];
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
only?: string | RegExp | Array<string | RegExp>;
|
||||
|
||||
/** Enable code generation. Default: `true`. */
|
||||
code?: boolean;
|
||||
|
||||
/** Include the AST in the returned object. Default: `true`. */
|
||||
ast?: boolean;
|
||||
|
||||
/** A path to an .babelrc file to extend. */
|
||||
extends?: string;
|
||||
|
||||
/** write comments to generated output. Default: `true`. */
|
||||
comments?: boolean;
|
||||
|
||||
/**
|
||||
* An optional callback that controls whether a comment should be output or not. Called as
|
||||
* `shouldPrintComment(commentContents)`. **NOTE**: This overrides the `comments` option when used.
|
||||
*/
|
||||
shouldPrintComment?: (comment: string) => boolean;
|
||||
|
||||
/**
|
||||
* Do not include superfluous whitespace characters and line terminators. When set to `"auto"`, `compact` is set to
|
||||
* `true` on input sizes of >100KB.
|
||||
*/
|
||||
compact?: boolean | "auto";
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
sourceMaps?: boolean | "inline" | "both";
|
||||
|
||||
/** Set `file` on returned source map. */
|
||||
sourceMapTarget?: string;
|
||||
|
||||
/** Set `sources[0]` on returned source map. */
|
||||
sourceFileName?: string;
|
||||
|
||||
/** The root from which all sources are relative. */
|
||||
sourceRoot?: string;
|
||||
|
||||
/** Specify whether or not to use `.babelrc` and `.babelignore` files. Default: `true`. */
|
||||
babelrc?: boolean;
|
||||
|
||||
/** Attach a comment before all non-user injected code. */
|
||||
auxiliaryCommentBefore?: string;
|
||||
|
||||
/** Attach a comment after all non-user injected code. */
|
||||
auxiliaryCommentAfter?: string;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
getModuleId?: (moduleName: string) => string;
|
||||
|
||||
/** Optional prefix for the AMD module formatter that will be prepend to the filename on module definitions. */
|
||||
moduleRoot?: string;
|
||||
|
||||
/**
|
||||
* If truthy, insert an explicit id for modules. By default, all modules are anonymous.
|
||||
* (Not available for `common` modules).
|
||||
*/
|
||||
moduleIds?: boolean;
|
||||
|
||||
/** Specify a custom name for module ids. */
|
||||
moduleId?: string;
|
||||
}
|
||||
|
||||
export interface BabelFileResult {
|
||||
ast?: Node;
|
||||
code?: string;
|
||||
map?: Object;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
/// <reference path="../babylon/babylon.d.ts" />
|
||||
/// <reference path="babel-generator.d.ts" />
|
||||
|
||||
|
||||
// Example from https://github.com/babel/babel/tree/master/packages/babel-generator
|
||||
import {parse} from 'babylon';
|
||||
import generate from 'babel-generator';
|
||||
|
||||
const code = 'class Example {}';
|
||||
const ast = parse(code);
|
||||
|
||||
ast.type;
|
||||
ast.loc.start;
|
||||
|
||||
const output = generate(ast, { /* options */ }, code);
|
||||
|
||||
|
||||
// Example from https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-generator
|
||||
let result = generate(ast, {
|
||||
retainLines: false,
|
||||
compact: "auto",
|
||||
concise: false,
|
||||
quotes: "double",
|
||||
// ...
|
||||
}, code);
|
||||
result.code;
|
||||
result.map;
|
||||
Vendored
+102
@@ -0,0 +1,102 @@
|
||||
// Type definitions for babel-generator v6.7
|
||||
// Project: https://github.com/babel/babel/tree/master/packages/babel-generator
|
||||
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../babel-types/babel-types.d.ts" />
|
||||
|
||||
declare module "babel-generator" {
|
||||
import * as t from 'babel-types';
|
||||
type Node = t.Node;
|
||||
|
||||
/**
|
||||
* 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: Node, opts?: GeneratorOptions, code?: string | {[filename: string]: string}): GeneratorResult;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
export interface GeneratorResult {
|
||||
map: Object;
|
||||
code: string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/// <reference path="babel-template.d.ts" />
|
||||
/// <reference path="../babel-generator/babel-generator.d.ts" />
|
||||
/// <reference path="../babel-types/babel-types.d.ts" />
|
||||
|
||||
|
||||
// Example from https://github.com/babel/babel/tree/master/packages/babel-template
|
||||
import template = require('babel-template');
|
||||
import generate from 'babel-generator';
|
||||
import * as t from 'babel-types';
|
||||
|
||||
const buildRequire = template(`
|
||||
var IMPORT_NAME = require(SOURCE);
|
||||
`);
|
||||
|
||||
const ast = buildRequire({
|
||||
IMPORT_NAME: t.identifier('myModule'),
|
||||
SOURCE: t.stringLiteral('my-module')
|
||||
});
|
||||
|
||||
console.log(generate(ast).code);
|
||||
// var myModule = require('my-module');
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
// Type definitions for babel-template v6.7
|
||||
// Project: https://github.com/babel/babel/tree/master/packages/babel-template
|
||||
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../babylon/babylon.d.ts" />
|
||||
/// <reference path="../babel-types/babel-types.d.ts" />
|
||||
|
||||
declare module "babel-template" {
|
||||
import {BabylonOptions} from 'babylon';
|
||||
import * as t from 'babel-types';
|
||||
type Node = t.Node;
|
||||
|
||||
// NB: This export doesn't match the handbook example, where `template` is the default export.
|
||||
// But it does match the runtime behaviour (at least at the time of this writing). For some reason,
|
||||
// babel-template/lib/index.js has this line at the bottom: module.exports = exports["default"];
|
||||
export = template;
|
||||
function template(code: string, opts?: BabylonOptions): UseTemplate;
|
||||
|
||||
type UseTemplate = (nodes?: {[placeholder: string]: Node}) => Node;
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
/// <reference path="babel-traverse.d.ts" />
|
||||
/// <reference path="../babel-types/babel-types.d.ts" />
|
||||
/// <reference path="../babylon/babylon.d.ts" />
|
||||
|
||||
|
||||
import * as babylon from "babylon";
|
||||
import traverse, {Visitor} from 'babel-traverse';
|
||||
import * as t from 'babel-types';
|
||||
|
||||
|
||||
// Examples from: https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md
|
||||
const MyVisitor: Visitor = {
|
||||
Identifier: {
|
||||
enter() {
|
||||
console.log("Entered!");
|
||||
},
|
||||
exit() {
|
||||
console.log("Exited!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const MyVisitor2: Visitor = {
|
||||
Identifier(path) {
|
||||
console.log("Visiting: " + path.node.name);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Example from https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-traverse
|
||||
const code = `function square(n) {
|
||||
return n * n;
|
||||
}`;
|
||||
|
||||
const ast = babylon.parse(code);
|
||||
|
||||
traverse(ast, {
|
||||
enter(path) {
|
||||
let node = path.node;
|
||||
if (t.isIdentifier(node) && node.name === "n") {
|
||||
node.name = "x";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Examples from https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#writing-your-first-babel-plugin
|
||||
|
||||
const v1: Visitor = {
|
||||
|
||||
BinaryExpression(path) {
|
||||
if (t.isIdentifier(path.node.left)) {
|
||||
// ...
|
||||
}
|
||||
path.replaceWith(
|
||||
t.binaryExpression("**", path.node.left, t.numericLiteral(2))
|
||||
);
|
||||
path.parentPath.replaceWith(
|
||||
t.expressionStatement(t.stringLiteral("Anyway the wind blows, doesn't really matter to me, to me."))
|
||||
);
|
||||
path.parentPath.remove();
|
||||
},
|
||||
|
||||
Identifier(path) {
|
||||
if (path.isReferencedIdentifier()) {
|
||||
// ...
|
||||
}
|
||||
if (t.isReferenced(path.node, path.parent)) {
|
||||
// ...
|
||||
}
|
||||
},
|
||||
|
||||
ReturnStatement(path) {
|
||||
path.replaceWithMultiple([
|
||||
t.expressionStatement(t.stringLiteral("Is this the real life?")),
|
||||
t.expressionStatement(t.stringLiteral("Is this just fantasy?")),
|
||||
t.expressionStatement(t.stringLiteral("(Enjoy singing the rest of the song in your head)")),
|
||||
]);
|
||||
},
|
||||
|
||||
FunctionDeclaration(path, state) {
|
||||
path.replaceWithSourceString(`function add(a, b) {
|
||||
return a + b;
|
||||
}`);
|
||||
|
||||
path.insertBefore(t.expressionStatement(t.stringLiteral("Because I'm easy come, easy go.")));
|
||||
path.insertAfter(t.expressionStatement(t.stringLiteral("A little high, little low.")));
|
||||
path.remove();
|
||||
|
||||
if (path.scope.hasBinding("n")) {
|
||||
// ...
|
||||
}
|
||||
if (path.scope.hasOwnBinding("n")) {
|
||||
// ...
|
||||
}
|
||||
|
||||
let id1 = path.scope.generateUidIdentifier("uid");
|
||||
id1.type;
|
||||
id1.name;
|
||||
let id2 = path.scope.generateUidIdentifier("uid");
|
||||
id2.type;
|
||||
id2.name;
|
||||
|
||||
const id = path.scope.generateUidIdentifierBasedOnNode(path.node.id);
|
||||
path.remove();
|
||||
path.scope.parent.push({ id, init: path.node });
|
||||
|
||||
path.scope.rename("n", "x");
|
||||
path.scope.rename("n");
|
||||
}
|
||||
};
|
||||
Vendored
+966
@@ -0,0 +1,966 @@
|
||||
// Type definitions for babel-traverse v6.7
|
||||
// Project: https://github.com/babel/babel/tree/master/packages/babel-traverse
|
||||
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../babel-types/babel-types.d.ts" />
|
||||
|
||||
declare module "babel-traverse" {
|
||||
import * as t from 'babel-types';
|
||||
type Node = t.Node;
|
||||
|
||||
export default function traverse(parent: Node | Node[], opts?: TraverseOptions, scope?: Scope, state?: any, parentPath?: NodePath<Node>): void;
|
||||
|
||||
export interface TraverseOptions extends Visitor {
|
||||
scope?: Scope;
|
||||
noScope?: boolean;
|
||||
}
|
||||
|
||||
export class Scope {
|
||||
constructor(path: NodePath<Node>, parentScope?: Scope);
|
||||
path: NodePath<Node>;
|
||||
block: Node;
|
||||
parentBlock: Node;
|
||||
parent: Scope;
|
||||
hub: Hub;
|
||||
bindings: { [name: string]: Binding; };
|
||||
|
||||
/** Traverse node with current scope and path. */
|
||||
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<Node>): void;
|
||||
|
||||
buildUndefinedNode(): Node;
|
||||
|
||||
registerConstantViolation(path: NodePath<Node>): void;
|
||||
|
||||
registerBinding(kind: string, path: NodePath<Node>, bindingPath?: NodePath<Node>): 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: any): void;
|
||||
|
||||
getProgramParent(): Scope;
|
||||
|
||||
getFunctionParent(): Scope;
|
||||
|
||||
getBlockParent(): Scope;
|
||||
|
||||
/** Walks the scope tree and gathers **all** bindings. */
|
||||
getAllBindings(...kinds: string[]): Object;
|
||||
|
||||
bindingIdentifierEquals(name: string, node: Node): boolean;
|
||||
|
||||
getBinding(name: string): Binding;
|
||||
|
||||
getOwnBinding(name: string): Binding;
|
||||
|
||||
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<Node>; kind: 'var' | 'let' | 'const'; });
|
||||
identifier: t.Identifier;
|
||||
scope: Scope;
|
||||
path: NodePath<Node>;
|
||||
kind: 'var' | 'let' | 'const';
|
||||
referenced: boolean;
|
||||
references: number;
|
||||
referencePaths: NodePath<Node>[];
|
||||
constant: boolean;
|
||||
constantViolations: NodePath<Node>[];
|
||||
}
|
||||
|
||||
export interface Visitor extends VisitNodeObject<Node> {
|
||||
ArrayExpression?: VisitNode<t.ArrayExpression>;
|
||||
AssignmentExpression?: VisitNode<t.AssignmentExpression>;
|
||||
LVal?: VisitNode<t.LVal>;
|
||||
Expression?: VisitNode<t.Expression>;
|
||||
BinaryExpression?: VisitNode<t.BinaryExpression>;
|
||||
Directive?: VisitNode<t.Directive>;
|
||||
DirectiveLiteral?: VisitNode<t.DirectiveLiteral>;
|
||||
BlockStatement?: VisitNode<t.BlockStatement>;
|
||||
BreakStatement?: VisitNode<t.BreakStatement>;
|
||||
Identifier?: VisitNode<t.Identifier>;
|
||||
CallExpression?: VisitNode<t.CallExpression>;
|
||||
CatchClause?: VisitNode<t.CatchClause>;
|
||||
ConditionalExpression?: VisitNode<t.ConditionalExpression>;
|
||||
ContinueStatement?: VisitNode<t.ContinueStatement>;
|
||||
DebuggerStatement?: VisitNode<t.DebuggerStatement>;
|
||||
DoWhileStatement?: VisitNode<t.DoWhileStatement>;
|
||||
Statement?: VisitNode<t.Statement>;
|
||||
EmptyStatement?: VisitNode<t.EmptyStatement>;
|
||||
ExpressionStatement?: VisitNode<t.ExpressionStatement>;
|
||||
File?: VisitNode<t.File>;
|
||||
Program?: VisitNode<t.Program>;
|
||||
ForInStatement?: VisitNode<t.ForInStatement>;
|
||||
VariableDeclaration?: VisitNode<t.VariableDeclaration>;
|
||||
ForStatement?: VisitNode<t.ForStatement>;
|
||||
FunctionDeclaration?: VisitNode<t.FunctionDeclaration>;
|
||||
FunctionExpression?: VisitNode<t.FunctionExpression>;
|
||||
IfStatement?: VisitNode<t.IfStatement>;
|
||||
LabeledStatement?: VisitNode<t.LabeledStatement>;
|
||||
StringLiteral?: VisitNode<t.StringLiteral>;
|
||||
NumericLiteral?: VisitNode<t.NumericLiteral>;
|
||||
NullLiteral?: VisitNode<t.NullLiteral>;
|
||||
BooleanLiteral?: VisitNode<t.BooleanLiteral>;
|
||||
RegExpLiteral?: VisitNode<t.RegExpLiteral>;
|
||||
LogicalExpression?: VisitNode<t.LogicalExpression>;
|
||||
MemberExpression?: VisitNode<t.MemberExpression>;
|
||||
NewExpression?: VisitNode<t.NewExpression>;
|
||||
ObjectExpression?: VisitNode<t.ObjectExpression>;
|
||||
ObjectMethod?: VisitNode<t.ObjectMethod>;
|
||||
ObjectProperty?: VisitNode<t.ObjectProperty>;
|
||||
RestElement?: VisitNode<t.RestElement>;
|
||||
ReturnStatement?: VisitNode<t.ReturnStatement>;
|
||||
SequenceExpression?: VisitNode<t.SequenceExpression>;
|
||||
SwitchCase?: VisitNode<t.SwitchCase>;
|
||||
SwitchStatement?: VisitNode<t.SwitchStatement>;
|
||||
ThisExpression?: VisitNode<t.ThisExpression>;
|
||||
ThrowStatement?: VisitNode<t.ThrowStatement>;
|
||||
TryStatement?: VisitNode<t.TryStatement>;
|
||||
UnaryExpression?: VisitNode<t.UnaryExpression>;
|
||||
UpdateExpression?: VisitNode<t.UpdateExpression>;
|
||||
VariableDeclarator?: VisitNode<t.VariableDeclarator>;
|
||||
WhileStatement?: VisitNode<t.WhileStatement>;
|
||||
WithStatement?: VisitNode<t.WithStatement>;
|
||||
AssignmentPattern?: VisitNode<t.AssignmentPattern>;
|
||||
ArrayPattern?: VisitNode<t.ArrayPattern>;
|
||||
ArrowFunctionExpression?: VisitNode<t.ArrowFunctionExpression>;
|
||||
ClassBody?: VisitNode<t.ClassBody>;
|
||||
ClassDeclaration?: VisitNode<t.ClassDeclaration>;
|
||||
ClassExpression?: VisitNode<t.ClassExpression>;
|
||||
ExportAllDeclaration?: VisitNode<t.ExportAllDeclaration>;
|
||||
ExportDefaultDeclaration?: VisitNode<t.ExportDefaultDeclaration>;
|
||||
ExportNamedDeclaration?: VisitNode<t.ExportNamedDeclaration>;
|
||||
Declaration?: VisitNode<t.Declaration>;
|
||||
ExportSpecifier?: VisitNode<t.ExportSpecifier>;
|
||||
ForOfStatement?: VisitNode<t.ForOfStatement>;
|
||||
ImportDeclaration?: VisitNode<t.ImportDeclaration>;
|
||||
ImportDefaultSpecifier?: VisitNode<t.ImportDefaultSpecifier>;
|
||||
ImportNamespaceSpecifier?: VisitNode<t.ImportNamespaceSpecifier>;
|
||||
ImportSpecifier?: VisitNode<t.ImportSpecifier>;
|
||||
MetaProperty?: VisitNode<t.MetaProperty>;
|
||||
ClassMethod?: VisitNode<t.ClassMethod>;
|
||||
ObjectPattern?: VisitNode<t.ObjectPattern>;
|
||||
SpreadElement?: VisitNode<t.SpreadElement>;
|
||||
Super?: VisitNode<t.Super>;
|
||||
TaggedTemplateExpression?: VisitNode<t.TaggedTemplateExpression>;
|
||||
TemplateLiteral?: VisitNode<t.TemplateLiteral>;
|
||||
TemplateElement?: VisitNode<t.TemplateElement>;
|
||||
YieldExpression?: VisitNode<t.YieldExpression>;
|
||||
AnyTypeAnnotation?: VisitNode<t.AnyTypeAnnotation>;
|
||||
ArrayTypeAnnotation?: VisitNode<t.ArrayTypeAnnotation>;
|
||||
BooleanTypeAnnotation?: VisitNode<t.BooleanTypeAnnotation>;
|
||||
BooleanLiteralTypeAnnotation?: VisitNode<t.BooleanLiteralTypeAnnotation>;
|
||||
NullLiteralTypeAnnotation?: VisitNode<t.NullLiteralTypeAnnotation>;
|
||||
ClassImplements?: VisitNode<t.ClassImplements>;
|
||||
ClassProperty?: VisitNode<t.ClassProperty>;
|
||||
DeclareClass?: VisitNode<t.DeclareClass>;
|
||||
DeclareFunction?: VisitNode<t.DeclareFunction>;
|
||||
DeclareInterface?: VisitNode<t.DeclareInterface>;
|
||||
DeclareModule?: VisitNode<t.DeclareModule>;
|
||||
DeclareTypeAlias?: VisitNode<t.DeclareTypeAlias>;
|
||||
DeclareVariable?: VisitNode<t.DeclareVariable>;
|
||||
ExistentialTypeParam?: VisitNode<t.ExistentialTypeParam>;
|
||||
FunctionTypeAnnotation?: VisitNode<t.FunctionTypeAnnotation>;
|
||||
FunctionTypeParam?: VisitNode<t.FunctionTypeParam>;
|
||||
GenericTypeAnnotation?: VisitNode<t.GenericTypeAnnotation>;
|
||||
InterfaceExtends?: VisitNode<t.InterfaceExtends>;
|
||||
InterfaceDeclaration?: VisitNode<t.InterfaceDeclaration>;
|
||||
IntersectionTypeAnnotation?: VisitNode<t.IntersectionTypeAnnotation>;
|
||||
MixedTypeAnnotation?: VisitNode<t.MixedTypeAnnotation>;
|
||||
NullableTypeAnnotation?: VisitNode<t.NullableTypeAnnotation>;
|
||||
NumericLiteralTypeAnnotation?: VisitNode<t.NumericLiteralTypeAnnotation>;
|
||||
NumberTypeAnnotation?: VisitNode<t.NumberTypeAnnotation>;
|
||||
StringLiteralTypeAnnotation?: VisitNode<t.StringLiteralTypeAnnotation>;
|
||||
StringTypeAnnotation?: VisitNode<t.StringTypeAnnotation>;
|
||||
ThisTypeAnnotation?: VisitNode<t.ThisTypeAnnotation>;
|
||||
TupleTypeAnnotation?: VisitNode<t.TupleTypeAnnotation>;
|
||||
TypeofTypeAnnotation?: VisitNode<t.TypeofTypeAnnotation>;
|
||||
TypeAlias?: VisitNode<t.TypeAlias>;
|
||||
TypeAnnotation?: VisitNode<t.TypeAnnotation>;
|
||||
TypeCastExpression?: VisitNode<t.TypeCastExpression>;
|
||||
TypeParameterDeclaration?: VisitNode<t.TypeParameterDeclaration>;
|
||||
TypeParameterInstantiation?: VisitNode<t.TypeParameterInstantiation>;
|
||||
ObjectTypeAnnotation?: VisitNode<t.ObjectTypeAnnotation>;
|
||||
ObjectTypeCallProperty?: VisitNode<t.ObjectTypeCallProperty>;
|
||||
ObjectTypeIndexer?: VisitNode<t.ObjectTypeIndexer>;
|
||||
ObjectTypeProperty?: VisitNode<t.ObjectTypeProperty>;
|
||||
QualifiedTypeIdentifier?: VisitNode<t.QualifiedTypeIdentifier>;
|
||||
UnionTypeAnnotation?: VisitNode<t.UnionTypeAnnotation>;
|
||||
VoidTypeAnnotation?: VisitNode<t.VoidTypeAnnotation>;
|
||||
JSXAttribute?: VisitNode<t.JSXAttribute>;
|
||||
JSXIdentifier?: VisitNode<t.JSXIdentifier>;
|
||||
JSXNamespacedName?: VisitNode<t.JSXNamespacedName>;
|
||||
JSXElement?: VisitNode<t.JSXElement>;
|
||||
JSXExpressionContainer?: VisitNode<t.JSXExpressionContainer>;
|
||||
JSXClosingElement?: VisitNode<t.JSXClosingElement>;
|
||||
JSXMemberExpression?: VisitNode<t.JSXMemberExpression>;
|
||||
JSXOpeningElement?: VisitNode<t.JSXOpeningElement>;
|
||||
JSXEmptyExpression?: VisitNode<t.JSXEmptyExpression>;
|
||||
JSXSpreadAttribute?: VisitNode<t.JSXSpreadAttribute>;
|
||||
JSXText?: VisitNode<t.JSXText>;
|
||||
Noop?: VisitNode<t.Noop>;
|
||||
ParenthesizedExpression?: VisitNode<t.ParenthesizedExpression>;
|
||||
AwaitExpression?: VisitNode<t.AwaitExpression>;
|
||||
BindExpression?: VisitNode<t.BindExpression>;
|
||||
Decorator?: VisitNode<t.Decorator>;
|
||||
DoExpression?: VisitNode<t.DoExpression>;
|
||||
ExportDefaultSpecifier?: VisitNode<t.ExportDefaultSpecifier>;
|
||||
ExportNamespaceSpecifier?: VisitNode<t.ExportNamespaceSpecifier>;
|
||||
RestProperty?: VisitNode<t.RestProperty>;
|
||||
SpreadProperty?: VisitNode<t.SpreadProperty>;
|
||||
Binary?: VisitNode<t.Binary>;
|
||||
Scopable?: VisitNode<t.Scopable>;
|
||||
BlockParent?: VisitNode<t.BlockParent>;
|
||||
Block?: VisitNode<t.Block>;
|
||||
Terminatorless?: VisitNode<t.Terminatorless>;
|
||||
CompletionStatement?: VisitNode<t.CompletionStatement>;
|
||||
Conditional?: VisitNode<t.Conditional>;
|
||||
Loop?: VisitNode<t.Loop>;
|
||||
While?: VisitNode<t.While>;
|
||||
ExpressionWrapper?: VisitNode<t.ExpressionWrapper>;
|
||||
For?: VisitNode<t.For>;
|
||||
ForXStatement?: VisitNode<t.ForXStatement>;
|
||||
Function?: VisitNode<t.Function>;
|
||||
FunctionParent?: VisitNode<t.FunctionParent>;
|
||||
Pureish?: VisitNode<t.Pureish>;
|
||||
Literal?: VisitNode<t.Literal>;
|
||||
Immutable?: VisitNode<t.Immutable>;
|
||||
UserWhitespacable?: VisitNode<t.UserWhitespacable>;
|
||||
Method?: VisitNode<t.Method>;
|
||||
ObjectMember?: VisitNode<t.ObjectMember>;
|
||||
Property?: VisitNode<t.Property>;
|
||||
UnaryLike?: VisitNode<t.UnaryLike>;
|
||||
Pattern?: VisitNode<t.Pattern>;
|
||||
Class?: VisitNode<t.Class>;
|
||||
ModuleDeclaration?: VisitNode<t.ModuleDeclaration>;
|
||||
ExportDeclaration?: VisitNode<t.ExportDeclaration>;
|
||||
ModuleSpecifier?: VisitNode<t.ModuleSpecifier>;
|
||||
Flow?: VisitNode<t.Flow>;
|
||||
FlowBaseAnnotation?: VisitNode<t.FlowBaseAnnotation>;
|
||||
FlowDeclaration?: VisitNode<t.FlowDeclaration>;
|
||||
JSX?: VisitNode<t.JSX>;
|
||||
}
|
||||
|
||||
export type VisitNode<T> = VisitNodeFunction<T> | VisitNodeObject<T>;
|
||||
|
||||
export type VisitNodeFunction<T> = (path: NodePath<T>, state: any) => void;
|
||||
|
||||
export interface VisitNodeObject<T> {
|
||||
enter?(path: NodePath<T>, state: any): void;
|
||||
exit?(path: NodePath<T>, state: any): void;
|
||||
}
|
||||
|
||||
export class NodePath<T> {
|
||||
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<Node>;
|
||||
context: TraversalContext;
|
||||
container: Object | Object[];
|
||||
listKey: string;
|
||||
inList: boolean;
|
||||
parentKey: string;
|
||||
key: string;
|
||||
node: T;
|
||||
scope: Scope;
|
||||
type: string;
|
||||
typeAnnotation: Object;
|
||||
|
||||
getScope(scope: Scope): Scope;
|
||||
|
||||
setData(key: string, val: any): any;
|
||||
|
||||
getData(key: string, def?: any): any;
|
||||
|
||||
buildCodeFrameError(msg: string, Error: Error): Error;
|
||||
|
||||
traverse(visitor: Visitor, state?: any): void;
|
||||
|
||||
set(key: string, node: Node): void;
|
||||
|
||||
getPathLocation(): string;
|
||||
|
||||
debug(buildMessage: Function): 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<Node>) => boolean): NodePath<Node>;
|
||||
|
||||
find(callback: (path: NodePath<Node>) => boolean): NodePath<Node>;
|
||||
|
||||
/** Get the parent function of the current path. */
|
||||
getFunctionParent(): NodePath<Node>;
|
||||
|
||||
/** Walk up the tree until we hit a parent node path in a list. */
|
||||
getStatementParent(): NodePath<Node>;
|
||||
|
||||
/**
|
||||
* 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<Node>[]): NodePath<Node>;
|
||||
|
||||
/** Get the earliest path in the tree where the provided `paths` intersect. */
|
||||
getDeepestCommonAncestorFrom(paths: NodePath<Node>[], filter?: Function): NodePath<Node>;
|
||||
|
||||
/**
|
||||
* 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<Node>[];
|
||||
|
||||
inType(...candidateTypes: string[]): boolean;
|
||||
|
||||
// ------------------------- inference -------------------------
|
||||
/** Infer the type of the current `NodePath`. */
|
||||
getTypeAnnotation(): t.FlowTypeAnnotation;
|
||||
|
||||
isBaseType(baseName: string, soft?: boolean): boolean;
|
||||
|
||||
couldBeBaseType(name: string): boolean;
|
||||
|
||||
baseTypeStrictlyMatches(right: NodePath<Node>): 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<Node>): 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;
|
||||
|
||||
// ------------------------- 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 -------------------------
|
||||
getStatementParent(): NodePath<Node>;
|
||||
|
||||
getOpposite(): NodePath<Node>;
|
||||
|
||||
getCompletionRecords(): NodePath<Node>[];
|
||||
|
||||
getSibling(key: string): NodePath<Node>;
|
||||
|
||||
get(key: string, context?: boolean | TraversalContext): NodePath<Node>;
|
||||
|
||||
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): boolean;
|
||||
isAssignmentExpression(opts?: Object): boolean;
|
||||
isBinaryExpression(opts?: Object): boolean;
|
||||
isDirective(opts?: Object): boolean;
|
||||
isDirectiveLiteral(opts?: Object): boolean;
|
||||
isBlockStatement(opts?: Object): boolean;
|
||||
isBreakStatement(opts?: Object): boolean;
|
||||
isCallExpression(opts?: Object): boolean;
|
||||
isCatchClause(opts?: Object): boolean;
|
||||
isConditionalExpression(opts?: Object): boolean;
|
||||
isContinueStatement(opts?: Object): boolean;
|
||||
isDebuggerStatement(opts?: Object): boolean;
|
||||
isDoWhileStatement(opts?: Object): boolean;
|
||||
isEmptyStatement(opts?: Object): boolean;
|
||||
isExpressionStatement(opts?: Object): boolean;
|
||||
isFile(opts?: Object): boolean;
|
||||
isForInStatement(opts?: Object): boolean;
|
||||
isForStatement(opts?: Object): boolean;
|
||||
isFunctionDeclaration(opts?: Object): boolean;
|
||||
isFunctionExpression(opts?: Object): boolean;
|
||||
isIdentifier(opts?: Object): boolean;
|
||||
isIfStatement(opts?: Object): boolean;
|
||||
isLabeledStatement(opts?: Object): boolean;
|
||||
isStringLiteral(opts?: Object): boolean;
|
||||
isNumericLiteral(opts?: Object): boolean;
|
||||
isNullLiteral(opts?: Object): boolean;
|
||||
isBooleanLiteral(opts?: Object): boolean;
|
||||
isRegExpLiteral(opts?: Object): boolean;
|
||||
isLogicalExpression(opts?: Object): boolean;
|
||||
isMemberExpression(opts?: Object): boolean;
|
||||
isNewExpression(opts?: Object): boolean;
|
||||
isProgram(opts?: Object): boolean;
|
||||
isObjectExpression(opts?: Object): boolean;
|
||||
isObjectMethod(opts?: Object): boolean;
|
||||
isObjectProperty(opts?: Object): boolean;
|
||||
isRestElement(opts?: Object): boolean;
|
||||
isReturnStatement(opts?: Object): boolean;
|
||||
isSequenceExpression(opts?: Object): boolean;
|
||||
isSwitchCase(opts?: Object): boolean;
|
||||
isSwitchStatement(opts?: Object): boolean;
|
||||
isThisExpression(opts?: Object): boolean;
|
||||
isThrowStatement(opts?: Object): boolean;
|
||||
isTryStatement(opts?: Object): boolean;
|
||||
isUnaryExpression(opts?: Object): boolean;
|
||||
isUpdateExpression(opts?: Object): boolean;
|
||||
isVariableDeclaration(opts?: Object): boolean;
|
||||
isVariableDeclarator(opts?: Object): boolean;
|
||||
isWhileStatement(opts?: Object): boolean;
|
||||
isWithStatement(opts?: Object): boolean;
|
||||
isAssignmentPattern(opts?: Object): boolean;
|
||||
isArrayPattern(opts?: Object): boolean;
|
||||
isArrowFunctionExpression(opts?: Object): boolean;
|
||||
isClassBody(opts?: Object): boolean;
|
||||
isClassDeclaration(opts?: Object): boolean;
|
||||
isClassExpression(opts?: Object): boolean;
|
||||
isExportAllDeclaration(opts?: Object): boolean;
|
||||
isExportDefaultDeclaration(opts?: Object): boolean;
|
||||
isExportNamedDeclaration(opts?: Object): boolean;
|
||||
isExportSpecifier(opts?: Object): boolean;
|
||||
isForOfStatement(opts?: Object): boolean;
|
||||
isImportDeclaration(opts?: Object): boolean;
|
||||
isImportDefaultSpecifier(opts?: Object): boolean;
|
||||
isImportNamespaceSpecifier(opts?: Object): boolean;
|
||||
isImportSpecifier(opts?: Object): boolean;
|
||||
isMetaProperty(opts?: Object): boolean;
|
||||
isClassMethod(opts?: Object): boolean;
|
||||
isObjectPattern(opts?: Object): boolean;
|
||||
isSpreadElement(opts?: Object): boolean;
|
||||
isSuper(opts?: Object): boolean;
|
||||
isTaggedTemplateExpression(opts?: Object): boolean;
|
||||
isTemplateElement(opts?: Object): boolean;
|
||||
isTemplateLiteral(opts?: Object): boolean;
|
||||
isYieldExpression(opts?: Object): boolean;
|
||||
isAnyTypeAnnotation(opts?: Object): boolean;
|
||||
isArrayTypeAnnotation(opts?: Object): boolean;
|
||||
isBooleanTypeAnnotation(opts?: Object): boolean;
|
||||
isBooleanLiteralTypeAnnotation(opts?: Object): boolean;
|
||||
isNullLiteralTypeAnnotation(opts?: Object): boolean;
|
||||
isClassImplements(opts?: Object): boolean;
|
||||
isClassProperty(opts?: Object): boolean;
|
||||
isDeclareClass(opts?: Object): boolean;
|
||||
isDeclareFunction(opts?: Object): boolean;
|
||||
isDeclareInterface(opts?: Object): boolean;
|
||||
isDeclareModule(opts?: Object): boolean;
|
||||
isDeclareTypeAlias(opts?: Object): boolean;
|
||||
isDeclareVariable(opts?: Object): boolean;
|
||||
isExistentialTypeParam(opts?: Object): boolean;
|
||||
isFunctionTypeAnnotation(opts?: Object): boolean;
|
||||
isFunctionTypeParam(opts?: Object): boolean;
|
||||
isGenericTypeAnnotation(opts?: Object): boolean;
|
||||
isInterfaceExtends(opts?: Object): boolean;
|
||||
isInterfaceDeclaration(opts?: Object): boolean;
|
||||
isIntersectionTypeAnnotation(opts?: Object): boolean;
|
||||
isMixedTypeAnnotation(opts?: Object): boolean;
|
||||
isNullableTypeAnnotation(opts?: Object): boolean;
|
||||
isNumericLiteralTypeAnnotation(opts?: Object): boolean;
|
||||
isNumberTypeAnnotation(opts?: Object): boolean;
|
||||
isStringLiteralTypeAnnotation(opts?: Object): boolean;
|
||||
isStringTypeAnnotation(opts?: Object): boolean;
|
||||
isThisTypeAnnotation(opts?: Object): boolean;
|
||||
isTupleTypeAnnotation(opts?: Object): boolean;
|
||||
isTypeofTypeAnnotation(opts?: Object): boolean;
|
||||
isTypeAlias(opts?: Object): boolean;
|
||||
isTypeAnnotation(opts?: Object): boolean;
|
||||
isTypeCastExpression(opts?: Object): boolean;
|
||||
isTypeParameterDeclaration(opts?: Object): boolean;
|
||||
isTypeParameterInstantiation(opts?: Object): boolean;
|
||||
isObjectTypeAnnotation(opts?: Object): boolean;
|
||||
isObjectTypeCallProperty(opts?: Object): boolean;
|
||||
isObjectTypeIndexer(opts?: Object): boolean;
|
||||
isObjectTypeProperty(opts?: Object): boolean;
|
||||
isQualifiedTypeIdentifier(opts?: Object): boolean;
|
||||
isUnionTypeAnnotation(opts?: Object): boolean;
|
||||
isVoidTypeAnnotation(opts?: Object): boolean;
|
||||
isJSXAttribute(opts?: Object): boolean;
|
||||
isJSXClosingElement(opts?: Object): boolean;
|
||||
isJSXElement(opts?: Object): boolean;
|
||||
isJSXEmptyExpression(opts?: Object): boolean;
|
||||
isJSXExpressionContainer(opts?: Object): boolean;
|
||||
isJSXIdentifier(opts?: Object): boolean;
|
||||
isJSXMemberExpression(opts?: Object): boolean;
|
||||
isJSXNamespacedName(opts?: Object): boolean;
|
||||
isJSXOpeningElement(opts?: Object): boolean;
|
||||
isJSXSpreadAttribute(opts?: Object): boolean;
|
||||
isJSXText(opts?: Object): boolean;
|
||||
isNoop(opts?: Object): boolean;
|
||||
isParenthesizedExpression(opts?: Object): boolean;
|
||||
isAwaitExpression(opts?: Object): boolean;
|
||||
isBindExpression(opts?: Object): boolean;
|
||||
isDecorator(opts?: Object): boolean;
|
||||
isDoExpression(opts?: Object): boolean;
|
||||
isExportDefaultSpecifier(opts?: Object): boolean;
|
||||
isExportNamespaceSpecifier(opts?: Object): boolean;
|
||||
isRestProperty(opts?: Object): boolean;
|
||||
isSpreadProperty(opts?: Object): boolean;
|
||||
isExpression(opts?: Object): boolean;
|
||||
isBinary(opts?: Object): boolean;
|
||||
isScopable(opts?: Object): boolean;
|
||||
isBlockParent(opts?: Object): boolean;
|
||||
isBlock(opts?: Object): boolean;
|
||||
isStatement(opts?: Object): boolean;
|
||||
isTerminatorless(opts?: Object): boolean;
|
||||
isCompletionStatement(opts?: Object): boolean;
|
||||
isConditional(opts?: Object): boolean;
|
||||
isLoop(opts?: Object): boolean;
|
||||
isWhile(opts?: Object): boolean;
|
||||
isExpressionWrapper(opts?: Object): boolean;
|
||||
isFor(opts?: Object): boolean;
|
||||
isForXStatement(opts?: Object): boolean;
|
||||
isFunction(opts?: Object): boolean;
|
||||
isFunctionParent(opts?: Object): boolean;
|
||||
isPureish(opts?: Object): boolean;
|
||||
isDeclaration(opts?: Object): boolean;
|
||||
isLVal(opts?: Object): boolean;
|
||||
isLiteral(opts?: Object): boolean;
|
||||
isImmutable(opts?: Object): boolean;
|
||||
isUserWhitespacable(opts?: Object): boolean;
|
||||
isMethod(opts?: Object): boolean;
|
||||
isObjectMember(opts?: Object): boolean;
|
||||
isProperty(opts?: Object): boolean;
|
||||
isUnaryLike(opts?: Object): boolean;
|
||||
isPattern(opts?: Object): boolean;
|
||||
isClass(opts?: Object): boolean;
|
||||
isModuleDeclaration(opts?: Object): boolean;
|
||||
isExportDeclaration(opts?: Object): boolean;
|
||||
isModuleSpecifier(opts?: Object): boolean;
|
||||
isFlow(opts?: Object): boolean;
|
||||
isFlowBaseAnnotation(opts?: Object): boolean;
|
||||
isFlowDeclaration(opts?: Object): boolean;
|
||||
isJSX(opts?: Object): boolean;
|
||||
isNumberLiteral(opts?: Object): boolean;
|
||||
isRegexLiteral(opts?: Object): boolean;
|
||||
isReferencedIdentifier(opts?: Object): boolean;
|
||||
isReferencedMemberExpression(opts?: Object): boolean;
|
||||
isBindingIdentifier(opts?: Object): boolean;
|
||||
isScope(opts?: Object): boolean;
|
||||
isReferenced(opts?: Object): boolean;
|
||||
isBlockScoped(opts?: Object): boolean;
|
||||
isVar(opts?: Object): boolean;
|
||||
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;
|
||||
}
|
||||
|
||||
interface TraversalContext {
|
||||
parentPath: NodePath<Node>;
|
||||
scope: Scope;
|
||||
state: any;
|
||||
opts: any;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/// <reference path="babel-types.d.ts" />
|
||||
/// <reference path="../babel-traverse/babel-traverse.d.ts" />
|
||||
|
||||
|
||||
// Examples from https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babel-types
|
||||
import traverse from "babel-traverse";
|
||||
import * as t from "babel-types";
|
||||
|
||||
let ast: t.Node;
|
||||
|
||||
traverse(ast, {
|
||||
enter(path) {
|
||||
let node = path.node;
|
||||
if (t.isIdentifier(node, { name: "n" })) {
|
||||
node.name = "x";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (t.isBinaryExpression(ast)) {
|
||||
ast.left;
|
||||
ast.right;
|
||||
ast.operator;
|
||||
}
|
||||
t.assertBinaryExpression(ast);
|
||||
t.assertBinaryExpression(ast, { operator: "*" });
|
||||
Vendored
+1403
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,24 @@
|
||||
/// <reference path="babylon.d.ts" />
|
||||
/// <reference path="../babel-types/babel-types.d.ts" />
|
||||
/// <reference path="../babel-types/babel-types.d.ts" />
|
||||
|
||||
|
||||
// Example from https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md#babylon
|
||||
import * as babylon from "babylon";
|
||||
declare function assert(expr: boolean): void;
|
||||
|
||||
const code = `function square(n) {
|
||||
return n * n;
|
||||
}`;
|
||||
|
||||
let node = babylon.parse(code);
|
||||
assert(node.type === "File");
|
||||
assert(node.start === 0);
|
||||
assert(node.end === 38);
|
||||
assert(node.loc.start > node.loc.end);
|
||||
|
||||
|
||||
babylon.parse(code, {
|
||||
sourceType: "module", // default: "script"
|
||||
plugins: ["jsx"] // default: []
|
||||
});
|
||||
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
// Type definitions for babylon v6.7
|
||||
// Project: https://github.com/babel/babylon
|
||||
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../babel-types/babel-types.d.ts" />
|
||||
|
||||
declare module "babylon" {
|
||||
import * as t from 'babel-types';
|
||||
type Node = t.Node;
|
||||
|
||||
export function parse(code: string, opts?: BabylonOptions): Node;
|
||||
|
||||
export interface BabylonOptions {
|
||||
/**
|
||||
* By default, import and export declarations can only appear at a program's top level.
|
||||
* Setting this option to true allows them anywhere where a statement is allowed.
|
||||
*/
|
||||
allowImportExportEverywhere?: boolean;
|
||||
|
||||
/**
|
||||
* By default, a return statement at the top level raises an error. Set this to true to accept such code.
|
||||
*/
|
||||
allowReturnOutsideFunction?: boolean;
|
||||
|
||||
allowSuperOutsideMethod?: boolean;
|
||||
|
||||
/**
|
||||
* Indicate the mode the code should be parsed in. Can be either "script" or "module".
|
||||
*/
|
||||
sourceType?: 'script' | 'module';
|
||||
|
||||
/**
|
||||
* Correlate output AST nodes with their source filename. Useful when
|
||||
* generating code and source maps from the ASTs of multiple input files.
|
||||
*/
|
||||
sourceFilename?: string;
|
||||
|
||||
/**
|
||||
* Array containing the plugins that you want to enable.
|
||||
*/
|
||||
plugins?: PluginName[];
|
||||
}
|
||||
|
||||
export type PluginName = 'jsx' | 'flow' | 'asyncFunctions' | 'classConstructorCall' | 'doExpressions'
|
||||
| 'trailingFunctionCommas' | 'objectRestSpread' | 'decorators' | 'classProperties' | 'exportExtensions'
|
||||
| 'exponentiationOperator' | 'asyncGenerators' | 'functionBind' | 'functionSent';
|
||||
}
|
||||
+6
@@ -36,6 +36,7 @@ declare namespace Chai {
|
||||
// From chai
|
||||
not: PromisedAssertion;
|
||||
deep: PromisedDeep;
|
||||
all: PromisedKeyFilter;
|
||||
a: PromisedTypeComparison;
|
||||
an: PromisedTypeComparison;
|
||||
include: PromisedInclude;
|
||||
@@ -129,6 +130,10 @@ declare namespace Chai {
|
||||
property: PromisedProperty;
|
||||
}
|
||||
|
||||
interface PromisedKeyFilter {
|
||||
keys: PromisedKeys;
|
||||
}
|
||||
|
||||
interface PromisedEqual {
|
||||
(value: any, message?: string): PromisedAssertion;
|
||||
}
|
||||
@@ -151,6 +156,7 @@ declare namespace Chai {
|
||||
(value: number, message?: string): PromisedAssertion;
|
||||
keys: PromisedKeys;
|
||||
members: PromisedMembers;
|
||||
all: PromisedKeyFilter;
|
||||
}
|
||||
|
||||
interface PromisedKeys {
|
||||
|
||||
Vendored
+6
@@ -1063,6 +1063,12 @@ declare namespace CodeMirror {
|
||||
*/
|
||||
function defineMode(id: string, modefactory: ModeFactory<any>): void;
|
||||
|
||||
/**
|
||||
* id will be the id for the defined mode. Typically, you should use this second argument to defineMode as your module scope function
|
||||
* (modes should not leak anything into the global scope!), i.e. write your whole mode inside this function.
|
||||
*/
|
||||
function defineMode<T>(id: string, modefactory: ModeFactory<T>): void;
|
||||
|
||||
/**
|
||||
* The first argument is a configuration object as passed to the mode constructor function, and the second argument
|
||||
* is a mode specification as in the EditorConfiguration mode option.
|
||||
|
||||
@@ -80,9 +80,8 @@ promiseNumber = catchWithSimpleResult;
|
||||
var catchWithPromiseResult = promiseString.catch(error => Promise.resolve(10));
|
||||
promiseNumber = catchWithPromiseResult;
|
||||
|
||||
promiseString = promiseString.catch<string>(function () {
|
||||
promiseString = promiseString.catch<string>(function (): string {
|
||||
throw new Error('Better error msg');
|
||||
return null;
|
||||
});
|
||||
|
||||
//examples coming from http://www.html5rocks.com/en/tutorials/es6/promises/
|
||||
|
||||
Vendored
+10
-1
@@ -58,7 +58,16 @@ declare namespace Promise {
|
||||
* the array passed to all can be a mixture of promise-like objects and other objects.
|
||||
* The fulfillment value is an array (in order) of fulfillment values. The rejection value is the first rejection value.
|
||||
*/
|
||||
function all<T>(promises: (T | Thenable<T>)[]): Promise<T[]>;
|
||||
function all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>, T9 | Thenable<T9>, T10 | Thenable<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
|
||||
function all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>, T9 | Thenable<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
|
||||
function all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>, T8 | Thenable<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
|
||||
function all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>, T7 | Thenable<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
|
||||
function all<T1, T2, T3, T4, T5, T6>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>, T6 | Thenable<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
|
||||
function all<T1, T2, T3, T4, T5>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>, T5 | Thenable<T5>]): Promise<[T1, T2, T3, T4, T5]>;
|
||||
function all<T1, T2, T3, T4>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>, T4 | Thenable <T4>]): Promise<[T1, T2, T3, T4]>;
|
||||
function all<T1, T2, T3>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>, T3 | Thenable<T3>]): Promise<[T1, T2, T3]>;
|
||||
function all<T1, T2>(values: [T1 | Thenable<T1>, T2 | Thenable<T2>]): Promise<[T1, T2]>;
|
||||
function all<T>(values: (T | Thenable<T>)[]): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Make a Promise that fulfills when any item fulfills, and rejects if any item rejects.
|
||||
|
||||
Vendored
+3
-3
@@ -12,6 +12,7 @@ declare module "hapi" {
|
||||
import http = require("http");
|
||||
import stream = require("stream");
|
||||
import Events = require("events");
|
||||
import url = require("url");
|
||||
|
||||
interface IDictionary<T> {
|
||||
[key: string]: T;
|
||||
@@ -303,7 +304,7 @@ declare module "hapi" {
|
||||
response(result: any): Response;
|
||||
|
||||
/** Sets a cookie on the response */
|
||||
state(name: string, value: string, options?: any): void;
|
||||
state(name: string, value: any, options?: any): void;
|
||||
|
||||
/** Clears a cookie on the response */
|
||||
unstate(name: string, options?: any): void;
|
||||
@@ -1250,8 +1251,7 @@ declare module "hapi" {
|
||||
request.setUrl('/test');
|
||||
return reply.continue();
|
||||
});*/
|
||||
setUrl(url: string): void;
|
||||
|
||||
setUrl(url: string | url.Url): void;
|
||||
/** request.setMethod(method)
|
||||
|
||||
Available only in 'onRequest' extension methods.
|
||||
|
||||
Vendored
+5
@@ -80,3 +80,8 @@ interface HelloJSServiceDef {
|
||||
}
|
||||
|
||||
declare var hello: HelloJSStatic;
|
||||
|
||||
// Support AMD require
|
||||
declare module 'hellojs' {
|
||||
export = hello;
|
||||
}
|
||||
|
||||
+39
-1
@@ -110,8 +110,46 @@ function noSniffTest() {
|
||||
*/
|
||||
function publicKeyPinsTest() {
|
||||
app.use(helmet.publicKeyPins({
|
||||
maxAge: 7776000000,
|
||||
sha256s: ["AbCdEf123=", "ZyXwVu456="],
|
||||
}));
|
||||
|
||||
app.use(helmet.publicKeyPins({
|
||||
maxAge: 7776000000,
|
||||
sha256s: ["AbCdEf123=", "ZyXwVu456="],
|
||||
includeSubdomains: false
|
||||
}));
|
||||
|
||||
app.use(helmet.publicKeyPins({
|
||||
maxAge: 7776000000,
|
||||
sha256s: ["AbCdEf123=", "ZyXwVu456="],
|
||||
includeSubdomains: true
|
||||
}));
|
||||
|
||||
app.use(helmet.publicKeyPins({
|
||||
maxAge: 7776000000,
|
||||
sha256s: ["AbCdEf123=", "ZyXwVu456="],
|
||||
includeSubdomains: true,
|
||||
reportUri: "http://example.com"
|
||||
}));
|
||||
|
||||
app.use(helmet.publicKeyPins({
|
||||
maxAge: 7776000000,
|
||||
sha256s: ["AbCdEf123=", "ZyXwVu456="],
|
||||
reportOnly: true
|
||||
}));
|
||||
|
||||
app.use(helmet.publicKeyPins({
|
||||
maxAge: 7776000000,
|
||||
sha256s: ["AbCdEf123=", "ZyXwVu456="],
|
||||
setIf: function (req, res) { return true; }
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Test for {@see helmet#dnsPrefetchControl} function.
|
||||
*/
|
||||
function dnsPrefetchControlTest() {
|
||||
app.use(helmet.dnsPrefetchControl());
|
||||
app.use(helmet.dnsPrefetchControl({ allow: false }));
|
||||
app.use(helmet.dnsPrefetchControl({ allow: true }));
|
||||
}
|
||||
|
||||
Vendored
+23
-1
@@ -40,10 +40,27 @@ declare module "helmet" {
|
||||
directives? : IHelmetCspDirectives
|
||||
}
|
||||
|
||||
interface IHelmetPublicKeyPinsSetIfFunction {
|
||||
(req: express.Request, res: express.Response): boolean;
|
||||
}
|
||||
|
||||
interface IHelmetPublicKeyPinsConfiguration {
|
||||
maxAge : number;
|
||||
sha256s : string[];
|
||||
includeSubdomains? : boolean;
|
||||
reportUri? : string;
|
||||
reportOnly? : boolean;
|
||||
setIf?: IHelmetPublicKeyPinsSetIfFunction
|
||||
}
|
||||
|
||||
interface IHelmetXssFilterConfiguration {
|
||||
setOnOldIE? : boolean;
|
||||
}
|
||||
|
||||
interface IHelmetDnsPrefetchControlConfiguration {
|
||||
allow? : boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* @summary Interface for helmet class.
|
||||
* @interface
|
||||
@@ -55,6 +72,11 @@ declare module "helmet" {
|
||||
*/
|
||||
():express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Stop browsers from doing DNS prefetching.
|
||||
*/
|
||||
dnsPrefetchControl(options ?: IHelmetDnsPrefetchControlConfiguration):express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Prevent clickjacking.
|
||||
* @param {string} header The header.
|
||||
@@ -98,7 +120,7 @@ declare module "helmet" {
|
||||
* @summary Adds the "Public-Key-Pins" header.
|
||||
* @return {RequestHandler} The Request handler.
|
||||
*/
|
||||
publicKeyPins(options ?: Object):express.RequestHandler;
|
||||
publicKeyPins(options ?: IHelmetPublicKeyPinsConfiguration):express.RequestHandler;
|
||||
|
||||
/**
|
||||
* @summary Mitigate cross-site scripting attacks with the "X-XSS-Protection" header.
|
||||
|
||||
@@ -387,6 +387,7 @@ class IonicTestController {
|
||||
ready = ionic.Platform.ready(callbackWithReturn);
|
||||
var setGrade: void = ionic.Platform.setGrade('iOS');
|
||||
var deviceInformation: string = ionic.Platform.device();
|
||||
var isBrowser: boolean = ionic.Platform.is('browser');
|
||||
var isWebView: boolean = ionic.Platform.isWebView();
|
||||
var isIPad: boolean = ionic.Platform.isIPad();
|
||||
var isIOS: boolean = ionic.Platform.isIOS();
|
||||
|
||||
Vendored
+4
@@ -32,6 +32,10 @@ interface IonicStatic {
|
||||
* Return the current device (given by cordova).
|
||||
*/
|
||||
device(): any;
|
||||
/**
|
||||
* Check if the platform name provided is detected.
|
||||
*/
|
||||
is(platformName: string): boolean;
|
||||
/**
|
||||
* Check if we are running within a WebView (such as Cordova).
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/// <reference path="../jquery/jquery.d.ts"/>
|
||||
/// <reference path="jquery-backstretch.d.ts"/>
|
||||
|
||||
var backstretch = jQuery.backstretch(['image.png'], {
|
||||
centeredX: false,
|
||||
centeredY: false,
|
||||
duration: 'normal',
|
||||
fade: 1000
|
||||
});
|
||||
|
||||
backstretch.next();
|
||||
backstretch.prev();
|
||||
backstretch.pause();
|
||||
backstretch.resize();
|
||||
backstretch.resume();
|
||||
backstretch.destroy(true);
|
||||
|
||||
jQuery('body').backstretch(['image.png']).pause();
|
||||
jQuery('body').backstretch('resume');
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
// Type definitions for backstretch v 2.0.4
|
||||
// Project: https://github.com/srobbin/jquery-backstretch
|
||||
// Definitions by: Dmytro Kulyk <https://github.com/dkulyk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
|
||||
declare namespace JQueryBackStretch {
|
||||
|
||||
interface BackStretchOptions {
|
||||
/**
|
||||
* The ratio of the width/height of the image doesn't always jive with the
|
||||
* width/height of the window. This parameter controls whether or not we
|
||||
* center the image on the X axis to account for the discrepancy.
|
||||
*/
|
||||
centeredX?:boolean;
|
||||
|
||||
/**
|
||||
* This parameter controls whether or not we center the image on the Y axis
|
||||
* to account for the aforementioned discrepancy.
|
||||
*/
|
||||
centeredY?:boolean;
|
||||
|
||||
/**
|
||||
* This is the speed at which the image will fade in. Integers in
|
||||
* milliseconds are accepted, as well as standard jQuery speed strings
|
||||
* (slow, normal, fast).
|
||||
*/
|
||||
duration?:number | string;
|
||||
|
||||
/**
|
||||
* The amount of time in between slides, when using Backstretch as a
|
||||
* slideshow, expressed as the number of milliseconds.
|
||||
*/
|
||||
fade?:number;
|
||||
}
|
||||
|
||||
interface BackStretch {
|
||||
/**
|
||||
* This method is called automatically when the container (window or
|
||||
* block-level element) is resized, however you can always call this
|
||||
* manually if needed.
|
||||
*/
|
||||
resize():BackStretch;
|
||||
|
||||
/**
|
||||
* Jump to the slide at a given index, where n is the number of the
|
||||
* image that you'd like to display. Slide number starts at 0.
|
||||
*
|
||||
* @param {number} newIndex
|
||||
*/
|
||||
show(newIndex:number):BackStretch;
|
||||
|
||||
/**
|
||||
* Advance to the next image in a slideshow.
|
||||
*/
|
||||
next():BackStretch;
|
||||
|
||||
/**
|
||||
* Display the previous image in a slideshow.
|
||||
*/
|
||||
prev():BackStretch;
|
||||
|
||||
/**
|
||||
* Pause the slideshow.
|
||||
*/
|
||||
pause():BackStretch;
|
||||
|
||||
/**
|
||||
* Resume a paused slideshow.
|
||||
*/
|
||||
resume():BackStretch;
|
||||
|
||||
/**
|
||||
* Destroy the Backstretch instance. Optionally, you can pass in a Boolean
|
||||
* parameter, preserveBackground, to determine whether or not you'd like
|
||||
* to keep the current image stretched as the background image.
|
||||
*
|
||||
* @param {boolean} preserveBackground
|
||||
*/
|
||||
destroy(preserveBackground?:boolean):void;
|
||||
}
|
||||
}
|
||||
|
||||
interface JQueryStatic {
|
||||
backstretch(images:string[], config?:JQueryBackStretch.BackStretchOptions):JQueryBackStretch.BackStretch;
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
backstretch(images:string[], config?:JQueryBackStretch.BackStretchOptions):JQueryBackStretch.BackStretch;
|
||||
backstretch(method:string):JQuery;
|
||||
}
|
||||
@@ -2528,6 +2528,18 @@ function test_jQuery() {
|
||||
$.post('url.xml', function (data) {
|
||||
var $child = $(data).find('child');
|
||||
});
|
||||
$.post({
|
||||
url: "test.php",
|
||||
success : () => {
|
||||
console.log("successfull");
|
||||
}
|
||||
});
|
||||
$.get({
|
||||
url: "test.php",
|
||||
success : () => {
|
||||
console.log("successfull");
|
||||
}
|
||||
});
|
||||
var foo = { foo: 'bar', hello: 'world' };
|
||||
var $foo = $(foo);
|
||||
var test1 = $foo.prop('foo');
|
||||
|
||||
Vendored
+12
-1
@@ -676,6 +676,12 @@ interface JQueryStatic {
|
||||
* @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).
|
||||
*/
|
||||
get(url: string, data?: Object|string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR;
|
||||
/**
|
||||
* Load data from the server using a HTTP GET request.
|
||||
*
|
||||
* @param settings The JQueryAjaxSettings to be used for the request
|
||||
*/
|
||||
get(settings : JQueryAjaxSettings): JQueryXHR;
|
||||
/**
|
||||
* Load JSON-encoded data from the server using a GET HTTP request.
|
||||
*
|
||||
@@ -721,7 +727,12 @@ interface JQueryStatic {
|
||||
* @param dataType The type of data expected from the server. Default: Intelligent Guess (xml, json, script, text, html).
|
||||
*/
|
||||
post(url: string, data?: Object|string, success?: (data: any, textStatus: string, jqXHR: JQueryXHR) => any, dataType?: string): JQueryXHR;
|
||||
|
||||
/**
|
||||
* Load data from the server using a HTTP POST request.
|
||||
*
|
||||
* @param settings The JQueryAjaxSettings to be used for the request
|
||||
*/
|
||||
post(settings : JQueryAjaxSettings): JQueryXHR;
|
||||
/**
|
||||
* A multi-purpose callbacks list object that provides a powerful way to manage callback lists.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/// <reference path="../koa/koa.d.ts" />
|
||||
/// <reference path="koa-mount.d.ts" />
|
||||
|
||||
import * as Koa from "koa";
|
||||
import mount = require("koa-mount");
|
||||
|
||||
const a = new Koa();
|
||||
|
||||
a.use((next) => {
|
||||
this.body = "Hello";
|
||||
})
|
||||
|
||||
const b = new Koa();
|
||||
|
||||
b.use((next) => {
|
||||
this.body = "World";
|
||||
});
|
||||
|
||||
const app = new Koa();
|
||||
|
||||
app.use(mount("/hello", a));
|
||||
app.use(mount("/world", b));
|
||||
|
||||
app.listen(3000);
|
||||
console.log("listening on port 3000");
|
||||
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// Type definitions for koa-mount v2.0.0
|
||||
// Project: https://github.com/koajs/mount
|
||||
// Definitions by: AmirSaber Sharifi <https://github.com/amirsaber>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../koa/koa.d.ts" />
|
||||
|
||||
declare module "koa-mount" {
|
||||
|
||||
import * as Koa from "koa";
|
||||
|
||||
interface Function { (ctx: Koa.Context, next?: () => any): any }
|
||||
|
||||
function mount(app: Function): Function;
|
||||
|
||||
function mount(app: Koa): Function;
|
||||
|
||||
function mount(prefix: string, app: Function): Function;
|
||||
|
||||
function mount(prefix: string, app: Koa): Function;
|
||||
|
||||
export = mount;
|
||||
}
|
||||
+51
-421
File diff suppressed because it is too large
Load Diff
Vendored
+370
-663
File diff suppressed because it is too large
Load Diff
Vendored
+2
@@ -274,6 +274,8 @@ declare namespace log4javascript {
|
||||
messages: any[];
|
||||
exception: Error;
|
||||
|
||||
constructor(logger: Logger, timeStamp: Date, level: Level, messages: string[], exception?: Error);
|
||||
|
||||
getThrowableStrRep: () => string;
|
||||
getCombinedMessages: () => string;
|
||||
toString: () => string;
|
||||
|
||||
Vendored
+12
@@ -5,6 +5,18 @@
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module "ng-dialog" {
|
||||
export type IDialogService = angular.dialog.IDialogService;
|
||||
export type IDialogOpenResult = angular.dialog.IDialogOpenResult;
|
||||
export type IDialogClosePromise = angular.dialog.IDialogClosePromise;
|
||||
export type IDialogProvider = angular.dialog.IDialogProvider;
|
||||
export type IDialogScope = angular.dialog.IDialogScope;
|
||||
export type IDialogConfirmScope = angular.dialog.IDialogConfirmScope;
|
||||
export type IDialogOptions = angular.dialog.IDialogOptions;
|
||||
export type IDialogOpenOptions = angular.dialog.IDialogOpenOptions;
|
||||
export type IDialogOpenConfirmOptions = angular.dialog.IDialogOpenConfirmOptions;
|
||||
}
|
||||
|
||||
declare namespace angular.dialog {
|
||||
|
||||
interface IDialogService {
|
||||
|
||||
Vendored
+20
@@ -22,28 +22,45 @@ declare module "nock" {
|
||||
|
||||
export interface Scope {
|
||||
get(path: string, data?: string): Scope;
|
||||
get(path: RegExp, data?: string): Scope;
|
||||
|
||||
post(path: string, data?: string): Scope;
|
||||
post(path: string, data?: Object): Scope;
|
||||
post(path: string, regex?: RegExp): Scope;
|
||||
post(path: RegExp, data?: string): Scope;
|
||||
post(path: RegExp, data?: Object): Scope;
|
||||
post(path: RegExp, regex?: RegExp): Scope;
|
||||
|
||||
patch(path: string, data?: string): Scope;
|
||||
patch(path: string, data?: Object): Scope;
|
||||
patch(path: string, regex?: RegExp): Scope;
|
||||
patch(path: RegExp, data?: string): Scope;
|
||||
patch(path: RegExp, data?: Object): Scope;
|
||||
patch(path: RegExp, regex?: RegExp): Scope;
|
||||
|
||||
put(path: string, data?: string): Scope;
|
||||
put(path: string, data?: Object): Scope;
|
||||
put(path: string, regex?: RegExp): Scope;
|
||||
put(path: RegExp, data?: string): Scope;
|
||||
put(path: RegExp, data?: Object): Scope;
|
||||
put(path: RegExp, regex?: RegExp): Scope;
|
||||
|
||||
head(path: string): Scope;
|
||||
head(path: RegExp): Scope;
|
||||
|
||||
delete(path: string, data?: string): Scope;
|
||||
delete(path: string, data?: Object): Scope;
|
||||
delete(path: string, regex?: RegExp): Scope;
|
||||
delete(path: RegExp, data?: string): Scope;
|
||||
delete(path: RegExp, data?: Object): Scope;
|
||||
delete(path: RegExp, regex?: RegExp): Scope;
|
||||
|
||||
merge(path: string, data?: string): Scope;
|
||||
merge(path: string, data?: Object): Scope;
|
||||
merge(path: string, regex?: RegExp): Scope;
|
||||
merge(path: RegExp, data?: string): Scope;
|
||||
merge(path: RegExp, data?: Object): Scope;
|
||||
merge(path: RegExp, regex?: RegExp): Scope;
|
||||
|
||||
query(params: any): Scope;
|
||||
query(acceptAnyParams: boolean): Scope;
|
||||
@@ -51,6 +68,9 @@ declare module "nock" {
|
||||
intercept(path: string, verb: string, body?: string, options?: any): Scope;
|
||||
intercept(path: string, verb: string, body?: Object, options?: any): Scope;
|
||||
intercept(path: string, verb: string, body?: RegExp, options?: any): Scope;
|
||||
intercept(path: RegExp, verb: string, body?: string, options?: any): Scope;
|
||||
intercept(path: RegExp, verb: string, body?: Object, options?: any): Scope;
|
||||
intercept(path: RegExp, verb: string, body?: RegExp, options?: any): Scope;
|
||||
|
||||
reply(responseCode: number, body?: string, headers?: Object): Scope;
|
||||
reply(responseCode: number, body?: Object, headers?: Object): Scope;
|
||||
|
||||
@@ -15,6 +15,7 @@ import * as querystring from "querystring";
|
||||
import * as path from "path";
|
||||
import * as readline from "readline";
|
||||
import * as childProcess from "child_process";
|
||||
import * as cluster from "cluster";
|
||||
import * as os from "os";
|
||||
import * as vm from "vm";
|
||||
// Specifically test buffer module regression.
|
||||
@@ -643,6 +644,18 @@ namespace readline_tests {
|
||||
childProcess.exec("echo test");
|
||||
childProcess.spawnSync("echo test");
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
/// cluster tests: https://nodejs.org/api/cluster.html ///
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
cluster.fork();
|
||||
Object.keys(cluster.workers).forEach(key => {
|
||||
const worker = cluster.workers[key];
|
||||
if (worker.isDead()) {
|
||||
console.log('worker %d is dead', worker.process.pid);
|
||||
}
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
/// os tests : https://nodejs.org/api/os.html
|
||||
////////////////////////////////////////////////////
|
||||
|
||||
Vendored
+5
-1
@@ -679,6 +679,8 @@ declare module "cluster" {
|
||||
kill(signal?: string): void;
|
||||
destroy(signal?: string): void;
|
||||
disconnect(): void;
|
||||
isConnected(): boolean;
|
||||
isDead(): boolean;
|
||||
}
|
||||
|
||||
export var settings: ClusterSettings;
|
||||
@@ -688,7 +690,9 @@ declare module "cluster" {
|
||||
export function fork(env?: any): Worker;
|
||||
export function disconnect(callback?: Function): void;
|
||||
export var worker: Worker;
|
||||
export var workers: Worker[];
|
||||
export var workers: {
|
||||
[index: string]: Worker
|
||||
};
|
||||
|
||||
// Event emitter
|
||||
export function addListener(event: string, listener: Function): void;
|
||||
|
||||
@@ -0,0 +1,270 @@
|
||||
/// <reference path="normalizr.d.ts" />
|
||||
|
||||
import { normalize, Schema, arrayOf, unionOf, valuesOf } from 'normalizr';
|
||||
|
||||
// First, define a schema for our entities:
|
||||
|
||||
const article1 = new Schema('articles');
|
||||
const user1 = new Schema('users');
|
||||
|
||||
// Then we define nesting rules:
|
||||
|
||||
article1.define({
|
||||
author: user1,
|
||||
contributors: arrayOf(user1)
|
||||
});
|
||||
|
||||
// Now we can use this schema in our API response handlers:
|
||||
|
||||
const ServerActionCreators = {
|
||||
// These are two different XHR endpoints with different response schemas.
|
||||
// We can use the schema objects defined earlier to express both of them:
|
||||
|
||||
receiveOneArticle(response: any) {
|
||||
// Here, the response is an object containing data about one article.
|
||||
// Passing the article schema as second parameter to normalize() lets it
|
||||
// correctly traverse the response tree and gather all entities:
|
||||
|
||||
// BEFORE:
|
||||
// {
|
||||
// id: 1,
|
||||
// title: 'Some Article',
|
||||
// author: {
|
||||
// id: 7,
|
||||
// name: 'Dan'
|
||||
// },
|
||||
// contributors: [{
|
||||
// id: 10,
|
||||
// name: 'Abe'
|
||||
// }, {
|
||||
// id: 15,
|
||||
// name: 'Fred'
|
||||
// }]
|
||||
// }
|
||||
//
|
||||
// AFTER:
|
||||
// {
|
||||
// result: 1, // <--- Note object is referenced by ID
|
||||
// entities: {
|
||||
// articles: {
|
||||
// 1: {
|
||||
// author: 7, // <--- Same happens for references to
|
||||
// contributors: [10, 15] // <--- other entities in the schema
|
||||
// ...}
|
||||
// },
|
||||
// users: {
|
||||
// 7: { ... },
|
||||
// 10: { ... },
|
||||
// 15: { ... }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
response = normalize(response, article1);
|
||||
},
|
||||
|
||||
receiveAllArticles(response: any) {
|
||||
// Here, the response is an object with the key 'articles' referencing
|
||||
// an array of article objects. Passing { articles: arrayOf(article) } as
|
||||
// second parameter to normalize() lets it correctly traverse the response
|
||||
// tree and gather all entities:
|
||||
|
||||
// BEFORE:
|
||||
// {
|
||||
// articles: [{
|
||||
// id: 1,
|
||||
// title: 'Some Article',
|
||||
// author: {
|
||||
// id: 7,
|
||||
// name: 'Dan'
|
||||
// },
|
||||
// ...
|
||||
// },
|
||||
// ...
|
||||
// ]
|
||||
// }
|
||||
//
|
||||
// AFTER:
|
||||
// {
|
||||
// result: {
|
||||
// articles: [1, 2, ...] // <--- Note how object array turned into ID array
|
||||
// },
|
||||
// entities: {
|
||||
// articles: {
|
||||
// 1: { author: 7, ... }, // <--- Same happens for references to other entities in the schema
|
||||
// 2: { ... },
|
||||
// ...
|
||||
// },
|
||||
// users: {
|
||||
// 7: { ... },
|
||||
// ..
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
response = normalize(response, {
|
||||
articles: arrayOf(article1)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// new Schema(key, [options])
|
||||
|
||||
const article2 = new Schema('articles');
|
||||
|
||||
// You can use a custom id attribute
|
||||
const article3 = new Schema('articles', { idAttribute: 'slug' });
|
||||
|
||||
// Or you can specify a function to infer it
|
||||
function generateSlug(entity: any) { /* ... */ }
|
||||
const article4 = new Schema('articles', { idAttribute: generateSlug });
|
||||
|
||||
// Schema.prototype.define(nestedSchema)
|
||||
|
||||
const article5 = new Schema('articles');
|
||||
const user5 = new Schema('users');
|
||||
|
||||
article5.define({
|
||||
author: user5
|
||||
});
|
||||
|
||||
// Schema.prototype.getKey()
|
||||
|
||||
const article6 = new Schema('articles');
|
||||
|
||||
article6.getKey();
|
||||
// articles
|
||||
|
||||
// Schema.prototype.getIdAttribute()
|
||||
|
||||
const article7 = new Schema('articles');
|
||||
const slugArticle7 = new Schema('articles', { idAttribute: 'slug' });
|
||||
|
||||
article7.getIdAttribute();
|
||||
// id
|
||||
slugArticle7.getIdAttribute();
|
||||
// slug
|
||||
|
||||
// arrayOf(schema, [options])
|
||||
|
||||
const article8 = new Schema('articles');
|
||||
const user8 = new Schema('users');
|
||||
|
||||
article8.define({
|
||||
author: user8,
|
||||
contributors: arrayOf(user8)
|
||||
});
|
||||
|
||||
const article9 = new Schema('articles');
|
||||
const image9 = new Schema('images');
|
||||
const video9 = new Schema('videos');
|
||||
const asset9 = {
|
||||
images: image9,
|
||||
videos: video9
|
||||
};
|
||||
|
||||
// You can specify the name of the attribute that determines the schema
|
||||
article9.define({
|
||||
assets: arrayOf(asset9, { schemaAttribute: 'type' })
|
||||
});
|
||||
|
||||
// Or you can specify a function to infer it
|
||||
function inferSchema9(entity: any) { /* ... */ }
|
||||
article9.define({
|
||||
assets: arrayOf(asset9, { schemaAttribute: inferSchema9 })
|
||||
});
|
||||
|
||||
// valuesOf(schema, [options])
|
||||
|
||||
const article10 = new Schema('articles');
|
||||
const user10 = new Schema('users');
|
||||
|
||||
article10.define({
|
||||
collaboratorsByRole: valuesOf(user10)
|
||||
});
|
||||
|
||||
const article11 = new Schema('articles');
|
||||
const user11 = new Schema('users');
|
||||
const group11 = new Schema('groups');
|
||||
const collaborator11 = {
|
||||
users: user11,
|
||||
groups: group11
|
||||
};
|
||||
|
||||
// You can specify the name of the attribute that determines the schema
|
||||
article11.define({
|
||||
collaboratorsByRole: valuesOf(collaborator11, { schemaAttribute: 'type' })
|
||||
});
|
||||
|
||||
// Or you can specify a function to infer it
|
||||
function inferSchema11(entity: any) { /* ... */ }
|
||||
article11.define({
|
||||
collaboratorsByRole: valuesOf(collaborator11, { schemaAttribute: inferSchema })
|
||||
});
|
||||
|
||||
// unionOf(schemaMap, [options])
|
||||
|
||||
const group12 = new Schema('groups');
|
||||
const user12 = new Schema('users');
|
||||
|
||||
// a member can be either a user or a group
|
||||
const member12 = {
|
||||
users: user12,
|
||||
groups: group12
|
||||
};
|
||||
|
||||
// You can specify the name of the attribute that determines the schema
|
||||
group12.define({
|
||||
owner: unionOf(member12, { schemaAttribute: 'type' })
|
||||
});
|
||||
|
||||
// Or you can specify a function to infer it
|
||||
function inferSchema(entity: any) { /* ... */ }
|
||||
group12.define({
|
||||
creator: unionOf(member12, { schemaAttribute: inferSchema })
|
||||
});
|
||||
|
||||
const group13 = new Schema('groups');
|
||||
const user13 = new Schema('users');
|
||||
|
||||
const member13 = unionOf({
|
||||
users: user13,
|
||||
groups: group13
|
||||
}, { schemaAttribute: 'type' });
|
||||
|
||||
group13.define({
|
||||
owner: member13,
|
||||
members: arrayOf(member13),
|
||||
relationships: valuesOf(member13)
|
||||
});
|
||||
|
||||
// normalize(obj, schema, [options])
|
||||
|
||||
const article14 = new Schema('articles');
|
||||
const user14 = new Schema('users');
|
||||
|
||||
article14.define({
|
||||
author: user14,
|
||||
contributors: arrayOf(user14),
|
||||
meta: {
|
||||
likes: arrayOf({
|
||||
user: user14
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
// ...
|
||||
|
||||
// Normalize one article object
|
||||
const json = { id: 1, author: /*...*/{} };
|
||||
const normalized1 = normalize(json, article14);
|
||||
|
||||
// Normalize an array of article objects
|
||||
const arr = [{ id: 1, author: /*...*/{} }/*, ...*/]
|
||||
const normalized2 = normalize(arr, arrayOf(article14));
|
||||
|
||||
// Normalize an array of article objects, referenced by an object key:
|
||||
const wrappedArr = { articles: [{ id: 1, author: /*...*/{} }/*, ...*/] }
|
||||
const normalized3 = normalize(wrappedArr, {
|
||||
articles: arrayOf(article14)
|
||||
});
|
||||
Vendored
+111
@@ -0,0 +1,111 @@
|
||||
// Type definitions for normalizr 2.0.1
|
||||
// Project: https://github.com/gaearon/normalizr/
|
||||
// Definitions by: Markus Peloso <https://github.com/ToastHawaii/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare module "normalizr" {
|
||||
export = Normalizr;
|
||||
}
|
||||
|
||||
declare namespace Normalizr {
|
||||
type AttributeSetting = string | ((entity: any) => any);
|
||||
|
||||
type SchemaClass = Schema | ArraySchema | UnionSchema;
|
||||
|
||||
type SchemaObject = { [property: string]: SchemaClass | SchemaObject };
|
||||
|
||||
type SchemaType = SchemaClass | SchemaObject | Object;
|
||||
|
||||
export class Schema {
|
||||
/**
|
||||
* Schema lets you define a type of entity returned by your API.
|
||||
* This should correspond to model in your server code.
|
||||
* @param key The key parameter lets you specify the name of the dictionary for this kind of entity.
|
||||
* @param options
|
||||
*/
|
||||
constructor(key: string, options?: { idAttribute: AttributeSetting; });
|
||||
|
||||
/**
|
||||
* Lets you specify relationships between different entities.
|
||||
* @param nestedSchema
|
||||
*/
|
||||
define(nestedSchema: SchemaObject): void;
|
||||
|
||||
/**
|
||||
* Returns the key of the schema.
|
||||
*/
|
||||
getKey(): string;
|
||||
|
||||
/**
|
||||
* Returns the idAttribute of the schema.
|
||||
*/
|
||||
getIdAttribute(): AttributeSetting;
|
||||
}
|
||||
|
||||
interface UnionSchema {
|
||||
getItemSchema(): SchemaType;
|
||||
getSchemaKey(item: any): string;
|
||||
}
|
||||
|
||||
interface ArraySchema {
|
||||
getItemSchema(): SchemaType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes an array of the schema passed as argument.
|
||||
* @param schema
|
||||
* @param options
|
||||
*/
|
||||
export function arrayOf(schema: SchemaType, options?: {
|
||||
/**
|
||||
* If the array contains entities with different schemas, you can use the schemaAttribute option to specify which schema to use for each entity.
|
||||
*/
|
||||
schemaAttribute: AttributeSetting
|
||||
}): ArraySchema;
|
||||
|
||||
/**
|
||||
* Describes a map whose values follow the schema passed as argument.
|
||||
* @param schema
|
||||
* @param options
|
||||
*/
|
||||
export function valuesOf(schema: SchemaType, options?: {
|
||||
/**
|
||||
* If the map contains entities with different schemas, you can use the schemaAttribute option to specify which schema to use for each entity.
|
||||
*/
|
||||
schemaAttribute: AttributeSetting
|
||||
}): ArraySchema;
|
||||
|
||||
/**
|
||||
* Describe a schema which is a union of multiple schemas. This is useful if you need the polymorphic behavior provided by arrayOf or valuesOf but for non-collection fields.
|
||||
* @param schemaMap
|
||||
* @param options
|
||||
*/
|
||||
export function unionOf(schemaMap: SchemaType, options?: {
|
||||
/**
|
||||
* Use the required schemaAttribute option to specify which schema to use for each entity.
|
||||
*/
|
||||
schemaAttribute: AttributeSetting
|
||||
}): UnionSchema;
|
||||
|
||||
/**
|
||||
* Normalizes object according to schema.
|
||||
* Passed schema should be a nested object reflecting the structure of API response.
|
||||
* @param obj
|
||||
* @param schema
|
||||
* @param options
|
||||
*/
|
||||
export function normalize(obj: any | Array<any>, schema: SchemaType, options?: {
|
||||
/**
|
||||
* This is useful if your backend emits additional fields, such as separate ID fields, you'd like to delete in the normalized entity.
|
||||
*/
|
||||
assignEntity?: (normalized: any, key: string, entity: any) => any;
|
||||
|
||||
/**
|
||||
* You can use this to resolve conflicts when merging entities with the same key.
|
||||
*/
|
||||
mergeIntoEntity?: (stored: any, normalized: any, entityKey: string) => any;
|
||||
}): {
|
||||
entites: any;
|
||||
result: any;
|
||||
};
|
||||
}
|
||||
Vendored
+5
-16
@@ -118,7 +118,6 @@ declare namespace p2 {
|
||||
|
||||
constructor(bodyA: Body, bodyB: Body, type: number, options?: {
|
||||
collideConnected?: boolean;
|
||||
wakeUpBodies?: boolean;
|
||||
});
|
||||
|
||||
type: number;
|
||||
@@ -135,9 +134,7 @@ declare namespace p2 {
|
||||
|
||||
export class DistanceConstraint extends Constraint {
|
||||
|
||||
constructor(bodyA: Body, bodyB: Body, type: number, options?: {
|
||||
collideConnected?: boolean;
|
||||
wakeUpBodies?: boolean;
|
||||
constructor(bodyA: Body, bodyB: Body, options?: {
|
||||
distance?: number;
|
||||
localAnchorA?: number[];
|
||||
localAnchorB?: number[];
|
||||
@@ -161,9 +158,7 @@ declare namespace p2 {
|
||||
|
||||
export class GearConstraint extends Constraint {
|
||||
|
||||
constructor(bodyA: Body, bodyB: Body, type: number, options?: {
|
||||
collideConnected?: boolean;
|
||||
wakeUpBodies?: boolean;
|
||||
constructor(bodyA: Body, bodyB: Body, options?: {
|
||||
angle?: number;
|
||||
ratio?: number;
|
||||
maxTorque?: number;
|
||||
@@ -179,9 +174,7 @@ declare namespace p2 {
|
||||
|
||||
export class LockConstraint extends Constraint {
|
||||
|
||||
constructor(bodyA: Body, bodyB: Body, type: number, options?: {
|
||||
collideConnected?: boolean;
|
||||
wakeUpBodies?: boolean;
|
||||
constructor(bodyA: Body, bodyB: Body, options?: {
|
||||
localOffsetB?: number[];
|
||||
localAngleB?: number;
|
||||
maxForce?: number;
|
||||
@@ -194,9 +187,7 @@ declare namespace p2 {
|
||||
|
||||
export class PrismaticConstraint extends Constraint {
|
||||
|
||||
constructor(bodyA: Body, bodyB: Body, type: number, options?: {
|
||||
collideConnected?: boolean;
|
||||
wakeUpBodies?: boolean;
|
||||
constructor(bodyA: Body, bodyB: Body, options?: {
|
||||
maxForce?: number;
|
||||
localAnchorA?: number[];
|
||||
localAnchorB?: number[];
|
||||
@@ -229,9 +220,7 @@ declare namespace p2 {
|
||||
|
||||
export class RevoluteConstraint extends Constraint {
|
||||
|
||||
constructor(bodyA: Body, bodyB: Body, type: number, options?: {
|
||||
collideConnected?: boolean;
|
||||
wakeUpBodies?: boolean;
|
||||
constructor(bodyA: Body, bodyB: Body, options?: {
|
||||
worldPivot?: number[];
|
||||
localPivotA?: number[];
|
||||
localPivotB?: number[];
|
||||
|
||||
Vendored
+1
-1
@@ -147,7 +147,7 @@ declare namespace Physijs {
|
||||
add(object:THREE.Object3D):void;
|
||||
remove(object:THREE.Object3D):void;
|
||||
setFixedTimeStep(fixedTimeStep:number):void;
|
||||
setGravity(gravity:number):void;
|
||||
setGravity(gravity:THREE.Vector3):void;
|
||||
simulate(timeStep?:number, maxSubSteps?:number):boolean;
|
||||
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ export class ReactBootstrapTest extends Component<any, any> {
|
||||
|
||||
<div style={style}>
|
||||
<div className='static-modal'>
|
||||
<Modal.Dialog>
|
||||
<Modal.Dialog onHide={this.callback} onEnter={this.callback} onEntered={this.callback} onEntering={this.callback} onExit={this.callback} onExited={this.callback} onExiting={this.callback}>
|
||||
<Modal.Header>
|
||||
<Modal.Title>Modal title</Modal.Title>
|
||||
</Modal.Header>
|
||||
|
||||
Vendored
+6
@@ -190,6 +190,12 @@ declare module "react-bootstrap" {
|
||||
dialogComponent?: any; // TODO: Add more specific type
|
||||
enforceFocus?: boolean;
|
||||
keyboard?: boolean;
|
||||
onEnter?: (node: HTMLElement) => any;
|
||||
onEntered?: (node: HTMLElement) => any;
|
||||
onEntering?: (node: HTMLElement) => any;
|
||||
onExit?: (node: HTMLElement) => any;
|
||||
onExited?: (node: HTMLElement) => any;
|
||||
onExiting?: (node: HTMLElement) => any;
|
||||
show?: boolean;
|
||||
}
|
||||
interface ModalClass extends React.ClassicComponentClass<ModalProps> {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
import * as React from 'react';
|
||||
import Helmet from 'react-helmet';
|
||||
import * as Helmet from 'react-helmet';
|
||||
|
||||
<Helmet title="My Title" />
|
||||
|
||||
|
||||
Vendored
+15
-10
@@ -1,13 +1,13 @@
|
||||
// Type definitions for react-helmet
|
||||
// Project: https://github.com/nfl/react-helmet
|
||||
// Definitions by: Evan Bremer <https://github.com/evanbb>
|
||||
// Definitions by: Evan Bremer <https://github.com/evanbb>, Isman Usoh <https://github.com/isman-usoh>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../react/react.d.ts" />
|
||||
|
||||
declare module 'react-helmet' {
|
||||
import { Component } from 'react';
|
||||
|
||||
declare namespace ReactHelmet {
|
||||
import React = __React;
|
||||
|
||||
interface HelmetProps {
|
||||
title?: string;
|
||||
titleTemplate?: string;
|
||||
@@ -25,15 +25,20 @@ declare module 'react-helmet' {
|
||||
meta: HelmetDatum;
|
||||
script: HelmetDatum;
|
||||
}
|
||||
|
||||
|
||||
interface HelmetDatum {
|
||||
toString(): string;
|
||||
toComponent(): Component<any, any>;
|
||||
toComponent(): React.Component<any, any>;
|
||||
}
|
||||
|
||||
class Helmet extends Component<HelmetProps, any> {
|
||||
static rewind(): HelmetData
|
||||
class HelmetComponent extends React.Component<HelmetProps, any> {}
|
||||
}
|
||||
|
||||
declare module "react-helmet" {
|
||||
var Helmet: {
|
||||
(): ReactHelmet.HelmetComponent
|
||||
rewind(): ReactHelmet.HelmetData
|
||||
}
|
||||
|
||||
export default Helmet;
|
||||
|
||||
export = Helmet;
|
||||
}
|
||||
|
||||
@@ -27,9 +27,27 @@ import {
|
||||
View,
|
||||
AppState,
|
||||
AppStateIOS,
|
||||
ViewPagerAndroid
|
||||
ViewPagerAndroid,
|
||||
Dimensions,
|
||||
} from 'react-native';
|
||||
|
||||
function testDimensions() {
|
||||
var {
|
||||
width,
|
||||
height,
|
||||
scale,
|
||||
fontScale,
|
||||
} = Dimensions.get("window");
|
||||
|
||||
var {
|
||||
width,
|
||||
height,
|
||||
scale,
|
||||
fontScale,
|
||||
} = Dimensions.get("screen");
|
||||
}
|
||||
|
||||
|
||||
var styles = StyleSheet.create(
|
||||
{
|
||||
container: {
|
||||
|
||||
Vendored
+22
-14
@@ -2499,8 +2499,28 @@ declare namespace __React {
|
||||
width: number;
|
||||
height: number;
|
||||
scale: number;
|
||||
fontScale: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initial dimensions are set before `runApplication` is called so they should
|
||||
* be available before any other require's are run, but may be updated later.
|
||||
*
|
||||
* Note: Although dimensions are available immediately, they may change (e.g
|
||||
* due to device rotation) so any rendering logic or styles that depend on
|
||||
* these constants should try to call this function on every render, rather
|
||||
* than caching the value (for example, using inline styles rather than
|
||||
* setting a value in a `StyleSheet`).
|
||||
*
|
||||
* Example: `var {height, width} = Dimensions.get('window');`
|
||||
*
|
||||
* @param {string} dim Name of dimension as defined when calling `set`.
|
||||
* @returns {Object?} Value for the dimension.
|
||||
* @see https://facebook.github.io/react-native/docs/dimensions.html#content
|
||||
*/
|
||||
export interface Dimensions {
|
||||
get( what: "window" | "screen" ): React.ScaledSize;
|
||||
}
|
||||
|
||||
export interface InteractionManagerStatic {
|
||||
runAfterInteractions( fn: () => void ): void;
|
||||
@@ -3447,6 +3467,7 @@ declare namespace __React {
|
||||
export var VibrationIOS: VibrationIOSStatic
|
||||
export type VibrationIOS = VibrationIOSStatic
|
||||
|
||||
export var Dimensions: Dimensions;
|
||||
|
||||
//
|
||||
// /TODO: BGR: These are leftovers of the initial port that must be revisited
|
||||
@@ -3509,17 +3530,4 @@ declare module "react-native" {
|
||||
|
||||
declare var global: __React.GlobalStatic
|
||||
|
||||
declare function require( name: string ): any
|
||||
|
||||
|
||||
//TODO: BGR: this is a left-over from the initial port. Not sure it makes any sense
|
||||
declare module "Dimensions" {
|
||||
import * as React from 'react-native';
|
||||
|
||||
interface Dimensions {
|
||||
get( what: string ): React.ScaledSize;
|
||||
}
|
||||
|
||||
var ExportDimensions: Dimensions;
|
||||
export = ExportDimensions;
|
||||
}
|
||||
declare function require( name: string ): any
|
||||
@@ -8,7 +8,7 @@
|
||||
import * as React from "react"
|
||||
import * as ReactDOM from "react-dom"
|
||||
|
||||
import { browserHistory, hashHistory, Router, Route, IndexRoute, Link } from "react-router"
|
||||
import { browserHistory, hashHistory, createMemoryHistory, Router, Route, IndexRoute, Link } from "react-router"
|
||||
|
||||
interface MasterContext {
|
||||
router: ReactRouter.RouterOnContext;
|
||||
|
||||
Vendored
+10
-2
@@ -86,6 +86,8 @@ declare namespace ReactRouter {
|
||||
const browserHistory: History;
|
||||
const hashHistory: History;
|
||||
|
||||
function createMemoryHistory(options?: H.HistoryOptions): H.History
|
||||
|
||||
/* components */
|
||||
|
||||
interface RouterProps extends React.Props<Router> {
|
||||
@@ -245,7 +247,7 @@ declare namespace ReactRouter {
|
||||
interface MatchArgs {
|
||||
routes?: RouteConfig
|
||||
history?: H.History
|
||||
location?: H.Location
|
||||
location?: H.Location | string
|
||||
parseQueryString?: ParseQueryString
|
||||
stringifyQuery?: StringifyQuery
|
||||
}
|
||||
@@ -412,6 +414,9 @@ declare module "react-router/lib/useRouterHistory" {
|
||||
export default function useRouterHistory<T>(createHistory: HistoryModule.CreateHistory<T>): CreateRouterHistory;
|
||||
}
|
||||
|
||||
declare module "react-router/lib/createMemoryHistory" {
|
||||
export default ReactRouter.createMemoryHistory;
|
||||
}
|
||||
|
||||
declare module "react-router" {
|
||||
|
||||
@@ -453,6 +458,8 @@ declare module "react-router" {
|
||||
|
||||
import useRouterHistory from "react-router/lib/useRouterHistory";
|
||||
|
||||
import createMemoryHistory from "react-router/lib/createMemoryHistory";
|
||||
|
||||
// PlainRoute is defined in the API documented at:
|
||||
// https://github.com/rackt/react-router/blob/master/docs/API.md
|
||||
// but not included in any of the .../lib modules above.
|
||||
@@ -492,7 +499,8 @@ declare module "react-router" {
|
||||
RouterContext,
|
||||
PropTypes,
|
||||
match,
|
||||
useRouterHistory
|
||||
useRouterHistory,
|
||||
createMemoryHistory
|
||||
}
|
||||
|
||||
export default Router
|
||||
|
||||
Vendored
+1
-1
@@ -173,7 +173,7 @@ declare namespace ReactSelect {
|
||||
* field placeholder, displayed when there's no value
|
||||
* @default "Select..."
|
||||
*/
|
||||
placeholder?: string;
|
||||
placeholder?: string | __React.ReactElement<any>;
|
||||
/**
|
||||
* whether to enable searching feature or not
|
||||
* @default true;
|
||||
|
||||
Vendored
+4
@@ -730,8 +730,10 @@ declare namespace __React {
|
||||
radialGradient: SVGFactory;
|
||||
rect: SVGFactory;
|
||||
stop: SVGFactory;
|
||||
symbol: SVGFactory;
|
||||
text: SVGFactory;
|
||||
tspan: SVGFactory;
|
||||
use: SVGFactory;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1538,8 +1540,10 @@ declare module "react/addons" {
|
||||
radialGradient: SVGFactory;
|
||||
rect: SVGFactory;
|
||||
stop: SVGFactory;
|
||||
symbol: SVGFactory;
|
||||
text: SVGFactory;
|
||||
tspan: SVGFactory;
|
||||
use: SVGFactory;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
Vendored
+4
@@ -2234,8 +2234,10 @@ declare namespace __React {
|
||||
radialGradient: SVGFactory;
|
||||
rect: SVGFactory;
|
||||
stop: SVGFactory;
|
||||
symbol: SVGFactory;
|
||||
text: SVGFactory;
|
||||
tspan: SVGFactory;
|
||||
use: SVGFactory;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -2464,7 +2466,9 @@ declare namespace JSX {
|
||||
radialGradient: React.SVGProps;
|
||||
rect: React.SVGProps;
|
||||
stop: React.SVGProps;
|
||||
symbol: React.SVGProps;
|
||||
text: React.SVGProps;
|
||||
tspan: React.SVGProps;
|
||||
use: React.SVGProps;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Restangular v1.4.0
|
||||
// Type definitions for Restangular v1.5.0
|
||||
// Project: https://github.com/mgonto/restangular
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -56,7 +56,7 @@ declare namespace restangular {
|
||||
addRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any): void;
|
||||
setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: angular.IRequestShortcutConfig) => {element: any; headers: any; params: any}): void;
|
||||
addFullRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: angular.IRequestShortcutConfig) => {headers: any; params: any; element: any; httpConfig: angular.IRequestShortcutConfig}): void;
|
||||
setErrorInterceptor(errorInterceptor: (response: IResponse, deferred: angular.IDeferred<any>) => any): void;
|
||||
setErrorInterceptor(errorInterceptor: (response: IResponse, deferred: angular.IDeferred<any>, responseHandler: (response: restangular.IResponse) => any) => any): void;
|
||||
setRestangularFields(fields: {[fieldName: string]: string}): void;
|
||||
setMethodOverriders(overriders: string[]): void;
|
||||
setJsonp(jsonp: boolean): void;
|
||||
|
||||
@@ -882,6 +882,8 @@ User.findAll( { order : [['id', ';DELETE YOLO INJECTIONS']] } );
|
||||
User.findAll( { include : [User], order : [[User, 'id', ';DELETE YOLO INJECTIONS']] } );
|
||||
User.findAll( { include : [User], order : [['id', 'ASC NULLS LAST'], [User, 'id', 'DESC NULLS FIRST']] } );
|
||||
User.findAll( { include : [{ model : User, where : { title : 'DoDat' }, include : [{ model : User }] }] } );
|
||||
User.findAll( { attributes: ['username', 'data']});
|
||||
User.findAll( { attributes: {include: ['username', 'data']} });
|
||||
|
||||
User.findById( 'a string' );
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -3121,7 +3121,7 @@ declare module "sequelize" {
|
||||
* `Sequelize.literal`, `Sequelize.fn` and so on), and the second is the name you want the attribute to
|
||||
* have in the returned instance
|
||||
*/
|
||||
attributes? : Array<string | [string, string]>;
|
||||
attributes? : Array<string> | { include?: Array<string>, exclude?: Array<string> };
|
||||
|
||||
/**
|
||||
* If true, only non-deleted records will be returned. If false, both deleted and non-deleted records will
|
||||
|
||||
Vendored
+4
@@ -574,3 +574,7 @@ declare namespace turf {
|
||||
*/
|
||||
function reclass(input: GeoJSON.FeatureCollection<any>, inField: string, outField: string, translations: Array<any>): GeoJSON.FeatureCollection<any>;
|
||||
}
|
||||
|
||||
declare module 'turf' {
|
||||
export= turf;
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -1511,6 +1511,10 @@ declare namespace uiGrid {
|
||||
* Defaults to 150
|
||||
*/
|
||||
expandableRowHeight?: number;
|
||||
/**
|
||||
* reference to the parent grid scope (the parent scope of the sub-grid element)
|
||||
*/
|
||||
expandableRowScope?: ng.IScope | Object;
|
||||
/**
|
||||
* Mandatory. The template for your expanded row
|
||||
*/
|
||||
|
||||
+11
-1
@@ -8,7 +8,7 @@ namespace TestConfig {
|
||||
Vue.config.unsafeDelimiters = ['{!!', '!!}'];
|
||||
Vue.config.silent = true;
|
||||
Vue.config.async = false;
|
||||
Vue.config.convertAllProperties = true;
|
||||
Vue.config.devtools = true;
|
||||
}
|
||||
|
||||
namespace TestGlobalAPI {
|
||||
@@ -67,6 +67,16 @@ namespace TestGlobalAPI {
|
||||
}
|
||||
}
|
||||
});
|
||||
Vue.component("component", {
|
||||
props: {
|
||||
a: [String, Number],
|
||||
b: {
|
||||
type: [Number, Function],
|
||||
required: true
|
||||
}
|
||||
},
|
||||
init: function() {}
|
||||
});
|
||||
var transition = Vue.transition("transition");
|
||||
Vue.transition("transition", transition);
|
||||
Vue.transition("transition", {
|
||||
|
||||
Vendored
+5
-4
@@ -1,4 +1,4 @@
|
||||
// Type definitions for vuejs 1.0.16
|
||||
// Type definitions for vuejs 1.0.21
|
||||
// Project: https://github.com/vuejs/vue
|
||||
// Definitions by: odangosan <https://github.com/odangosan>, kaorun343 <https://github.com/kaorun343>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -11,7 +11,7 @@ interface Array<T> {
|
||||
declare namespace vuejs {
|
||||
|
||||
interface PropOption {
|
||||
type?: { new (...args: any[]): any; };
|
||||
type?: { new (...args: any[]): any; } | { new (...args: any[]): any; }[];
|
||||
required?: boolean;
|
||||
default?: any;
|
||||
twoWay?: boolean;
|
||||
@@ -68,13 +68,14 @@ declare namespace vuejs {
|
||||
|
||||
interface ComponentOption {
|
||||
data?: { [key: string]: any } | Function;
|
||||
props?: string[] | { [key: string]: (PropOption | { new (...args: any[]): any; }) };
|
||||
props?: string[] | { [key: string]: (PropOption | { new (...args: any[]): any; } | { new (...args: any[]): any; }[]) };
|
||||
computed?: { [key: string]: (Function | ComputedOption) };
|
||||
methods?: { [key: string]: Function };
|
||||
watch?: { [key: string]: ((val: any, oldVal: any) => void) | string | WatchOption };
|
||||
el?: string | HTMLElement | (() => HTMLElement);
|
||||
template?: string;
|
||||
replace?: boolean;
|
||||
init?(): void;
|
||||
created?(): void;
|
||||
beforeCompile?(): void;
|
||||
compiled?(): void;
|
||||
@@ -143,7 +144,7 @@ declare namespace vuejs {
|
||||
unsafeDelimiters: [string, string];
|
||||
silent: boolean;
|
||||
async: boolean;
|
||||
convertAllProperties: boolean;
|
||||
devtools: boolean;
|
||||
}
|
||||
|
||||
interface VueUtil {
|
||||
|
||||
Reference in New Issue
Block a user