Files
DefinitelyTyped/babel-types/babel-types-tests.ts
yortus 0754cc639a Initial typings for babel v6 (#9031)
* 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)
2016-04-23 15:21:08 +09:00

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: "*" });