Files
DefinitelyTyped/babylon/babylon-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

25 lines
670 B
TypeScript

/// <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: []
});