Skip to content

TypeScript Target Configuration

To configure TypeScript target, use [ts] in genotype.toml.

This configuration reference lists all available TypeScript configuration options.

See the Genotype Configuration for global settings and Common Target Options.

Set to true to generate TypeScript. Defaults to false; see enable target.

[ts]
enabled = true

mode selects what Genotype generates:

  • "types" (default): TypeScript type definitions.
  • "zod": Zod schemas and inferred types for runtime validation. Adds Zod to the generated package’s dependencies.
[ts]
enabled = true
mode = "zod"

See the TypeScript guide for generated code examples.

prefer selects how object type definitions are rendered in types mode:

  • "interface" (default): Generate interfaces, e.g., interface Book { ... }.
  • "alias": Generate type aliases, e.g., type Book = { ... }.
[ts]
enabled = true
prefer = "alias"

ext selects the extension used in generated local imports and re-exports:

  • "js" (default): JavaScript extensions, e.g., "./book.js".
  • "ts": TypeScript extensions, e.g., "./book.ts".
  • "none": No extension, e.g., "./book".
[ts]
enabled = true
ext = "none"

Generated source files always have the .ts extension.

[ts.naming] - Source File and Directory Names

Section titled “[ts.naming] - Source File and Directory Names”

naming.source_file controls generated file names. It defaults to "camelCase".

naming.source_dir controls generated directory names. When omitted, it follows naming.source_file.

Both accept:

  • "camelCase"
  • "PascalCase"
  • "snake_case"
  • "kebab-case"
[ts.naming]
source_file = "camelCase"
source_dir = "kebab-case"

This turns shop_goods/order_item.type into shop-goods/orderItem.ts. Generated local import paths use the same naming rules.

Overrides package generation for TypeScript. Inherits the global setting when omitted; see target package generation.

Defaults to "ts", relative to the global output directory. See target output directory.

Manifest options in [ts.manifest] become fields in package.json. Package name and version overrides go directly in that table:

[ts.manifest]
name = "@bookstore/types"
version = "0.2.0"
private = true
[ts.manifest.dependencies]
"@bookstore/shared-types" = "^1.0.0"

The generated package uses ES modules, with source files under src and an index.ts entry point. Its default name uses kebab-case. See package generation for layout controls.

tsconfig is an optional table written as tsconfig.json in the TypeScript package directory. When omitted, no tsconfig.json is generated:

[ts.tsconfig]
include = ["src/**/*.ts"]
[ts.tsconfig.compilerOptions]
strict = true
noEmit = true
module = "NodeNext"
moduleResolution = "NodeNext"

The table is converted directly to JSON, without adding compiler option defaults. It has no effect when package generation is disabled.

Values in external modules are JavaScript package import paths:

[ts.dependencies]
shared_types = "@bookstore/shared-types"

Adds formatters for TypeScript; defaults to []. See target formatters for execution order and formatter configuration for commands and presets.