This is the documentation for
v1 but the latest version is
v2
.
You can switch versions in the menu on the left/at the top.
Check your current version with the following command:
composer show spatie/typescript-transformer
##Basic installation
You can install this package via composer:
composer require spatie/laravel-typescript-transformer
The package will automatically register a service provider.
You can publish the config file with:
php artisan vendor:publish --provider="Spatie\LaravelTypeScriptTransformer\TypeScriptTransformerServiceProvider"
This is the default content of the config file:
return [
'searching_path' => app_path(),
'collectors' => [
Spatie\TypeScriptTransformer\Collectors\AnnotationCollector::class,
],
'transformers' => [
Spatie\LaravelTypeScriptTransformer\Transformers\SpatieStateTransformer::class,
Spatie\TypeScriptTransformer\Transformers\SpatieEnumTransformer::class,
Spatie\TypeScriptTransformer\Transformers\DtoTransformer::class,
],
'class_property_replacements' => [
DateTime::class => 'string',
DateTimeImmutable::class => 'string',
Carbon::class => 'string',
CarbonImmutable::class => 'string',
],
'output_file' => resource_path('types/generated.d.ts'),
];