* babel-generator: Add TypeScript support * Remove type declarations; not published from babylon * Remove TODOs * Consistently use `this.word` for tokens that are words
39 lines
762 B
JavaScript
39 lines
762 B
JavaScript
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);
|
|
}
|
|
}
|