angular/clang-format

enum formatting

vicb opened this issue · 6 comments

vicb commented
enum TokenType {
  CHARACTER,
  IDENTIFIER,
  KEYWORD,
  STRING,
  OPERATOR,
  NUMBER
}

@Injectable() export class Lexer {
} 

should be

enum TokenType {
  CHARACTER,
  IDENTIFIER,
  KEYWORD,
  STRING,
  OPERATOR,
  NUMBER
}

@Injectable() 
export class Lexer {
} 

Most probably caused because there is ";" after the enum - it would cause Dart to fail.

/cc @mprobst

vicb commented

Actually this should rather be a bug on ts2dart as TypeScript enum can have a ";"

No, this is a valid clang-format issue. enum declarations do not need a trailing semicolon in TypeScript, and clang-format incorrectly doesn't terminate the current line after one.

vicb commented

👍

We should still fix ts2dart to remove the optional ";", right ?

clang-format never removes tokens, it only remodels whitespace. Your ; will just end up as an empty statement in the code, on its own line, so it'll be easy enough to remove.

As discussed offline, enum X { Y, Z } should not be followed by a semicolon, so the ts2dart translation is fine.

The formatting patch has been submitted, closing this issue.