mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Merge pull request #26432 from rpetrich/babel-traverse
babel-traverse: Improve safety on NodePath
This commit is contained in:
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as t from 'babel-types';
|
||||
export { t as types };
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||
// Johnny Estilles <https://github.com/johnnyestilles>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as t from 'babel-types';
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { BabylonOptions } from 'babylon';
|
||||
import * as t from 'babel-types';
|
||||
|
||||
Vendored
+23
-10
@@ -2,15 +2,17 @@
|
||||
// Project: https://github.com/babel/babel/tree/master/packages/babel-traverse
|
||||
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Ryan Petrich <https://github.com/rpetrich>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as t from 'babel-types';
|
||||
export type Node = t.Node;
|
||||
|
||||
export default function traverse(parent: Node | Node[], opts?: TraverseOptions, scope?: Scope, state?: any, parentPath?: NodePath): void;
|
||||
export default function traverse<S>(parent: Node | Node[], opts: TraverseOptions<S>, scope: Scope, state: S, parentPath?: NodePath): void;
|
||||
export default function traverse(parent: Node | Node[], opts: TraverseOptions, scope?: Scope, state?: any, parentPath?: NodePath): void;
|
||||
|
||||
export interface TraverseOptions extends Visitor {
|
||||
export interface TraverseOptions<S = Node> extends Visitor<S> {
|
||||
scope?: Scope;
|
||||
noScope?: boolean;
|
||||
}
|
||||
@@ -25,6 +27,7 @@ export class Scope {
|
||||
bindings: { [name: string]: Binding; };
|
||||
|
||||
/** Traverse node with current scope and path. */
|
||||
traverse<S>(node: Node | Node[], opts: TraverseOptions<S>, state: S): void;
|
||||
traverse(node: Node | Node[], opts?: TraverseOptions, state?: any): void;
|
||||
|
||||
/** Generate a unique identifier and add it to the current scope. */
|
||||
@@ -339,10 +342,10 @@ export class NodePath<T = Node> {
|
||||
listKey: string;
|
||||
inList: boolean;
|
||||
parentKey: string;
|
||||
key: string;
|
||||
key: string | number;
|
||||
node: T;
|
||||
scope: Scope;
|
||||
type: string;
|
||||
type: T extends undefined | null ? string | null : string;
|
||||
typeAnnotation: object;
|
||||
|
||||
getScope(scope: Scope): Scope;
|
||||
@@ -353,7 +356,8 @@ export class NodePath<T = Node> {
|
||||
|
||||
buildCodeFrameError<TError extends Error>(msg: string, Error?: new (msg: string) => TError): TError;
|
||||
|
||||
traverse(visitor: Visitor, state?: any): void;
|
||||
traverse<T>(visitor: Visitor<T>, state: T): void;
|
||||
traverse(visitor: Visitor): void;
|
||||
|
||||
set(key: string, node: Node): void;
|
||||
|
||||
@@ -372,10 +376,10 @@ export class NodePath<T = Node> {
|
||||
find(callback: (path: NodePath) => boolean): NodePath;
|
||||
|
||||
/** Get the parent function of the current path. */
|
||||
getFunctionParent(): NodePath;
|
||||
getFunctionParent(): NodePath<t.Function>;
|
||||
|
||||
/** Walk up the tree until we hit a parent node path in a list. */
|
||||
getStatementParent(): NodePath;
|
||||
getStatementParent(): NodePath<t.Statement>;
|
||||
|
||||
/**
|
||||
* Get the deepest common ancestor and then from it, get the earliest relationship path
|
||||
@@ -537,6 +541,9 @@ export class NodePath<T = Node> {
|
||||
/** Get the source code associated with this node. */
|
||||
getSource(): string;
|
||||
|
||||
/** Check if the current path will maybe execute before another path */
|
||||
willIMaybeExecuteBefore(path: NodePath): boolean;
|
||||
|
||||
// ------------------------- context -------------------------
|
||||
call(key: string): boolean;
|
||||
|
||||
@@ -582,9 +589,15 @@ export class NodePath<T = Node> {
|
||||
|
||||
getCompletionRecords(): NodePath[];
|
||||
|
||||
getSibling(key: string): NodePath;
|
||||
getSibling(key: string | number): NodePath;
|
||||
getAllPrevSiblings(): NodePath[];
|
||||
getAllNextSiblings(): NodePath[];
|
||||
|
||||
get(key: string, context?: boolean | TraversalContext): NodePath;
|
||||
get<K extends keyof T>(key: K, context?: boolean | TraversalContext):
|
||||
T[K] extends Array<Node | null | undefined> ? Array<NodePath<T[K][number]>> :
|
||||
T[K] extends Node | null | undefined ? NodePath<T[K]> :
|
||||
never;
|
||||
get(key: string, context?: boolean | TraversalContext): NodePath | NodePath[];
|
||||
|
||||
getBindingIdentifiers(duplicates?: boolean): Node[];
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Boris Cherny <https://github.com/bcherny>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
export interface Comment {
|
||||
value: string;
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/simlrh/babel-webpack-plugin
|
||||
// Definitions by: Jed Fox <https://github.com/j-f1>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Plugin } from 'webpack';
|
||||
import { TransformOptions } from 'babel-core';
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2>
|
||||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/pugjs/babylon-walk
|
||||
// Definitions by: Marek Buchar <https://github.com/czbuchi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as babelTypes from 'babel-types';
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Troy Gerwien <https://github.com/yortus>
|
||||
// Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { File, Expression } from 'babel-types';
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/istanbuljs/istanbuljs
|
||||
// Definitions by: Jason Cheatham <https://github.com/jason0x43>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { FileCoverage, FileCoverageData, Range } from 'istanbul-lib-coverage';
|
||||
import { RawSourceMap } from 'source-map';
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/prettier/prettier
|
||||
// Definitions by: Ika <https://github.com/ikatyang>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
export type AST = any;
|
||||
export type Doc = doc.builders.Doc;
|
||||
|
||||
Reference in New Issue
Block a user