README.md
May 22, 2026 ยท View on GitHub
TS for GIR
TypeScript type definition generator for GObject introspection GIR files
ts-for-gir generates accurate TypeScript definitions from GObject Introspection for GJS projects โ strong typing, IDE jump-to-definition, autocompletion across the whole GNOME stack.
๐ Project page on the gjsify website: gjsify.github.io/gjsify/projects/ts-for-gir โ install paths, quickstart, generator usage, links to the related Patterns docs.
Browse the full TypeScript API Documentation for GLib, GTK, GStreamer, and more.
Quick Start
gjsify dlx @ts-for-gir/cli create my-app # no install, no Node.js
# or
npx @ts-for-gir/cli create my-app # via npm
Pick a template interactively, or pass --template <id>:
| Template | Best for |
|---|---|
types-gjsify | Node-free GJS app โ all dev scripts (install, build, run, format) routed through gjsify |
types-npm | Single-package, types from @girs/* NPM, esbuild + node |
types-locally | Generate types into ./@types/ (no @girs/* dep) |
types-workspace | npm workspace with @girs/* as locally-generated workspace packages |
cd my-app && npm start # or `gjsify run start` for types-gjsify
Installation
GJS โ no Node.js required
curl -fsSL https://raw.githubusercontent.com/gjsify/ts-for-gir/main/install.js -o /tmp/install.js
gjs -m /tmp/install.js && rm /tmp/install.js
Installs to ~/.local/bin/. Update later with ts-for-gir self-update. Powered by GJSify.
Alternative โ if you already have the gjsify CLI installed: gjsify dlx @ts-for-gir/cli <args> (npx-style, no install) or gjsify install -g @ts-for-gir/cli (managed global).
Node.js
npx @ts-for-gir/cli --help
# or globally:
npm install -g @ts-for-gir/cli
CLI Usage
ts-for-gir generate Gtk-4.0 # generate types for a single module
ts-for-gir generate Gtk-4.0 --reporter # with diagnostics
ts-for-gir analyze -f ./ts-for-gir-report.json # inspect the report
ts-for-gir --help # all commands
See the CLI documentation for advanced options.
Pre-generated NPM Packages
If you just want the types without generating them yourself:
npm install @girs/gjs @girs/gtk-4.0
import "@girs/gjs";
import "@girs/gjs/dom";
import "@girs/gtk-4.0";
import Gtk from "gi://Gtk?version=4.0";
const button = new Gtk.Button();
All packages are listed at gjsify/types. Missing a module? Open an issue.
Showcase
GNOME Applications
- Audio Player โ Play audio files
- Counters โ Keep track of anything
- Ignition โ Manage startup apps and scripts
- Learn 6502 โ Learn programming on vintage game consoles
- Sound Recorder โ A simple, modern sound recorder
- Sticky Notes โ Pin notes to your desktop
- Weather โ Show weather conditions and forecast
- K'uychi โ Generate color palettes
GNOME Shell Extensions
- gTile โ Tiling window management for GNOME Shell
- Copyous โ Clipboard manager for GNOME Shell
- Rounded Window Corners โ Add rounded corners to windows
Example Projects
Looking for a starting point? These example projects demonstrate how to use the TypeScript definitions with various bundlers:
- GTK 4 Template with Vite โ Modern UI with Vite bundling
- GNOME TypeScript Template โ A template using GTK, libadwaita, TypeScript, Flatpak, and Meson
More examples with screenshots and descriptions can be found in the Examples directory. For information on using the examples with different CLI options, refer to the CLI documentation.
Project Structure
ts-for-gir consists of several packages:
@ts-for-gir/cliโ Command-line interface for generating TypeScript definitions, documentation, and analyzing reports@gi.ts/parserโ Parser for GObject Introspection XML files@ts-for-gir/libโ Core library for processing GIR data@ts-for-gir/reporterโ Reporting system for problems and statistics with dependency injection@ts-for-gir/generator-typescriptโ TypeScript definition generator@ts-for-gir/generator-jsonโ TypeDoc JSON generator with GIR metadata enrichment@ts-for-gir/generator-html-docโ HTML documentation generator using TypeDoc@ts-for-gir/generator-baseโ Shared base class for generators@ts-for-gir/typedoc-themeโ Custom TypeDoc theme inspired by gi-docgen@ts-for-gir/gir-module-metadataโ Curated metadata (descriptions, logos, licenses) for GIR namespaces@ts-for-gir/templatesโ Template files for generated packages (tsconfig, typedoc config, ambient declarations)@ts-for-gir/tsconfigโ Shared TypeScript configuration@ts-for-gir/language-serverโ Language server for GIR files (experimental)
Submodules
This repo contains Git submodules for pre-generated types and documentation:
types-dev(branchdev) โ used during local development. Scripts write generated packages here.types-release(branchmain) โ updated by the release workflow on tags.docs(branchmain) โ generated HTML documentation, deployed to gjsify.github.io/docs.
Useful scripts:
gjsify run build:types # regenerate into ./types-dev
gjsify run build:types:release # regenerate into ./types-release
gjsify run build:doc # build HTML docs into ./docs
Further Reading
- TypeScript API Documentation
- Examples
- CLI Documentation
- gjsify/types โ pre-generated NPM packages
- gjsify/gnome-shell โ hand-written Shell Extension types