Skip to Content

typir

The library for type systems and type checking for software languages in the web

OpenSource, written in TypeScript, and follows pragmatic approaches for simplifying type checking in practical language engineering projects by providing default implementations for recurring problems.

$ npm install typir

What is Typir?

Typir is a stand-alone library that provides a TypeScript API for language engineers without requiring an additional, external DSL for formalizing types. Whether you're building a domain-specific language, a programming language, or any other language-based tool, Typir simplifies type checking with ready-to-use implementations.

✓ What Typir Provides

  • • Predefined types and operators
  • • Type-checking services out of the box
  • • Circular type definitions support
  • • Caching and performance optimization
  • • Meaningful, customizable error messages
  • • Dependency injection for customization

✗ What Typir Does Not Include

  • • Rule engines and constraint solving
  • • Formal proofs
  • • External DSLs for formalizing types
  • • Dynamic type system support

Typir focuses on static type systems for checking during development time.

Core Features

Predefined Types

  • • Primitive types (number, string, boolean, etc.)
  • • Function types with overloading
  • • Structurally typed classes
  • • Top and bottom types
  • • Custom types API

Type-checking Services

  • • Assignability checking
  • • Type equality verification
  • • Implicit and explicit conversion
  • • Type inference for AST nodes
  • • Sub-typing relationships
  • • Validation with detailed errors

Operators

  • • Binary and unary operators
  • • Operator overloading support
  • • Custom operator definitions
  • • Type-safe operator inference

Advanced Capabilities

  • • Circular type definitions
  • • Intelligent caching system
  • • Performance optimizations
  • • Incremental type system updates

Customization

  • • Dependency injection support
  • • Override default implementations
  • • Custom error messages
  • • Flexible validation rules

Type Graph

  • • Nodes representing types
  • • Edges for type relationships
  • • Conversion path analysis
  • • Sub-type hierarchy tracking

NPM Packages

typir

The core package with default implementations for type checking services and predefined types. Use this for any language, with or without a language workbench.

typir-langium

The binding of Typir for Langium, a language workbench for developing textual DSLs in the web. Includes all features of Typir core plus Langium-specific APIs.

Examples

LOX Language

Static type checking for the LOX programming language, implemented with Typir-Langium. Demonstrates classes, functions, and advanced type checking.

View Example →

OX Language

A reduced version of LOX, implemented with Typir-Langium. Perfect for learning the basics of type checking with Typir.

View Example →

Expression Language

A simple expression language with a handwritten parser, implemented with Typir core. Shows how to use Typir without a language workbench.

View Example →

Resources & Community

Blog: Announcing Typir

TypeFox Blog • June 6, 2025

Read Article

LangDev'24 Talk

October 17, 2024

OCX/EclipseCon'24 Talk

October 24, 2024