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: Node reference weight: 4

A quick reference of all available TypeScript AST nodes.

Types

Primitives

Node Output
new TypeScriptString() string
new TypeScriptNumber() number
new TypeScriptBoolean() boolean
new TypeScriptNull() null
new TypeScriptUndefined() undefined
new TypeScriptVoid() void
new TypeScriptNever() never
new TypeScriptUnknown() unknown
new TypeScriptAny() any

Combining Types

TypeScriptUnionstring | number

new TypeScriptUnion([new TypeScriptString(), new TypeScriptNumber()])

TypeScriptIntersectionA & B

new TypeScriptIntersection([new TypeScriptIdentifier('A'), new TypeScriptIdentifier('B')])

TypeScriptArraystring[]

new TypeScriptArray([new TypeScriptString()])

TypeScriptTuple[string, number]

new TypeScriptTuple([new TypeScriptString(), new TypeScriptNumber()])

Generics

TypeScriptGenericRecord<string, number>

Used both for generic type usage (concrete type arguments) and generic type declarations (with TypeScriptGenericTypeParameter arguments).

// Usage: Record<string, number>
new TypeScriptGeneric(new TypeScriptIdentifier('Record'), [new TypeScriptString(), new TypeScriptNumber()])

// Declaration: Container<T extends object>
new TypeScriptGeneric(new TypeScriptIdentifier('Container'), [
    new TypeScriptGenericTypeParameter(new TypeScriptIdentifier('T'), extends: new TypeScriptIdentifier('object')),
])

TypeScriptGenericTypeParameterT, T extends string, T extends string = string

Declares a generic type variable with optional constraint and default. Used inside TypeScriptGeneric for type declarations.

// Bare: T
new TypeScriptGenericTypeParameter(new TypeScriptIdentifier('T'))

// With constraint: T extends string
new TypeScriptGenericTypeParameter(new TypeScriptIdentifier('T'), extends: new TypeScriptString())

// With constraint and default: T extends string = string
new TypeScriptGenericTypeParameter(new TypeScriptIdentifier('T'), extends: new TypeScriptString(), default: new TypeScriptString())

Advanced Type Operators

TypeScriptConditionalT extends string ? number : boolean

new TypeScriptConditional(
    TypeScriptOperator::extends(new TypeScriptIdentifier('T'), new TypeScriptString()),
    new TypeScriptNumber(),
    new TypeScriptBoolean(),
)

TypeScriptMappedType{ [K in keyof T]: T[K] }

// Simple: { [K in keyof T]: T[K] }
new TypeScriptMappedType(
    'K',
    TypeScriptOperator::keyof(new TypeScriptIdentifier('T')),
    new TypeScriptIndexedAccess(new TypeScriptIdentifier('T'), [new TypeScriptIdentifier('K')]),
)

// With modifiers: { readonly [K in keyof T]?: T[K] }
new TypeScriptMappedType(
    'K',
    TypeScriptOperator::keyof(new TypeScriptIdentifier('T')),
    new TypeScriptIndexedAccess(new TypeScriptIdentifier('T'), [new TypeScriptIdentifier('K')]),
    readonlyModifier: 'readonly',
    optionalModifier: '?',
)

TypeScriptIndexedAccessUser["name"]

new TypeScriptIndexedAccess(new TypeScriptIdentifier('User'), [new TypeScriptLiteral('name')])

TypeScriptOperatorkeyof T, typeof config, T extends U

TypeScriptOperator::keyof(new TypeScriptIdentifier('T'))
TypeScriptOperator::typeof(new TypeScriptIdentifier('config'))
TypeScriptOperator::extends(new TypeScriptIdentifier('T'), new TypeScriptIdentifier('U'))

TypeScriptCallable(...args: any[]) => any or custom function types like (x: string) => void

new TypeScriptCallable() // (...args: any[]) => any
new TypeScriptCallable([new TypeScriptParameter('x', new TypeScriptString())], new TypeScriptVoid()) // (x: string) => void

Objects & Interfaces

TypeScriptObject{ name: string }

For describing object type shapes in type annotations. Compare with TypeScriptObjectLiteral for value-level JSON objects.

new TypeScriptObject([new TypeScriptProperty('name', new TypeScriptString())])

TypeScriptPropertyreadonly name?: string

new TypeScriptProperty('name', new TypeScriptString(), isOptional: true, isReadonly: true)

TypeScriptIndexSignature[key: string]

new TypeScriptIndexSignature(new TypeScriptString(), 'key')

TypeScriptInterfaceinterface User { name: string; greet(): void; }

new TypeScriptInterface('User', [new TypeScriptProperty('name', new TypeScriptString())], [new TypeScriptMethodSignature('greet', [], new TypeScriptVoid())])

TypeScriptMethodSignaturegetName(id: number): string;

new TypeScriptMethodSignature('getName', [new TypeScriptParameter('id', new TypeScriptNumber())], new TypeScriptString())

Declarations & Expressions

Declarations

TypeScriptAliastype Name = string;

new TypeScriptAlias('Name', new TypeScriptString())
// or with explicit identifier: new TypeScriptAlias(new TypeScriptIdentifier('Name'), new TypeScriptString())

TypeScriptEnumenum Status { Active = 'active' }

new TypeScriptEnum('Status', [['name' => 'Active', 'value' => 'active']])

TypeScriptFunctionDeclarationfunction greet(name: string): string { ... }

new TypeScriptFunctionDeclaration('greet', [new TypeScriptParameter('name', new TypeScriptString())], new TypeScriptString(), new TypeScriptRaw('return name;'))

TypeScriptVariableDeclarationconst name = "world"

TypeScriptVariableDeclaration::const('name', new TypeScriptLiteral('world'))

TypeScriptOperator::export()export type Name = string;

TypeScriptOperator::export(new TypeScriptAlias('Name', new TypeScriptString()))

TypeScriptImportimport { User as AppUser } from './types';

new TypeScriptImport('./types', [['name' => 'User', 'alias' => 'AppUser']])

TypeScriptNamespacedeclare namespace App { namespace Models { ... } } or namespace Models { ... }

new TypeScriptNamespace('App', [$typeNode], children: [
    new TypeScriptNamespace('Models', [$otherTypeNode], declare: false)
])

Expressions

Value-level nodes that produce JavaScript/TypeScript expressions. Some output similar syntax to type-level nodes but serve a different purpose.

TypeScriptCallExpressioncreateAction<UserParams>("index")

new TypeScriptCallExpression(new TypeScriptIdentifier('createAction'), [new TypeScriptLiteral('index')], genericTypes: [new TypeScriptIdentifier('UserParams')])

TypeScriptArrayExpression["a", "b", "c"]

For array literals in expressions. Compare with TypeScriptTuple for type-level tuples.

new TypeScriptArrayExpression([new TypeScriptLiteral('a'), new TypeScriptLiteral('b'), new TypeScriptLiteral('c')])

TypeScriptObjectLiteral{ "method": "GET", "url": "/users" }

For JSON object values. Compare with TypeScriptObject for type-level object shapes.

new TypeScriptObjectLiteral(['method' => 'GET', 'url' => '/users'])

Building Blocks

Low-level nodes used as parts of other nodes.

TypeScriptIdentifierMyType (auto-quotes invalid identifiers)

new TypeScriptIdentifier('MyType')

TypeScriptLiteral"hello", 42, true

new TypeScriptLiteral('hello')

TypeScriptParametername?: string, ...args: string[]

new TypeScriptParameter('name', new TypeScriptString(), isOptional: true)

TypeScriptRaw — pass-through raw TypeScript, supports references for %placeholder% substitution and additionalImports for external TS file imports

new TypeScriptRaw('Record<string, never>')
new TypeScriptRaw('%User% | null', references: ['User' => UserData::class])
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