#4959·baml

TypeScript client: `///` doc comments containing `*/` break out of the generated JSDoc comment

Author: yoarajotaCreated Sep 22, 2026Updated Sep 22, 2026

Product: BAML

Describe the bug A /// doc comment on a class, enum, or field breaks out of its JSDoc block in the generated TypeScript client if it contains */. On a class doc comment, whatever comes after */ lands as a live top-level statement in types.ts, right before the export interface. On a field or enum-value doc comment, the same corruption drops the text inside the interface/enum body instead, which tsc then rejects.

Root cause: prefix_lines in engine/generators/languages/typescript/src/utils.rs writes each docstring line straight into a /** ... */ block with no escaping. It's the only place the EnumTS/ClassTS/FieldTS askama templates in generated_types.rs render a docstring for the TS target.

Reproduction Steps

mkdir -p repro/baml_src && cd repro
cat > baml_src/generators.baml <<'BAML'
generator target {
  output_type "typescript"
  output_dir "../"
  version "0.226.2"
}
BAML
cat > baml_src/main.baml <<'BAML'
/// normal doc */ export const injected = 1; /*
class Foo {
  kind string
}
BAML
npx --yes @boundaryml/[email protected] generate
cat baml_client/types.ts

Output includes:

typescript
/**
 * normal doc */ export const injected = 1; /*
 */
export interface Foo {
  kind: string
}

export const injected = 1; is a real statement now, not a comment.

BAML Version: 0.226.2 (npm @boundaryml/baml). prefix_lines and the three docstring templates in generated_types.rs are unchanged at main HEAD (60112f5) — I read the current source directly, I just didn't have cargo/mise on hand to build that commit and re-run the repro against it.

Language/Framework: Node.js

Fix direction: escape */ (*\/ works) wherever a docstring gets spliced into a /** ... */ block, before the template sees it.