Type Annotations
Optional TypeScript-style type annotations in Tish.
Tish supports optional TypeScript-style type annotations. Types are parsed but not enforced at runtime (gradual typing). Omit them for dynamic typing.
Syntax
// Variable declarations
let x: number = 42
const name: string = "hello"
let arr: number[] = [1, 2, 3]
// Function parameters and return types
fn add(a: number, b: number): number {
return a + b
}
// Object types
let person: { name: string, age: number } = { name: "Alice", age: 30 }
// Union types
let value: number | string = 42
// Rest parameters
fn sum(...args: number[]): number { ... }Supported Types
Notes
- Type annotations are optional; omitting them is equivalent to dynamic typing.
- Types are parsed and stored in the AST but not enforced during evaluation.
- Future phases may add type inference and type checking.