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)
25 lines
670 B
TypeScript
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: []
|
|
});
|