Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Typescript Transformer Laravel Package

spatie/typescript-transformer

Automatically generate TypeScript definitions from your PHP/Laravel code. spatie/typescript-transformer scans classes and types, then outputs .d.ts files so your frontend stays in sync with backend models, DTOs and enums with minimal manual typing.

View on GitHub
Deep Wiki
Context7

title: Using different writers in providers weight: 2

Currently, TypeScript transformer will output all transformed objects using the default writer configured. While most of the time this is sufficient, there are cases where you might want to have more control over how certain transformed objects are written down.

For example, in the Laravel package all types from classes, enums, and interfaces are written to a single file using namespaces. Yet the package also provide some helper functions allowing you to generate URLs for your routes. These helper functions are best written to a separate file without namespaces.

In order to achieve this, TypeScript transformer allows you to use different writers per transformed object, you can set a writer on a transformed object as such:

$transformed->setWriter(new ModuleWriter());

Please notice that you can only set writers on a transformed object once and we advise you for performance reasons to create a writer in the constructor of your provider and reuse it for all transformed objects within that provider.

It is still possible to reference transformed objects written down by writers from other providers or the default writer, TypeScript transformer will take care of linking them together and generating the correct import statements.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky