Skip to content

Emit database column comments as JSDoc in generated types #91

Closed

Description

@spinlud

What to build

Surface database column comments in the generated output as /** … */ JSDoc leading comments on the generated declarations, so they show up as editor type hints.

The introspection half is already done: the shared column-metadata already carries a comment field, populated today for MySQL and MariaDB (information_schema.COLUMNS.COLUMN_COMMENT), Postgres (pg_description), and MSSQL (sys.extended_properties / MS_Description). The comment is currently only forwarded to Sequelize's runtime comment option, not rendered as a code-level doc comment. No introspection query changes are required.

The work is purely in the emitter: attach a synthetic leading JSDoc comment (ts.addSyntheticLeadingComment with MultiLineCommentTrivia, text lead * to produce /** … */) to the generated declarations, in both output formats:

  • Native format: on the declare attribute property declarations (the primary v13 format).
  • Decorator format: on the class property (above its @Column decorator) and the strict Attributes interface property signature — the block PR Add comment generation to TypeScript interfaces #61 originally patched.

Acceptance criteria

  • Columns with a non-empty comment render a /** <comment> */ JSDoc leading comment on the generated declaration in the native format (declare attributes) and the decorator format (class property and Attributes interface).
  • Empty/whitespace comments produce no comment (MySQL/MariaDB return '' rather than null — guard on truthiness).
  • SQLite is a no-op (PRAGMA exposes no column comments) and is unaffected.
  • Comment text is sanitised so an embedded */ cannot prematurely close the JSDoc block.
  • Integration tests: for MySQL, MariaDB, Postgres, and MSSQL a column carrying a comment produces the JSDoc in generated output; SQLite output is unchanged. Reuse PR Add comment generation to TypeScript interfaces #61's per-dialect comment-seeding SQL (MySQL/MariaDB COMMENT '…', Postgres COMMENT ON COLUMN …, MSSQL sp_addextendedproperty … 'MS_Description').
  • On completion (once this change is merged), close PR Add comment generation to TypeScript interfaces #61 with a comment pointing to this ticket.

Blocked by

None (can start immediately).

Source

Extracted from PR #61 (predates the v13 native emitter; only patched the decorator Attributes interface). Reuse its addSyntheticLeadingComment approach and test seed SQL; redo placement to also cover the native emitter. Supersedes PR #61 — close it pointing here.

Activity

  1. added a commit that references this issue on Sep 11, 2026
  2. spinlud commented on Sep 11, 2026

    @spinlud
    OwnerAuthor

    Shipped in v13.1.0 (sequelize-typescript-generator@13.1.0 on npm), merged via #92. Database column comments are now emitted as /** … */ JSDoc in both the native and decorator output formats. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agentReady for an agent to implement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions