Skip to content

Improve the type of TemplateExpression #145

@bakkot

Description

@bakkot

TemplateExpression has

interface TemplateExpression : Expression {
  attribute Expression? tag;
  attribute (Expression or TemplateElement)[] elements;
}

but that's imprecise: the elements must alternate, be nonempty, and begin and end with TemplateElement. A better type would be

interface TemplatePart {
  attribute Expression expression;
  attribute TemplateElement string;
}
interface TemplateExpression : Expression {
  attribute Expression? tag;
  attribute TemplateElement first;
  attribute TemplatePart[] parts;
}

which represents precisely the legal templates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions