Always expand enums (#1914)

We do the same for classes, and it's usually written that way even if it fits in one line, even in the TS docs: https://www.typescriptlang.org/docs/handbook/enums.html

Fixes #1873
master
Christopher Chedeau 2017-06-02 15:09:55 -07:00 committed by GitHub
parent a255977009
commit 2f9ea794db
7 changed files with 94 additions and 7 deletions

View File

@ -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,
"}"
])
)

View File

@ -319,7 +319,10 @@ class C {
import c = C;
enum E { Red, Blue }
enum E {
Red,
Blue
}
import e = E;

View File

@ -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
}
`;

View File

@ -3,6 +3,10 @@
exports[`enumDeclaration.ts 1`] = `
enum E { A, B, C }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
enum E { A, B, C }
enum E {
A,
B,
C
}
`;

View File

@ -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
}
`;

View File

@ -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
}

View File

@ -0,0 +1 @@
run_spec(__dirname, { parser: "typescript" });