Skip to content

fix(markdown-template): keep parent scope in enum optional blocks - #684

Merged
mttrbrts merged 1 commit into
mainfrom
claude/fix-enum-optional-scope
Oct 11, 2026
Merged

mttrbrts merged 1 commit into
mainfrom
claude/fix-enum-optional-scope

Conversation

@mttrbrts

@mttrbrts mttrbrts commented Oct 11, 2026 •

Copy link
Copy Markdown
Member

This is a follow-up to #683. @Shubh-Raj raised this case in their review of #647.

#683 keeps the parent scope only when the optional property is primitive. property.isPrimitive() is false for enum fields, so an enum optional still scoped its body to the enum declaration. On main today, all of these fail with Unknown property:

{{#optional billingFrequency}}{{billingFrequency}}{{/optional}}
{{#optional billingFrequency}}{{name}}{{/optional}}
{{#optional billingFrequency}}{{this}}{{/optional}}

Change

OptionalDefinition now treats enum properties as scalars, like primitives:

  • the body keeps the parent scope;
  • {{this}} resolves to the enum field, as an EnumVariableDefinition with its enumValues.

Tests

The new tests cover:

  • named and sibling variables in an enum #optional block;
  • rejection of unknown variables;
  • {{this}} used together with named variables in the same block, for enum and primitive optionals. @Shubh-Raj also suggested this case.

Results:

  • Both new tests fail without the change.
  • markdown-template passes (28 tests) and markdown-transform passes (31).
  • tsc --noEmit is clean, and ESLint reports no errors.

🤖 Generated with Claude Code

property.isPrimitive() is false for enum fields, so {{#optional billingFrequency}}
on an enum property still scoped its body to the enum declaration and
rejected {{billingFrequency}}, {{this}} and sibling variables. Treat enum optionals
as scalars, like primitives.

Follow-up to #683, raised in review of #647.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Matt Roberts <code@rbrts.uk>
@mttrbrts
mttrbrts force-pushed the claude/fix-enum-optional-scope branch from 1d3c373 to 990ee2f Compare October 11, 2026 10:56
@mttrbrts
mttrbrts enabled auto-merge (squash) October 11, 2026 10:57
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 38133762789

Coverage increased (+0.4%) to 83.247%

Details

  • Coverage increased (+0.4%) from the base build.
  • Patch coverage: 2 of 2 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 2412
Covered Lines: 2052
Line Coverage: 85.07%
Relevant Branches: 871
Covered Branches: 681
Branch Coverage: 78.19%
Branches in Coverage %: Yes
Coverage Strength: 1109.55 hits per line

💛 - Coveralls

@mttrbrts
mttrbrts disabled auto-merge October 11, 2026 11:01
@mttrbrts
mttrbrts merged commit 18b9dd3 into main Oct 11, 2026
7 checks passed
@mttrbrts
mttrbrts deleted the claude/fix-enum-optional-scope branch October 11, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants