Drupal is a registered trademark of Dries Buytaert
Release: Leaflet 10.4.11 Minor update available for module leaflet (10.4.11). Release: Session Inspector 1.0.8 Minor update available for module session_inspector (1.0.8). Release: Migrate QA 2.0.4 Minor update available for module migrate_qa (2.0.4). Release: CKEditor Description List 3.0.0 Major update available for module ckeditor_descriptionlist (3.0.0). Release: FlowDrop 2.4.0 Minor update available for module flowdrop (2.4.0). Release: JWT Token Refresh 1.0.4 Minor update available for module jwt_token_refresh (1.0.4). Release: ConReg 1.0.0-beta1 First beta version released for module conreg (1.0.0-beta1). Release: AI Image Studio 1.0.0-beta8 New beta version released for module ai_image_studio (1.0.0-beta8). Usage Milestone: Statistics Counter Module statistics_counter crossed 1,000 active installs. Module Revived: Decoupled Router 2.0.7 Module decoupled_router updated after 11 months of inactivity (2.0.7).

This module generates TypeScript type definitions for Drupal entities, and can optionally create functions to convert data between types. It is run via a Drush command using a configuration file.

Generates TypeScript type definitions from your site's own entity and field definitions, so a decoupled frontend describes Drupal's data by reading Drupal rather than by hand-maintaining interfaces that drift.

Choose which entity types to describe in the Drupal UI, then generate:

drush tsg --dir=../app/src/definitions --parser

Everything is derived from the Entity, Field and Typed Data APIs. Add a field
in Drupal, regenerate, and the compiler tells you what needs updating. Field
types the module has never heard of are described through their Typed Data
definitions rather than ignored, so a contributed field usually works without
anyone adding support for it.

What you can generate

Each output is opt-in, and all of them describe the same schema.

Drupal's payload shape is always written. It matches what the `serialization` module sends, wrappers and all.

title: FieldItemList<StringItem>

A frontend shape, and the functions producing it (`--normalized`,
`--parser`). The same content with the item wrappers removed, single values
collapsed, and references as pointers. The generated parsers are plain
functions, and the output imports nothing outside itself.

title: string | null
field_tags: EntityReferenceTaxonomyTermItem[]     // Ref<"taxonomy_term">

JSON:API (`--jsonapi`). A resource type per bundle, with attributes,
relationships narrowed to the resource types they can point at, and a document
that is a union of a data document and an error document, so reading `data`
without handling a failed request is a compile error. Sparse fieldsets have a
type too.

A bundle-to-component contract (`--components`). A map from every bundle to the component that renders it, so adding a bundle in Drupal stops the frontend compiling until someone assigns a component, rather than shipping a region nobody noticed was blank.

A language-neutral manifest (`--manifest`). `schema.json`, the same schema
as data rather than as types: field types, cardinality, allowed values, storage
classifications. For generating things this module does not, such as Zod
validators, JSON Schema, OpenAPI or documentation.

Works with most content entities

Definitions can be generated from nearly any content entity defined in your site. It also works with Layout Builder, Drupal Canvas, and Paragraphs.

Keeping definitions in sync

`--check` writes nothing and compares what would be generated against what is already there, exiting non-zero if they differ. Run it in CI against a site
installed from your committed configuration, and a field added without
regenerating fails the build instead of reaching production.

drush tsg --dir=../app/src/definitions --parser --check

Extending

Component generators are tagged services, so a contributed module can describe its own field types, or replace how a core one is described, by registering a generator at a higher priority. Generators receive the module's schema model rather than Drupal's managers.

The included `typescript_generator_metatag` submodule is a working example.

Requirements

Drupal 11 or 12, and Drush 13 or later.

The JSON:API output additionally needs the core `jsonapi` module. Nothing else is required, and the generated files have no runtime dependencies.

Upgrading from 3.x

4.0 is a rearchitecture. The YAML configuration file is gone in favor of Drupal
configuration and an admin form, the command takes its output directory as an option.

Activity

Tracked releases
2
Tracked since
Aug 2026
Latest release
2 days ago
Releases (12 mo)
2 ▲ from 0
Maintenance
Active

Releases

Version Type Release date
4.0.0 Stable Aug 21, 2026
4.0.x-dev Dev Aug 18, 2026