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: Helpers weight: 5

When building custom transformed providers you may need access to actions like transpiling PHP types to TypeScript, discovering certain types and more.

use Spatie\TypeScriptTransformer\TransformedProviders\ActionAwareTransformedProvider;
use Spatie\TypeScriptTransformer\TransformedProviders\TransformedProviderActions;
use Spatie\TypeScriptTransformer\TransformedProviders\TransformedProvider;

class CustomProvider implements TransformedProvider, ActionAwareTransformedProvider
{
    private TransformedProviderActions $actions;

    public function setActions(TransformedProviderActions $actions): void
    {
        $this->actions = $actions;
    }

    public function provide(): array
    {
        $classNode = $this->actions->parseUserDefinedTypeAction->execute('Record<string, int>');
    }
}

The TransformedProviderActions object provides:

  • loadPhpClassNodeAction - Load a PhpClassNode from a file path
  • discoverTypesAction - Discover PHP classes in directories
  • transpilePhpStanTypeToTypeScriptNodeAction - Transpile PHPStan doc types to TypeScript nodes
  • transpilePhpTypeNodeToTypeScriptNodeAction - Transpile native PHP types to TypeScript nodes
  • parseUserDefinedTypeAction - Parse a user-defined type string into a TypeScript node
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.
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
spatie/mailcoach-vapor