mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-29 00:51:29 +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)
22 lines
637 B
TypeScript
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');
|