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

@@ -0,0 +1,38 @@
export function TypeAnnotation(node) {
this.token(":");
this.space();
if (node.optional) this.token("?");
this.print(node.typeAnnotation, node);
}
export function TypeParameterInstantiation(node): void {
this.token("<");
this.printList(node.params, node, {});
this.token(">");
}
export { TypeParameterInstantiation as TypeParameterDeclaration };
export function TypeParameter(node) {
this._variance(node);
this.word(node.name);
if (node.bound) {
this.print(node.bound, node);
}
if (node.constraint) {
this.space();
this.word("extends");
this.space();
this.print(node.constraint, node);
}
if (node.default) {
this.space();
this.token("=");
this.space();
this.print(node.default, node);
}
}