type-rb

module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2026 License: MIT

README

TypeRB

[!WARNING] TypeRB is in alpha. The language, standard library, and tooling may change without notice.

TypeRB is a statically typed programming language that compiles to Go, Ruby, and TypeScript.

Try TypeRB

A Tour of TypeRB

Learn the language through guided, executable lessons.

TypeRB Playground

Write, run, format, and transpile TypeRB while switching between Go, Ruby, and TypeScript output.

With the compiler installed, launch the same tools locally:

trb tour
trb play

Install

brew install type-rb/tap/trb
trb version

To build the compiler from source, use Go 1.26:

go install github.com/type-rb/type-rb/cmd/trb@latest

REPL

For a terminal workflow, start a typed REPL from any directory. It uses Go mode when no project configuration is present:

$ trb
trb:go> puts("Hello, TypeRB!")
Hello, TypeRB!
trb:go> 1 + 2
3 : Integer

Select another target for a one-off session:

trb repl --mode ruby
trb repl --mode typescript

Create a project

Create and run a Go project:

trb init --mode go --module example.com/hello hello
cd hello

Create main.trb:

def main()
	puts("Hello from TypeRB")
	return
end

Then format and run it:

trb fmt
trb run

trb run builds in a temporary directory before executing the program. Use trb build when you want to keep the generated source.

Go projects can also produce an executable:

trb build --compile
./bin/hello

To start a portable JSON API with file-based routes and explicit request ID and access-log middleware, generate the Web template:

trb init --mode go --module example.com/api --template web api
cd api
trb run

Targets

  • Go for native binaries and services
  • Ruby for server and application development
  • TypeScript for browser applications

Every target uses the same TypeRB grammar and portable semantics. A target mode selects the backend, toolchain, and package ecosystem. Target-specific APIs require explicit imports.

Documentation

Read the documentation for the CLI, configuration, language, standard library, target guides, current status, and roadmap.

License

TypeRB is available under the MIT License.

Directories

Path Synopsis
cmd
trb command
trb-wasm command
internal
ast
Package ast defines the lossless syntax tree.
Package ast defines the lossless syntax tree.
checker
Package checker resolves names, infers local declaration types, validates assignments/returns, and records a type for every portable expression.
Package checker resolves names, infers local declaration types, validates assignments/returns, and records a type for every portable expression.
cli
codegen/naming
Package naming contains target-independent helpers for encoding TypeRB source names that are not valid identifiers in every backend.
Package naming contains target-independent helpers for encoding TypeRB source names that are not valid identifiers in every backend.
compiler
Package compiler owns the public compilation pipeline.
Package compiler owns the public compilation pipeline.
dbtool
Package dbtool adapts external schema management tools to TypeRB's stable database commands.
Package dbtool adapts external schema management tools to TypeRB's stable database commands.
declaration
Package declaration defines compiler-owned type information supplied by runtime-library providers.
Package declaration defines compiler-owned type information supplied by runtime-library providers.
formatter
Package formatter implements a deterministic, comment-preserving TypeRB printer.
Package formatter implements a deterministic, comment-preserving TypeRB printer.
ir
Package ir defines the resolved, target-independent representation consumed by every backend.
Package ir defines the resolved, target-independent representation consumed by every backend.
languageservice
Package languageservice provides editor-independent analysis used by the REPL and future browser and language-server adapters.
Package languageservice provides editor-independent analysis used by the REPL and future browser and language-server adapters.
lexer
Package lexer provides the lossless lexical layer used by both the compiler and formatter.
Package lexer provides the lossless lexical layer used by both the compiler and formatter.
lower
Package lower converts checked syntax AST into the normalized IR.
Package lower converts checked syntax AST into the normalized IR.
official
Package official loads versioned TypeRB packages bundled with the compiler.
Package official loads versioned TypeRB packages bundled with the compiler.
orm
Package orm owns the compiler-side integration for the official trb/orm package.
Package orm owns the compiler-side integration for the official trb/orm package.
packages
Package packages generates target package-manager manifests from trbconfig.jsonc.
Package packages generates target package-manager manifests from trbconfig.jsonc.
parser
Package parser implements TypeRB's handwritten recursive-descent and Pratt parsers.
Package parser implements TypeRB's handwritten recursive-descent and Pratt parsers.
playground
Package playground serves the local TypeRB playground and guided tour.
Package playground serves the local TypeRB playground and guided tour.
project
Package project owns trbconfig.jsonc discovery, validation, and persistence.
Package project owns trbconfig.jsonc discovery, validation, and persistence.
projectintegration
Package projectintegration runs compile-time hooks declared by TypeRB packages without teaching the compiler pipeline their domain-specific data.
Package projectintegration runs compile-time hooks declared by TypeRB packages without teaching the compiler pipeline their domain-specific data.
repl
Package repl implements TypeRB's project-aware interactive evaluator.
Package repl implements TypeRB's project-aware interactive evaluator.
resolver
Package resolver turns syntax imports into project or compiler-known package identities before type checking.
Package resolver turns syntax imports into project or compiler-known package identities before type checking.
schemalock
Package schemalock owns the deterministic, backend-independent database schema artifact consumed by compiler integrations and command-line tools.
Package schemalock owns the deterministic, backend-independent database schema artifact consumed by compiler integrations and command-line tools.
stdlib
Package stdlib describes compiler-known portable and platform packages.
Package stdlib describes compiler-known portable and platform packages.
typeprovider
Package typeprovider loads compiler-owned declaration graphs for explicitly imported platform packages.
Package typeprovider loads compiler-owned declaration graphs for explicitly imported platform packages.
typeprovider/rails
Package rails supplies TypeRB declarations for Rails and derives ActiveRecord model types from db/schema.rb.
Package rails supplies TypeRB declarations for Rails and derives ActiveRecord model types from db/schema.rb.
typeprovider/rails/schema
Package schema defines the normalized AST for the subset of Rails schema DSL that contributes model types.
Package schema defines the normalized AST for the subset of Rails schema DSL that contributes model types.
types
Package types contains target-independent semantic types.
Package types contains target-independent semantic types.
web
Package web owns target-independent compilation support for trb/web.
Package web owns target-independent compilation support for trb/web.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL