Files
DefinitelyTyped/babel-template/babel-template-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

22 lines
637 B
TypeScript

/// <reference path="babel-template.d.ts" />
/// <reference path="../babel-generator/babel-generator.d.ts" />
/// <reference path="../babel-types/babel-types.d.ts" />
// Example from https://github.com/babel/babel/tree/master/packages/babel-template
import template = require('babel-template');
import generate from 'babel-generator';
import * as t from 'babel-types';
const buildRequire = template(`
var IMPORT_NAME = require(SOURCE);
`);
const ast = buildRequire({
IMPORT_NAME: t.identifier('myModule'),
SOURCE: t.stringLiteral('my-module')
});
console.log(generate(ast).code);
// var myModule = require('my-module');