mwg API
    Preparing search index...

    Function emitTableTypes

    • Emits a TypeScript module with one named row interface and one typed row accessor per table, for a game's own build script to write and import. The declarations describe the same values contentCatalog returns - column type for column type, every field optional for the absent-cell rule above - so regenerating after an MWL edit turns a changed column type or a removed column into a compile error wherever the old shape was used.

      Parameters

      Returns string

      import { compile, contentCatalog, emitTableTypes } from '@datamoc/mwg/mwl';

      const catalog = contentCatalog(
      compile(
      "[{ tag: 'table', id: 'roster', columns: 'kind:string', children: [{ tag: 'row', kind: 'goblin' }] }]",
      ),
      );
      console.log(emitTableTypes(catalog.tables).includes('export interface RosterRow')); // true