Workflow
Code generation
Messagevisor can generate TypeScript helpers from your project, mainly to make runtime integrations more typed and ergonomic.
Generate TypeScript#
$ npx messagevisor generate-code --language typescript --out-dir src/generatedGenerated files are application helpers, not source definitions. Commit them when your application build expects them to be present, or generate them in CI when you prefer generated code to stay out of pull requests.
React helpers#
$ npx messagevisor generate-code --language typescript --out-dir src/generated --reactFiltering#
$ npx messagevisor generate-code --language typescript --out-dir src/generated --target=web$ npx messagevisor generate-code --language typescript --out-dir src/generated --includeMessages="auth*"What code generation is for#
Code generation is useful when you want:
- typed message key access
- project-aware helper code
- a smoother integration layer in TypeScript or React apps
- autocomplete for available message keys
- fewer hard-coded string keys in application code
For example, generated helpers can make it easier for app developers to discover dashboard.welcome while still letting product and localization reviewers inspect the real source in messages/dashboard/welcome.yml.
What it is not for#
Code generation does not replace:
build- runtime datafiles
- the SDK itself
Think of it as a typed convenience layer around the same underlying project model.
Current scope#
Only TypeScript generation is supported today.
The command can filter by --target, --includeMessages, and --excludeMessages, which is useful when one app only consumes a subset of a larger Messagevisor project.
For sets-based projects, pass --set=<set> to generate against the same authored tree that will be built and deployed.
Checking application call sites today#
Code generation catches mistyped keys when application code uses the generated types, but Messagevisor does not yet ship a source-code extractor. For an interim CI check:
- generate the typed key union into a deterministic directory;
- fail CI when regeneration changes committed output;
- search application code for literal calls such as
translate("..."),t("..."), or your wrapper API; - compare those literals with
npx messagevisor list --messages --json; - treat dynamic keys as a reviewed exception instead of guessing their possible values.
This can identify literal calls to undefined keys and defined keys with no discovered literal call sites. It cannot prove that a key assembled dynamically is unused. Runtime deprecated_message diagnostics remain the safer last-mile signal while migrating or retiring keys.