fix TSInterfaceDeclaration, TSInterfaceBody, TSInterfaceHeritage (#1599)

This commit is contained in:
Danny Martini authored and Christopher Chedeau committed 2017-05-12 17:13:38 -07:00
1 parent c86a57a91e
commit 19183e6452
5 files changed
+16 -14

No files matched your search

+1 -2
View File
@@ -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"
]
}
}
+6 -6
View File
@@ -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":
+6 -1
View File
@@ -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")
@@ -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 };
}
@@ -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 }
}