Skip to content

Template parser emits invalid TypeScript new ); when optional seed block is empty in generated Column class #10

Description

@jamespaulengay
### Bug description

Generated TypeScript can be invalid in templates emitted by Stackpress.

### Reproduction

1. Generate client/schema code from `templates/blog` (or a similar flow).
2. Inspect generated file:
   - `templates/blog/node_modules/blog-client/Profile/columns/AddressColumn.ts`
3. Formatting/build step fails with:

```txt
SyntaxError: Expression expected. (23:26)
... this._fieldset = new );

Actual behavior

Prettier/parser throws:

SyntaxError: Expression expected. (23:26)
  21 |   public constructor() {
  22 |
> 23 |     this._fieldset = new );
     |                          ^
  24 |     this.shape = this._fieldset.shape.refine(

Expected behavior

Generated constructor call should include a class and optional argument only when present:

  • this._fieldset = new AddressSchema(seed);
  • this._fieldset = new AddressSchema();

Root cause hypothesis

The template output for constructor creation appears to be generated with a nested optional block, which can produce an empty argument list and emit invalid TS (new );).

Suggested fix

  • Prefer passing seed as a direct template value in this path instead of using nested conditional tags inside new (...).
  • Or harden the template parser to avoid token parsing where method/name and close patterns consume reserved markers like %, <, and >.

Environment

  • Repository: stackpress-lib
  • Path: /Users/cnc/Projects/stackpress-lib/stackpress
  • Error location: templates/blog/node_modules/blog-client/Profile/columns/AddressColumn.ts line 23

Relevant error snippet

SyntaxError: Expression expected. (23:26)
  23 |     this._fieldset = new );
     |                          ^

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