This is an archive of the discontinued LLVM Phabricator instance.

clang-format: [JS] handle semis in generic types.
ClosedPublic

Authored by mprobst on Nov 24 2017, 4:07 AM.

Details

Summary

TypeScript generic type arguments can contain object (literal) types,
which in turn can contain semicolons:

const x: Array<{a: number; b: string;} = [];

Previously, clang-format would incorrectly categorize the braced list as
a block and terminate the line at the openening {, and then format the
entire expression badly.

With this change, clang-format recognizes < preceding a { as
introducing a type expression. In JS, < comparison with an object
literal can never be true, so the chance of introducing false positives
here is very low.

Diff Detail

Repository
rL LLVM

Event Timeline

mprobst created this revision.Nov 24 2017, 4:07 AM
djasper accepted this revision.Nov 24 2017, 9:03 AM

Looks good.

This revision is now accepted and ready to land.Nov 24 2017, 9:03 AM
This revision was automatically updated to reflect the committed changes.