type-rb

module
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 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

Add calculator_test.trb beside application source and run portable tests:

import { describe, expect, test } from trb/std/test

describe("Calculator") do
	test("adds numbers") do
		expect(1 + 2).to_equal(3)
	end
end
trb test

The VS Code extension discovers the same suites in Test Explorer. See the testing guide for filtering and assertion APIs.

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

Follow the learning path, or browse the documentation for application guides, references, current status, and the 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/effectplan
Package effectplan performs whole-project call-graph analysis for backend effects that remain intentionally absent from TypeRB source signatures.
Package effectplan performs whole-project call-graph analysis for backend effects that remain intentionally absent from TypeRB source signatures.
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.
compilerservice
Package compilerservice owns reusable, editor-independent project snapshots.
Package compilerservice owns reusable, editor-independent project snapshots.
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.
jobs
Package jobs models the compile-time contract shared by portable job adapters.
Package jobs models the compile-time contract shared by portable job adapters.
jobs/sqladapter
Package sqladapter owns the compile-time configuration for the official trb/jobs/sql adapter.
Package sqladapter owns the compile-time configuration for the official trb/jobs/sql adapter.
jobs/sqlstore
Package sqlstore defines the durable state model and dialect-specific SQL used by the portable SQL job adapter.
Package sqlstore defines the durable state model and dialect-specific SQL used by the portable SQL job adapter.
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.
lsp
Package lsp adapts the shared compiler and language services to the Language Server Protocol.
Package lsp adapts the shared compiler and language services to the Language Server Protocol.
nativepackage
Package nativepackage owns cached type information derived from native target-language packages.
Package nativepackage owns cached type information derived from native target-language packages.
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.
sourcemap
Package sourcemap records backend-independent relationships between generated code and TypeRB source.
Package sourcemap records backend-independent relationships between generated code and TypeRB source.
stdlib
Package stdlib describes compiler-known portable and platform packages.
Package stdlib describes compiler-known portable and platform packages.
testsuite
Package testsuite discovers and prepares TypeRB test declarations without coupling the parser or the language server to the test runner.
Package testsuite discovers and prepares TypeRB test declarations without coupling the parser or the language server to the test runner.
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