Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Standard Library

The standard library (scsc/base) provides built-in types, mapping strategies, and language-specific type constants. Import it with:

import scsc/base

Built-in Types

Integer Types

SchemaScriptPHP TypeTypeScript Type
intintnumber
int8intnumber
int16intnumber
int32intnumber
int64intnumber

Unsigned Integer Types

SchemaScriptPHP TypeTypeScript Type
uintintnumber
uint8intnumber
uint16intnumber
uint32intnumber
uint64stringbigint

Note: uint64 maps to string in PHP and bigint in TypeScript because 64-bit unsigned integers exceed the safe integer range of PHP’s int and JavaScript’s number.

Floating Point Types

SchemaScriptPHP TypeTypeScript Type
floatfloatnumber
float32floatnumber
float64floatnumber
doublefloatnumber

Text & Binary

SchemaScriptPHP TypeTypeScript Type
stringstringstring
bytesstringUint8Array

Boolean

SchemaScriptPHP TypeTypeScript Type
boolboolboolean

Identifiers

SchemaScriptPHP TypeTypeScript Type
uuidstringstring

Temporal Types

SchemaScriptPHP TypeTypeScript Type
timestampstringstring
datetimestringstring
datestringstring
timestringstring

Dynamic Types

SchemaScriptPHP TypeTypeScript Type
anymixedunknown
mixedmixedunknown

Collections

SchemaScriptPHP TypeTypeScript Type
map<K, V>arrayRecord<K, V>

map<K, V> is a generic key-value mapping type. See Generics for details.

Mapping Strategies

The MappingStrategy namespace provides constants for property name conversion:

ConstantExample
MappingStrategy::camelCasemyProperty
MappingStrategy::pascalCaseMyProperty
MappingStrategy::snakeCasemy_property
MappingStrategy::screamingSnakeCaseMY_PROPERTY
MappingStrategy::kebabCasemy-property

Usage:

[map] = {
  api = {
    strategy = MappingStrategy::snakeCase
  }
}

See Property Mapping for details.

Language Type Constants

The standard library also provides namespace constants for native language types. These are used internally by type alias annotations:

PHP types (SCSC::Lang::PHP::Type::*): int, string, bool, float, array, object, null, mixed

TypeScript types (SCSC::Lang::TS::Type::*): number, string, boolean, any, null, undefined, object, bigint, Uint8Array, unknown

You can reference these in your own @lang.php and @lang.ts annotations:

[type] = {
  @lang.php(SCSC::Lang::PHP::Type::int)
  @lang.ts(SCSC::Lang::TS::Type::number)
  myCustomInt
}