diff --git a/package.json b/package.json index cf2ec6af2..6ecbc79f8 100644 --- a/package.json +++ b/package.json @@ -69,8 +69,7 @@ "tests/typescript/conformance/es6/Symbols/jsfmt.spec.js", "tests/typescript/conformance/classes/jsfmt.spec.js", "tests/typescript/conformance/classes/constructorDeclarations/constructorParameters/jsfmt.spec.js", - "tests/typescript/custom/module/jsfmt.spec.js", - "tests/typescript/conformance/interfaces/interfaceDeclarations/jsfmt.spec.js" + "tests/typescript/custom/module/jsfmt.spec.js" ] } } diff --git a/src/printer.js b/src/printer.js index b1d780022..4a7caab73 100644 --- a/src/printer.js +++ b/src/printer.js @@ -770,10 +770,10 @@ function genericPrintNoParens(path, options, print, args) { " " ); - if (n.heritageClauses) { - prefix.push( + if (n.heritage.length) { + parts.push( "extends ", - join(", ", path.map(print, "heritageClauses")), + join(", ", path.map(print, "heritage")), " " ); } @@ -857,12 +857,11 @@ function genericPrintNoParens(path, options, print, args) { let content; if (props.length === 0 && !n.typeAnnotation) { if (!hasDanglingComments(n)) { - return concat([concat(prefix), leftBrace, rightBrace]); + return concat([leftBrace, rightBrace]); } content = group( concat([ - concat(prefix), leftBrace, comments.printDanglingComments(path, options), softline, @@ -871,7 +870,6 @@ function genericPrintNoParens(path, options, print, args) { ); } else { content = concat([ - concat(prefix), leftBrace, indent( align( @@ -1628,6 +1626,8 @@ function genericPrintNoParens(path, options, print, args) { } parts.push(concat(printClass(path, options, print))); return concat(parts); + case "TSInterfaceHeritage": + return path.call(print, "id"); case "TSHeritageClause": return join(", ", path.map(print, "types")); case "TSExpressionWithTypeArguments": diff --git a/src/typescript-ast-nodes.js b/src/typescript-ast-nodes.js index 7c4353594..b270f9b03 100644 --- a/src/typescript-ast-nodes.js +++ b/src/typescript-ast-nodes.js @@ -155,7 +155,12 @@ module.exports = function(fork) { def("TSInterfaceDeclaration") .build("name", "members") .field("name", def("Identifier")) - .field("members", [def("TSMethodSignature")]); + .field("members", [def("TSMethodSignature")]) + .bases("Declaration"); + + def("TSInterfaceBody") + .build("body") + .bases("Node"); def("TSModuleDeclaration") .build("modifiers", "name", "body") diff --git a/tests/typescript/conformance/interfaces/interfaceDeclarations/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/conformance/interfaces/interfaceDeclarations/__snapshots__/jsfmt.spec.js.snap index 73647566d..320e5d519 100644 --- a/tests/typescript/conformance/interfaces/interfaceDeclarations/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript/conformance/interfaces/interfaceDeclarations/__snapshots__/jsfmt.spec.js.snap @@ -17,14 +17,13 @@ interface Derived extends Base, Base2 { x: { b: string } } -interface Derived2 extends Base, Base2 { // error +interface Derived2 extends Base, Base2 { x: { a: number; b: string } } interface Derived3 extends Base, Base2 { x: { a: string; b: string } } - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ interface Base { x: { @@ -44,7 +43,7 @@ interface Derived extends Base, Base2 { x: { b: string }; } -interface Derived2 extends Base, Base2 { // error +interface Derived2 extends Base, Base2 { x: { a: number, b: string }; } diff --git a/tests/typescript/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes2.ts b/tests/typescript/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes2.ts index 4ff83a669..4e44c20c7 100644 --- a/tests/typescript/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes2.ts +++ b/tests/typescript/conformance/interfaces/interfaceDeclarations/interfaceWithMultipleBaseTypes2.ts @@ -14,11 +14,10 @@ interface Derived extends Base, Base2 { x: { b: string } } -interface Derived2 extends Base, Base2 { // error +interface Derived2 extends Base, Base2 { x: { a: number; b: string } } interface Derived3 extends Base, Base2 { x: { a: string; b: string } } -