Skip to content

Type System Overview

FScript’s type system is strict, structural, predictable, and mostly inferred. It aims to feel familiar to TypeScript users while giving the compiler stronger guarantees.

Main goals

  • reject ill-typed programs before execution
  • avoid implicit any
  • support structural typing for plain data
  • keep local code lightweight through inference where that is safe
  • make exported APIs explicit and readable

The core type categories

  • primitive types
  • record types
  • array types
  • function types
  • generator sequence types
  • union and intersection types
  • literal types
  • generic types
  • Unknown
  • Never

Comparison to TypeScript

The overall feel is intentionally familiar, but Draft 0.1 is stricter in several ways:

  • no implicit any
  • more emphasis on explicit annotations at module boundaries
  • stronger preference for closed record shapes
  • a design goal of avoiding internal runtime type mismatches in well-typed code

Best reading order

  1. Inference
  2. Primitive Types
  3. Records
  4. Functions
  5. Unions
  6. Tagged Unions