diff --git a/src/printer.js b/src/printer.js index d15644cec..70613a88f 100644 --- a/src/printer.js +++ b/src/printer.js @@ -1590,7 +1590,10 @@ function genericPrintNoParens(path, options, print, args) { case "TSHeritageClause": return join(", ", path.map(print, "types")); case "TSExpressionWithTypeArguments": - return path.call(print, "expression"); + return concat([ + path.call(print, "expression"), + printTypeParameters(path, options, print, "typeArguments") + ]); case "TemplateElement": return join(literalline, n.value.raw.split(/\r?\n/g)); case "TemplateLiteral": diff --git a/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap index 94753d21f..bd9506446 100644 --- a/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript/compiler/__snapshots__/jsfmt.spec.js.snap @@ -18,6 +18,43 @@ interface i2 { `; +exports[`checkInfiniteExpansionTermination.ts 1`] = ` +// Regression test for #1002 +// Before fix this code would cause infinite loop + +interface IObservable { + n: IObservable; // Needed, must be T[] +} + +// Needed +interface ISubject extends IObservable { } + +interface Foo { x } +interface Bar { y } + +var values: IObservable; +var values2: ISubject; +values = values2; +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Regression test for #1002 +// Before fix this code would cause infinite loop + +interface IObservable { + n: IObservable // Needed, must be T[] +} + +// Needed +interface ISubject extends IObservable {} + +interface Foo { x } +interface Bar { y } + +var values: IObservable; +var values2: ISubject; +values = values2; + +`; + exports[`functionOverloadsOnGenericArity1.ts 1`] = ` // overloading on arity not allowed interface C { diff --git a/tests/typescript/compiler/checkInfiniteExpansionTermination.ts b/tests/typescript/compiler/checkInfiniteExpansionTermination.ts new file mode 100644 index 000000000..8514ebce9 --- /dev/null +++ b/tests/typescript/compiler/checkInfiniteExpansionTermination.ts @@ -0,0 +1,16 @@ +// Regression test for #1002 +// Before fix this code would cause infinite loop + +interface IObservable { + n: IObservable; // Needed, must be T[] +} + +// Needed +interface ISubject extends IObservable { } + +interface Foo { x } +interface Bar { y } + +var values: IObservable; +var values2: ISubject; +values = values2;