Skip to content

LiteralMapExpression needs support for collection-if expression #1145

Open
@lukehutch

Description

@lukehutch

LiteralMapExpression does not yet support collection-if. This means it's not possible to generate the following:

{
  if (x != null) 'x' : x,
  if (y != null) 'y': y,
  if (z != null) 'z': z,
}

I need to be able to add these conditions in order to minimize the text-rendered size of sparse JSON maps.

Presumably the way to support this would be similar to how literalSpread works:

literalMap({
  collectionIf(refer('x').isNotNull(), 'x'): refer('x'),
  // ...
})

Expression.visitLiteralMapExpression will also need to be updated to support this (and it should work for sets and lists too)..

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions