Skip to content

Commit

Permalink
clang-format: Recognize the .ts (TypeScript) extension as JavaScript.
Browse files Browse the repository at this point in the history
Patch by Martin Probst. Thank you.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@231926 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
djasper-gh committed Mar 11, 2015
1 parent b78479d commit a47fa0b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/Format/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,8 @@ const char *StyleOptionHelpDescription =
static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
if (FileName.endswith(".java")) {
return FormatStyle::LK_Java;
} else if (FileName.endswith_lower(".js")) {
} else if (FileName.endswith_lower(".js") || FileName.endswith_lower(".ts")) {
// JavaScript or TypeScript.
return FormatStyle::LK_JavaScript;
} else if (FileName.endswith_lower(".proto") ||
FileName.endswith_lower(".protodevel")) {
Expand Down
2 changes: 1 addition & 1 deletion tools/clang-format/clang-format-diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def main():
help='custom pattern selecting file paths to reformat '
'(case sensitive, overrides -iregex)')
parser.add_argument('-iregex', metavar='PATTERN', default=
r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hpp|m|mm|inc|js|proto'
r'.*\.(cpp|cc|c\+\+|cxx|c|cl|h|hpp|m|mm|inc|js|ts|proto'
r'|protodevel|java)',
help='custom pattern selecting file paths to reformat '
'(case insensitive, overridden by -regex)')
Expand Down

0 comments on commit a47fa0b

Please sign in to comment.