Skip to content

Primitive Types

IonPath provides a rich set of built-in types covering integers, floats, strings, dates, and special types. Each type has a fixed wire encoding and mappings to C# and TypeScript.

Integer Types

Signed and unsigned integers from 8-bit to 128-bit.

Ion Type C# TypeScript Size Description
i1sbytenumber8 bitsSigned byte (-128 to 127)
i2shortnumber16 bitsSigned short
i4intnumber32 bitsSigned integer
i8longbigint64 bitsSigned long
i16Int128bigint128 bitsSigned 128-bit integer
u1bytenumber8 bitsUnsigned byte (0 to 255)
u2ushortnumber16 bitsUnsigned short
u4uintnumber32 bitsUnsigned integer
u8ulongbigint64 bitsUnsigned long
u16UInt128bigint128 bitsUnsigned 128-bit integer

The naming convention follows byte count: i4 = 4 bytes = 32 bits. u prefix means unsigned, i means signed.

Floating-Point Types

Ion Type C# TypeScript Size Description
f2Halfnumber16 bitsIEEE 754 half precision
f4floatnumber32 bitsIEEE 754 single precision
f8doublenumber64 bitsIEEE 754 double precision

Special Types

Ion Type C# TypeScript Description
voidvoidvoidNo value — used for methods with no return
boolboolbooleanBoolean true/false
stringstringstringUTF-8 text
guidGuidstring128-bit UUID
bigintBigIntegerbigintArbitrary-precision integer
bytesbyte[] / IonBytesUint8ArrayRaw binary data
uriUristringURI/URL

Date & Time Types

Ion Type C# TypeScript Description
datetimeDateTimeDateUTC date and time
dateonlyDateOnlystringDate without time component
timeonlyTimeOnlystringTime without date component
durationTimeSpannumberTime span / duration

Generic Wrappers

These built-in generic types wrap other types:

Wrapper Description
Maybe<T> Optional value. Shorthand: T?. Null on the wire when absent.
Array<T> Variable-length sequence. Shorthand: T[]. CBOR array encoding.
Partial<T> Sparse update — only modified fields are serialized. Shorthand: ~T.

Usage Example

msg UserProfile {
    id: u4;                  // unsigned 32-bit integer
    name: string;             // UTF-8 text
    email: string?;            // optional string (Maybe<string>)
    avatar: bytes?;            // optional binary data
    score: f8;                // double-precision float
    createdAt: datetime;       // UTC timestamp
    tags: string[];            // array of strings
    largeId: u8;              // 64-bit unsigned (bigint in TS)
    uniqueRef: guid;          // 128-bit UUID
}