This is an archive of the discontinued LLVM Phabricator instance.

clang-format: [JS] fix union type spacing in object & array types.
ClosedPublic

Authored by mprobst on Aug 1 2017, 4:02 AM.

Details

Summary

Previously, clang-format would insert whitespace in union types nested in object
and array types, as it wouldn't recognize those as a type operator:

const x: {foo: number | null};
const x: [number | null];

While this is correct for actual binary operators, clang-format should not
insert whitespace into union and intersection types to mark those:

const x: {foo: number|null};
const x: [number|null];

This change propagates that the context is not an expression by inspecting
the preceding token and marking as non-expression if it was a type colon.

Diff Detail

Repository
rL LLVM

Event Timeline

mprobst created this revision.Aug 1 2017, 4:02 AM

Friendly ping.

This revision is now accepted and ready to land.Aug 8 2017, 12:58 AM
This revision was automatically updated to reflect the committed changes.