diff --git a/src/printer.js b/src/printer.js index 22ec8956b..d9a5d0a21 100644 --- a/src/printer.js +++ b/src/printer.js @@ -2464,10 +2464,9 @@ function genericPrintNoParens(path, options, print, args) { group( concat([ "{", - options.bracketSpacing ? line : softline, indent( concat([ - softline, + hardline, printArrayItems(path, options, "members", print) ]) ), @@ -2476,8 +2475,7 @@ function genericPrintNoParens(path, options, print, args) { options, /* sameIndent */ true ), - softline, - options.bracketSpacing ? line : softline, + hardline, "}" ]) ) diff --git a/tests/typescript/conformance/internalModules/importDeclarations/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/conformance/internalModules/importDeclarations/__snapshots__/jsfmt.spec.js.snap index bf94b090a..c8b96da17 100644 --- a/tests/typescript/conformance/internalModules/importDeclarations/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript/conformance/internalModules/importDeclarations/__snapshots__/jsfmt.spec.js.snap @@ -319,7 +319,10 @@ class C { import c = C; -enum E { Red, Blue } +enum E { + Red, + Blue +} import e = E; diff --git a/tests/typescript/conformance/types/constKeyword/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/conformance/types/constKeyword/__snapshots__/jsfmt.spec.js.snap index 04e9413cc..813ae8d5b 100644 --- a/tests/typescript/conformance/types/constKeyword/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript/conformance/types/constKeyword/__snapshots__/jsfmt.spec.js.snap @@ -3,6 +3,10 @@ exports[`constKeyword.ts 1`] = ` const enum E { A, B, C } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const enum E { A, B, C } +const enum E { + A, + B, + C +} `; diff --git a/tests/typescript/conformance/types/enumDeclaration/__snapshots__/jsfmt.spec.js.snap b/tests/typescript/conformance/types/enumDeclaration/__snapshots__/jsfmt.spec.js.snap index 2b45eff75..fadda5189 100644 --- a/tests/typescript/conformance/types/enumDeclaration/__snapshots__/jsfmt.spec.js.snap +++ b/tests/typescript/conformance/types/enumDeclaration/__snapshots__/jsfmt.spec.js.snap @@ -3,6 +3,10 @@ exports[`enumDeclaration.ts 1`] = ` enum E { A, B, C } ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -enum E { A, B, C } +enum E { + A, + B, + C +} `; diff --git a/tests/typescript_enum/__snapshots__/jsfmt.spec.js.snap b/tests/typescript_enum/__snapshots__/jsfmt.spec.js.snap new file mode 100644 index 000000000..04d8dccf7 --- /dev/null +++ b/tests/typescript_enum/__snapshots__/jsfmt.spec.js.snap @@ -0,0 +1,53 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`enum.ts 1`] = ` +enum Direction { + Up = 1, + Down, + Left, + Right +} + +enum FileAccess { + // constant members + None, + Read = 1 << 1, + Write = 1 << 2, + ReadWrite = Read | Write, + // computed member + G = "123".length +} + +enum Empty { +} + +const enum Enum { + A = 1, + B = A * 2 +} +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +enum Direction { + Up = 1, + Down, + Left, + Right +} + +enum FileAccess { + // constant members + None, + Read = 1 << 1, + Write = 1 << 2, + ReadWrite = Read | Write, + // computed member + G = "123".length +} + +enum Empty {} + +const enum Enum { + A = 1, + B = A * 2 +} + +`; diff --git a/tests/typescript_enum/enum.ts b/tests/typescript_enum/enum.ts new file mode 100644 index 000000000..96b2f13e3 --- /dev/null +++ b/tests/typescript_enum/enum.ts @@ -0,0 +1,24 @@ +enum Direction { + Up = 1, + Down, + Left, + Right +} + +enum FileAccess { + // constant members + None, + Read = 1 << 1, + Write = 1 << 2, + ReadWrite = Read | Write, + // computed member + G = "123".length +} + +enum Empty { +} + +const enum Enum { + A = 1, + B = A * 2 +} diff --git a/tests/typescript_enum/jsfmt.spec.js b/tests/typescript_enum/jsfmt.spec.js new file mode 100644 index 000000000..bc085c48c --- /dev/null +++ b/tests/typescript_enum/jsfmt.spec.js @@ -0,0 +1 @@ +run_spec(__dirname, { parser: "typescript" });