mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 04:49:15 +08:00
* add babel v6 definitions (6 modules) - babel-core - babel-generator - babel-template - babel-traverse - babel-types - babylon * fix failing tests - remove nullable annotations (not supported in tsc1.8.7) - explicit 'any' - remove property type guard (not supported in tsc1.8.7)
27 lines
650 B
TypeScript
27 lines
650 B
TypeScript
/// <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: "*" });
|