diff --git a/src/clean-ast.js b/src/clean-ast.js
index 77892e7b4..15ce0b531 100644
--- a/src/clean-ast.js
+++ b/src/clean-ast.js
@@ -81,6 +81,24 @@ function massageAST(ast) {
};
}
+ // (TypeScript) ignore empty `specifiers` array
+ if (
+ ast.type === "TSNamespaceExportDeclaration" &&
+ ast.specifiers &&
+ ast.specifiers.length === 0
+ ) {
+ delete newObj.specifiers;
+ }
+
+ // (TypeScript) allow parenthesization of TSFunctionType
+ if (
+ ast.type === "TSParenthesizedType" &&
+ ast.typeAnnotation.type === "TypeAnnotation" &&
+ ast.typeAnnotation.typeAnnotation.type === "TSFunctionType"
+ ) {
+ return newObj.typeAnnotation.typeAnnotation;
+ }
+
// We convert
to
if (ast.type === "JSXOpeningElement") {
delete newObj.selfClosing;
diff --git a/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap
index feaa30074..d62ff0f0f 100644
--- a/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap
+++ b/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap
@@ -214,6 +214,21 @@ interface i2 {
`;
+exports[`contextualSignatureInstantiation2.ts 1`] = `
+// dot f g x = f(g(x))
+var dot: (f: (_: T) => S) => (g: (_: U) => T) => (_: U) => S;
+dot = (f: (_: T) => S) => (g: (_: U) => T): (r:U) => S => (x) => f(g(x));
+var id: (x:T) => T;
+var r23 = dot(id)(id);~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// dot f g x = f(g(x))
+var dot: (f: (_: T) => S) => (g: (_: U) => T) => (_: U) => S;
+dot = (f: (_: T) => S) => (g: (_: U) => T): ((r: U) => S) => x =>
+ f(g(x));
+var id: (x: T) => T;
+var r23 = dot(id)(id);
+
+`;
+
exports[`decrementAndIncrementOperators.ts 1`] = `
var x = 0;
@@ -310,6 +325,42 @@ interface Foo {
`;
+exports[`es5ExportDefaultClassDeclaration4.ts 1`] = `
+// @target: es5
+// @module: commonjs
+// @declaration: true
+
+declare module "foo" {
+ export var before: C;
+
+ export default class C {
+ method(): C;
+ }
+
+ export var after: C;
+
+ export var t: typeof C;
+}
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// @target: es5
+// @module: commonjs
+// @declaration: true
+
+declare module "foo" {
+ export var before: C;
+
+ export class C {
+ method(): C;
+ }
+
+ export var after: C;
+
+ export var t: typeof C;
+}
+
+`;
+
exports[`functionOverloadsOnGenericArity1.ts 1`] = `
// overloading on arity not allowed
interface C {
diff --git a/tests/typescript/compiler/contextualSignatureInstantiation2.ts b/tests/typescript/compiler/contextualSignatureInstantiation2.ts
new file mode 100644
index 000000000..b9d46af36
--- /dev/null
+++ b/tests/typescript/compiler/contextualSignatureInstantiation2.ts
@@ -0,0 +1,5 @@
+// dot f g x = f(g(x))
+var dot: (f: (_: T) => S) => (g: (_: U) => T) => (_: U) => S;
+dot = (f: (_: T) => S) => (g: (_: U) => T): (r:U) => S => (x) => f(g(x));
+var id: (x:T) => T;
+var r23 = dot(id)(id);
\ No newline at end of file
diff --git a/tests/typescript/compiler/es5ExportDefaultClassDeclaration4.ts b/tests/typescript/compiler/es5ExportDefaultClassDeclaration4.ts
new file mode 100644
index 000000000..4e8acc50e
--- /dev/null
+++ b/tests/typescript/compiler/es5ExportDefaultClassDeclaration4.ts
@@ -0,0 +1,16 @@
+// @target: es5
+// @module: commonjs
+// @declaration: true
+
+declare module "foo" {
+ export var before: C;
+
+ export default class C {
+ method(): C;
+ }
+
+ export var after: C;
+
+ export var t: typeof C;
+}
+