babel-generator: Add TypeScript support (#5896)

* babel-generator: Add TypeScript support

* Remove type declarations; not published from babylon

* Remove TODOs

* Consistently use `this.word` for tokens that are words
This commit is contained in:
Andy
2017-07-28 13:07:05 -07:00
committed by Henry Zhu
parent f83c83d49c
commit c1d07fd6db
284 changed files with 1450 additions and 51 deletions

View File

@@ -93,6 +93,14 @@ export function Binary(node: Object, parent: Object): boolean {
return false;
}
export function TSAsExpression() {
return true;
}
export function TSTypeAssertion() {
return true;
}
export function BinaryExpression(node: Object, parent: Object): boolean {
// let i = (1 in []);
// for ((1 in []);;);
@@ -173,7 +181,9 @@ export function ConditionalExpression(node: Object, parent: Object): boolean {
t.isBinary(parent) ||
t.isConditionalExpression(parent, { test: node }) ||
t.isAwaitExpression(parent) ||
t.isTaggedTemplateExpression(parent)
t.isTaggedTemplateExpression(parent) ||
t.isTSTypeAssertion(parent) ||
t.isTSAsExpression(parent)
) {
return true;
}