diff options
author | Martin Probst <martin@probst.io> | 2018-09-27 06:48:13 +0000 |
---|---|---|
committer | Martin Probst <martin@probst.io> | 2018-09-27 06:48:13 +0000 |
commit | 3315aed44ad03f04a7ca2a53dec42ec2d8bc8001 (patch) | |
tree | 6924fdbdf905698e39d656dfb6ccfc308eaed020 /clang/unittests/Format/FormatTestJS.cpp | |
parent | 77708b2390879010fd866dad4eb8d361deaa15af (diff) | |
download | bcm5719-llvm-3315aed44ad03f04a7ca2a53dec42ec2d8bc8001.tar.gz bcm5719-llvm-3315aed44ad03f04a7ca2a53dec42ec2d8bc8001.zip |
clang-format: [JS] conditional types.
Summary:
This change adds some rudimentary support for conditional types.
Specifically it avoids breaking before `extends` and `infer` keywords,
which are subject to Automatic Semicolon Insertion, so breaking before
them creates incorrect syntax.
The actual formatting of the type expression is odd, but there is as of
yet no clear idea on how to format these.
See https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#conditional-types.
Reviewers: krasimir
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D52536
llvm-svn: 343179
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index ba0700edd4f..5a71f003371 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -2308,5 +2308,14 @@ TEST_F(FormatTestJS, ParameterNamingComment) { verifyFormat("callFoo(/*spaceAfterParameterNamingComment=*/ 1);"); } +TEST_F(FormatTestJS, ConditionalTypes) { + // Formatting below is not necessarily intentional, this just ensures that + // clang-format does not break the code. + verifyFormat( // wrap + "type UnionToIntersection<U> =\n" + " (U extends any ? (k: U) => void :\n" + " never) extends((k: infer I) => void) ? I : never;"); +} + } // end namespace tooling } // end namespace clang |