Example Transformation
This PHP data object:Installation
Install the TypeScript transformer package:typescript-transformer.php:
If you’re using the
DtoTransformer provided by the package, put the DataTypeScriptTransformer before it.Usage
Annotate data objects you want to transform:Transform All Data Objects
Use theDataTypeScriptCollector to automatically transform all data objects:
In typescript-transformer.php:
If you’re using the
DefaultCollector, put the DataTypeScriptCollector before it.Optional Types
Lazy and optional properties become optional in TypeScript:Optional Without Lazy/Optional Types
Use theOptional attribute from typescript-transformer:
Alias the TypeScript
Optional attribute to avoid conflicts with Laravel Data’s Optional type.